Change GetDevicesAndDescriptions to fill in one vector instead of 2

Ignore changes in non-joystick devices when automapping
This commit is contained in:
Chris Danford
2006-02-27 17:51:27 +00:00
parent 0ac58078b4
commit bf0cc13a47
37 changed files with 148 additions and 124 deletions
+1 -1
View File
@@ -124,7 +124,7 @@ None=None
[InputMapper]
Connected=Connected
Disconnected=Disconnected
Remapping all joysticks.=Remapping all joysticks.
Auto-mapping all joysticks.=Auto-mapping all joysticks.
[Language]
Name=English
+8 -7
View File
@@ -77,18 +77,19 @@ static bool ChangeAppPri()
#if defined(_WINDOWS)
if( g_BoostAppPriority == BOOST_AUTO )
{
vector<InputDevice> vDevices;
vector<RString> vDescriptions;
vector<InputDeviceInfo> vDevices;
// This can get called before INPUTMAN is constructed.
if( INPUTMAN )
{
INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions);
RString sInputDevices = join( ",", vDescriptions );
if( sInputDevices.find("NTPAD") != string::npos )
INPUTMAN->GetDevicesAndDescriptions(vDevices);
FOREACH_CONST( InputDeviceInfo, vDevices, d )
{
LOG->Trace( "Using NTPAD. Don't boost priority." );
return false;
if( d->sDesc.find("NTPAD") != string::npos )
{
LOG->Trace( "Using NTPAD. Don't boost priority." );
return false;
}
}
}
}
+44 -27
View File
@@ -457,9 +457,8 @@ void InputMapper::ApplyMapping( const Mapping *maps, GameController gc, InputDev
void InputMapper::AutoMapJoysticksForCurrentGame()
{
vector<InputDevice> vDevices;
vector<RString> vDescriptions;
INPUTMAN->GetDevicesAndDescriptions(vDevices,vDescriptions);
vector<InputDeviceInfo> vDevices;
INPUTMAN->GetDevicesAndDescriptions(vDevices);
int iNumJoysticksMapped = 0;
@@ -467,8 +466,8 @@ void InputMapper::AutoMapJoysticksForCurrentGame()
for( unsigned i=0; i<vDevices.size(); i++ )
{
InputDevice id = vDevices[i];
RString sDescription = vDescriptions[i];
InputDevice id = vDevices[i].id;
const RString &sDescription = vDevices[i].sDesc;
for( unsigned j=0; j<ARRAYSIZE(g_AutoJoyMappings); j++ )
{
const AutoJoyMapping& mapping = g_AutoJoyMappings[j];
@@ -576,45 +575,63 @@ void InputMapper::SaveMappingsToDisk()
ini.WriteFile( SpecialFiles::KEYMAPS_PATH );
}
static LocalizedString CONNECTED ( "InputMapper", "Connected" );
static LocalizedString DISCONNECTED ( "InputMapper", "Disconnected" );
static LocalizedString REMAPPING_ALL_JOYSTICKS ( "InputMapper", "Remapping all joysticks." );
bool InputMapper::CheckForChangedInputDevicesAndRemap( RString &sMessage )
static LocalizedString CONNECTED ( "InputMapper", "Connected" );
static LocalizedString DISCONNECTED ( "InputMapper", "Disconnected" );
static LocalizedString AUTOMAPPING_ALL_JOYSTICKS ( "InputMapper", "Auto-mapping all joysticks." );
bool InputMapper::CheckForChangedInputDevicesAndRemap( RString &sMessageOut )
{
//
// update last seen joysticks
//
vector<InputDevice> vDevices;
vector<RString> vsDescriptions;
INPUTMAN->GetDevicesAndDescriptions( vDevices, vsDescriptions );
RString sInputDevices = join( ",", vsDescriptions );
// Only check for changes in joysticks since that's all we know how to remap.
if( g_sLastSeenInputDevices.Get() == sInputDevices )
// update last seen joysticks
vector<InputDeviceInfo> vDevices;
INPUTMAN->GetDevicesAndDescriptions( vDevices );
// Strip non-joysticks.
vector<RString> vsLastSeenJoysticks;
split( g_sLastSeenInputDevices, ",", vsLastSeenJoysticks );
vector<RString> vsCurrent;
vector<RString> vsCurrentJoysticks;
for( int i=vDevices.size()-1; i>=0; i-- )
{
vsCurrent.push_back( vDevices[i].sDesc );
if( IsJoystick(vDevices[i].id) )
{
vsCurrentJoysticks.push_back( vDevices[i].sDesc );
}
else
{
vector<RString>::iterator iter = find( vsLastSeenJoysticks.begin(), vsLastSeenJoysticks.end(), vDevices[i].sDesc );
if( iter != vsLastSeenJoysticks.end() )
vsLastSeenJoysticks.erase( iter );
}
}
bool bJoysticksChanged = !VectorsAreEqual(vsCurrentJoysticks,vsLastSeenJoysticks);
if( !bJoysticksChanged )
return false;
vector<RString> vsLastSeen;
split( g_sLastSeenInputDevices, ",", vsLastSeen );
vector<RString> vsConnects, vsDisconnects;
GetConnectsDisconnects( vsLastSeen, vsDescriptions, vsDisconnects, vsConnects );
GetConnectsDisconnects( vsLastSeenJoysticks, vsCurrentJoysticks, vsDisconnects, vsConnects );
sMessage = RString();
sMessageOut = RString();
if( !vsConnects.empty() )
sMessage += CONNECTED.GetValue()+": " + join( "\n", vsConnects ) + "\n";
sMessageOut += CONNECTED.GetValue()+": " + join( "\n", vsConnects ) + "\n";
if( !vsDisconnects.empty() )
sMessage += DISCONNECTED.GetValue()+": " + join( "\n", vsDisconnects ) + "\n";
sMessageOut += DISCONNECTED.GetValue()+": " + join( "\n", vsDisconnects ) + "\n";
if( g_bAutoMapOnJoyChange )
{
sMessage += REMAPPING_ALL_JOYSTICKS.GetValue();
sMessageOut += AUTOMAPPING_ALL_JOYSTICKS.GetValue();
AutoMapJoysticksForCurrentGame();
SaveMappingsToDisk();
MESSAGEMAN->Broadcast( Message_AutoJoyMappingApplied );
}
LOG->Info( sMessage );
LOG->Info( sMessageOut );
g_sLastSeenInputDevices.Set( sInputDevices );
g_sLastSeenInputDevices.Set( join(",",vsCurrent) );
PREFSMAN->SavePrefsToDisk();
return true;
+26 -23
View File
@@ -62,10 +62,10 @@ bool RageInput::DevicesChanged()
return false;
}
void RageInput::GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut ) const
void RageInput::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut ) const
{
for( unsigned i = 0; i < m_pDevices.size(); ++i )
m_pDevices[i]->GetDevicesAndDescriptions( vDevicesOut, vDescriptionsOut );
m_pDevices[i]->GetDevicesAndDescriptions( vDevicesOut );
}
void RageInput::WindowReset()
@@ -84,13 +84,14 @@ RString RageInput::GetDeviceSpecificInputString( const DeviceInput &di )
{
FOREACH( InputHandler*, m_pDevices, i )
{
vector<InputDevice> vDevices;
vector<RString> vDescriptions;
(*i)->GetDevicesAndDescriptions( vDevices, vDescriptions );
vector<InputDeviceInfo> vDevices;
(*i)->GetDevicesAndDescriptions( vDevices );
bool bMatch = find(vDevices.begin(), vDevices.end(), di.device) != vDevices.end();
if( bMatch )
return (*i)->GetDeviceSpecificInputString(di);
FOREACH_CONST( InputDeviceInfo, vDevices, idi )
{
if( idi->id == di.device )
return (*i)->GetDeviceSpecificInputString(di);
}
}
return di.ToString();
@@ -100,13 +101,14 @@ InputDeviceState RageInput::GetInputDeviceState( InputDevice id )
{
FOREACH( InputHandler*, m_pDevices, i )
{
vector<InputDevice> vDevices;
vector<RString> vDescriptions;
(*i)->GetDevicesAndDescriptions( vDevices, vDescriptions );
vector<InputDeviceInfo> vDevices;
(*i)->GetDevicesAndDescriptions( vDevices );
bool bMatch = find(vDevices.begin(), vDevices.end(), id) != vDevices.end();
if( bMatch )
return (*i)->GetInputDeviceState(id);
FOREACH_CONST( InputDeviceInfo, vDevices, idi )
{
if( idi->id == id )
return (*i)->GetInputDeviceState(id);
}
}
return InputDeviceState_INVALID;
@@ -114,18 +116,17 @@ InputDeviceState RageInput::GetInputDeviceState( InputDevice id )
RString RageInput::GetDisplayDevicesString() const
{
vector<InputDevice> vDevices;
vector<RString> vDescriptions;
vector<InputDeviceInfo> vDevices;
GetDevicesAndDescriptions( vDevices );
vector<RString> vs;
GetDevicesAndDescriptions( vDevices, vDescriptions );
ASSERT( vDevices.size() == vDescriptions.size() );
for( unsigned i=0; i<vDevices.size(); ++i )
{
const RString sDescription = vDescriptions[i];
InputDevice device = vDevices[i];
const RString &sDescription = vDevices[i].sDesc;
InputDevice id = vDevices[i].id;
if( sDescription == "MonkeyKeyboard" )
continue; // hide this
vs.push_back( ssprintf("%s (%s)", sDescription.c_str(), InputDeviceToString(device).c_str()) );
vs.push_back( ssprintf("%s (%s)", sDescription.c_str(), InputDeviceToString(id).c_str()) );
}
return join("\n",vs);
}
@@ -140,9 +141,11 @@ public:
static int GetDescriptions( T* p, lua_State *L )
{
vector<InputDevice> vDevices;
vector<InputDeviceInfo> vDevices;
p->GetDevicesAndDescriptions( vDevices );
vector<RString> vsDescriptions;
p->GetDevicesAndDescriptions( vDevices, vsDescriptions );
FOREACH_CONST( InputDeviceInfo, vDevices, idi )
vsDescriptions.push_back( idi->sDesc );
LuaHelpers::CreateTableFromArray( vsDescriptions, L );
return 1;
}
+1 -1
View File
@@ -17,7 +17,7 @@ public:
void LoadDrivers();
void Update();
bool DevicesChanged();
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vsDescriptionsOut ) const;
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vOut ) const;
void WindowReset();
void AddHandler( InputHandler *pHandler );
RString GetDeviceSpecificInputString( const DeviceInput &di );
+21 -1
View File
@@ -36,6 +36,26 @@ enum InputDevice
#define FOREACH_InputDevice( i ) FOREACH_ENUM( InputDevice, NUM_INPUT_DEVICES, i )
const RString& InputDeviceToString( InputDevice i );
InputDevice StringToInputDevice( const RString& s );
inline bool IsJoystick( InputDevice id ) { return DEVICE_JOY1 <= id && id < DEVICE_JOY1+NUM_JOYSTICKS; }
struct InputDeviceInfo
{
InputDeviceInfo( InputDevice id_, RString sDesc_ )
{
id = id_;
sDesc = sDesc_;
}
InputDevice id;
RString sDesc;
bool operator==( const InputDeviceInfo &other ) const
{
return id == other.id &&
sDesc == other.sDesc;
}
};
enum InputDeviceState
@@ -302,7 +322,7 @@ public:
char ToChar() const;
bool IsJoystick() const { return DEVICE_JOY1 <= device && device < DEVICE_JOY1+NUM_JOYSTICKS; }
bool IsJoystick() const { return ::IsJoystick(device); }
};
#endif
+2 -2
View File
@@ -62,7 +62,7 @@ IntDir=.\../Debug6
TargetDir=\cvs\stepmania\Program
TargetName=StepMania-debug
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -99,7 +99,7 @@ IntDir=.\../Release6
TargetDir=\cvs\stepmania\Program
TargetName=StepMania
SOURCE="$(InputPath)"
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PreLink_Cmds=archutils\Win32\verinc cl /Zl /nologo /c verstub.cpp /Fo$(IntDir)\
PostBuild_Cmds=archutils\Win32\mapconv $(IntDir)\$(TargetName).map $(TargetDir)\StepMania.vdi
# End Special Build Tool
@@ -29,7 +29,7 @@ public:
virtual ~InputHandler() { }
virtual void Update() { }
virtual bool DevicesChanged() { return false; }
virtual void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut ) = 0;
virtual void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut ) = 0;
// Override to return a pretty string that's specific to the controller type.
virtual RString GetDeviceSpecificInputString( const DeviceInput &di );
@@ -240,10 +240,10 @@ InputHandler_Carbon::InputHandler_Carbon() : m_Sem( "Input thread started" ), m_
}
}
void InputHandler_Carbon::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc )
void InputHandler_Carbon::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices )
{
FOREACH_CONST( HIDDevice *, m_vDevices, i )
(*i)->GetDevicesAndDescriptions( dev, desc );
(*i)->GetDevicesAndDescriptions( vDevices );
}
RString InputHandler_Carbon::GetDeviceSpecificInputString( const DeviceInput &di )
@@ -33,7 +33,7 @@ public:
~InputHandler_Carbon();
bool DevicesChanged() { LockMut( m_ChangeLock ); return m_bChanged; }
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
RString GetDeviceSpecificInputString( const DeviceInput &di );
static void QueueCallBack( void *target, int result, void *refcon, void *sender );
@@ -586,13 +586,10 @@ void InputHandler_DInput::InputThreadMain()
CloseHandle(Handle);
}
void InputHandler_DInput::GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut )
void InputHandler_DInput::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
for( unsigned i=0; i < Devices.size(); ++i )
{
vDevicesOut.push_back( Devices[i].dev );
vDescriptionsOut.push_back( Devices[i].JoystickInst.tszProductName );
}
vDevicesOut.push_back( InputDeviceInfo(Devices[i].dev, Devices[i].JoystickInst.tszProductName) );
}
/*
@@ -10,7 +10,7 @@ class InputHandler_DInput: public InputHandler
public:
InputHandler_DInput();
~InputHandler_DInput();
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
void Update();
bool DevicesChanged();
void WindowReset();
@@ -179,15 +179,14 @@ void InputHandler_Linux_Joystick::InputThread()
InputHandler::UpdateTimer();
}
void InputHandler_Linux_Joystick::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut)
void InputHandler_Linux_Joystick::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
for(int i = 0; i < NUM_JOYSTICKS; ++i)
{
if (fds[i] < 0)
continue;
vDevicesOut.push_back( InputDevice(DEVICE_JOY1+i) );
vDescriptionsOut.push_back( m_sDescription[i] );
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_JOY1+i), m_sDescription[i]) );
}
}
@@ -11,7 +11,7 @@ public:
enum { NUM_JOYSTICKS = 4 };
InputHandler_Linux_Joystick();
~InputHandler_Linux_Joystick();
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut);
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
private:
static int InputThread_Start( void *p );
@@ -189,10 +189,9 @@ void InputHandler_Linux_tty::Update()
InputHandler::UpdateTimer();
}
void InputHandler_Linux_tty::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut)
void InputHandler_Linux_tty::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
vDevicesOut.push_back( InputDevice(DEVICE_KEYBOARD) );
vDescriptionsOut.push_back( "Keyboard" );
vDevicesOut.push_back( InputDeviceInfo(DEVICE_KEYBOARD,"Keyboard") );
}
/*
@@ -12,7 +12,7 @@ public:
void Update();
InputHandler_Linux_tty();
~InputHandler_Linux_tty();
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut);
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
};
#define USE_INPUT_HANDLER_LINUX_TTY
@@ -12,10 +12,9 @@ InputHandler_MonkeyKeyboard::~InputHandler_MonkeyKeyboard()
{
}
void InputHandler_MonkeyKeyboard::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut)
void InputHandler_MonkeyKeyboard::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
vDevicesOut.push_back( InputDevice(DEVICE_KEYBOARD) );
vDescriptionsOut.push_back( "MonkeyKeyboard" );
vDevicesOut.push_back( InputDeviceInfo(DEVICE_KEYBOARD,"MonkeyKeyboard") );
}
static const DeviceButton g_keys[] =
@@ -11,7 +11,7 @@ public:
void Update();
InputHandler_MonkeyKeyboard();
~InputHandler_MonkeyKeyboard();
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
private:
RageTimer m_timerPressButton;
@@ -248,18 +248,14 @@ void InputHandler_SDL::Update()
}
void InputHandler_SDL::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut)
void InputHandler_SDL::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
vDevicesOut.push_back( DEVICE_KEYBOARD );
vDescriptionsOut.push_back( "Keyboard" );
vDevicesOut.push_back( InputDeviceInfo(DEVICE_KEYBOARD,"Keyboard") );
for( int i=0; i<SDL_NumJoysticks(); i++ )
{
if( SDL_JoystickOpened(i) )
{
vDevicesOut.push_back( InputDevice(DEVICE_JOY1+i) );
vDescriptionsOut.push_back( SDL_JoystickName(i) );
}
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_JOY1+i), SDL_JoystickName(i)) );
}
}
@@ -14,7 +14,7 @@ public:
void Update();
InputHandler_SDL();
~InputHandler_SDL();
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut);
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
};
#define USE_INPUT_HANDLER_SDL
@@ -65,12 +65,11 @@ InputHandler_Win32_MIDI::~InputHandler_Win32_MIDI()
}
}
void InputHandler_Win32_MIDI::GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut )
void InputHandler_Win32_MIDI::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
if( m_bFoundDevice )
{
vDevicesOut.push_back( InputDevice(DEVICE_MIDI) );
vDescriptionsOut.push_back( "Win32_MIDI" );
vDevicesOut.push_back( InputDeviceInfo(DEVICE_MIDI,"Win32_MIDI") );
}
}
@@ -10,7 +10,7 @@ public:
InputHandler_Win32_MIDI();
~InputHandler_Win32_MIDI();
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
void SetDev( DeviceInput key, bool pressed ) { ButtonPressed( key, pressed ); }
@@ -37,7 +37,7 @@ InputHandler_Win32_Para::InputHandler_Win32_Para()
SAFE_DELETE( dev );
}
void InputHandler_Win32_Para::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut)
void InputHandler_Win32_Para::GetDevicesAndDescriptions(vector<InputDeviceInfo>& vDevicesOut )
{
// The device appears as a HID joystick
}
@@ -9,7 +9,7 @@ class InputHandler_Win32_Para: public InputHandler
{
public:
InputHandler_Win32_Para();
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
};
#define USE_INPUT_HANDLER_WIN32_PARA
@@ -87,14 +87,13 @@ RString InputHandler_Win32_Pump::GetDeviceSpecificInputString( const DeviceInput
return InputHandler::GetDeviceSpecificInputString( di );
}
void InputHandler_Win32_Pump::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut)
void InputHandler_Win32_Pump::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
for(int i = 0; i < NUM_PUMPS; ++i)
{
if( m_pDevice[i].IsOpen() )
{
vDevicesOut.push_back( InputDevice(DEVICE_PUMP1+i) );
vDescriptionsOut.push_back( "Pump USB" );
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_PUMP1+i),"Pump USB") );
}
}
}
@@ -12,7 +12,7 @@ public:
InputHandler_Win32_Pump();
~InputHandler_Win32_Pump();
RString GetDeviceSpecificInputString( const DeviceInput &di );
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
private:
USBDevice *m_pDevice;
@@ -170,10 +170,9 @@ void InputHandler_X11::Update()
}
void InputHandler_X11::GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut )
void InputHandler_X11::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
vDevicesOut.push_back( DEVICE_KEYBOARD );
vDescriptionsOut.push_back( "Keyboard" );
vDevicesOut.push_back( InputDeviceInfo(DEVICE_KEYBOARD,"Keyboard") );
}
/*
@@ -11,7 +11,7 @@ public:
InputHandler_X11();
~InputHandler_X11();
void Update();
void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut );
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
};
#define USE_INPUT_HANDLER_X11
@@ -161,14 +161,13 @@ void InputHandler_Xbox::Update()
InputHandler::UpdateTimer();
}
void InputHandler_Xbox::GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut)
void InputHandler_Xbox::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut )
{
for( int i=0; i<NUM_JOYSTICKS; i++ )
{
if( joysticks[i] != 0 )
{
vDevicesOut.push_back( InputDevice(DEVICE_JOY1+i) );
vDescriptionsOut.push_back( "XboxGameHardware" );
vDevicesOut.push_back( InputDeviceInfo(InputDevice(DEVICE_JOY1+i),"XboxGameHardware") );
}
}
}
@@ -16,7 +16,7 @@ public:
void Update();
InputHandler_Xbox();
~InputHandler_Xbox();
void GetDevicesAndDescriptions(vector<InputDevice>& vDevicesOut, vector<RString>& vDescriptionsOut);
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevicesOut );
private:
void getHandles();
+1 -1
View File
@@ -117,7 +117,7 @@ public:
/*
* Add a device and a description for each logical device.
*/
virtual void GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const = 0;
virtual void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const = 0;
};
#endif
@@ -192,12 +192,11 @@ int JoystickDevice::AssignIDs( InputDevice startID )
return m_vSticks.size();
}
void JoystickDevice::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const
void JoystickDevice::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const
{
FOREACH_CONST( Joystick, m_vSticks, i )
{
dev.push_back( i->id );
desc.push_back( GetDescription() );
vDevices.push_back( InputDeviceInfo(i->id,GetDescription()) );
}
}
@@ -31,7 +31,7 @@ public:
void GetButtonPresses( vector<pair<DeviceInput, bool> >& vPresses, int cookie,
int value, const RageTimer& now ) const;
int AssignIDs( InputDevice startID );
void GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const;
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const;
};
@@ -165,12 +165,11 @@ void KeyboardDevice::GetButtonPresses( vector<pair<DeviceInput, bool> >& vPresse
}
void KeyboardDevice::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const
void KeyboardDevice::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const
{
if( dev.size() && dev[0] == DEVICE_KEYBOARD )
if( vDevices.size() && vDevices[0] == DEVICE_KEYBOARD )
return;
dev.insert( dev.begin(), DEVICE_KEYBOARD );
desc.insert( desc.begin(), "Keyboard" );
vDevices.insert( dev.begin(), InputDeviceInfo(DEVICE_KEYBOARD,"Keyboard") );
}
/*
@@ -17,7 +17,7 @@ protected:
public:
void GetButtonPresses( vector<pair<DeviceInput, bool> >& vPresses, int cookie,
int value, const RageTimer& now ) const;
void GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const;
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const;
};
@@ -66,10 +66,9 @@ int PumpDevice::AssignIDs( InputDevice startID )
return 1;
}
void PumpDevice::GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const
void PumpDevice::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const
{
dev.push_back( m_Id );
desc.push_back( "Pump USB" );
vDevices.push_back( InputDeviceInfo(m_Id,"Pump USB") );
}
/*
+1 -1
View File
@@ -19,7 +19,7 @@ public:
void GetButtonPresses( vector<pair<DeviceInput, bool> >& vPresses, int cookie,
int value, const RageTimer& now ) const;
int AssignIDs( InputDevice startID );
void GetDevicesAndDescriptions( vector<InputDevice>& dev, vector<RString>& desc ) const;
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const;
};
#endif