query for InputDeviceState
This commit is contained in:
@@ -68,6 +68,22 @@ CString RageInput::GetDeviceSpecificInputString( const DeviceInput &di )
|
||||
return di.toString();
|
||||
}
|
||||
|
||||
InputDeviceState RageInput::GetInputDeviceState( InputDevice id )
|
||||
{
|
||||
FOREACH( InputHandler*, m_pDevices, i )
|
||||
{
|
||||
vector<InputDevice> vDevices;
|
||||
vector<CString> vDescriptions;
|
||||
(*i)->GetDevicesAndDescriptions( vDevices, vDescriptions );
|
||||
|
||||
bool bMatch = find(vDevices.begin(), vDevices.end(), id) != vDevices.end();
|
||||
if( bMatch )
|
||||
return (*i)->GetInputDeviceState(id);
|
||||
}
|
||||
|
||||
return InputDeviceState_INVALID;
|
||||
}
|
||||
|
||||
|
||||
// lua start
|
||||
#include "LuaBinding.h"
|
||||
|
||||
@@ -19,6 +19,7 @@ public:
|
||||
void WindowReset();
|
||||
void AddHandler( InputHandler *pHandler );
|
||||
CString GetDeviceSpecificInputString( const DeviceInput &di );
|
||||
InputDeviceState GetInputDeviceState( InputDevice id );
|
||||
|
||||
// Lua
|
||||
void PushSelf( lua_State *L );
|
||||
|
||||
@@ -39,6 +39,16 @@ const CString& InputDeviceToString( InputDevice i );
|
||||
InputDevice StringToInputDevice( const CString& s );
|
||||
|
||||
|
||||
enum InputDeviceState
|
||||
{
|
||||
InputDeviceState_Connected,
|
||||
InputDeviceState_Disconnected,
|
||||
InputDeviceState_MissingMultitap,
|
||||
NUM_InputDeviceState,
|
||||
InputDeviceState_INVALID
|
||||
};
|
||||
|
||||
|
||||
/* Only raw, unshifted keys go in this table; this doesn't include internationalized
|
||||
* keyboards, only keys that we might actually want to test for programmatically. Any
|
||||
* other keys are mapped to KEY_OTHER_0 and up. (If we want to support real international
|
||||
|
||||
@@ -30,9 +30,13 @@ public:
|
||||
virtual void Update( float fDeltaTime ) { }
|
||||
virtual void GetDevicesAndDescriptions( vector<InputDevice>& vDevicesOut, vector<CString>& vDescriptionsOut ) = 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 CString GetDeviceSpecificInputString( const DeviceInput &di ) { return di.toString(); }
|
||||
|
||||
// Override to find out whether the controller is currently plugged in.
|
||||
// Not all InputHandlers will support this. Not applicable to all InputHandlers.
|
||||
virtual InputDeviceState GetInputDeviceState( InputDevice id ) { return InputDeviceState_Connected; }
|
||||
|
||||
/* In Windows, some devices need to be recreated if we recreate our main window.
|
||||
* Override this if you need to do that. */
|
||||
virtual void WindowReset() { }
|
||||
|
||||
Reference in New Issue
Block a user