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