Files
itgmania212121/stepmania/src/arch/InputHandler/InputHandler_Win32_Pump.cpp
T

68 lines
1.6 KiB
C++
Raw Normal View History

2003-02-16 04:02:21 +00:00
#include "global.h"
2003-02-16 01:16:25 +00:00
#include "InputHandler_Win32_Pump.h"
#include "RageLog.h"
#include "RageInputDevice.h"
2003-03-19 20:34:40 +00:00
#include "archutils/Win32/USB.h"
2003-02-16 01:16:25 +00:00
2003-02-16 02:25:22 +00:00
InputHandler_Win32_Pump::InputHandler_Win32_Pump()
2003-02-16 01:16:25 +00:00
{
const int pump_usb_vid = 0x0d2f, pump_usb_pid = 0x0001;
2003-03-19 20:34:40 +00:00
dev = new USBDevice[NUM_PUMPS];
2003-02-16 01:16:25 +00:00
for(int i = 0; i < NUM_PUMPS; ++i)
{
2003-03-19 20:34:40 +00:00
if(dev[i].Open(pump_usb_vid, pump_usb_pid, i))
2003-02-16 01:16:25 +00:00
LOG->Info("Found Pump pad %i", i);
}
}
2003-02-16 02:25:22 +00:00
InputHandler_Win32_Pump::~InputHandler_Win32_Pump()
2003-02-16 01:16:25 +00:00
{
delete[] dev;
}
2003-02-16 02:25:22 +00:00
void InputHandler_Win32_Pump::Update(float fDeltaTime)
2003-02-16 01:16:25 +00:00
{
2003-05-28 04:21:12 +00:00
static const int bits[NUM_PUMP_PAD_BUTTONS] = {
2003-02-16 01:16:25 +00:00
/* P1 */ (1<<9), (1<<12), (1<<13), (1<<11), (1<<10),
/* ESC */ (1<<16),
/* P1 */ (1<<17), (1<<20), (1<<21), (1<<19), (1<<18),
};
for(int i = 0; i < NUM_PUMPS; ++i)
{
int ret = dev[i].GetPadEvent();
if(ret == -1)
continue; /* no event */
InputDevice id = InputDevice(DEVICE_PUMP1 + i);
for (int butno = 0 ; butno < NUM_PUMP_PAD_BUTTONS ; butno++)
2003-07-13 01:03:09 +00:00
ButtonPressed(DeviceInput(id, butno), !(ret & bits[butno]));
2003-02-16 01:16:25 +00:00
}
2003-07-13 01:03:09 +00:00
InputHandler::Update( fDeltaTime );
2003-02-16 01:16:25 +00:00
}
2003-05-28 02:35:05 +00:00
void InputHandler_Win32_Pump::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut)
{
for(int i = 0; i < NUM_PUMPS; ++i)
{
if( dev[i].IsOpen() )
{
vDevicesOut.push_back( InputDevice(DEVICE_PUMP1+i) );
vDescriptionsOut.push_back( "Pump USB" );
}
}
}
2003-03-19 20:34:40 +00:00
/*
-----------------------------------------------------------------------------
Copyright (c) 2002-2003 by the person(s) listed below. All rights reserved.
Glenn Maynard
-----------------------------------------------------------------------------
*/