From 5351df658658496da3460d111539131abbfb669b Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Sat, 20 Aug 2005 22:49:25 +0000 Subject: [PATCH] query for InputDeviceState --- stepmania/src/RageInput.cpp | 16 ++++++++++++++++ stepmania/src/RageInput.h | 1 + stepmania/src/RageInputDevice.h | 10 ++++++++++ stepmania/src/arch/InputHandler/InputHandler.h | 6 +++++- 4 files changed, 32 insertions(+), 1 deletion(-) diff --git a/stepmania/src/RageInput.cpp b/stepmania/src/RageInput.cpp index 52ce38142c..d10b9e23aa 100644 --- a/stepmania/src/RageInput.cpp +++ b/stepmania/src/RageInput.cpp @@ -68,6 +68,22 @@ CString RageInput::GetDeviceSpecificInputString( const DeviceInput &di ) return di.toString(); } +InputDeviceState RageInput::GetInputDeviceState( InputDevice id ) +{ + FOREACH( InputHandler*, m_pDevices, i ) + { + vector vDevices; + vector 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" diff --git a/stepmania/src/RageInput.h b/stepmania/src/RageInput.h index a7b3804282..3c5fa55a0d 100644 --- a/stepmania/src/RageInput.h +++ b/stepmania/src/RageInput.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 ); diff --git a/stepmania/src/RageInputDevice.h b/stepmania/src/RageInputDevice.h index ea2307a82c..41d63111bc 100644 --- a/stepmania/src/RageInputDevice.h +++ b/stepmania/src/RageInputDevice.h @@ -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 diff --git a/stepmania/src/arch/InputHandler/InputHandler.h b/stepmania/src/arch/InputHandler/InputHandler.h index f2b6ccd3c1..b10054de09 100644 --- a/stepmania/src/arch/InputHandler/InputHandler.h +++ b/stepmania/src/arch/InputHandler/InputHandler.h @@ -30,9 +30,13 @@ public: virtual void Update( float fDeltaTime ) { } virtual void GetDevicesAndDescriptions( vector& vDevicesOut, vector& 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() { }