style
This commit is contained in:
@@ -10,16 +10,16 @@ class InputHandler_DInput: public InputHandler
|
|||||||
public:
|
public:
|
||||||
InputHandler_DInput();
|
InputHandler_DInput();
|
||||||
~InputHandler_DInput();
|
~InputHandler_DInput();
|
||||||
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut);
|
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut );
|
||||||
void Update(float fDeltaTime);
|
void Update( float fDeltaTime );
|
||||||
void WindowReset();
|
void WindowReset();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RageThread InputThread;
|
RageThread InputThread;
|
||||||
bool shutdown;
|
bool shutdown;
|
||||||
|
|
||||||
void UpdatePolled(DIDevice &device, const RageTimer &tm);
|
void UpdatePolled( DIDevice &device, const RageTimer &tm );
|
||||||
void UpdateBuffered(DIDevice &device, const RageTimer &tm);
|
void UpdateBuffered( DIDevice &device, const RageTimer &tm );
|
||||||
void PollAndAcquireDevices();
|
void PollAndAcquireDevices();
|
||||||
|
|
||||||
static int InputThread_Start( void *p ) { ((InputHandler_DInput *) p)->InputThreadMain(); return 0; }
|
static int InputThread_Start( void *p ) { ((InputHandler_DInput *) p)->InputThreadMain(); return 0; }
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
class InputHandler_MonkeyKeyboard: public InputHandler
|
class InputHandler_MonkeyKeyboard: public InputHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Update(float fDeltaTime);
|
void Update( float fDeltaTime );
|
||||||
InputHandler_MonkeyKeyboard();
|
InputHandler_MonkeyKeyboard();
|
||||||
~InputHandler_MonkeyKeyboard();
|
~InputHandler_MonkeyKeyboard();
|
||||||
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut);
|
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
RageTimer m_timerPressButton;
|
RageTimer m_timerPressButton;
|
||||||
|
|||||||
@@ -8,10 +8,10 @@ class USBDevice;
|
|||||||
class InputHandler_Win32_Para: public InputHandler
|
class InputHandler_Win32_Para: public InputHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Update(float fDeltaTime);
|
void Update( float fDeltaTime );
|
||||||
InputHandler_Win32_Para();
|
InputHandler_Win32_Para();
|
||||||
~InputHandler_Win32_Para();
|
~InputHandler_Win32_Para();
|
||||||
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut);
|
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USBDevice *dev;
|
USBDevice *dev;
|
||||||
|
|||||||
@@ -9,25 +9,25 @@
|
|||||||
|
|
||||||
InputHandler_Win32_Pump::InputHandler_Win32_Pump()
|
InputHandler_Win32_Pump::InputHandler_Win32_Pump()
|
||||||
{
|
{
|
||||||
shutdown = false;
|
m_bShutdown = false;
|
||||||
const int pump_usb_vid = 0x0d2f, pump_usb_pid = 0x0001;
|
const int pump_usb_vid = 0x0d2f, pump_usb_pid = 0x0001;
|
||||||
|
|
||||||
dev = new USBDevice[NUM_PUMPS];
|
m_pDevice = new USBDevice[NUM_PUMPS];
|
||||||
|
|
||||||
bool FoundOnePad = false;
|
bool bFoundOnePad = false;
|
||||||
for(int i = 0; i < NUM_PUMPS; ++i)
|
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||||
{
|
{
|
||||||
if(dev[i].Open(pump_usb_vid, pump_usb_pid, sizeof(long), i))
|
if( m_pDevice[i].Open(pump_usb_vid, pump_usb_pid, sizeof(long), i) )
|
||||||
{
|
{
|
||||||
FoundOnePad = true;
|
bFoundOnePad = true;
|
||||||
LOG->Info("Found Pump pad %i", i);
|
LOG->Info( "Found Pump pad %i", i );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Don't start a thread if we have no pads. */
|
/* Don't start a thread if we have no pads. */
|
||||||
if( FoundOnePad && PREFSMAN->m_bThreadedInput )
|
if( bFoundOnePad && PREFSMAN->m_bThreadedInput )
|
||||||
{
|
{
|
||||||
InputThread.SetName("Pump thread");
|
InputThread.SetName( "Pump thread" );
|
||||||
InputThread.Create( InputThread_Start, this );
|
InputThread.Create( InputThread_Start, this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,16 +36,16 @@ InputHandler_Win32_Pump::~InputHandler_Win32_Pump()
|
|||||||
{
|
{
|
||||||
if( InputThread.IsCreated() )
|
if( InputThread.IsCreated() )
|
||||||
{
|
{
|
||||||
shutdown = true;
|
m_bShutdown = true;
|
||||||
LOG->Trace("Shutting down Pump thread ...");
|
LOG->Trace( "Shutting down Pump thread ..." );
|
||||||
InputThread.Wait();
|
InputThread.Wait();
|
||||||
LOG->Trace("Pump thread shut down.");
|
LOG->Trace( "Pump thread shut down." );
|
||||||
}
|
}
|
||||||
|
|
||||||
delete[] dev;
|
delete[] m_pDevice;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler_Win32_Pump::HandleInput( int devno, int event )
|
void InputHandler_Win32_Pump::HandleInput( int iDevice, int iEvent )
|
||||||
{
|
{
|
||||||
static const int bits[NUM_PUMP_PAD_BUTTONS] = {
|
static const int bits[NUM_PUMP_PAD_BUTTONS] = {
|
||||||
/* P1 */ (1<<9), (1<<12), (1<<13), (1<<11), (1<<10),
|
/* P1 */ (1<<9), (1<<12), (1<<13), (1<<11), (1<<10),
|
||||||
@@ -53,17 +53,17 @@ void InputHandler_Win32_Pump::HandleInput( int devno, int event )
|
|||||||
/* P1 */ (1<<17), (1<<20), (1<<21), (1<<19), (1<<18),
|
/* P1 */ (1<<17), (1<<20), (1<<21), (1<<19), (1<<18),
|
||||||
};
|
};
|
||||||
|
|
||||||
InputDevice id = InputDevice(DEVICE_PUMP1 + devno);
|
InputDevice id = InputDevice( DEVICE_PUMP1 + iDevice );
|
||||||
|
|
||||||
for (int butno = 0 ; butno < NUM_PUMP_PAD_BUTTONS ; butno++)
|
for( int iButton = 0; iButton < NUM_PUMP_PAD_BUTTONS; ++iButton )
|
||||||
{
|
{
|
||||||
DeviceInput di(id, butno);
|
DeviceInput di( id, iButton );
|
||||||
|
|
||||||
/* If we're in a thread, our timestamp is accurate. */
|
/* If we're in a thread, our timestamp is accurate. */
|
||||||
if( InputThread.IsCreated() )
|
if( InputThread.IsCreated() )
|
||||||
di.ts.Touch();
|
di.ts.Touch();
|
||||||
|
|
||||||
ButtonPressed(di, !(event & bits[butno]));
|
ButtonPressed( di, !(iEvent & bits[iButton]) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +71,7 @@ void InputHandler_Win32_Pump::GetDevicesAndDescriptions(vector<InputDevice>& vDe
|
|||||||
{
|
{
|
||||||
for(int i = 0; i < NUM_PUMPS; ++i)
|
for(int i = 0; i < NUM_PUMPS; ++i)
|
||||||
{
|
{
|
||||||
if( dev[i].IsOpen() )
|
if( m_pDevice[i].IsOpen() )
|
||||||
{
|
{
|
||||||
vDevicesOut.push_back( InputDevice(DEVICE_PUMP1+i) );
|
vDevicesOut.push_back( InputDevice(DEVICE_PUMP1+i) );
|
||||||
vDescriptionsOut.push_back( "Pump USB" );
|
vDescriptionsOut.push_back( "Pump USB" );
|
||||||
@@ -87,47 +87,47 @@ int InputHandler_Win32_Pump::InputThread_Start( void *p )
|
|||||||
|
|
||||||
void InputHandler_Win32_Pump::InputThreadMain()
|
void InputHandler_Win32_Pump::InputThreadMain()
|
||||||
{
|
{
|
||||||
if(!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST))
|
if( !SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST) )
|
||||||
LOG->Warn(werr_ssprintf(GetLastError(), "Failed to set Pump thread priority"));
|
LOG->Warn( werr_ssprintf(GetLastError(), "Failed to set Pump thread priority") );
|
||||||
|
|
||||||
/* Enable priority boosting. */
|
/* Enable priority boosting. */
|
||||||
SetThreadPriorityBoost( GetCurrentThread(), FALSE );
|
SetThreadPriorityBoost( GetCurrentThread(), FALSE );
|
||||||
|
|
||||||
vector<WindowsFileIO *> sources;
|
vector<WindowsFileIO *> apSources;
|
||||||
for( int i = 0; i < NUM_PUMPS; ++i )
|
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||||
{
|
{
|
||||||
if( dev[i].io.IsOpen() )
|
if( m_pDevice[i].io.IsOpen() )
|
||||||
sources.push_back( &dev[i].io );
|
apSources.push_back( &m_pDevice[i].io );
|
||||||
}
|
}
|
||||||
|
|
||||||
while(!shutdown)
|
while( !m_bShutdown )
|
||||||
{
|
{
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
int actual = 0, val = 0;
|
int iActual = 0, iVal = 0;
|
||||||
int ret = WindowsFileIO::read_several(sources, &val, actual, 0.100f);
|
int iRet = WindowsFileIO::read_several( apSources, &iVal, iActual, 0.100f );
|
||||||
|
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
if(ret <= 0)
|
if( iRet <= 0 )
|
||||||
continue; /* no event */
|
continue; /* no event */
|
||||||
|
|
||||||
HandleInput( actual, val );
|
HandleInput( iActual, iVal );
|
||||||
InputHandler::UpdateTimer();
|
InputHandler::UpdateTimer();
|
||||||
}
|
}
|
||||||
CHECKPOINT;
|
CHECKPOINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
void InputHandler_Win32_Pump::Update(float fDeltaTime)
|
void InputHandler_Win32_Pump::Update( float fDeltaTime )
|
||||||
{
|
{
|
||||||
if( !InputThread.IsCreated() )
|
if( !InputThread.IsCreated() )
|
||||||
{
|
{
|
||||||
for(int i = 0; i < NUM_PUMPS; ++i)
|
for( int i = 0; i < NUM_PUMPS; ++i )
|
||||||
{
|
{
|
||||||
int ret = dev[i].GetPadEvent();
|
int iRet = m_pDevice[i].GetPadEvent();
|
||||||
|
|
||||||
if(ret == -1)
|
if( iRet == -1 )
|
||||||
continue; /* no event */
|
continue; /* no event */
|
||||||
|
|
||||||
HandleInput( i, ret );
|
HandleInput( i, iRet );
|
||||||
}
|
}
|
||||||
InputHandler::UpdateTimer();
|
InputHandler::UpdateTimer();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,15 +8,15 @@ class USBDevice;
|
|||||||
class InputHandler_Win32_Pump: public InputHandler
|
class InputHandler_Win32_Pump: public InputHandler
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
void Update(float fDeltaTime);
|
void Update( float fDeltaTime );
|
||||||
InputHandler_Win32_Pump();
|
InputHandler_Win32_Pump();
|
||||||
~InputHandler_Win32_Pump();
|
~InputHandler_Win32_Pump();
|
||||||
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut);
|
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
USBDevice *dev;
|
USBDevice *m_pDevice;
|
||||||
RageThread InputThread;
|
RageThread InputThread;
|
||||||
bool shutdown;
|
bool m_bShutdown;
|
||||||
|
|
||||||
static int InputThread_Start( void *p );
|
static int InputThread_Start( void *p );
|
||||||
void InputThreadMain();
|
void InputThreadMain();
|
||||||
|
|||||||
Reference in New Issue
Block a user