From 7039cafa9a008d4d61d97929dd1dfdb41f9b350f Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Wed, 28 Dec 2005 08:52:20 +0000 Subject: [PATCH] Merge input symbols: any device can have any input key. - This reduces the number of types associated with input; adding a distinct input type doesn't introduce a whole new enumerated type and related functions. - Special handling for different devices is needed less often. If you want to respond to an F1 press, simply check for KEY_F1; the device type doesn't really matter (though it'll usually be a keyboard). - This allows cleaner support for generalized USB devices. While they're usually of the traditional classes (keyboard, joystick) with associated inputs, they don't have to be. - Forced casts between parallel types can be removed, and weakly-specified variables (ints instead of the enum type) can be fixed. Some things that might have been merged havn't; for example, arrow keys on a keyboard (KEY_UP) are still distinct from axes on a joystick (JOY_UP). These may or may not be merged in the future. Some were: removed PUMP_ symbols. Treat them as generic buttons, and just give them names with GetDeviceSpecificInputString. It's not worth introducing more special names for something only used in one place. --- stepmania/src/Game.h | 5 +- stepmania/src/InputFilter.cpp | 4 +- stepmania/src/InputFilter.h | 2 +- stepmania/src/InputMapper.cpp | 26 ++-- stepmania/src/InputMapper.h | 2 +- stepmania/src/RageInputDevice.cpp | 249 ++++++++---------------------- stepmania/src/RageInputDevice.h | 75 +++------ stepmania/src/ScreenTestInput.cpp | 2 +- 8 files changed, 107 insertions(+), 258 deletions(-) diff --git a/stepmania/src/Game.h b/stepmania/src/Game.h index f2e7426e09..91ed283386 100644 --- a/stepmania/src/Game.h +++ b/stepmania/src/Game.h @@ -6,6 +6,7 @@ #include "GameInput.h" #include "MenuInput.h" #include "GameConstantsAndTypes.h" +#include "RageInputDevice.h" struct lua_State; @@ -34,7 +35,7 @@ const int MAX_STYLES_PER_GAME = 10; class Style; -#define NO_DEFAULT_KEY -1 +#define NO_DEFAULT_KEY DeviceButton_Invalid class Game { @@ -49,7 +50,7 @@ public: char m_szButtonNames[MAX_GAME_BUTTONS][60]; // The name used by the button graphics system. e.g. "left", "right", "middle C", "snare" GameButton m_DedicatedMenuButton[NUM_MENU_BUTTONS]; GameButton m_SecondaryMenuButton[NUM_MENU_BUTTONS]; - int m_iDefaultKeyboardKey[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS]; // default keyboard keys only have an effect the current game is this game + DeviceButton m_iDefaultKeyboardKey[MAX_GAME_CONTROLLERS][MAX_GAME_BUTTONS]; // default keyboard keys only have an effect the current game is this game GameButton ButtonNameToIndex( const CString &sButtonName ) const; MenuInput GameInputToMenuInput( GameInput GameI ) const; // looks up current style in GAMESTATE. Yuck. diff --git a/stepmania/src/InputFilter.cpp b/stepmania/src/InputFilter.cpp index 9e36057738..d657e079fb 100644 --- a/stepmania/src/InputFilter.cpp +++ b/stepmania/src/InputFilter.cpp @@ -140,7 +140,7 @@ void InputFilter::SetButtonComment( const DeviceInput &di, const CString &sComme void InputFilter::ResetDevice( InputDevice device ) { RageTimer now; - for( int button = 0; button < GetNumDeviceButtons(device); ++button ) + FOREACH_ENUM2( DeviceButton, button ) ButtonPressed( DeviceInput(device, button, -1, now), false ); } @@ -173,7 +173,7 @@ void InputFilter::Update( float fDeltaTime ) * things like "key pressed, key release, key repeat". */ LockMut(*queuemutex); - DeviceInput di( (InputDevice)0,0,1.0f,now); + DeviceInput di( (InputDevice)0,DeviceButton_Invalid,1.0f,now); set