Return -1 if no InputDevice numbers can be assigned to logical devices.

This commit is contained in:
Steve Checkoway
2006-02-27 00:21:14 +00:00
parent 5a916de95b
commit a63a1284fa
3 changed files with 11 additions and 14 deletions
@@ -165,11 +165,8 @@ void JoystickDevice::GetButtonPresses( vector<pair<DeviceInput, bool> >& vPresse
int JoystickDevice::AssignIDs( InputDevice startID ) int JoystickDevice::AssignIDs( InputDevice startID )
{ {
if( startID < DEVICE_JOY1 ) if( startID < DEVICE_JOY1 || startID > DEVICE_JOY16 )
{ return -1;
m_vSticks.clear();
return 0;
}
FOREACH( Joystick, m_vSticks, i ) FOREACH( Joystick, m_vSticks, i )
{ {
if( startID > DEVICE_JOY16 ) if( startID > DEVICE_JOY16 )
@@ -48,33 +48,32 @@ void PumpDevice::GetButtonPresses( vector<pair<DeviceInput, bool> >& vPresses, i
} }
if( db1 != DeviceButton_Invalid ) if( db1 != DeviceButton_Invalid )
{ {
DeviceInput di( id, db1, pressed1 ? 1.0f : 0.0f , now ); DeviceInput di( m_Id, db1, pressed1 ? 1.0f : 0.0f , now );
vPresses.push_back( pair<DeviceInput, bool>(di, pressed1) ); vPresses.push_back( pair<DeviceInput, bool>(di, pressed1) );
} }
if( db2 != DeviceButton_Invalid ) if( db2 != DeviceButton_Invalid )
{ {
DeviceInput di( id, db2, pressed2 ? 1.0f : 0.0f , now ); DeviceInput di( m_Id, db2, pressed2 ? 1.0f : 0.0f , now );
vPresses.push_back( pair<DeviceInput, bool>(di, pressed2) ); vPresses.push_back( pair<DeviceInput, bool>(di, pressed2) );
} }
} }
int PumpDevice::AssignIDs( InputDevice startID ) int PumpDevice::AssignIDs( InputDevice startID )
{ {
id = DEVICE_NONE;
if( startID < DEVICE_PUMP1 || startID > DEVICE_PUMP2 ) if( startID < DEVICE_PUMP1 || startID > DEVICE_PUMP2 )
return 0; return -1;
id = startID; m_Id = startID;
return 1; return 1;
} }
void PumpDevice::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const void PumpDevice::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const
{ {
dev.push_back( id ); dev.push_back( m_Id );
desc.push_back( "Pump USB" ); desc.push_back( "Pump USB" );
} }
/* /*
* (c) 2005-2006 Steve Checkoway * (c) 2006 Steve Checkoway
* All rights reserved. * All rights reserved.
* *
* Permission is hereby granted, free of charge, to any person obtaining a * Permission is hereby granted, free of charge, to any person obtaining a
+2 -1
View File
@@ -6,7 +6,8 @@
class PumpDevice : public HIDDevice class PumpDevice : public HIDDevice
{ {
private: private:
InputDevice id; InputDevice m_Id;
protected: protected:
bool AddLogicalDevice( int usagePage, int usage ) { return true; } bool AddLogicalDevice( int usagePage, int usage ) { return true; }
void AddElement( int usagePage, int usage, int cookie, void AddElement( int usagePage, int usage, int cookie,