From 4a588230e11937c13c9b5d67a1bf4ab27c6115e1 Mon Sep 17 00:00:00 2001 From: Chris Danford Date: Fri, 29 Nov 2002 20:37:12 +0000 Subject: [PATCH] DirectInput replaced with SDL's input routines. Keyboard works, but joystick and pump are untested. --- stepmania/src/GameManager.cpp | 117 ++-- stepmania/src/InputFilter.cpp | 3 +- stepmania/src/InputMapper.cpp | 1 + stepmania/src/RageDisplay.cpp | 3 - stepmania/src/RageInput.cpp | 769 ++++++++----------------- stepmania/src/RageInput.h | 83 +-- stepmania/src/Screen.cpp | 2 +- stepmania/src/ScreenEdit.cpp | 269 ++++----- stepmania/src/ScreenGameplay.cpp | 24 +- stepmania/src/ScreenMapControllers.cpp | 18 +- stepmania/src/ScreenSandbox.cpp | 12 +- stepmania/src/ScreenTextEntry.cpp | 10 +- stepmania/src/StdAfx.h | 8 - stepmania/src/StepMania.cpp | 22 +- 14 files changed, 504 insertions(+), 837 deletions(-) diff --git a/stepmania/src/GameManager.cpp b/stepmania/src/GameManager.cpp index 3b5e044ef7..ccc05eafdc 100644 --- a/stepmania/src/GameManager.cpp +++ b/stepmania/src/GameManager.cpp @@ -18,6 +18,7 @@ #include "IniFile.h" #include "RageLog.h" #include "RageUtil.h" +#include "SDL_keysym.h" // for SDLKeys GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program @@ -106,28 +107,28 @@ GameDef g_GameDefs[NUM_GAMES] = }, { // m_iDefaultKeyboardKey { // PLAYER_1 - DIK_LEFT, // DANCE_BUTTON_LEFT, - DIK_RIGHT, // DANCE_BUTTON_RIGHT, - DIK_UP, // DANCE_BUTTON_UP, - DIK_DOWN, // DANCE_BUTTON_DOWN, + SDLK_LEFT, // DANCE_BUTTON_LEFT, + SDLK_RIGHT, // DANCE_BUTTON_RIGHT, + SDLK_UP, // DANCE_BUTTON_UP, + SDLK_DOWN, // DANCE_BUTTON_DOWN, -1, //no default key // DANCE_BUTTON_UPLEFT, -1, //no default key // DANCE_BUTTON_UPRIGHT, - DIK_RETURN, // DANCE_BUTTON_START, - DIK_ESCAPE, // DANCE_BUTTON_BACK + SDLK_RETURN, // DANCE_BUTTON_START, + SDLK_ESCAPE, // DANCE_BUTTON_BACK -1, //no default key // DANCE_BUTTON_MENULEFT -1, //no default key // DANCE_BUTTON_MENURIGHT - DIK_UP, // DANCE_BUTTON_MENUUP - DIK_DOWN, // DANCE_BUTTON_MENUDOWN + SDLK_UP, // DANCE_BUTTON_MENUUP + SDLK_DOWN, // DANCE_BUTTON_MENUDOWN }, { // PLAYER_2 - DIK_NUMPAD4, // DANCE_BUTTON_LEFT, - DIK_NUMPAD6, // DANCE_BUTTON_RIGHT, - DIK_NUMPAD8, // DANCE_BUTTON_UP, - DIK_NUMPAD2, // DANCE_BUTTON_DOWN, - DIK_NUMPAD7, // DANCE_BUTTON_UPLEFT, - DIK_NUMPAD9, // DANCE_BUTTON_UPRIGHT, - DIK_NUMPADENTER, // DANCE_BUTTON_START, - DIK_NUMPAD0, // DANCE_BUTTON_BACK + SDLK_KP4, // DANCE_BUTTON_LEFT, + SDLK_KP6, // DANCE_BUTTON_RIGHT, + SDLK_KP8, // DANCE_BUTTON_UP, + SDLK_KP2, // DANCE_BUTTON_DOWN, + SDLK_KP7, // DANCE_BUTTON_UPLEFT, + SDLK_KP9, // DANCE_BUTTON_UPRIGHT, + SDLK_KP_ENTER, // DANCE_BUTTON_START, + SDLK_KP0, // DANCE_BUTTON_BACK -1, //no default key // DANCE_BUTTON_MENULEFT -1, //no default key // DANCE_BUTTON_MENURIGHT -1, //no default key // DANCE_BUTTON_MENUUP @@ -184,26 +185,26 @@ GameDef g_GameDefs[NUM_GAMES] = }, { // m_iDefaultKeyboardKey { // PLAYER_1 - DIK_Q, // PUMP_BUTTON_UPLEFT, - DIK_E, // PUMP_BUTTON_UPRIGHT, - DIK_S, // PUMP_BUTTON_CENTER, - DIK_Z, // PUMP_BUTTON_DOWNLEFT, - DIK_C, // PUMP_BUTTON_DOWNRIGHT, - DIK_RETURN, // PUMP_BUTTON_START, - DIK_ESCAPE, // PUMP_BUTTON_BACK, - DIK_LEFT, // PUMP_BUTTON_MENULEFT - DIK_RIGHT, // PUMP_BUTTON_MENURIGHT - DIK_UP, // PUMP_BUTTON_MENUUP - DIK_DOWN, // PUMP_BUTTON_MENUDOWN + SDLK_q, // PUMP_BUTTON_UPLEFT, + SDLK_e, // PUMP_BUTTON_UPRIGHT, + SDLK_s, // PUMP_BUTTON_CENTER, + SDLK_z, // PUMP_BUTTON_DOWNLEFT, + SDLK_c, // PUMP_BUTTON_DOWNRIGHT, + SDLK_RETURN, // PUMP_BUTTON_START, + SDLK_ESCAPE, // PUMP_BUTTON_BACK, + SDLK_LEFT, // PUMP_BUTTON_MENULEFT + SDLK_RIGHT, // PUMP_BUTTON_MENURIGHT + SDLK_UP, // PUMP_BUTTON_MENUUP + SDLK_DOWN, // PUMP_BUTTON_MENUDOWN }, { // PLAYER_2 - DIK_NUMPAD7, // PUMP_BUTTON_UPLEFT, - DIK_NUMPAD9, // PUMP_BUTTON_UPRIGHT, - DIK_NUMPAD5, // PUMP_BUTTON_CENTER, - DIK_NUMPAD1, // PUMP_BUTTON_DOWNLEFT, - DIK_NUMPAD3, // PUMP_BUTTON_DOWNRIGHT, - DIK_NUMPADENTER, // PUMP_BUTTON_START, - DIK_NUMPAD0, // PUMP_BUTTON_BACK, + SDLK_KP7, // PUMP_BUTTON_UPLEFT, + SDLK_KP9, // PUMP_BUTTON_UPRIGHT, + SDLK_KP5, // PUMP_BUTTON_CENTER, + SDLK_KP1, // PUMP_BUTTON_DOWNLEFT, + SDLK_KP3, // PUMP_BUTTON_DOWNRIGHT, + SDLK_KP_ENTER, // PUMP_BUTTON_START, + SDLK_KP0, // PUMP_BUTTON_BACK, -1, //no default key // PUMP_BUTTON_MENULEFT -1, //no default key // PUMP_BUTTON_MENURIGHT -1, //no default key // PUMP_BUTTON_MENUUP @@ -264,19 +265,19 @@ GameDef g_GameDefs[NUM_GAMES] = }, { // m_iDefaultKeyboardKey { // PLAYER_1 - DIK_Z, // EZ2_BUTTON_FOOTUPLEFT, - DIK_B, // EZ2_BUTTON_FOOTUPRIGHT, - DIK_C, // EZ2_BUTTON_FOOTDOWN, - DIK_X, // EZ2_BUTTON_HANDUPLEFT, - DIK_V, // EZ2_BUTTON_HANDUPRIGHT, - DIK_S, // EZ2_BUTTON_HANDLRLEFT, - DIK_F, // EZ2_BUTTON_HANDLRRIGHT, - DIK_RETURN, // EZ2_BUTTON_START, - DIK_ESCAPE, // EZ2_BUTTON_BACK, - DIK_LEFT, // EZ2_BUTTON_MENULEFT - DIK_RIGHT, // EZ2_BUTTON_MENURIGHT - DIK_UP, // EZ2_BUTTON_MENUUP - DIK_DOWN, // EZ2_BUTTON_MENUDOWN + SDLK_z, // EZ2_BUTTON_FOOTUPLEFT, + SDLK_b, // EZ2_BUTTON_FOOTUPRIGHT, + SDLK_c, // EZ2_BUTTON_FOOTDOWN, + SDLK_x, // EZ2_BUTTON_HANDUPLEFT, + SDLK_v, // EZ2_BUTTON_HANDUPRIGHT, + SDLK_s, // EZ2_BUTTON_HANDLRLEFT, + SDLK_f, // EZ2_BUTTON_HANDLRRIGHT, + SDLK_RETURN, // EZ2_BUTTON_START, + SDLK_ESCAPE, // EZ2_BUTTON_BACK, + SDLK_LEFT, // EZ2_BUTTON_MENULEFT + SDLK_RIGHT, // EZ2_BUTTON_MENURIGHT + SDLK_UP, // EZ2_BUTTON_MENUUP + SDLK_DOWN, // EZ2_BUTTON_MENUDOWN }, { // PLAYER_2 -1, // EZ2_BUTTON_FOOTUPLEFT, @@ -344,17 +345,17 @@ GameDef g_GameDefs[NUM_GAMES] = }, { // m_iDefaultKeyboardKey { // PLAYER_1 - DIK_Z, // PARA_BUTTON_LEFT, - DIK_X, // PARA_BUTTON_UPLEFT, - DIK_C, // PARA_BUTTON_UP, - DIK_V, // PARA_BUTTON_UPRIGHT, - DIK_B, // PARA_BUTTON_RIGHT, - DIK_RETURN, // PARA_BUTTON_START, - DIK_ESCAPE, // PARA_BUTTON_BACK - DIK_LEFT, //no default key // PARA_BUTTON_MENULEFT - DIK_RIGHT, //no default key // PARA_BUTTON_MENURIGHT - DIK_UP, // PARA_BUTTON_MENUUP - DIK_DOWN, // PARA_BUTTON_MENUDOWN + SDLK_z, // PARA_BUTTON_LEFT, + SDLK_x, // PARA_BUTTON_UPLEFT, + SDLK_c, // PARA_BUTTON_UP, + SDLK_v, // PARA_BUTTON_UPRIGHT, + SDLK_b, // PARA_BUTTON_RIGHT, + SDLK_RETURN, // PARA_BUTTON_START, + SDLK_ESCAPE, // PARA_BUTTON_BACK + SDLK_LEFT, //no default key // PARA_BUTTON_MENULEFT + SDLK_RIGHT, //no default key // PARA_BUTTON_MENURIGHT + SDLK_UP, // PARA_BUTTON_MENUUP + SDLK_DOWN, // PARA_BUTTON_MENUDOWN }, { // PLAYER_2 -1, // PARA_BUTTON_LEFT, diff --git a/stepmania/src/InputFilter.cpp b/stepmania/src/InputFilter.cpp index 70651c745b..5bf1c4c83a 100644 --- a/stepmania/src/InputFilter.cpp +++ b/stepmania/src/InputFilter.cpp @@ -14,6 +14,7 @@ #include "InputFilter.h" #include "RageLog.h" #include "RageInput.h" +#include "SDL_keyboard.h" InputFilter* INPUTFILTER = NULL; // global and accessable from anywhere in our program @@ -58,7 +59,7 @@ float InputFilter::GetSecsHeld( DeviceInput di ) void InputFilter::GetInputEvents( InputEventArray &array, float fDeltaTime ) { - INPUTMAN->Update(); + INPUTMAN->Update( fDeltaTime ); for( int d=0; d #include "RageInput.h" -#include +#include "SDL.h" +#include "SDL_keyboard.h" #include "RageUtil.h" #include "RageLog.h" #include "RageException.h" - RageInput* INPUTMAN = NULL; // globally accessable input device static const char *PumpButtonNames[] = { @@ -53,7 +49,7 @@ int DeviceInput::NumButtons(InputDevice device) case DEVICE_PUMP2: return NUM_PUMP_PAD_BUTTONS; default: - ASSERT( false ); + ASSERT(0); // invalid device } return -1; /* quiet compiler */ } @@ -136,116 +132,117 @@ CString DeviceInput::GetDescription() break; case DEVICE_KEYBOARD: // keyboard - sReturn = "Key "; - + sReturn = ssprintf("Key %s", SDL_GetKeyName((SDLKey)button) ); +/* switch( button ) { - case DIK_ESCAPE: sReturn += "Escape"; break; - case DIK_1: sReturn += "1"; break; - case DIK_2: sReturn += "2"; break; - case DIK_3: sReturn += "3"; break; - case DIK_4: sReturn += "4"; break; - case DIK_5: sReturn += "5"; break; - case DIK_6: sReturn += "6"; break; - case DIK_7: sReturn += "7"; break; - case DIK_8: sReturn += "8"; break; - case DIK_9: sReturn += "9"; break; - case DIK_0: sReturn += "0"; break; - case DIK_MINUS: sReturn += "Minus"; break; - case DIK_EQUALS: sReturn += "Equals"; break; - case DIK_BACK: sReturn += "Backsp"; break; - case DIK_TAB: sReturn += "Tab"; break; - case DIK_Q: sReturn += "Q"; break; - case DIK_W: sReturn += "W"; break; - case DIK_E: sReturn += "E"; break; - case DIK_R: sReturn += "R"; break; - case DIK_T: sReturn += "T"; break; - case DIK_Y: sReturn += "Y"; break; - case DIK_U: sReturn += "U"; break; - case DIK_I: sReturn += "I"; break; - case DIK_O: sReturn += "O"; break; - case DIK_P: sReturn += "P"; break; - case DIK_LBRACKET: sReturn += "LBracket"; break; - case DIK_RBRACKET: sReturn += "RBracket"; break; - case DIK_RETURN: sReturn += "Return"; break; - case DIK_LCONTROL: sReturn += "LControl"; break; - case DIK_A: sReturn += "A"; break; - case DIK_S: sReturn += "S"; break; - case DIK_D: sReturn += "D"; break; - case DIK_F: sReturn += "F"; break; - case DIK_G: sReturn += "G"; break; - case DIK_H: sReturn += "H"; break; - case DIK_J: sReturn += "J"; break; - case DIK_K: sReturn += "K"; break; - case DIK_L: sReturn += "L"; break; - case DIK_SEMICOLON: sReturn += "Semicln"; break; - case DIK_APOSTROPHE:sReturn += "Apostro"; break; - case DIK_GRAVE: sReturn += "Grave"; break; - case DIK_LSHIFT: sReturn += "LShift"; break; - case DIK_BACKSLASH: sReturn += "Backslsh"; break; - case DIK_Z: sReturn += "Z"; break; - case DIK_X: sReturn += "X"; break; - case DIK_C: sReturn += "C"; break; - case DIK_V: sReturn += "V"; break; - case DIK_B: sReturn += "B"; break; - case DIK_N: sReturn += "N"; break; - case DIK_M: sReturn += "M"; break; - case DIK_COMMA: sReturn += "Comma"; break; - case DIK_PERIOD: sReturn += "Period"; break; - case DIK_SLASH: sReturn += "Slash"; break; - case DIK_RSHIFT: sReturn += "RShift"; break; - case DIK_MULTIPLY: sReturn += "Mult"; break; - case DIK_LMENU: sReturn += "LMenu"; break; - case DIK_SPACE: sReturn += "Space"; break; - case DIK_CAPITAL: sReturn += "CapsLk"; break; - case DIK_F1: sReturn += "F1"; break; - case DIK_F2: sReturn += "F2"; break; - case DIK_F3: sReturn += "F3"; break; - case DIK_F4: sReturn += "F4"; break; - case DIK_F5: sReturn += "F5"; break; - case DIK_F6: sReturn += "F6"; break; - case DIK_F7: sReturn += "F7"; break; - case DIK_F8: sReturn += "F8"; break; - case DIK_F9: sReturn += "F9"; break; - case DIK_F10: sReturn += "F10"; break; - case DIK_NUMLOCK: sReturn += "Numlock"; break; - case DIK_SCROLL: sReturn += "Scroll"; break; - case DIK_NUMPAD7: sReturn += "NumPad7"; break; - case DIK_NUMPAD8: sReturn += "NumPad8"; break; - case DIK_NUMPAD9: sReturn += "NumPad9"; break; - case DIK_SUBTRACT: sReturn += "Subtract"; break; - case DIK_NUMPAD4: sReturn += "NumPad4"; break; - case DIK_NUMPAD5: sReturn += "NumPad5"; break; - case DIK_NUMPAD6: sReturn += "NumPad6"; break; - case DIK_ADD: sReturn += "Add"; break; - case DIK_NUMPAD1: sReturn += "NumPad1"; break; - case DIK_NUMPAD2: sReturn += "NumPad2"; break; - case DIK_NUMPAD3: sReturn += "NumPad3"; break; - case DIK_NUMPAD0: sReturn += "NumPad0"; break; - case DIK_DECIMAL: sReturn += "Decimal"; break; - case DIK_RMENU: sReturn += "RightAlt"; break; - case DIK_PAUSE: sReturn += "Pause"; break; - case DIK_HOME: sReturn += "Home"; break; - case DIK_UP: sReturn += "Up"; break; - case DIK_PRIOR: sReturn += "PageUp"; break; - case DIK_LEFT: sReturn += "Left"; break; - case DIK_RIGHT: sReturn += "Right"; break; - case DIK_END: sReturn += "End"; break; - case DIK_DOWN: sReturn += "Down"; break; - case DIK_NEXT: sReturn += "PageDn"; break; - case DIK_INSERT: sReturn += "Insert"; break; - case DIK_DELETE: sReturn += "Delete"; break; - case DIK_LWIN: sReturn += "LeftWin"; break; - case DIK_RWIN: sReturn += "RightWin"; break; - case DIK_APPS: sReturn += "AppMenu"; break; - case DIK_NUMPADENTER: sReturn += "PadEnter"; break; - case DIK_DIVIDE: sReturn += "PadSlash"; break; + case SDLK_ESCAPE: sReturn += "Escape"; break; + case SDLK_1: sReturn += "1"; break; + case SDLK_2: sReturn += "2"; break; + case SDLK_3: sReturn += "3"; break; + case SDLK_4: sReturn += "4"; break; + case SDLK_5: sReturn += "5"; break; + case SDLK_6: sReturn += "6"; break; + case SDLK_7: sReturn += "7"; break; + case SDLK_8: sReturn += "8"; break; + case SDLK_9: sReturn += "9"; break; + case SDLK_0: sReturn += "0"; break; + case SDLK_MINUS: sReturn += "Minus"; break; + case SDLK_EQUALS: sReturn += "Equals"; break; + case SDLK_BACKSPACE: sReturn += "Backsp"; break; + case SDLK_TAB: sReturn += "Tab"; break; + case SDLK_Q: sReturn += "Q"; break; + case SDLK_W: sReturn += "W"; break; + case SDLK_E: sReturn += "E"; break; + case SDLK_R: sReturn += "R"; break; + case SDLK_T: sReturn += "T"; break; + case SDLK_Y: sReturn += "Y"; break; + case SDLK_U: sReturn += "U"; break; + case SDLK_I: sReturn += "I"; break; + case SDLK_O: sReturn += "O"; break; + case SDLK_P: sReturn += "P"; break; + case SDLK_LBRACKET: sReturn += "LBracket"; break; + case SDLK_RBRACKET: sReturn += "RBracket"; break; + case SDLK_RETURN: sReturn += "Return"; break; + case SDLK_LCONTROL: sReturn += "LControl"; break; + case SDLK_A: sReturn += "A"; break; + case SDLK_S: sReturn += "S"; break; + case SDLK_D: sReturn += "D"; break; + case SDLK_F: sReturn += "F"; break; + case SDLK_G: sReturn += "G"; break; + case SDLK_H: sReturn += "H"; break; + case SDLK_J: sReturn += "J"; break; + case SDLK_K: sReturn += "K"; break; + case SDLK_L: sReturn += "L"; break; + case SDLK_SEMICOLON: sReturn += "Semicln"; break; + case SDLK_APOSTROPHE:sReturn += "Apostro"; break; + case SDLK_GRAVE: sReturn += "Grave"; break; + case SDLK_LSHIFT: sReturn += "LShift"; break; + case SDLK_BACKSLASH: sReturn += "Backslsh"; break; + case SDLK_Z: sReturn += "Z"; break; + case SDLK_X: sReturn += "X"; break; + case SDLK_C: sReturn += "C"; break; + case SDLK_V: sReturn += "V"; break; + case SDLK_B: sReturn += "B"; break; + case SDLK_N: sReturn += "N"; break; + case SDLK_M: sReturn += "M"; break; + case SDLK_COMMA: sReturn += "Comma"; break; + case SDLK_PERIOD: sReturn += "Period"; break; + case SDLK_SLASH: sReturn += "Slash"; break; + case SDLK_RSHIFT: sReturn += "RShift"; break; + case SDLK_MULTIPLY: sReturn += "Mult"; break; + case SDLK_LMENU: sReturn += "LMenu"; break; + case SDLK_SPACE: sReturn += "Space"; break; + case SDLK_CAPITAL: sReturn += "CapsLk"; break; + case SDLK_F1: sReturn += "F1"; break; + case SDLK_F2: sReturn += "F2"; break; + case SDLK_F3: sReturn += "F3"; break; + case SDLK_F4: sReturn += "F4"; break; + case SDLK_F5: sReturn += "F5"; break; + case SDLK_F6: sReturn += "F6"; break; + case SDLK_F7: sReturn += "F7"; break; + case SDLK_F8: sReturn += "F8"; break; + case SDLK_F9: sReturn += "F9"; break; + case SDLK_F10: sReturn += "F10"; break; + case SDLK_NUMLOCK: sReturn += "Numlock"; break; + case SDLK_SCROLL: sReturn += "Scroll"; break; + case SDLK_NUMPAD7: sReturn += "NumPad7"; break; + case SDLK_NUMPAD8: sReturn += "NumPad8"; break; + case SDLK_NUMPAD9: sReturn += "NumPad9"; break; + case SDLK_SUBTRACT: sReturn += "Subtract"; break; + case SDLK_NUMPAD4: sReturn += "NumPad4"; break; + case SDLK_NUMPAD5: sReturn += "NumPad5"; break; + case SDLK_NUMPAD6: sReturn += "NumPad6"; break; + case SDLK_ADD: sReturn += "Add"; break; + case SDLK_NUMPAD1: sReturn += "NumPad1"; break; + case SDLK_NUMPAD2: sReturn += "NumPad2"; break; + case SDLK_NUMPAD3: sReturn += "NumPad3"; break; + case SDLK_NUMPAD0: sReturn += "NumPad0"; break; + case SDLK_DECIMAL: sReturn += "Decimal"; break; + case SDLK_RMENU: sReturn += "RightAlt"; break; + case SDLK_PAUSE: sReturn += "Pause"; break; + case SDLK_HOME: sReturn += "Home"; break; + case SDLK_UP: sReturn += "Up"; break; + case SDLK_PRIOR: sReturn += "PageUp"; break; + case SDLK_LEFT: sReturn += "Left"; break; + case SDLK_RIGHT: sReturn += "Right"; break; + case SDLK_END: sReturn += "End"; break; + case SDLK_DOWN: sReturn += "Down"; break; + case SDLK_NEXT: sReturn += "PageDn"; break; + case SDLK_INSERT: sReturn += "Insert"; break; + case SDLK_DELETE: sReturn += "Delete"; break; + case SDLK_LWIN: sReturn += "LeftWin"; break; + case SDLK_RWIN: sReturn += "RightWin"; break; + case SDLK_APPS: sReturn += "AppMenu"; break; + case SDLK_NUMPADENTER: sReturn += "PadEnter"; break; + case SDLK_DIVIDE: sReturn += "PadSlash"; break; default: sReturn += "Unknown Key"; break; } +*/ break; default: - ASSERT( false ); // what device is this? + ASSERT(0); // what device is this? } return sReturn; @@ -275,7 +272,7 @@ bool DeviceInput::fromString( const CString &s ) } /* FIXME: The main font doesn't have '`' (0x29), so that's disabled. */ -static const char dik_charmap[] = { +static const char SDLK_charmap[] = { /* 0 1 2 3 4 5 6 7 8 9 A B C D E F */ /* 0x0x */ 0, 0,'1','2','3','4','5','6','7', '8','9', '0','-','=', 0, 0, /* 0x1x */ 'q','w','e','r','t','y','u','i','o', 'p','[', ']', 0, 0,'a','s', @@ -296,8 +293,8 @@ char DeviceInput::ToChar() const switch( device ) { case DEVICE_KEYBOARD: - if( button < sizeof(dik_charmap) ) - return dik_charmap[button]; + if( button < sizeof(SDLK_charmap) ) + return SDLK_charmap[button]; return '\0'; default: return '\0'; @@ -305,231 +302,60 @@ char DeviceInput::ToChar() const } -//----------------------------------------------------------------------------- -// Name: EnumJoysticksCallMenuBack( PlayerNumber pn ) -// Desc: Called once for each enumerated joystick. If we find one, create a -// device interface on it so we can play with it. -//----------------------------------------------------------------------------- -BOOL CALLBACK RageInput::EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, - VOID* pContext ) -{ - RageInput* pInput = (RageInput*)pContext; - LPDIRECTINPUT8 pDI = pInput->GetDirectInput(); - - static int i=0; // ASSUMPTION: This callback is only used on application start! - - // Obtain an interface to the enumerated joystick. - if( i >= NUM_JOYSTICKS ) - return DIENUM_STOP; // we only care about the first 4 - - HRESULT hr = pDI->CreateDevice( pdidInstance->guidInstance, - &pInput->m_pJoystick[i++], - NULL ); - if( FAILED( hr ) ) - throw RageException( hr, "Error in CreateDevice() for joystick %d.", i ); - - return DIENUM_CONTINUE; -} - - - - -//----------------------------------------------------------------------------- -// Name: EnumAxesCallMenuBack( PlayerNumber pn ) -// Desc: Callback function for enumerating the axes on a joystick -//----------------------------------------------------------------------------- -BOOL CALLBACK RageInput::EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext ) -{ - LPDIRECTINPUTDEVICE8 pJoystick = (LPDIRECTINPUTDEVICE8)pContext; - - DIPROPRANGE diprg; - diprg.diph.dwSize = sizeof(DIPROPRANGE); - diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER); - diprg.diph.dwHow = DIPH_BYID; - diprg.diph.dwObj = pdidoi->dwType; // Specify the enumerated axis - diprg.lMin = -1000; - diprg.lMax = +1000; - - // Set the range for the axis - if( FAILED( pJoystick->SetProperty( DIPROP_RANGE, &diprg.diph ) ) ) - return DIENUM_STOP; - - - return DIENUM_CONTINUE; -} - - - - -RageInput::RageInput( HWND hWnd ) +RageInput::RageInput() { LOG->Trace( "RageInput::RageInput()" ); - int i; + SDL_InitSubSystem( SDL_INIT_JOYSTICK ); - m_hWnd = hWnd; + // init state info + memset( m_keys, 0, sizeof(m_keys) ); + memset( m_oldKeys, 0, sizeof(m_oldKeys) ); + memset( m_joyState, 0, sizeof(m_joyState) ); + memset( m_oldJoyState, 0, sizeof(m_oldJoyState) ); + memset( m_pumpState, 0, sizeof(m_pumpState) ); + memset( m_oldPumpState, 0, sizeof(m_oldPumpState) ); - m_pDI = NULL; - m_pKeyboard = NULL; - m_pMouse = NULL; - for( i=0; iTrace( "Found joystick %d: %s", i, SDL_JoystickName(i) ); + } + SDL_JoystickEventState( SDL_IGNORE ); - ZeroMemory( &m_oldJoyState, sizeof(m_oldJoyState) ); - ZeroMemory( &m_pumpState, sizeof(m_pumpState) ); - ZeroMemory( &m_oldPumpState, sizeof(m_oldPumpState) ); + + // + // Init pumps + // m_Pumps = new pump_t[NUM_PUMPS]; - Initialize(); -} - -RageInput::~RageInput() -{ - Release(); -} - -void RageInput::Initialize() -{ - HRESULT hr; - - //////////////////////////////// - // Create the DirectInput object - //////////////////////////////// - if( FAILED(hr = DirectInput8Create( GetModuleHandle(NULL), DIRECTINPUT_VERSION, - IID_IDirectInput8, (VOID**)&m_pDI, NULL ) ) ) - throw RageException( hr, "DirectInput8Create failed." ); - - ///////////////////////////// - // Create the keyboard device - ///////////////////////////// - - // Create our DirectInput Object for the Keyboard - if( FAILED( hr = m_pDI->CreateDevice( GUID_SysKeyboard, &m_pKeyboard, NULL ) ) ) - m_pKeyboard = NULL; - - if(m_pKeyboard) { - // Set our Cooperation Level with each Device - if( FAILED( hr = m_pKeyboard->SetCooperativeLevel(m_hWnd, DISCL_FOREGROUND | - DISCL_NOWINKEY | - DISCL_NONEXCLUSIVE) ) ) - throw RageException( hr, "m_pKeyboard->SetCooperativeLevel failed." ); - - // Set the Data Format of each device - if( FAILED( hr = m_pKeyboard->SetDataFormat(&c_dfDIKeyboard) ) ) - throw RageException( hr, "m_pKeyboard->SetDataFormat failed." ); - - // Acquire the Keyboard Device - //if( FAILED( hr = m_pKeyboard->Acquire() ) ) - // throw RageException( "m_pKeyboard->Acquire failed.", hr ); - } - - - ////////////////////////// - // Create the mouse device - ////////////////////////// - - // Obtain an interface to the system mouse device. - if( FAILED( hr = m_pDI->CreateDevice( GUID_SysMouse, &m_pMouse, NULL ) ) ) - m_pMouse = NULL; - - if(m_pMouse) { - if( FAILED( hr = m_pMouse->SetCooperativeLevel( m_hWnd, DISCL_NONEXCLUSIVE|DISCL_FOREGROUND ) ) ) - throw RageException( hr, "m_pMouse->SetCooperativeLevel failed." ); - - if( FAILED( hr = m_pMouse->SetDataFormat( &c_dfDIMouse2 ) ) ) - throw RageException( hr, "m_pMouse->SetDataFormat failed." ); -/* - DIPROPDWORD dipdw; - dipdw.diph.dwSize = sizeof(DIPROPDWORD); - dipdw.diph.dwHeaderSize = sizeof(DIPROPHEADER); - dipdw.diph.dwObj = 0; - dipdw.diph.dwHow = DIPH_DEVICE; - dipdw.dwData = DIPROPAXISMODE_ABS; - - if( FAILED( m_pMouse->SetProperty( DIPROP_AXISMODE, &dipdw.diph ) ) ) - return E_FAIL;*/ - //if( FAILED( hr = m_pMouse->Acquire())) - // throw RageException( "m_pMouse->Acquire failed.", hr ); - - m_RelPosition_x = m_RelPosition_y = 0; - - m_AbsPosition_x = 640/2; - m_AbsPosition_y = 480/2; - } - - { - /* Nasty hack to work around a bug in DirectInput8: Pump pads - * crash EnumDevices. Prevent this by opening the pad with - * exclusive access while we enumerate, then closing it when - * we finish. We don't do anything with this; we open it - * for real down below, since we don't *really* want to open - * the pad with exclusive access. (I also don't want to introduce - * dependencies, such as "pump must be initialized before joysticks", - * so this doesn't bite us again down the road.) */ - pump_t m_TempPumps[NUM_PUMPS]; - for(int pumpNo = 0; pumpNo < NUM_PUMPS; ++pumpNo) - m_TempPumps[pumpNo].init(pumpNo, false); - - ////////////////////////////// - // Create the joystick devices - ////////////////////////////// - // Look for joysticks - // TODO: Why is this function so slow to return? Is it just my machine? - if( FAILED( hr = m_pDI->EnumDevices( DI8DEVCLASS_GAMECTRL, - EnumJoysticksCallback, - (VOID*)this, - DIEDFL_ATTACHEDONLY ) ) ) - throw RageException( hr, "m_pDI->EnumDevices failed." ); - } - - for( int i=0; iSetDataFormat( &c_dfDIJoystick2 ) ) ) - throw RageException( hr, "m_pJoystick[i]->SetDataFormat failed." ); - - - // Set the cooperative level to let DInput know how this device should - // interact with the system and with other DInput applications. - if( m_pJoystick[i] ) - if( FAILED( hr = m_pJoystick[i]->SetCooperativeLevel( m_hWnd, DISCL_NONEXCLUSIVE | DISCL_BACKGROUND ) ) ) - throw RageException( hr, "m_pJoystick[i]->SetCooperativeLevel failed." ); - - - /* - // Determine how many axis the joystick has (so we don't error out setting - // properties for unavailable axis) - if ( m_pJoystick[i] ) { - g_diDevCaps.dwSize = sizeof(DIDEVCAPS); - if ( FAILED( hr = m_pJoystick[i]->GetCapabilities(&g_diDevCaps) ) ) - return hr; - } - */ - - // Enumerate the axes of the joyctick and set the range of each axis. Note: - // we could just use the defaults, but we're just trying to show an example - // of enumerating device objects (axes, buttons, etc.). - if( m_pJoystick[i] ) - if ( FAILED( hr = m_pJoystick[i]->EnumObjects( EnumAxesCallback, (VOID*)m_pJoystick[i], DIDFT_AXIS ) ) ) - throw RageException( hr, "m_pJoystick[i]->EnumObjects failed." ); - - // Acquire the newly created devices - if( m_pJoystick[i] ) - if( FAILED( hr = m_pJoystick[i]->Acquire() ) ) - throw RageException( hr, "m_pJoystick[i]->Acquire failed." ); - } +// { +// /* Nasty hack to work around a bug in DirectInput8: Pump pads +// * crash EnumDevices. Prevent this by opening the pad with +// * exclusive access while we enumerate, then closing it when +// * we finish. We don't do anything with this; we open it +// * for real down below, since we don't *really* want to open +// * the pad with exclusive access. (I also don't want to introduce +// * dependencies, such as "pump must be initialized before joysticks", +// * so this doesn't bite us again down the road.) */ +// pump_t m_TempPumps[NUM_PUMPS]; +// for(int pumpNo = 0; pumpNo < NUM_PUMPS; ++pumpNo) +// m_TempPumps[pumpNo].init(pumpNo, false); +// +// } for(int pumpNo = 0; pumpNo < NUM_PUMPS; ++pumpNo) { @@ -538,91 +364,96 @@ void RageInput::Initialize() } } -void RageInput::Release() +RageInput::~RageInput() { - // Unacquire the keyboard device - if (m_pKeyboard) - m_pKeyboard->Unacquire(); - // Release the keyboard device - SAFE_RELEASE(m_pKeyboard); - // Unacquire the Mouse device - if (m_pMouse) - m_pMouse->Unacquire(); - // Release the Mouse device - SAFE_RELEASE(m_pMouse); + // + // De-init keyboard + // + // + // De-init joysticks + // for( int i=0; iUnacquire(); - // Release the Mouse device - SAFE_RELEASE(m_pJoystick[i]); + if( m_pJoystick[i] ) + { + SDL_JoystickClose(m_pJoystick[i]); + m_pJoystick[i] = NULL; + } } - // Release the DirectInput object - SAFE_RELEASE(m_pDI); + // + // De-init pumps + // delete[] m_Pumps; + + + SDL_QuitSubSystem( SDL_INIT_JOYSTICK ); } -HRESULT RageInput::UpdateMouse() +void RageInput::Update( float fDeltaTime ) { - if( NULL == m_pMouse ) - return E_FAIL; - - ZeroMemory( &m_mouseState, sizeof(m_mouseState) ); - - // Get the input's device state, and put the state in DIMOUSESTATE2 - if (FAILED(m_pMouse->GetDeviceState( sizeof(DIMOUSESTATE2), &m_mouseState ))) - { - // If input is lost then acquire and keep trying - HRESULT hr = m_pMouse->Acquire(); - while( hr == DIERR_INPUTLOST ) - hr = m_pMouse->Acquire(); - - return E_FAIL; - } + // + // Move last current state to old state + // + memcpy( m_oldKeys, m_keys, sizeof(m_oldKeys) ); + memcpy( m_oldJoyState, m_joyState, sizeof(m_joyState) ); + memcpy( m_oldPumpState, m_pumpState, sizeof(m_pumpState) ); - m_RelPosition_x = m_mouseState.lX; - m_RelPosition_y = m_mouseState.lY; + // + // Update keyboard + // + SDL_PumpEvents(); + Uint8* keystate = SDL_GetKeyState(NULL); + memcpy( m_keys, keystate, sizeof(m_keys) ); - m_AbsPosition_x += m_mouseState.lX; - m_AbsPosition_y += m_mouseState.lY; + // + // Update Joystick + // + SDL_JoystickUpdate(); - /* Clamp the mouse to 0...640-1, 0...480-1. */ - m_AbsPosition_x = clamp(m_AbsPosition_x, 0, 640-1); - m_AbsPosition_y = clamp(m_AbsPosition_y, 0, 480-1); + memset( m_joyState, 0, sizeof(m_joyState) ); // clear current state - return S_OK; -} - -HRESULT RageInput::UpdateKeyboard() -{ - ZeroMemory( &m_keys, sizeof(m_keys) ); - - if( NULL == m_pKeyboard ) - return E_FAIL; - - if( FAILED(m_pKeyboard->GetDeviceState( sizeof(m_keys),(LPVOID)&m_keys )) ) + for( int joy=0; joyAcquire(); - while( hr == DIERR_INPUTLOST ) - hr = m_pKeyboard->Acquire(); + SDL_Joystick* pJoy = m_pJoystick[joy]; + if( !pJoy ) + continue; - return E_FAIL; + int iNumJoyAxes = min(NUM_JOYSTICK_AXES,SDL_JoystickNumAxes(pJoy)); + for( int axis=0; axis= AXIS_THRESHOLD) -#define IS_UP(a) IS_LEFT(a) -#define IS_DOWN(a) IS_RIGHT(a) - - - HRESULT hr; - - ////////////////////////////////////////////////////////////////// - // the current state last update becomes the old state this update - ////////////////////////////////////////////////////////////////// - - CopyMemory( &m_oldKeys, &m_keys, sizeof(m_keys) ); - CopyMemory( &m_oldPumpState, &m_pumpState, sizeof(m_pumpState) ); - CopyMemory( &m_oldJoyState, &m_joyState, sizeof(m_joyState) ); - - ZeroMemory( &m_joyState, sizeof(m_joyState) ); - - - //////////////////// - // Read the keyboard - //////////////////// - UpdateKeyboard(); - - //////////////////// - // Read the mouse - //////////////////// - UpdateMouse(); - - ///////////////////// - // Read the joysticks - ///////////////////// - - // read joystick state - for( BYTE i=0; i<4; i++ ) // foreach joystick - { - // read joystick states - if ( !m_pJoystick[i] ) - continue; - - // Poll the device to read the current state - hr = m_pJoystick[i]->Poll(); - if( FAILED(hr) ) - { - // DInput is telling us that the input stream has been - // interrupted. We aren't tracking any state between polls, so - // we don't have any special reset that needs to be done. We - // just re-acquire and try again. - hr = m_pJoystick[i]->Acquire(); - while( hr == DIERR_INPUTLOST ) - hr = m_pJoystick[i]->Acquire(); - - // hr may be DIERR_OTHERAPPHASPRIO or other errors. This - // may occur when the app is minimized or in the process of - // switching, so just try again later - break; - } - - DIJOYSTATE2 joyState; - ZeroMemory( &joyState, sizeof(joyState) ); - // Get the input's device state - if( FAILED( hr = m_pJoystick[i]->GetDeviceState( sizeof(DIJOYSTATE2), &joyState ) ) ) - { - LOG->Trace(hr, "Failed to read joystick %i\n", i); - continue; - } - - if ( IS_LEFT(joyState.lX) ) m_joyState[i][JOY_LEFT] = true; - if ( IS_RIGHT(joyState.lX) ) m_joyState[i][JOY_RIGHT] = true; - if ( IS_UP(joyState.lY) ) m_joyState[i][JOY_UP] = true; - if ( IS_DOWN(joyState.lY) ) m_joyState[i][JOY_DOWN] = true; - if ( IS_UP(joyState.lZ) ) m_joyState[i][JOY_Z_UP] = true; - if ( IS_DOWN(joyState.lZ) ) m_joyState[i][JOY_Z_DOWN] = true; - if ( IS_UP(joyState.lRz) ) m_joyState[i][JOY_Z_ROT_UP] = true; - if ( IS_DOWN(joyState.lRz) ) m_joyState[i][JOY_Z_ROT_DOWN] = true; - if ( joyState.rgdwPOV[0] == 27000 ) m_joyState[i][JOY_HAT_LEFT] = true; - if ( joyState.rgdwPOV[0] == 9000 ) m_joyState[i][JOY_HAT_RIGHT] = true; - if ( joyState.rgdwPOV[0] == 0 ) m_joyState[i][JOY_HAT_UP] = true; - if ( joyState.rgdwPOV[0] == 18000 ) m_joyState[i][JOY_HAT_DOWN] = true; - - for (int button_index = JOY_1; button_index < NUM_JOYSTICK_BUTTONS; ++button_index) - { - if ( IS_PRESSED( joyState.rgbButtons[button_index - JOY_1] ) ) - m_joyState[i][button_index] = true; - } - } - - UpdatePump(); } -bool RageInput::BeingPressed( DeviceInput di, bool Prev ) -{ - if(Prev) return WasBeingPressed(di); - return IsBeingPressed(di); -} - -bool RageInput::IsBeingPressed( DeviceInput di ) +bool RageInput::BeingPressed( DeviceInput di, bool bPrevState ) { switch( di.device ) { case DEVICE_KEYBOARD: - return 0 != m_keys[ di.button ]; - case DEVICE_JOY1: - case DEVICE_JOY2: - case DEVICE_JOY3: - case DEVICE_JOY4: { - return m_joyState[di.device - DEVICE_JOY1][ di.button ]; - } - case DEVICE_PUMP1: - case DEVICE_PUMP2: - { - ASSERT(di.button < NUM_PUMP_PAD_BUTTONS); - return m_pumpState[di.device - DEVICE_PUMP1].button[di.button]; - } - default: - ASSERT( false ); // bad device - } - - return false; // how did we get here?!? -} - -bool RageInput::WasBeingPressed( DeviceInput di ) -{ - switch( di.device ) - { - case DEVICE_KEYBOARD: - return 0 != m_oldKeys[ di.button ]; + { + ASSERT(di.button < NUM_KEYBOARD_BUTTONS); + return (bPrevState?m_oldKeys:m_keys) [ di.button ]; + } case DEVICE_JOY1: case DEVICE_JOY2: case DEVICE_JOY3: case DEVICE_JOY4: - return m_oldJoyState[di.device - DEVICE_JOY1][ di.button ]; - + { + ASSERT(di.button < NUM_JOYSTICK_BUTTONS); + return (bPrevState?m_oldJoyState:m_joyState) [di.device - DEVICE_JOY1].button[ di.button ]; + } case DEVICE_PUMP1: - case DEVICE_PUMP2: { - ASSERT(di.button < NUM_PUMP_PAD_BUTTONS); - return m_oldPumpState[di.device - DEVICE_PUMP1].button[di.button]; - } - + case DEVICE_PUMP2: + { + ASSERT(di.button < NUM_PUMP_PAD_BUTTONS); + return (bPrevState?m_oldPumpState:m_pumpState) [di.device - DEVICE_PUMP1].button[di.button]; + } default: - ASSERT( false ); // bad device + ASSERT( 0 ); // bad device + return false; // hush compiler } - - return false; // how did we get here?!? } extern "C" { diff --git a/stepmania/src/RageInput.h b/stepmania/src/RageInput.h index 978a9c70eb..8c989c8bc0 100644 --- a/stepmania/src/RageInput.h +++ b/stepmania/src/RageInput.h @@ -4,25 +4,27 @@ ----------------------------------------------------------------------------- File: RageInput.h - Desc: Wrapper for DirectInput. Generates InputEvents. + Desc: Wrapper for SDL's input routines. Generates InputEvents. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. + Chris Danford ----------------------------------------------------------------------------- */ -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#endif +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; -#include -#include "RageUtil.h" - -const int NUM_KEYBOARD_BUTTONS = 256; +#include "SDL_keysym.h" +const int NUM_KEYBOARD_BUTTONS = SDLK_LAST; const int NUM_JOYSTICKS = 4; +const int NUM_JOYSTICK_AXES = 4; // X, Y, Z, rudder +const int NUM_JOYSTICK_HATS = 1; const int NUM_PUMPS = 2; const int NUM_PUMP_PAD_BUTTONS = 11; +const int NUM_DEVICE_BUTTONS = NUM_KEYBOARD_BUTTONS; + enum InputDevice { DEVICE_KEYBOARD = 0, DEVICE_JOY1, @@ -47,8 +49,6 @@ enum JoystickButton { NUM_JOYSTICK_BUTTONS // leave this at the end }; -const int NUM_DEVICE_BUTTONS = MAX( MAX( NUM_KEYBOARD_BUTTONS, NUM_JOYSTICK_BUTTONS ), - NUM_PUMP_PAD_BUTTONS ); struct DeviceInput { @@ -78,32 +78,20 @@ public: }; - class RageInput { - // Our Screens Handle - HWND m_hWnd; + SDL_Joystick* m_pJoystick[NUM_JOYSTICKS]; - // Main DirectInput Object - LPDIRECTINPUT8 m_pDI; - // Keyboard Device - LPDIRECTINPUTDEVICE8 m_pKeyboard; - // Mouse Device - LPDIRECTINPUTDEVICE8 m_pMouse; - // Joystick Devices - LPDIRECTINPUTDEVICE8 m_pJoystick[NUM_JOYSTICKS]; + // Keyboard state data + bool m_keys[NUM_KEYBOARD_BUTTONS]; + bool m_oldKeys[NUM_KEYBOARD_BUTTONS]; - // Arrays for Keyboard Data - byte m_keys[NUM_KEYBOARD_BUTTONS]; - byte m_oldKeys[NUM_KEYBOARD_BUTTONS]; - - // DirectInput mouse state structure - DIMOUSESTATE2 m_mouseState; - - // Joystick data for NUM_JOYSTICKS controllers - bool m_joyState[NUM_JOYSTICKS][NUM_JOYSTICK_BUTTONS]; - bool m_oldJoyState[NUM_JOYSTICKS][NUM_JOYSTICK_BUTTONS]; + // Joystick state data + struct { + bool button[NUM_JOYSTICK_BUTTONS]; + } m_joyState[NUM_JOYSTICKS], m_oldJoyState[NUM_JOYSTICKS]; + // Pump state data struct { bool button[NUM_PUMP_PAD_BUTTONS]; } m_pumpState[NUM_PUMPS], m_oldPumpState[NUM_PUMPS]; @@ -121,37 +109,14 @@ class RageInput int GetPadEvent(); } *m_Pumps; - INT m_AbsPosition_x, m_AbsPosition_y; - INT m_RelPosition_x, m_RelPosition_y; - - static BOOL CALLBACK EnumJoysticksCallback( const DIDEVICEINSTANCE* pdidInstance, - VOID* pContext ); - - static BOOL CALLBACK EnumAxesCallback( const DIDEVICEOBJECTINSTANCE* pdidoi, - VOID* pContext ); - - HRESULT UpdateMouse(); - HRESULT UpdateKeyboard(); - HRESULT UpdatePump(); - - LPDIRECTINPUT8 GetDirectInput() { return m_pDI; } - public: - RageInput(HWND hWnd); + RageInput(); ~RageInput(); - // Initialize DirectInput Resources - void Initialize(); - // Release all DirectInput Resources - void Release(); - // Get our Devices State - void Update(); - bool IsBeingPressed( DeviceInput di ); - bool WasBeingPressed( DeviceInput di ); - bool BeingPressed( DeviceInput di, bool Prev = false); - -// DIMOUSESTATE2 GetMouseState() { return dimMouseState; } - void GetAbsPosition( int &x, int &y ) const { x = m_AbsPosition_x; y = m_AbsPosition_y; } + void Update( float fDeltaTime ); + bool BeingPressed( DeviceInput di, bool bPrevState ); + bool IsBeingPressed( DeviceInput di ) { return BeingPressed(di, false); } + bool WasBeingPressed( DeviceInput di ) { return BeingPressed(di, true); } }; namespace USB { diff --git a/stepmania/src/Screen.cpp b/stepmania/src/Screen.cpp index 99f57d65c1..8399a59a53 100644 --- a/stepmania/src/Screen.cpp +++ b/stepmania/src/Screen.cpp @@ -71,7 +71,7 @@ void Screen::Input( const DeviceInput& DeviceI, const InputEventType type, const if(type == IET_RELEASE) return; // don't care /* Don't make the user hold the back button if they're pressing escape. */ - if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == DIK_ESCAPE ) + if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_ESCAPE ) { this->MenuBack( MenuI.player ); return; diff --git a/stepmania/src/ScreenEdit.cpp b/stepmania/src/ScreenEdit.cpp index ffc8791fdc..c3ca8400f4 100644 --- a/stepmania/src/ScreenEdit.cpp +++ b/stepmania/src/ScreenEdit.cpp @@ -24,6 +24,7 @@ #include "RageLog.h" #include #include "ThemeManager.h" +#include "SDL_keysym.h" // for SDLKeys #include @@ -129,29 +130,29 @@ const CString ACTION_MENU_ITEM_TEXT[NUM_ACTION_MENU_ITEMS] = { "Q: Quit" }; const int ACTION_MENU_ITEM_KEY[NUM_ACTION_MENU_ITEMS] = { - DIK_RETURN, - DIK_SPACE, - DIK_P, - DIK_R, - DIK_T, - DIK_X, - DIK_C, - DIK_V, - DIK_D, - DIK_E, - DIK_N, - DIK_I, - DIK_B, - DIK_INSERT, - DIK_DELETE, - DIK_G, - DIK_H, - DIK_J, - DIK_K, - DIK_L, - DIK_M, - DIK_S, - DIK_Q, + SDLK_RETURN, + SDLK_SPACE, + SDLK_p, + SDLK_r, + SDLK_t, + SDLK_x, + SDLK_c, + SDLK_v, + SDLK_d, + SDLK_e, + SDLK_n, + SDLK_i, + SDLK_b, + SDLK_INSERT, + SDLK_DELETE, + SDLK_g, + SDLK_h, + SDLK_j, + SDLK_k, + SDLK_l, + SDLK_m, + SDLK_s, + SDLK_q, }; const CString NAMING_MENU_ITEM_TEXT[NUM_NAMING_MENU_ITEMS] = { @@ -164,12 +165,12 @@ const CString NAMING_MENU_ITEM_TEXT[NUM_NAMING_MENU_ITEMS] = { }; // Pairs of keystroke + ifCapital const std::pair NAMING_MENU_ITEM_KEY[NUM_NAMING_MENU_ITEMS] = { - std::make_pair(DIK_M, false), - std::make_pair(DIK_S, false), - std::make_pair(DIK_A, false), - std::make_pair(DIK_M, true), - std::make_pair(DIK_S, true), - std::make_pair(DIK_A, true), + std::make_pair(SDLK_m, false), + std::make_pair(SDLK_s, false), + std::make_pair(SDLK_a, false), + std::make_pair(SDLK_m, true), + std::make_pair(SDLK_s, true), + std::make_pair(SDLK_a, true), }; const ScreenMessage SM_GoToPrevScreen = ScreenMessage(SM_User+1); @@ -550,7 +551,7 @@ void ScreenEdit::DrawPrimitives() m_textHelp.Draw(); m_textInfo.Draw(); m_Fade.Draw(); -/* if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,DIK_F1) ) ) +/* if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,SDLK_F1) ) ) { m_rectShortcutsBack.Draw(); m_textShortcuts.Draw(); @@ -688,8 +689,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ if(type == IET_RELEASE) { switch( DeviceI.button ) { - case DIK_LSHIFT: - case DIK_RSHIFT: + case SDLK_LSHIFT: + case SDLK_RSHIFT: shiftAnchor = -1; break; } @@ -698,21 +699,21 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ switch( DeviceI.button ) { - case DIK_1: - case DIK_2: - case DIK_3: - case DIK_4: - case DIK_5: - case DIK_6: - case DIK_7: - case DIK_8: - case DIK_9: - case DIK_0: + case SDLK_1: + case SDLK_2: + case SDLK_3: + case SDLK_4: + case SDLK_5: + case SDLK_6: + case SDLK_7: + case SDLK_8: + case SDLK_9: + case SDLK_0: { if( type != IET_FIRST_PRESS ) break; // We only care about first presses - int iCol = DeviceI.button - DIK_1; + int iCol = DeviceI.button - SDLK_1; const float fSongBeat = GAMESTATE->m_fSongBeat; const int iSongIndex = BeatToNoteRow( fSongBeat ); @@ -744,10 +745,10 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } } break; - case DIK_Q: + case SDLK_q: SCREENMAN->SetNewScreen( "ScreenEditMenu" ); break; - case DIK_S: + case SDLK_s: { // copy edit into current Notes Notes* pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; @@ -761,24 +762,24 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","edit save") ); } break; - case DIK_UP: - case DIK_DOWN: - case DIK_PGUP: - case DIK_PGDN: + case SDLK_UP: + case SDLK_DOWN: + case SDLK_PAGEUP: + case SDLK_PAGEDOWN: { float fBeatsToMove=0.f; switch( DeviceI.button ) { - case DIK_UP: - case DIK_DOWN: + case SDLK_UP: + case SDLK_DOWN: fBeatsToMove = NoteTypeToBeat( m_SnapDisplay.GetNoteType() ); - if( DeviceI.button == DIK_UP ) + if( DeviceI.button == SDLK_UP ) fBeatsToMove *= -1; break; - case DIK_PGUP: - case DIK_PGDN: + case SDLK_PAGEUP: + case SDLK_PAGEDOWN: fBeatsToMove = BEATS_PER_MEASURE; - if( DeviceI.button == DIK_PGUP ) + if( DeviceI.button == SDLK_PAGEUP ) fBeatsToMove *= -1; } @@ -788,7 +789,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ // check to see if they're holding a button for( int col=0; colIsBeingPressed(di) ) continue; @@ -805,8 +806,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_NoteFieldEdit.AddHoldNote( newHN ); } - if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT))) + if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) || + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT))) { /* Shift is being held. * @@ -836,23 +837,23 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_soundChangeLine.Play(); } break; - case DIK_HOME: + case SDLK_HOME: GAMESTATE->m_fSongBeat = 0; m_soundChangeLine.Play(); break; - case DIK_END: + case SDLK_END: GAMESTATE->m_fSongBeat = m_NoteFieldEdit.GetLastBeat(); m_soundChangeLine.Play(); break; - case DIK_RIGHT: + case SDLK_RIGHT: m_SnapDisplay.PrevSnapMode(); OnSnapModeChange(); break; - case DIK_LEFT: + case SDLK_LEFT: m_SnapDisplay.NextSnapMode(); OnSnapModeChange(); break; - case DIK_RETURN: + case SDLK_RETURN: if( m_NoteFieldEdit.m_fEndMarker != -1 && GAMESTATE->m_fSongBeat > m_NoteFieldEdit.m_fEndMarker ) { // invalid! The begin maker must be placed before the end marker @@ -864,7 +865,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_soundMarker.Play(); } break; - case DIK_SPACE: + case SDLK_SPACE: if( m_NoteFieldEdit.m_fBeginMarker != -1 && GAMESTATE->m_fSongBeat < m_NoteFieldEdit.m_fBeginMarker ) { // invalid! The end maker must be placed after the begin marker @@ -876,11 +877,11 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_soundMarker.Play(); } break; - case DIK_G: - case DIK_H: - case DIK_J: - case DIK_K: - case DIK_L: + case SDLK_g: + case SDLK_h: + case SDLK_j: + case SDLK_k: + case SDLK_l: { if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 ) { @@ -892,11 +893,11 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ NoteType noteType2; switch( DeviceI.button ) { - case DIK_G: noteType1 = NOTE_TYPE_4TH; noteType2 = NOTE_TYPE_4TH; break; - case DIK_H: noteType1 = NOTE_TYPE_8TH; noteType2 = NOTE_TYPE_8TH; break; - case DIK_J: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_12TH; break; - case DIK_K: noteType1 = NOTE_TYPE_16TH; noteType2 = NOTE_TYPE_16TH; break; - case DIK_L: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_16TH; break; + case SDLK_g: noteType1 = NOTE_TYPE_4TH; noteType2 = NOTE_TYPE_4TH; break; + case SDLK_h: noteType1 = NOTE_TYPE_8TH; noteType2 = NOTE_TYPE_8TH; break; + case SDLK_j: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_12TH; break; + case SDLK_k: noteType1 = NOTE_TYPE_16TH; noteType2 = NOTE_TYPE_16TH; break; + case SDLK_l: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_16TH; break; default: ASSERT( false ); return; } @@ -904,7 +905,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } } break; - case DIK_ESCAPE: + case SDLK_ESCAPE: { m_EditMode = MODE_ACTION_MENU; m_iMenuSelection = 0; @@ -915,7 +916,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_rectRecordBack.SetTweenDiffuse( RageColor(0,0,0,0.8f) ); } break; - case DIK_N: + case SDLK_n: { m_EditMode = MODE_NAMING_MENU; m_iMenuSelection = 0; @@ -926,15 +927,15 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_rectRecordBack.SetTweenDiffuse( RageColor(0,0,0,0.8f) ); } break; - case DIK_R: - case DIK_P: + case SDLK_r: + case SDLK_p: { if( m_NoteFieldEdit.m_fBeginMarker == -1 ) m_NoteFieldEdit.m_fBeginMarker = GAMESTATE->m_fSongBeat; if( m_NoteFieldEdit.m_fEndMarker == -1 ) m_NoteFieldEdit.m_fEndMarker = m_pSong->m_fLastBeat; - if(DeviceI.button == DIK_R) { + if(DeviceI.button == SDLK_r) { m_EditMode = MODE_RECORDING; // initialize m_NoteFieldRecord @@ -960,7 +961,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate ); } break; - case DIK_T: + case SDLK_t: if( GAMESTATE->m_SongOptions.m_fMusicRate == 1.0f ) GAMESTATE->m_SongOptions.m_fMusicRate = 0.9f; else if( GAMESTATE->m_SongOptions.m_fMusicRate == 0.9f ) GAMESTATE->m_SongOptions.m_fMusicRate = 0.8f; else if( GAMESTATE->m_SongOptions.m_fMusicRate == 0.8f ) GAMESTATE->m_SongOptions.m_fMusicRate = 0.7f; @@ -971,8 +972,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ else if( GAMESTATE->m_SongOptions.m_fMusicRate == 1.2f ) GAMESTATE->m_SongOptions.m_fMusicRate = 1.1f; else if( GAMESTATE->m_SongOptions.m_fMusicRate == 1.1f ) GAMESTATE->m_SongOptions.m_fMusicRate = 1.0f; break; - case DIK_INSERT: - case DIK_DELETE: + case SDLK_INSERT: + case SDLK_DELETE: { NoteData temp; temp.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks; @@ -980,11 +981,11 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ int iPasteAtRow; switch( DeviceI.button ) { - case DIK_INSERT: + case SDLK_INSERT: iTakeFromRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); iPasteAtRow = BeatToNoteRow( GAMESTATE->m_fSongBeat+1 ); break; - case DIK_DELETE: + case SDLK_DELETE: iTakeFromRow = BeatToNoteRow( GAMESTATE->m_fSongBeat+1 ); iPasteAtRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); break; @@ -994,7 +995,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_NoteFieldEdit.CopyRange( &temp, 0, MAX_TAP_NOTE_ROWS-iTakeFromRow, iPasteAtRow ); } break; - case DIK_X: + case SDLK_x: if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 ) { m_soundInvalid.Play(); @@ -1008,7 +1009,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_NoteFieldEdit.ClearRange( iFirstRow, iLastRow ); } break; - case DIK_C: + case SDLK_c: if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 ) { m_soundInvalid.Play(); @@ -1021,7 +1022,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_Clipboard.CopyRange( &m_NoteFieldEdit, iFirstRow, iLastRow ); } break; - case DIK_V: + case SDLK_v: { int iSrcFirstRow = 0; int iSrcLastRow = BeatToNoteRow( m_Clipboard.GetLastBeat() ); @@ -1031,18 +1032,18 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } break; - case DIK_D: + case SDLK_d: { Difficulty &dc = m_pNotes->m_Difficulty; dc = Difficulty( (dc+1)%NUM_DIFFICULTIES ); } break; - case DIK_E: + case SDLK_e: SCREENMAN->TextEntry( SM_None, "Edit notes description.\nPress Enter to confirm,\nEscape to cancel.", m_pNotes->m_sDescription, ChangeDescription, NULL ); break; - case DIK_B: + case SDLK_b: { CString sOldBackground; unsigned i; @@ -1058,22 +1059,22 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } break; - case DIK_I: + case SDLK_i: if( GAMESTATE->m_SongOptions.m_AssistType==SongOptions::ASSIST_TICK ) GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_NONE; else GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_TICK; break; - case DIK_F7: - case DIK_F8: + case SDLK_F7: + case SDLK_F8: { float fBPM = m_pSong->GetBPMAtBeat( GAMESTATE->m_fSongBeat ); float fDeltaBPM; switch( DeviceI.button ) { - case DIK_F7: fDeltaBPM = - 0.020f; break; - case DIK_F8: fDeltaBPM = + 0.020f; break; + case SDLK_F7: fDeltaBPM = - 0.020f; break; + case SDLK_F8: fDeltaBPM = + 0.020f; break; default: ASSERT(0); return; } switch( type ) @@ -1103,14 +1104,14 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } } break; - case DIK_F9: - case DIK_F10: + case SDLK_F9: + case SDLK_F10: { float fStopDelta; switch( DeviceI.button ) { - case DIK_F9: fStopDelta = -0.02f; break; - case DIK_F10: fStopDelta = +0.02f; break; + case SDLK_F9: fStopDelta = -0.02f; break; + case SDLK_F10: fStopDelta = +0.02f; break; default: ASSERT(0); return; } switch( type ) @@ -1141,14 +1142,14 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ } } break; - case DIK_F11: - case DIK_F12: + case SDLK_F11: + case SDLK_F12: { float fOffsetDelta; switch( DeviceI.button ) { - case DIK_F11: fOffsetDelta = -0.02f; break; - case DIK_F12: fOffsetDelta = +0.02f; break; + case SDLK_F11: fOffsetDelta = -0.02f; break; + case SDLK_F12: fOffsetDelta = +0.02f; break; default: ASSERT(0); return; } switch( type ) @@ -1160,18 +1161,18 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ m_pSong->m_fBeat0OffsetInSeconds += fOffsetDelta; } break; - case DIK_M: + case SDLK_m: MUSIC->Load( m_pSong->GetMusicPath() ); MUSIC->Play( false, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds ); break; - case DIK_LBRACKET: - case DIK_RBRACKET: + case SDLK_LEFTBRACKET: + case SDLK_RIGHTBRACKET: { float fDelta; switch( DeviceI.button ) { - case DIK_LBRACKET: fDelta = -0.02f; break; - case DIK_RBRACKET: fDelta = +0.02f; break; + case SDLK_LEFTBRACKET: fDelta = -0.02f; break; + case SDLK_RIGHTBRACKET: fDelta = +0.02f; break; default: ASSERT(0); return; } switch( type ) @@ -1180,8 +1181,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ case IET_FAST_REPEAT: fDelta *= 40; break; } - if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT))) + if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) || + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT))) { m_pSong->m_fMusicSampleLengthSeconds += fDelta; m_pSong->m_fMusicSampleLengthSeconds = max(m_pSong->m_fMusicSampleLengthSeconds,0); @@ -1196,7 +1197,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ void ScreenEdit::InputRecord( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) { - if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == DIK_ESCAPE ) + if( DeviceI.device == DEVICE_KEYBOARD && DeviceI.button == SDLK_ESCAPE ) { TransitionFromRecordToEdit(); return; @@ -1240,23 +1241,23 @@ void ScreenEdit::InputActionMenu( const DeviceInput& DeviceI, const InputEventTy switch( DeviceI.button ) { - case DIK_UP: + case SDLK_UP: MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] ); m_iMenuSelection = (m_iMenuSelection-1+NUM_ACTION_MENU_ITEMS) % NUM_ACTION_MENU_ITEMS; printf( "%d\n", m_iMenuSelection ); MenuItemGainFocus( &m_textActionMenu[m_iMenuSelection] ); break; - case DIK_DOWN: + case SDLK_DOWN: MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] ); m_iMenuSelection = (m_iMenuSelection+1) % NUM_ACTION_MENU_ITEMS; printf( "%d\n", m_iMenuSelection ); MenuItemGainFocus( &m_textActionMenu[m_iMenuSelection] ); break; - case DIK_RETURN: - case DIK_ESCAPE: + case SDLK_RETURN: + case SDLK_ESCAPE: TransitionToEdit(); MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] ); - if( DeviceI.button == DIK_RETURN ) + if( DeviceI.button == SDLK_RETURN ) { SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") ); int iMenuKey = ACTION_MENU_ITEM_KEY[m_iMenuSelection]; @@ -1285,15 +1286,15 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy if(type == IET_RELEASE) return; // don't care bool translit = forceShiftPressed || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT)); + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) || + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT)); switch( DeviceI.button ) { - case DIK_M: - case DIK_S: - case DIK_A: - case DIK_ESCAPE: - case DIK_RETURN: + case SDLK_m: + case SDLK_s: + case SDLK_a: + case SDLK_ESCAPE: + case SDLK_RETURN: TransitionToEdit(); MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] ); break; @@ -1301,7 +1302,7 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy switch( DeviceI.button ) { - case DIK_M: + case SDLK_m: if(translit) { SCREENMAN->TextEntry( SM_None, "Edit song main title transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sMainTitleTranslit, ChangeMainTitleTranslit, NULL); } else { @@ -1309,7 +1310,7 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy } break; - case DIK_S: + case SDLK_s: if(translit) { SCREENMAN->TextEntry( SM_None, "Edit song sub title transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sSubTitleTranslit, ChangeSubTitleTranslit, NULL); } else { @@ -1317,7 +1318,7 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy } break; - case DIK_A: + case SDLK_a: if(translit) { SCREENMAN->TextEntry( SM_None, "Edit song artist transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sArtistTranslit, ChangeArtistTranslit, NULL); } else { @@ -1325,19 +1326,19 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy } break; - case DIK_UP: + case SDLK_UP: MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] ); m_iMenuSelection = (m_iMenuSelection-1+NUM_NAMING_MENU_ITEMS) % NUM_NAMING_MENU_ITEMS; printf( "%d\n", m_iMenuSelection ); MenuItemGainFocus( &m_textNamingMenu[m_iMenuSelection] ); break; - case DIK_DOWN: + case SDLK_DOWN: MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] ); m_iMenuSelection = (m_iMenuSelection+1) % NUM_NAMING_MENU_ITEMS; printf( "%d\n", m_iMenuSelection ); MenuItemGainFocus( &m_textNamingMenu[m_iMenuSelection] ); break; - case DIK_RETURN: + case SDLK_RETURN: SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") ); const std::pair& pairMenuKey = NAMING_MENU_ITEM_KEY[m_iMenuSelection]; InputNamingMenu( DeviceInput(DEVICE_KEYBOARD,pairMenuKey.first), IET_FIRST_PRESS, GameInput(), MenuInput(), StyleInput(), pairMenuKey.second ); @@ -1354,17 +1355,17 @@ void ScreenEdit::InputPlay( const DeviceInput& DeviceI, const InputEventType typ { switch( DeviceI.button ) { - case DIK_ESCAPE: + case SDLK_ESCAPE: TransitionToEdit(); break; - case DIK_F11: - case DIK_F12: + case SDLK_F11: + case SDLK_F12: { float fOffsetDelta; switch( DeviceI.button ) { - case DIK_F11: fOffsetDelta = -0.020f; break; - case DIK_F12: fOffsetDelta = +0.020f; break; + case SDLK_F11: fOffsetDelta = -0.020f; break; + case SDLK_F12: fOffsetDelta = +0.020f; break; default: ASSERT(0); return; } switch( type ) diff --git a/stepmania/src/ScreenGameplay.cpp b/stepmania/src/ScreenGameplay.cpp index 6878f1e8d9..7336b2cf02 100644 --- a/stepmania/src/ScreenGameplay.cpp +++ b/stepmania/src/ScreenGameplay.cpp @@ -868,7 +868,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ if( GAMESTATE->m_bDemonstration ) { /* Special case:always allow escape. */ - if( DeviceI.device==DEVICE_KEYBOARD && DeviceI.button==DIK_ESCAPE && !m_Fade.IsClosing() ) + if( DeviceI.device==DEVICE_KEYBOARD && DeviceI.button==SDLK_ESCAPE && !m_Fade.IsClosing() ) { this->SendScreenMessage( SM_BeginFadingToTitleMenu, 0 ); } @@ -890,7 +890,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ { switch( DeviceI.button ) { - case DIK_F6: + case SDLK_F6: m_bChangedOffsetOrBPM = true; if (GAMESTATE->m_SongOptions.m_AutoAdjust == SongOptions::ADJUST_ON) { @@ -906,7 +906,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ m_textDebug.BeginTweening( 0.5f ); // fade out m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) ); break; - case DIK_F7: + case SDLK_F7: if( GAMESTATE->m_SongOptions.m_AssistType == SongOptions::ASSIST_NONE ) GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_TICK; else @@ -918,19 +918,19 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ m_textDebug.BeginTweening( 0.5f ); // fade out m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) ); break; - case DIK_F8: + case SDLK_F8: PREFSMAN->m_bAutoPlay = !PREFSMAN->m_bAutoPlay; break; - case DIK_F9: - case DIK_F10: + case SDLK_F9: + case SDLK_F10: { m_bChangedOffsetOrBPM = true; float fOffsetDelta; switch( DeviceI.button ) { - case DIK_F9: fOffsetDelta = -0.025f; break; - case DIK_F10: fOffsetDelta = +0.025f; break; + case SDLK_F9: fOffsetDelta = -0.025f; break; + case SDLK_F10: fOffsetDelta = +0.025f; break; default: ASSERT(0); return; } if( type == IET_FAST_REPEAT ) @@ -947,16 +947,16 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) ); } break; - case DIK_F11: - case DIK_F12: + case SDLK_F11: + case SDLK_F12: { m_bChangedOffsetOrBPM = true; float fOffsetDelta; switch( DeviceI.button ) { - case DIK_F11: fOffsetDelta = -0.02f; break; - case DIK_F12: fOffsetDelta = +0.02f; break; + case SDLK_F11: fOffsetDelta = -0.02f; break; + case SDLK_F12: fOffsetDelta = +0.02f; break; default: ASSERT(0); return; } if( type == IET_FAST_REPEAT ) diff --git a/stepmania/src/ScreenMapControllers.cpp b/stepmania/src/ScreenMapControllers.cpp index 337dbf7552..0ea9b972ff 100644 --- a/stepmania/src/ScreenMapControllers.cpp +++ b/stepmania/src/ScreenMapControllers.cpp @@ -178,9 +178,9 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy /* We only advertise space as doing this, but most games * use either backspace or delete, and I find them more * intuitive, so allow them, too. -gm */ - case DIK_SPACE: - case DIK_DELETE: - case DIK_BACK: /* Clear the selected input mapping. */ + case SDLK_SPACE: + case SDLK_DELETE: + case SDLK_BACKSPACE: /* Clear the selected input mapping. */ { GameInput curGameI( (GameController)m_iCurController, (GameButton)m_iCurButton ); INPUTMAPPER->ClearFromInputMap( curGameI, m_iCurSlot ); @@ -189,7 +189,7 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy INPUTMAPPER->SaveMappingsToDisk(); } break; - case DIK_LEFT: /* Move the selection left, wrapping up. */ + case SDLK_LEFT: /* Move the selection left, wrapping up. */ if( m_iCurSlot == 0 && m_iCurController == 0 ) break; // can't go left any more m_iCurSlot--; @@ -199,7 +199,7 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy m_iCurController--; } break; - case DIK_RIGHT: /* Move the selection right, wrapping down. */ + case SDLK_RIGHT: /* Move the selection right, wrapping down. */ if( m_iCurSlot == NUM_CHANGABLE_SLOTS-1 && m_iCurController == MAX_GAME_CONTROLLERS-1 ) break; // can't go right any more m_iCurSlot++; @@ -209,20 +209,20 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy m_iCurController++; } break; - case DIK_UP: /* Move the selection up. */ + case SDLK_UP: /* Move the selection up. */ if( m_iCurButton == 0 ) break; // can't go up any more m_iCurButton--; break; - case DIK_DOWN: /* Move the selection down. */ + case SDLK_DOWN: /* Move the selection down. */ if( m_iCurButton == GAMESTATE->GetCurrentGameDef()->m_iButtonsPerController-1 ) break; // can't go down any more m_iCurButton++; break; - case DIK_ESCAPE: /* Quit the screen. */ + case SDLK_ESCAPE: /* Quit the screen. */ m_Menu.TweenOffScreenToBlack( SM_GoToNextScreen, true ); break; - case DIK_RETURN: /* Change the selection. */ + case SDLK_RETURN: /* Change the selection. */ m_bWaitingForPress = true; break; } diff --git a/stepmania/src/ScreenSandbox.cpp b/stepmania/src/ScreenSandbox.cpp index af2e83439c..ba1098f83d 100644 --- a/stepmania/src/ScreenSandbox.cpp +++ b/stepmania/src/ScreenSandbox.cpp @@ -55,26 +55,26 @@ void ScreenSandbox::Input( const DeviceInput& DeviceI, const InputEventType type case DEVICE_KEYBOARD: switch( DeviceI.button ) { - case DIK_LEFT: + case SDLK_LEFT: obj.SetX(obj.GetX() - 10); break; - case DIK_RIGHT: + case SDLK_RIGHT: obj.SetX(obj.GetX() + 10); break; - case DIK_UP: + case SDLK_UP: obj.SetY(obj.GetY() - 10); break; - case DIK_DOWN: + case SDLK_DOWN: obj.SetY(obj.GetY() + 10); break; - case DIK_T: + case SDLK_t: { SDL_Event *event; event = (SDL_Event *) malloc(sizeof(event)); event->type = SDL_QUIT; SDL_PushEvent(event); } - case DIK_ESCAPE: + case SDLK_ESCAPE: { SCREENMAN->SetNewScreen( "ScreenTitleMenu" ); } diff --git a/stepmania/src/ScreenTextEntry.cpp b/stepmania/src/ScreenTextEntry.cpp index 47ed89ee39..57d57212a4 100644 --- a/stepmania/src/ScreenTextEntry.cpp +++ b/stepmania/src/ScreenTextEntry.cpp @@ -83,14 +83,14 @@ void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType ty switch( DeviceI.button ) { - case DIK_ESCAPE: + case SDLK_ESCAPE: m_bCancelled = true; MenuStart(PLAYER_1); break; - case DIK_RETURN: + case SDLK_RETURN: MenuStart(PLAYER_1); break; - case DIK_BACK: + case SDLK_BACKSPACE: m_sAnswer = m_sAnswer.Left( max(0,m_sAnswer.GetLength()-1) ); m_textAnswer.SetText( m_sAnswer ); break; @@ -99,8 +99,8 @@ void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType ty c = DeviceI.ToChar(); bool bHoldingShift = - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || - INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT)); + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) || + INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT)); // International keyboards often have other keys mapped to shifted keys, and always // using a US layout is a bit gimped. This is better than nothing though. diff --git a/stepmania/src/StdAfx.h b/stepmania/src/StdAfx.h index 07f12bd1bc..8263544c60 100644 --- a/stepmania/src/StdAfx.h +++ b/stepmania/src/StdAfx.h @@ -46,14 +46,6 @@ using namespace std; -// Don't include these everywhere. They're big. -Chris -//#include -//#include - -#ifndef DIRECTINPUT_VERSION -#define DIRECTINPUT_VERSION 0x0800 -#endif -#include #if 1 diff --git a/stepmania/src/StepMania.cpp b/stepmania/src/StepMania.cpp index 6e769633ea..fbd8400ebc 100644 --- a/stepmania/src/StepMania.cpp +++ b/stepmania/src/StepMania.cpp @@ -353,7 +353,7 @@ int main(int argc, char* argv[]) throw RageException( "SDL_GetWMInfo failed" ); HWND hwnd = info.window; - INPUTMAN = new RageInput( hwnd ); + INPUTMAN = new RageInput(); // SOUNDMAN = new RageSoundManager(); // These things depend on the TextureManager, so do them after! @@ -482,13 +482,13 @@ void GameLoop() // See ScreenManager::Update comments for why we shouldn't do this. -glenn //if( fDeltaTime > 0.050f ) // we dropped a bunch of frames // fDeltaTime = 0.050f; - if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_TAB) ) ) { - if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_GRAVE) ) ) + if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_TAB) ) ) { + if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_QUOTEDBL) ) ) fDeltaTime = 0; /* both; stop time */ else fDeltaTime *= 4; } else - if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_GRAVE) ) ) + if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_QUOTEDBL) ) ) fDeltaTime /= 4; TEXTUREMAN->Update( fDeltaTime ); @@ -506,10 +506,10 @@ void GameLoop() /* ALT-F4 -> quit (better place for this? in ScreenManager perhaps?) */ /* Nah. this is fine. -Chris */ - if(type == IET_FIRST_PRESS && DeviceI == DeviceInput(DEVICE_KEYBOARD, DIK_F4)) + if(type == IET_FIRST_PRESS && DeviceI == DeviceInput(DEVICE_KEYBOARD, SDLK_F4)) { - if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_RMENU)) || - INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_LMENU)) ) + if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_RALT)) || + INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LALT)) ) { // pressed Alt+F4 SDL_Event *event; @@ -526,7 +526,7 @@ void GameLoop() // fall through } } - else if( type == IET_FIRST_PRESS && DeviceI == DeviceInput(DEVICE_KEYBOARD, DIK_F5)) + else if( type == IET_FIRST_PRESS && DeviceI == DeviceInput(DEVICE_KEYBOARD, SDLK_F5)) { // pressed F5. Toggle detail. if(PREFSMAN->m_iDisplayWidth != 640) @@ -544,10 +544,10 @@ void GameLoop() } - if(type == IET_FIRST_PRESS && DeviceI == DeviceInput(DEVICE_KEYBOARD, DIK_RETURN)) + if(type == IET_FIRST_PRESS && DeviceI == DeviceInput(DEVICE_KEYBOARD, SDLK_RETURN)) { - if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_RMENU)) || - INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_LMENU)) ) + if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_RALT)) || + INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LALT)) ) { /* alt-enter */ PREFSMAN->m_bWindowed = !PREFSMAN->m_bWindowed;