DirectInput replaced with SDL's input routines. Keyboard works, but joystick and pump are untested.

This commit is contained in:
Chris Danford
2002-11-29 20:37:12 +00:00
parent 529057a85e
commit 4a588230e1
14 changed files with 504 additions and 837 deletions
+59 -58
View File
@@ -18,6 +18,7 @@
#include "IniFile.h" #include "IniFile.h"
#include "RageLog.h" #include "RageLog.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "SDL_keysym.h" // for SDLKeys
GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program GameManager* GAMEMAN = NULL; // global and accessable from anywhere in our program
@@ -106,28 +107,28 @@ GameDef g_GameDefs[NUM_GAMES] =
}, },
{ // m_iDefaultKeyboardKey { // m_iDefaultKeyboardKey
{ // PLAYER_1 { // PLAYER_1
DIK_LEFT, // DANCE_BUTTON_LEFT, SDLK_LEFT, // DANCE_BUTTON_LEFT,
DIK_RIGHT, // DANCE_BUTTON_RIGHT, SDLK_RIGHT, // DANCE_BUTTON_RIGHT,
DIK_UP, // DANCE_BUTTON_UP, SDLK_UP, // DANCE_BUTTON_UP,
DIK_DOWN, // DANCE_BUTTON_DOWN, SDLK_DOWN, // DANCE_BUTTON_DOWN,
-1, //no default key // DANCE_BUTTON_UPLEFT, -1, //no default key // DANCE_BUTTON_UPLEFT,
-1, //no default key // DANCE_BUTTON_UPRIGHT, -1, //no default key // DANCE_BUTTON_UPRIGHT,
DIK_RETURN, // DANCE_BUTTON_START, SDLK_RETURN, // DANCE_BUTTON_START,
DIK_ESCAPE, // DANCE_BUTTON_BACK SDLK_ESCAPE, // DANCE_BUTTON_BACK
-1, //no default key // DANCE_BUTTON_MENULEFT -1, //no default key // DANCE_BUTTON_MENULEFT
-1, //no default key // DANCE_BUTTON_MENURIGHT -1, //no default key // DANCE_BUTTON_MENURIGHT
DIK_UP, // DANCE_BUTTON_MENUUP SDLK_UP, // DANCE_BUTTON_MENUUP
DIK_DOWN, // DANCE_BUTTON_MENUDOWN SDLK_DOWN, // DANCE_BUTTON_MENUDOWN
}, },
{ // PLAYER_2 { // PLAYER_2
DIK_NUMPAD4, // DANCE_BUTTON_LEFT, SDLK_KP4, // DANCE_BUTTON_LEFT,
DIK_NUMPAD6, // DANCE_BUTTON_RIGHT, SDLK_KP6, // DANCE_BUTTON_RIGHT,
DIK_NUMPAD8, // DANCE_BUTTON_UP, SDLK_KP8, // DANCE_BUTTON_UP,
DIK_NUMPAD2, // DANCE_BUTTON_DOWN, SDLK_KP2, // DANCE_BUTTON_DOWN,
DIK_NUMPAD7, // DANCE_BUTTON_UPLEFT, SDLK_KP7, // DANCE_BUTTON_UPLEFT,
DIK_NUMPAD9, // DANCE_BUTTON_UPRIGHT, SDLK_KP9, // DANCE_BUTTON_UPRIGHT,
DIK_NUMPADENTER, // DANCE_BUTTON_START, SDLK_KP_ENTER, // DANCE_BUTTON_START,
DIK_NUMPAD0, // DANCE_BUTTON_BACK SDLK_KP0, // DANCE_BUTTON_BACK
-1, //no default key // DANCE_BUTTON_MENULEFT -1, //no default key // DANCE_BUTTON_MENULEFT
-1, //no default key // DANCE_BUTTON_MENURIGHT -1, //no default key // DANCE_BUTTON_MENURIGHT
-1, //no default key // DANCE_BUTTON_MENUUP -1, //no default key // DANCE_BUTTON_MENUUP
@@ -184,26 +185,26 @@ GameDef g_GameDefs[NUM_GAMES] =
}, },
{ // m_iDefaultKeyboardKey { // m_iDefaultKeyboardKey
{ // PLAYER_1 { // PLAYER_1
DIK_Q, // PUMP_BUTTON_UPLEFT, SDLK_q, // PUMP_BUTTON_UPLEFT,
DIK_E, // PUMP_BUTTON_UPRIGHT, SDLK_e, // PUMP_BUTTON_UPRIGHT,
DIK_S, // PUMP_BUTTON_CENTER, SDLK_s, // PUMP_BUTTON_CENTER,
DIK_Z, // PUMP_BUTTON_DOWNLEFT, SDLK_z, // PUMP_BUTTON_DOWNLEFT,
DIK_C, // PUMP_BUTTON_DOWNRIGHT, SDLK_c, // PUMP_BUTTON_DOWNRIGHT,
DIK_RETURN, // PUMP_BUTTON_START, SDLK_RETURN, // PUMP_BUTTON_START,
DIK_ESCAPE, // PUMP_BUTTON_BACK, SDLK_ESCAPE, // PUMP_BUTTON_BACK,
DIK_LEFT, // PUMP_BUTTON_MENULEFT SDLK_LEFT, // PUMP_BUTTON_MENULEFT
DIK_RIGHT, // PUMP_BUTTON_MENURIGHT SDLK_RIGHT, // PUMP_BUTTON_MENURIGHT
DIK_UP, // PUMP_BUTTON_MENUUP SDLK_UP, // PUMP_BUTTON_MENUUP
DIK_DOWN, // PUMP_BUTTON_MENUDOWN SDLK_DOWN, // PUMP_BUTTON_MENUDOWN
}, },
{ // PLAYER_2 { // PLAYER_2
DIK_NUMPAD7, // PUMP_BUTTON_UPLEFT, SDLK_KP7, // PUMP_BUTTON_UPLEFT,
DIK_NUMPAD9, // PUMP_BUTTON_UPRIGHT, SDLK_KP9, // PUMP_BUTTON_UPRIGHT,
DIK_NUMPAD5, // PUMP_BUTTON_CENTER, SDLK_KP5, // PUMP_BUTTON_CENTER,
DIK_NUMPAD1, // PUMP_BUTTON_DOWNLEFT, SDLK_KP1, // PUMP_BUTTON_DOWNLEFT,
DIK_NUMPAD3, // PUMP_BUTTON_DOWNRIGHT, SDLK_KP3, // PUMP_BUTTON_DOWNRIGHT,
DIK_NUMPADENTER, // PUMP_BUTTON_START, SDLK_KP_ENTER, // PUMP_BUTTON_START,
DIK_NUMPAD0, // PUMP_BUTTON_BACK, SDLK_KP0, // PUMP_BUTTON_BACK,
-1, //no default key // PUMP_BUTTON_MENULEFT -1, //no default key // PUMP_BUTTON_MENULEFT
-1, //no default key // PUMP_BUTTON_MENURIGHT -1, //no default key // PUMP_BUTTON_MENURIGHT
-1, //no default key // PUMP_BUTTON_MENUUP -1, //no default key // PUMP_BUTTON_MENUUP
@@ -264,19 +265,19 @@ GameDef g_GameDefs[NUM_GAMES] =
}, },
{ // m_iDefaultKeyboardKey { // m_iDefaultKeyboardKey
{ // PLAYER_1 { // PLAYER_1
DIK_Z, // EZ2_BUTTON_FOOTUPLEFT, SDLK_z, // EZ2_BUTTON_FOOTUPLEFT,
DIK_B, // EZ2_BUTTON_FOOTUPRIGHT, SDLK_b, // EZ2_BUTTON_FOOTUPRIGHT,
DIK_C, // EZ2_BUTTON_FOOTDOWN, SDLK_c, // EZ2_BUTTON_FOOTDOWN,
DIK_X, // EZ2_BUTTON_HANDUPLEFT, SDLK_x, // EZ2_BUTTON_HANDUPLEFT,
DIK_V, // EZ2_BUTTON_HANDUPRIGHT, SDLK_v, // EZ2_BUTTON_HANDUPRIGHT,
DIK_S, // EZ2_BUTTON_HANDLRLEFT, SDLK_s, // EZ2_BUTTON_HANDLRLEFT,
DIK_F, // EZ2_BUTTON_HANDLRRIGHT, SDLK_f, // EZ2_BUTTON_HANDLRRIGHT,
DIK_RETURN, // EZ2_BUTTON_START, SDLK_RETURN, // EZ2_BUTTON_START,
DIK_ESCAPE, // EZ2_BUTTON_BACK, SDLK_ESCAPE, // EZ2_BUTTON_BACK,
DIK_LEFT, // EZ2_BUTTON_MENULEFT SDLK_LEFT, // EZ2_BUTTON_MENULEFT
DIK_RIGHT, // EZ2_BUTTON_MENURIGHT SDLK_RIGHT, // EZ2_BUTTON_MENURIGHT
DIK_UP, // EZ2_BUTTON_MENUUP SDLK_UP, // EZ2_BUTTON_MENUUP
DIK_DOWN, // EZ2_BUTTON_MENUDOWN SDLK_DOWN, // EZ2_BUTTON_MENUDOWN
}, },
{ // PLAYER_2 { // PLAYER_2
-1, // EZ2_BUTTON_FOOTUPLEFT, -1, // EZ2_BUTTON_FOOTUPLEFT,
@@ -344,17 +345,17 @@ GameDef g_GameDefs[NUM_GAMES] =
}, },
{ // m_iDefaultKeyboardKey { // m_iDefaultKeyboardKey
{ // PLAYER_1 { // PLAYER_1
DIK_Z, // PARA_BUTTON_LEFT, SDLK_z, // PARA_BUTTON_LEFT,
DIK_X, // PARA_BUTTON_UPLEFT, SDLK_x, // PARA_BUTTON_UPLEFT,
DIK_C, // PARA_BUTTON_UP, SDLK_c, // PARA_BUTTON_UP,
DIK_V, // PARA_BUTTON_UPRIGHT, SDLK_v, // PARA_BUTTON_UPRIGHT,
DIK_B, // PARA_BUTTON_RIGHT, SDLK_b, // PARA_BUTTON_RIGHT,
DIK_RETURN, // PARA_BUTTON_START, SDLK_RETURN, // PARA_BUTTON_START,
DIK_ESCAPE, // PARA_BUTTON_BACK SDLK_ESCAPE, // PARA_BUTTON_BACK
DIK_LEFT, //no default key // PARA_BUTTON_MENULEFT SDLK_LEFT, //no default key // PARA_BUTTON_MENULEFT
DIK_RIGHT, //no default key // PARA_BUTTON_MENURIGHT SDLK_RIGHT, //no default key // PARA_BUTTON_MENURIGHT
DIK_UP, // PARA_BUTTON_MENUUP SDLK_UP, // PARA_BUTTON_MENUUP
DIK_DOWN, // PARA_BUTTON_MENUDOWN SDLK_DOWN, // PARA_BUTTON_MENUDOWN
}, },
{ // PLAYER_2 { // PLAYER_2
-1, // PARA_BUTTON_LEFT, -1, // PARA_BUTTON_LEFT,
+2 -1
View File
@@ -14,6 +14,7 @@
#include "InputFilter.h" #include "InputFilter.h"
#include "RageLog.h" #include "RageLog.h"
#include "RageInput.h" #include "RageInput.h"
#include "SDL_keyboard.h"
InputFilter* INPUTFILTER = NULL; // global and accessable from anywhere in our program 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 ) void InputFilter::GetInputEvents( InputEventArray &array, float fDeltaTime )
{ {
INPUTMAN->Update(); INPUTMAN->Update( fDeltaTime );
for( int d=0; d<NUM_INPUT_DEVICES; d++ ) // foreach InputDevice for( int d=0; d<NUM_INPUT_DEVICES; d++ ) // foreach InputDevice
{ {
+1
View File
@@ -16,6 +16,7 @@
#include "GameState.h" #include "GameState.h"
#include "RageLog.h" #include "RageLog.h"
#include "InputFilter.h" #include "InputFilter.h"
#include "RageUtil.h"
InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program InputMapper* INPUTMAPPER = NULL; // global and accessable from anywhere in our program
-3
View File
@@ -31,7 +31,6 @@
#include "SDL_opengl.h" #include "SDL_opengl.h"
#include "glext.h" #include "glext.h"
PFNGLBLENDFUNCSEPARATEPROC glBlendFuncSeparate;
RageDisplay* DISPLAY = NULL; RageDisplay* DISPLAY = NULL;
@@ -161,8 +160,6 @@ void RageDisplay::SetupExtensions()
if(g_oglspecs.glExts.find("GL_EXT_texture_env_combine") != g_oglspecs.glExts.end()) if(g_oglspecs.glExts.find("GL_EXT_texture_env_combine") != g_oglspecs.glExts.end())
g_oglspecs.EXT_texture_env_combine = true; g_oglspecs.EXT_texture_env_combine = true;
glBlendFuncSeparate = (PFNGLBLENDFUNCSEPARATEPROC) SDL_GL_GetProcAddress ("glBlendFuncSeparate");
/* Windows vsync: */ /* Windows vsync: */
if(g_oglspecs.glExts.find("WGL_EXT_swap_control") != g_oglspecs.glExts.end()) { if(g_oglspecs.glExts.find("WGL_EXT_swap_control") != g_oglspecs.glExts.end()) {
wglSwapIntervalEXT = (PWSWAPINTERVALEXTPROC) SDL_GL_GetProcAddress("wglSwapIntervalEXT"); wglSwapIntervalEXT = (PWSWAPINTERVALEXTPROC) SDL_GL_GetProcAddress("wglSwapIntervalEXT");
+238 -529
View File
@@ -6,31 +6,27 @@
Desc: Wrapper for DirectInput. Generates InputEvents. Desc: Wrapper for DirectInput. Generates InputEvents.
Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
*/ */
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// In-line Links // In-line Links
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "ddk/setupapi.lib") #pragma comment(lib, "ddk/setupapi.lib")
#pragma comment(lib, "ddk/hid.lib") #pragma comment(lib, "ddk/hid.lib")
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// Includes // Includes
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#include <windows.h>
#include "RageInput.h" #include "RageInput.h"
#include <dinput.h> #include "SDL.h"
#include "SDL_keyboard.h"
#include "RageUtil.h" #include "RageUtil.h"
#include "RageLog.h" #include "RageLog.h"
#include "RageException.h" #include "RageException.h"
RageInput* INPUTMAN = NULL; // globally accessable input device RageInput* INPUTMAN = NULL; // globally accessable input device
static const char *PumpButtonNames[] = { static const char *PumpButtonNames[] = {
@@ -53,7 +49,7 @@ int DeviceInput::NumButtons(InputDevice device)
case DEVICE_PUMP2: case DEVICE_PUMP2:
return NUM_PUMP_PAD_BUTTONS; return NUM_PUMP_PAD_BUTTONS;
default: default:
ASSERT( false ); ASSERT(0); // invalid device
} }
return -1; /* quiet compiler */ return -1; /* quiet compiler */
} }
@@ -136,116 +132,117 @@ CString DeviceInput::GetDescription()
break; break;
case DEVICE_KEYBOARD: // keyboard case DEVICE_KEYBOARD: // keyboard
sReturn = "Key "; sReturn = ssprintf("Key %s", SDL_GetKeyName((SDLKey)button) );
/*
switch( button ) switch( button )
{ {
case DIK_ESCAPE: sReturn += "Escape"; break; case SDLK_ESCAPE: sReturn += "Escape"; break;
case DIK_1: sReturn += "1"; break; case SDLK_1: sReturn += "1"; break;
case DIK_2: sReturn += "2"; break; case SDLK_2: sReturn += "2"; break;
case DIK_3: sReturn += "3"; break; case SDLK_3: sReturn += "3"; break;
case DIK_4: sReturn += "4"; break; case SDLK_4: sReturn += "4"; break;
case DIK_5: sReturn += "5"; break; case SDLK_5: sReturn += "5"; break;
case DIK_6: sReturn += "6"; break; case SDLK_6: sReturn += "6"; break;
case DIK_7: sReturn += "7"; break; case SDLK_7: sReturn += "7"; break;
case DIK_8: sReturn += "8"; break; case SDLK_8: sReturn += "8"; break;
case DIK_9: sReturn += "9"; break; case SDLK_9: sReturn += "9"; break;
case DIK_0: sReturn += "0"; break; case SDLK_0: sReturn += "0"; break;
case DIK_MINUS: sReturn += "Minus"; break; case SDLK_MINUS: sReturn += "Minus"; break;
case DIK_EQUALS: sReturn += "Equals"; break; case SDLK_EQUALS: sReturn += "Equals"; break;
case DIK_BACK: sReturn += "Backsp"; break; case SDLK_BACKSPACE: sReturn += "Backsp"; break;
case DIK_TAB: sReturn += "Tab"; break; case SDLK_TAB: sReturn += "Tab"; break;
case DIK_Q: sReturn += "Q"; break; case SDLK_Q: sReturn += "Q"; break;
case DIK_W: sReturn += "W"; break; case SDLK_W: sReturn += "W"; break;
case DIK_E: sReturn += "E"; break; case SDLK_E: sReturn += "E"; break;
case DIK_R: sReturn += "R"; break; case SDLK_R: sReturn += "R"; break;
case DIK_T: sReturn += "T"; break; case SDLK_T: sReturn += "T"; break;
case DIK_Y: sReturn += "Y"; break; case SDLK_Y: sReturn += "Y"; break;
case DIK_U: sReturn += "U"; break; case SDLK_U: sReturn += "U"; break;
case DIK_I: sReturn += "I"; break; case SDLK_I: sReturn += "I"; break;
case DIK_O: sReturn += "O"; break; case SDLK_O: sReturn += "O"; break;
case DIK_P: sReturn += "P"; break; case SDLK_P: sReturn += "P"; break;
case DIK_LBRACKET: sReturn += "LBracket"; break; case SDLK_LBRACKET: sReturn += "LBracket"; break;
case DIK_RBRACKET: sReturn += "RBracket"; break; case SDLK_RBRACKET: sReturn += "RBracket"; break;
case DIK_RETURN: sReturn += "Return"; break; case SDLK_RETURN: sReturn += "Return"; break;
case DIK_LCONTROL: sReturn += "LControl"; break; case SDLK_LCONTROL: sReturn += "LControl"; break;
case DIK_A: sReturn += "A"; break; case SDLK_A: sReturn += "A"; break;
case DIK_S: sReturn += "S"; break; case SDLK_S: sReturn += "S"; break;
case DIK_D: sReturn += "D"; break; case SDLK_D: sReturn += "D"; break;
case DIK_F: sReturn += "F"; break; case SDLK_F: sReturn += "F"; break;
case DIK_G: sReturn += "G"; break; case SDLK_G: sReturn += "G"; break;
case DIK_H: sReturn += "H"; break; case SDLK_H: sReturn += "H"; break;
case DIK_J: sReturn += "J"; break; case SDLK_J: sReturn += "J"; break;
case DIK_K: sReturn += "K"; break; case SDLK_K: sReturn += "K"; break;
case DIK_L: sReturn += "L"; break; case SDLK_L: sReturn += "L"; break;
case DIK_SEMICOLON: sReturn += "Semicln"; break; case SDLK_SEMICOLON: sReturn += "Semicln"; break;
case DIK_APOSTROPHE:sReturn += "Apostro"; break; case SDLK_APOSTROPHE:sReturn += "Apostro"; break;
case DIK_GRAVE: sReturn += "Grave"; break; case SDLK_GRAVE: sReturn += "Grave"; break;
case DIK_LSHIFT: sReturn += "LShift"; break; case SDLK_LSHIFT: sReturn += "LShift"; break;
case DIK_BACKSLASH: sReturn += "Backslsh"; break; case SDLK_BACKSLASH: sReturn += "Backslsh"; break;
case DIK_Z: sReturn += "Z"; break; case SDLK_Z: sReturn += "Z"; break;
case DIK_X: sReturn += "X"; break; case SDLK_X: sReturn += "X"; break;
case DIK_C: sReturn += "C"; break; case SDLK_C: sReturn += "C"; break;
case DIK_V: sReturn += "V"; break; case SDLK_V: sReturn += "V"; break;
case DIK_B: sReturn += "B"; break; case SDLK_B: sReturn += "B"; break;
case DIK_N: sReturn += "N"; break; case SDLK_N: sReturn += "N"; break;
case DIK_M: sReturn += "M"; break; case SDLK_M: sReturn += "M"; break;
case DIK_COMMA: sReturn += "Comma"; break; case SDLK_COMMA: sReturn += "Comma"; break;
case DIK_PERIOD: sReturn += "Period"; break; case SDLK_PERIOD: sReturn += "Period"; break;
case DIK_SLASH: sReturn += "Slash"; break; case SDLK_SLASH: sReturn += "Slash"; break;
case DIK_RSHIFT: sReturn += "RShift"; break; case SDLK_RSHIFT: sReturn += "RShift"; break;
case DIK_MULTIPLY: sReturn += "Mult"; break; case SDLK_MULTIPLY: sReturn += "Mult"; break;
case DIK_LMENU: sReturn += "LMenu"; break; case SDLK_LMENU: sReturn += "LMenu"; break;
case DIK_SPACE: sReturn += "Space"; break; case SDLK_SPACE: sReturn += "Space"; break;
case DIK_CAPITAL: sReturn += "CapsLk"; break; case SDLK_CAPITAL: sReturn += "CapsLk"; break;
case DIK_F1: sReturn += "F1"; break; case SDLK_F1: sReturn += "F1"; break;
case DIK_F2: sReturn += "F2"; break; case SDLK_F2: sReturn += "F2"; break;
case DIK_F3: sReturn += "F3"; break; case SDLK_F3: sReturn += "F3"; break;
case DIK_F4: sReturn += "F4"; break; case SDLK_F4: sReturn += "F4"; break;
case DIK_F5: sReturn += "F5"; break; case SDLK_F5: sReturn += "F5"; break;
case DIK_F6: sReturn += "F6"; break; case SDLK_F6: sReturn += "F6"; break;
case DIK_F7: sReturn += "F7"; break; case SDLK_F7: sReturn += "F7"; break;
case DIK_F8: sReturn += "F8"; break; case SDLK_F8: sReturn += "F8"; break;
case DIK_F9: sReturn += "F9"; break; case SDLK_F9: sReturn += "F9"; break;
case DIK_F10: sReturn += "F10"; break; case SDLK_F10: sReturn += "F10"; break;
case DIK_NUMLOCK: sReturn += "Numlock"; break; case SDLK_NUMLOCK: sReturn += "Numlock"; break;
case DIK_SCROLL: sReturn += "Scroll"; break; case SDLK_SCROLL: sReturn += "Scroll"; break;
case DIK_NUMPAD7: sReturn += "NumPad7"; break; case SDLK_NUMPAD7: sReturn += "NumPad7"; break;
case DIK_NUMPAD8: sReturn += "NumPad8"; break; case SDLK_NUMPAD8: sReturn += "NumPad8"; break;
case DIK_NUMPAD9: sReturn += "NumPad9"; break; case SDLK_NUMPAD9: sReturn += "NumPad9"; break;
case DIK_SUBTRACT: sReturn += "Subtract"; break; case SDLK_SUBTRACT: sReturn += "Subtract"; break;
case DIK_NUMPAD4: sReturn += "NumPad4"; break; case SDLK_NUMPAD4: sReturn += "NumPad4"; break;
case DIK_NUMPAD5: sReturn += "NumPad5"; break; case SDLK_NUMPAD5: sReturn += "NumPad5"; break;
case DIK_NUMPAD6: sReturn += "NumPad6"; break; case SDLK_NUMPAD6: sReturn += "NumPad6"; break;
case DIK_ADD: sReturn += "Add"; break; case SDLK_ADD: sReturn += "Add"; break;
case DIK_NUMPAD1: sReturn += "NumPad1"; break; case SDLK_NUMPAD1: sReturn += "NumPad1"; break;
case DIK_NUMPAD2: sReturn += "NumPad2"; break; case SDLK_NUMPAD2: sReturn += "NumPad2"; break;
case DIK_NUMPAD3: sReturn += "NumPad3"; break; case SDLK_NUMPAD3: sReturn += "NumPad3"; break;
case DIK_NUMPAD0: sReturn += "NumPad0"; break; case SDLK_NUMPAD0: sReturn += "NumPad0"; break;
case DIK_DECIMAL: sReturn += "Decimal"; break; case SDLK_DECIMAL: sReturn += "Decimal"; break;
case DIK_RMENU: sReturn += "RightAlt"; break; case SDLK_RMENU: sReturn += "RightAlt"; break;
case DIK_PAUSE: sReturn += "Pause"; break; case SDLK_PAUSE: sReturn += "Pause"; break;
case DIK_HOME: sReturn += "Home"; break; case SDLK_HOME: sReturn += "Home"; break;
case DIK_UP: sReturn += "Up"; break; case SDLK_UP: sReturn += "Up"; break;
case DIK_PRIOR: sReturn += "PageUp"; break; case SDLK_PRIOR: sReturn += "PageUp"; break;
case DIK_LEFT: sReturn += "Left"; break; case SDLK_LEFT: sReturn += "Left"; break;
case DIK_RIGHT: sReturn += "Right"; break; case SDLK_RIGHT: sReturn += "Right"; break;
case DIK_END: sReturn += "End"; break; case SDLK_END: sReturn += "End"; break;
case DIK_DOWN: sReturn += "Down"; break; case SDLK_DOWN: sReturn += "Down"; break;
case DIK_NEXT: sReturn += "PageDn"; break; case SDLK_NEXT: sReturn += "PageDn"; break;
case DIK_INSERT: sReturn += "Insert"; break; case SDLK_INSERT: sReturn += "Insert"; break;
case DIK_DELETE: sReturn += "Delete"; break; case SDLK_DELETE: sReturn += "Delete"; break;
case DIK_LWIN: sReturn += "LeftWin"; break; case SDLK_LWIN: sReturn += "LeftWin"; break;
case DIK_RWIN: sReturn += "RightWin"; break; case SDLK_RWIN: sReturn += "RightWin"; break;
case DIK_APPS: sReturn += "AppMenu"; break; case SDLK_APPS: sReturn += "AppMenu"; break;
case DIK_NUMPADENTER: sReturn += "PadEnter"; break; case SDLK_NUMPADENTER: sReturn += "PadEnter"; break;
case DIK_DIVIDE: sReturn += "PadSlash"; break; case SDLK_DIVIDE: sReturn += "PadSlash"; break;
default: sReturn += "Unknown Key"; break; default: sReturn += "Unknown Key"; break;
} }
*/
break; break;
default: default:
ASSERT( false ); // what device is this? ASSERT(0); // what device is this?
} }
return sReturn; return sReturn;
@@ -275,7 +272,7 @@ bool DeviceInput::fromString( const CString &s )
} }
/* FIXME: The main font doesn't have '`' (0x29), so that's disabled. */ /* 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 */ /* 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, /* 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', /* 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 ) switch( device )
{ {
case DEVICE_KEYBOARD: case DEVICE_KEYBOARD:
if( button < sizeof(dik_charmap) ) if( button < sizeof(SDLK_charmap) )
return dik_charmap[button]; return SDLK_charmap[button];
return '\0'; return '\0';
default: default:
return '\0'; 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();
RageInput::RageInput()
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 )
{ {
LOG->Trace( "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; // Init keyboard
m_pMouse = NULL; //
for( i=0; i<NUM_JOYSTICKS; i++ ) SDL_EnableKeyRepeat( 0, 0 );
m_pJoystick[i]=NULL;
ZeroMemory( &m_keys, sizeof(m_keys) ); //
ZeroMemory( &m_oldKeys, sizeof(m_oldKeys) ); // Init joysticks
//
memset( m_pJoystick, 0, sizeof(m_pJoystick) );
int iNumJoySticks = min( SDL_NumJoysticks(), NUM_JOYSTICKS );
for( int i=0; i<iNumJoySticks; i++ )
{
m_pJoystick[i] = SDL_JoystickOpen( i );
LOG->Trace( "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]; m_Pumps = new pump_t[NUM_PUMPS];
Initialize(); // {
} // /* Nasty hack to work around a bug in DirectInput8: Pump pads
// * crash EnumDevices. Prevent this by opening the pad with
RageInput::~RageInput() // * exclusive access while we enumerate, then closing it when
{ // * we finish. We don't do anything with this; we open it
Release(); // * 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",
void RageInput::Initialize() // * so this doesn't bite us again down the road.) */
{ // pump_t m_TempPumps[NUM_PUMPS];
HRESULT hr; // for(int pumpNo = 0; pumpNo < NUM_PUMPS; ++pumpNo)
// m_TempPumps[pumpNo].init(pumpNo, false);
//////////////////////////////// //
// 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; i<NUM_JOYSTICKS; i++ )
{
// Set the data format to "simple joystick" - a predefined data format
//
// A data format specifies which controls on a device we are interested in,
// and how they should be reported. This tells DInput that we will be
// passing a DIJOYSTATE2 structure to IDirectInputDevice::GetDeviceState().
if( m_pJoystick[i] )
if( FAILED( hr = m_pJoystick[i]->SetDataFormat( &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." );
}
for(int pumpNo = 0; pumpNo < NUM_PUMPS; ++pumpNo) 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) // De-init keyboard
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 joysticks
//
for( int i=0; i<NUM_JOYSTICKS; i++ ) for( int i=0; i<NUM_JOYSTICKS; i++ )
{ {
if (m_pJoystick[i]) if( m_pJoystick[i] )
m_pJoystick[i]->Unacquire(); {
// Release the Mouse device SDL_JoystickClose(m_pJoystick[i]);
SAFE_RELEASE(m_pJoystick[i]); m_pJoystick[i] = NULL;
}
} }
// Release the DirectInput object //
SAFE_RELEASE(m_pDI); // De-init pumps
//
delete[] m_Pumps; delete[] m_Pumps;
SDL_QuitSubSystem( SDL_INIT_JOYSTICK );
} }
HRESULT RageInput::UpdateMouse() void RageInput::Update( float fDeltaTime )
{ {
if( NULL == m_pMouse ) //
return E_FAIL; // Move last current state to old state
//
ZeroMemory( &m_mouseState, sizeof(m_mouseState) ); memcpy( m_oldKeys, m_keys, sizeof(m_oldKeys) );
memcpy( m_oldJoyState, m_joyState, sizeof(m_joyState) );
// Get the input's device state, and put the state in DIMOUSESTATE2 memcpy( m_oldPumpState, m_pumpState, sizeof(m_pumpState) );
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;
}
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. */ memset( m_joyState, 0, sizeof(m_joyState) ); // clear current state
m_AbsPosition_x = clamp(m_AbsPosition_x, 0, 640-1);
m_AbsPosition_y = clamp(m_AbsPosition_y, 0, 480-1);
return S_OK; for( int joy=0; joy<NUM_JOYSTICKS; joy++ ) // foreach joystick
}
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 )) )
{ {
// DirectInput may be telling us that the input stream has been SDL_Joystick* pJoy = m_pJoystick[joy];
// interrupted. We aren't tracking any state between polls, so if( !pJoy )
// we don't have any special reset that needs to be done. continue;
// We just re-acquire and try again.
// If input is lost then acquire and keep trying int iNumJoyAxes = min(NUM_JOYSTICK_AXES,SDL_JoystickNumAxes(pJoy));
HRESULT hr = m_pKeyboard->Acquire(); for( int axis=0; axis<iNumJoyAxes; axis++ )
while( hr == DIERR_INPUTLOST ) {
hr = m_pKeyboard->Acquire(); Sint16 val = SDL_JoystickGetAxis(pJoy,axis);
if( val < -100 )
{
JoystickButton b = (JoystickButton)(JOY_LEFT+2*axis);
m_joyState[joy].button[b] = true;
}
}
return E_FAIL; int iNumJoyHats = min(NUM_JOYSTICK_HATS,SDL_JoystickNumHats(pJoy));
for( int hat=0; axis<iNumJoyHats; hat++ )
{
Uint8 val = SDL_JoystickGetHat(pJoy,hat);
m_joyState[joy].button[JOY_HAT_UP] = (val & SDL_HAT_UP) != 0;
m_joyState[joy].button[JOY_HAT_RIGHT] = (val & SDL_HAT_RIGHT) != 0;
m_joyState[joy].button[JOY_HAT_DOWN] = (val & SDL_HAT_DOWN) != 0;
m_joyState[joy].button[JOY_HAT_LEFT] = (val & SDL_HAT_LEFT) != 0;
}
int iNumJoyButtons = MIN(NUM_JOYSTICK_BUTTONS,SDL_JoystickNumButtons(pJoy));
for( int button=0; button<iNumJoyButtons; button++ )
{
JoystickButton b = (JoystickButton)(JOY_1 + button);
m_joyState[joy].button[b] = SDL_JoystickGetButton(pJoy,button) != 0;
}
} }
return S_OK;
}
HRESULT RageInput::UpdatePump() //
{ // Update Pump
//
for( int i=0; i<NUM_PUMPS; i++ ) for( int i=0; i<NUM_PUMPS; i++ )
{ {
if(m_Pumps[i].h == INVALID_HANDLE_VALUE) if(m_Pumps[i].h == INVALID_HANDLE_VALUE)
@@ -650,159 +481,37 @@ HRESULT RageInput::UpdatePump()
m_pumpState[i].button[butno] = true; m_pumpState[i].button[butno] = true;
} }
} }
return S_OK;
}
void RageInput::Update()
{
// macros for reading DI state structures
#define IS_PRESSED(b) (b & 0x80)
#define AXIS_THRESHOLD 250 // joystick axis threshold
#define IS_LEFT(a) (a <= -AXIS_THRESHOLD)
#define IS_RIGHT(a) (a >= 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 ) bool RageInput::BeingPressed( DeviceInput di, bool bPrevState )
{
if(Prev) return WasBeingPressed(di);
return IsBeingPressed(di);
}
bool RageInput::IsBeingPressed( DeviceInput di )
{ {
switch( di.device ) switch( di.device )
{ {
case DEVICE_KEYBOARD: case DEVICE_KEYBOARD:
return 0 != m_keys[ di.button ]; {
case DEVICE_JOY1: ASSERT(di.button < NUM_KEYBOARD_BUTTONS);
case DEVICE_JOY2: return (bPrevState?m_oldKeys:m_keys) [ di.button ];
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 ];
case DEVICE_JOY1: case DEVICE_JOY1:
case DEVICE_JOY2: case DEVICE_JOY2:
case DEVICE_JOY3: case DEVICE_JOY3:
case DEVICE_JOY4: 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_PUMP1:
case DEVICE_PUMP2: { case DEVICE_PUMP2:
ASSERT(di.button < NUM_PUMP_PAD_BUTTONS); {
return m_oldPumpState[di.device - DEVICE_PUMP1].button[di.button]; ASSERT(di.button < NUM_PUMP_PAD_BUTTONS);
} return (bPrevState?m_oldPumpState:m_pumpState) [di.device - DEVICE_PUMP1].button[di.button];
}
default: default:
ASSERT( false ); // bad device ASSERT( 0 ); // bad device
return false; // hush compiler
} }
return false; // how did we get here?!?
} }
extern "C" { extern "C" {
+24 -59
View File
@@ -4,25 +4,27 @@
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
File: RageInput.h 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. Copyright (c) 2001-2002 by the person(s) listed below. All rights reserved.
Chris Danford
----------------------------------------------------------------------------- -----------------------------------------------------------------------------
*/ */
#ifndef DIRECTINPUT_VERSION struct _SDL_Joystick;
#define DIRECTINPUT_VERSION 0x0800 typedef struct _SDL_Joystick SDL_Joystick;
#endif
#include <dinput.h> #include "SDL_keysym.h"
#include "RageUtil.h"
const int NUM_KEYBOARD_BUTTONS = 256;
const int NUM_KEYBOARD_BUTTONS = SDLK_LAST;
const int NUM_JOYSTICKS = 4; 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_PUMPS = 2;
const int NUM_PUMP_PAD_BUTTONS = 11; const int NUM_PUMP_PAD_BUTTONS = 11;
const int NUM_DEVICE_BUTTONS = NUM_KEYBOARD_BUTTONS;
enum InputDevice { enum InputDevice {
DEVICE_KEYBOARD = 0, DEVICE_KEYBOARD = 0,
DEVICE_JOY1, DEVICE_JOY1,
@@ -47,8 +49,6 @@ enum JoystickButton {
NUM_JOYSTICK_BUTTONS // leave this at the end 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 struct DeviceInput
{ {
@@ -78,32 +78,20 @@ public:
}; };
class RageInput class RageInput
{ {
// Our Screens Handle SDL_Joystick* m_pJoystick[NUM_JOYSTICKS];
HWND m_hWnd;
// Main DirectInput Object // Keyboard state data
LPDIRECTINPUT8 m_pDI; bool m_keys[NUM_KEYBOARD_BUTTONS];
// Keyboard Device bool m_oldKeys[NUM_KEYBOARD_BUTTONS];
LPDIRECTINPUTDEVICE8 m_pKeyboard;
// Mouse Device
LPDIRECTINPUTDEVICE8 m_pMouse;
// Joystick Devices
LPDIRECTINPUTDEVICE8 m_pJoystick[NUM_JOYSTICKS];
// Arrays for Keyboard Data // Joystick state data
byte m_keys[NUM_KEYBOARD_BUTTONS]; struct {
byte m_oldKeys[NUM_KEYBOARD_BUTTONS]; bool button[NUM_JOYSTICK_BUTTONS];
} m_joyState[NUM_JOYSTICKS], m_oldJoyState[NUM_JOYSTICKS];
// 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];
// Pump state data
struct { struct {
bool button[NUM_PUMP_PAD_BUTTONS]; bool button[NUM_PUMP_PAD_BUTTONS];
} m_pumpState[NUM_PUMPS], m_oldPumpState[NUM_PUMPS]; } m_pumpState[NUM_PUMPS], m_oldPumpState[NUM_PUMPS];
@@ -121,37 +109,14 @@ class RageInput
int GetPadEvent(); int GetPadEvent();
} *m_Pumps; } *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: public:
RageInput(HWND hWnd); RageInput();
~RageInput(); ~RageInput();
// Initialize DirectInput Resources void Update( float fDeltaTime );
void Initialize(); bool BeingPressed( DeviceInput di, bool bPrevState );
// Release all DirectInput Resources bool IsBeingPressed( DeviceInput di ) { return BeingPressed(di, false); }
void Release(); bool WasBeingPressed( DeviceInput di ) { return BeingPressed(di, true); }
// 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; }
}; };
namespace USB { namespace USB {
+1 -1
View File
@@ -71,7 +71,7 @@ void Screen::Input( const DeviceInput& DeviceI, const InputEventType type, const
if(type == IET_RELEASE) return; // don't care if(type == IET_RELEASE) return; // don't care
/* Don't make the user hold the back button if they're pressing escape. */ /* 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 ); this->MenuBack( MenuI.player );
return; return;
+135 -134
View File
@@ -24,6 +24,7 @@
#include "RageLog.h" #include "RageLog.h"
#include <math.h> #include <math.h>
#include "ThemeManager.h" #include "ThemeManager.h"
#include "SDL_keysym.h" // for SDLKeys
#include <utility> #include <utility>
@@ -129,29 +130,29 @@ const CString ACTION_MENU_ITEM_TEXT[NUM_ACTION_MENU_ITEMS] = {
"Q: Quit" "Q: Quit"
}; };
const int ACTION_MENU_ITEM_KEY[NUM_ACTION_MENU_ITEMS] = { const int ACTION_MENU_ITEM_KEY[NUM_ACTION_MENU_ITEMS] = {
DIK_RETURN, SDLK_RETURN,
DIK_SPACE, SDLK_SPACE,
DIK_P, SDLK_p,
DIK_R, SDLK_r,
DIK_T, SDLK_t,
DIK_X, SDLK_x,
DIK_C, SDLK_c,
DIK_V, SDLK_v,
DIK_D, SDLK_d,
DIK_E, SDLK_e,
DIK_N, SDLK_n,
DIK_I, SDLK_i,
DIK_B, SDLK_b,
DIK_INSERT, SDLK_INSERT,
DIK_DELETE, SDLK_DELETE,
DIK_G, SDLK_g,
DIK_H, SDLK_h,
DIK_J, SDLK_j,
DIK_K, SDLK_k,
DIK_L, SDLK_l,
DIK_M, SDLK_m,
DIK_S, SDLK_s,
DIK_Q, SDLK_q,
}; };
const CString NAMING_MENU_ITEM_TEXT[NUM_NAMING_MENU_ITEMS] = { 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 // Pairs of keystroke + ifCapital
const std::pair<int, bool> NAMING_MENU_ITEM_KEY[NUM_NAMING_MENU_ITEMS] = { const std::pair<int, bool> NAMING_MENU_ITEM_KEY[NUM_NAMING_MENU_ITEMS] = {
std::make_pair(DIK_M, false), std::make_pair(SDLK_m, false),
std::make_pair(DIK_S, false), std::make_pair(SDLK_s, false),
std::make_pair(DIK_A, false), std::make_pair(SDLK_a, false),
std::make_pair(DIK_M, true), std::make_pair(SDLK_m, true),
std::make_pair(DIK_S, true), std::make_pair(SDLK_s, true),
std::make_pair(DIK_A, true), std::make_pair(SDLK_a, true),
}; };
const ScreenMessage SM_GoToPrevScreen = ScreenMessage(SM_User+1); const ScreenMessage SM_GoToPrevScreen = ScreenMessage(SM_User+1);
@@ -550,7 +551,7 @@ void ScreenEdit::DrawPrimitives()
m_textHelp.Draw(); m_textHelp.Draw();
m_textInfo.Draw(); m_textInfo.Draw();
m_Fade.Draw(); m_Fade.Draw();
/* if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,DIK_F1) ) ) /* if( INPUTFILTER->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD,SDLK_F1) ) )
{ {
m_rectShortcutsBack.Draw(); m_rectShortcutsBack.Draw();
m_textShortcuts.Draw(); m_textShortcuts.Draw();
@@ -688,8 +689,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
if(type == IET_RELEASE) if(type == IET_RELEASE)
{ {
switch( DeviceI.button ) { switch( DeviceI.button ) {
case DIK_LSHIFT: case SDLK_LSHIFT:
case DIK_RSHIFT: case SDLK_RSHIFT:
shiftAnchor = -1; shiftAnchor = -1;
break; break;
} }
@@ -698,21 +699,21 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_1: case SDLK_1:
case DIK_2: case SDLK_2:
case DIK_3: case SDLK_3:
case DIK_4: case SDLK_4:
case DIK_5: case SDLK_5:
case DIK_6: case SDLK_6:
case DIK_7: case SDLK_7:
case DIK_8: case SDLK_8:
case DIK_9: case SDLK_9:
case DIK_0: case SDLK_0:
{ {
if( type != IET_FIRST_PRESS ) if( type != IET_FIRST_PRESS )
break; // We only care about first presses 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 float fSongBeat = GAMESTATE->m_fSongBeat;
const int iSongIndex = BeatToNoteRow( fSongBeat ); const int iSongIndex = BeatToNoteRow( fSongBeat );
@@ -744,10 +745,10 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
} }
} }
break; break;
case DIK_Q: case SDLK_q:
SCREENMAN->SetNewScreen( "ScreenEditMenu" ); SCREENMAN->SetNewScreen( "ScreenEditMenu" );
break; break;
case DIK_S: case SDLK_s:
{ {
// copy edit into current Notes // copy edit into current Notes
Notes* pNotes = GAMESTATE->m_pCurNotes[PLAYER_1]; 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") ); SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","edit save") );
} }
break; break;
case DIK_UP: case SDLK_UP:
case DIK_DOWN: case SDLK_DOWN:
case DIK_PGUP: case SDLK_PAGEUP:
case DIK_PGDN: case SDLK_PAGEDOWN:
{ {
float fBeatsToMove=0.f; float fBeatsToMove=0.f;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_UP: case SDLK_UP:
case DIK_DOWN: case SDLK_DOWN:
fBeatsToMove = NoteTypeToBeat( m_SnapDisplay.GetNoteType() ); fBeatsToMove = NoteTypeToBeat( m_SnapDisplay.GetNoteType() );
if( DeviceI.button == DIK_UP ) if( DeviceI.button == SDLK_UP )
fBeatsToMove *= -1; fBeatsToMove *= -1;
break; break;
case DIK_PGUP: case SDLK_PAGEUP:
case DIK_PGDN: case SDLK_PAGEDOWN:
fBeatsToMove = BEATS_PER_MEASURE; fBeatsToMove = BEATS_PER_MEASURE;
if( DeviceI.button == DIK_PGUP ) if( DeviceI.button == SDLK_PAGEUP )
fBeatsToMove *= -1; fBeatsToMove *= -1;
} }
@@ -788,7 +789,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
// check to see if they're holding a button // check to see if they're holding a button
for( int col=0; col<m_NoteFieldEdit.m_iNumTracks && col<=10; col++ ) for( int col=0; col<m_NoteFieldEdit.m_iNumTracks && col<=10; col++ )
{ {
const DeviceInput di(DEVICE_KEYBOARD, DIK_1+col); const DeviceInput di(DEVICE_KEYBOARD, SDLK_1+col);
if( !INPUTFILTER->IsBeingPressed(di) ) if( !INPUTFILTER->IsBeingPressed(di) )
continue; continue;
@@ -805,8 +806,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
m_NoteFieldEdit.AddHoldNote( newHN ); m_NoteFieldEdit.AddHoldNote( newHN );
} }
if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT))) INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT)))
{ {
/* Shift is being held. /* Shift is being held.
* *
@@ -836,23 +837,23 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
m_soundChangeLine.Play(); m_soundChangeLine.Play();
} }
break; break;
case DIK_HOME: case SDLK_HOME:
GAMESTATE->m_fSongBeat = 0; GAMESTATE->m_fSongBeat = 0;
m_soundChangeLine.Play(); m_soundChangeLine.Play();
break; break;
case DIK_END: case SDLK_END:
GAMESTATE->m_fSongBeat = m_NoteFieldEdit.GetLastBeat(); GAMESTATE->m_fSongBeat = m_NoteFieldEdit.GetLastBeat();
m_soundChangeLine.Play(); m_soundChangeLine.Play();
break; break;
case DIK_RIGHT: case SDLK_RIGHT:
m_SnapDisplay.PrevSnapMode(); m_SnapDisplay.PrevSnapMode();
OnSnapModeChange(); OnSnapModeChange();
break; break;
case DIK_LEFT: case SDLK_LEFT:
m_SnapDisplay.NextSnapMode(); m_SnapDisplay.NextSnapMode();
OnSnapModeChange(); OnSnapModeChange();
break; break;
case DIK_RETURN: case SDLK_RETURN:
if( m_NoteFieldEdit.m_fEndMarker != -1 && GAMESTATE->m_fSongBeat > m_NoteFieldEdit.m_fEndMarker ) if( m_NoteFieldEdit.m_fEndMarker != -1 && GAMESTATE->m_fSongBeat > m_NoteFieldEdit.m_fEndMarker )
{ {
// invalid! The begin maker must be placed before the end marker // 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(); m_soundMarker.Play();
} }
break; break;
case DIK_SPACE: case SDLK_SPACE:
if( m_NoteFieldEdit.m_fBeginMarker != -1 && GAMESTATE->m_fSongBeat < m_NoteFieldEdit.m_fBeginMarker ) if( m_NoteFieldEdit.m_fBeginMarker != -1 && GAMESTATE->m_fSongBeat < m_NoteFieldEdit.m_fBeginMarker )
{ {
// invalid! The end maker must be placed after the begin marker // 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(); m_soundMarker.Play();
} }
break; break;
case DIK_G: case SDLK_g:
case DIK_H: case SDLK_h:
case DIK_J: case SDLK_j:
case DIK_K: case SDLK_k:
case DIK_L: case SDLK_l:
{ {
if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 ) 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; NoteType noteType2;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_G: noteType1 = NOTE_TYPE_4TH; noteType2 = NOTE_TYPE_4TH; break; case SDLK_g: noteType1 = NOTE_TYPE_4TH; noteType2 = NOTE_TYPE_4TH; break;
case DIK_H: noteType1 = NOTE_TYPE_8TH; noteType2 = NOTE_TYPE_8TH; break; case SDLK_h: noteType1 = NOTE_TYPE_8TH; noteType2 = NOTE_TYPE_8TH; break;
case DIK_J: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_12TH; break; case SDLK_j: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_12TH; break;
case DIK_K: noteType1 = NOTE_TYPE_16TH; noteType2 = NOTE_TYPE_16TH; break; case SDLK_k: noteType1 = NOTE_TYPE_16TH; noteType2 = NOTE_TYPE_16TH; break;
case DIK_L: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_16TH; break; case SDLK_l: noteType1 = NOTE_TYPE_12TH; noteType2 = NOTE_TYPE_16TH; break;
default: ASSERT( false ); return; default: ASSERT( false ); return;
} }
@@ -904,7 +905,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
} }
} }
break; break;
case DIK_ESCAPE: case SDLK_ESCAPE:
{ {
m_EditMode = MODE_ACTION_MENU; m_EditMode = MODE_ACTION_MENU;
m_iMenuSelection = 0; 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) ); m_rectRecordBack.SetTweenDiffuse( RageColor(0,0,0,0.8f) );
} }
break; break;
case DIK_N: case SDLK_n:
{ {
m_EditMode = MODE_NAMING_MENU; m_EditMode = MODE_NAMING_MENU;
m_iMenuSelection = 0; 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) ); m_rectRecordBack.SetTweenDiffuse( RageColor(0,0,0,0.8f) );
} }
break; break;
case DIK_R: case SDLK_r:
case DIK_P: case SDLK_p:
{ {
if( m_NoteFieldEdit.m_fBeginMarker == -1 ) if( m_NoteFieldEdit.m_fBeginMarker == -1 )
m_NoteFieldEdit.m_fBeginMarker = GAMESTATE->m_fSongBeat; m_NoteFieldEdit.m_fBeginMarker = GAMESTATE->m_fSongBeat;
if( m_NoteFieldEdit.m_fEndMarker == -1 ) if( m_NoteFieldEdit.m_fEndMarker == -1 )
m_NoteFieldEdit.m_fEndMarker = m_pSong->m_fLastBeat; m_NoteFieldEdit.m_fEndMarker = m_pSong->m_fLastBeat;
if(DeviceI.button == DIK_R) { if(DeviceI.button == SDLK_r) {
m_EditMode = MODE_RECORDING; m_EditMode = MODE_RECORDING;
// initialize m_NoteFieldRecord // initialize m_NoteFieldRecord
@@ -960,7 +961,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate ); m_soundMusic.SetPlaybackRate( GAMESTATE->m_SongOptions.m_fMusicRate );
} }
break; break;
case DIK_T: case SDLK_t:
if( GAMESTATE->m_SongOptions.m_fMusicRate == 1.0f ) GAMESTATE->m_SongOptions.m_fMusicRate = 0.9f; 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.9f ) GAMESTATE->m_SongOptions.m_fMusicRate = 0.8f;
else if( GAMESTATE->m_SongOptions.m_fMusicRate == 0.8f ) GAMESTATE->m_SongOptions.m_fMusicRate = 0.7f; 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.2f ) GAMESTATE->m_SongOptions.m_fMusicRate = 1.1f;
else if( GAMESTATE->m_SongOptions.m_fMusicRate == 1.1f ) GAMESTATE->m_SongOptions.m_fMusicRate = 1.0f; else if( GAMESTATE->m_SongOptions.m_fMusicRate == 1.1f ) GAMESTATE->m_SongOptions.m_fMusicRate = 1.0f;
break; break;
case DIK_INSERT: case SDLK_INSERT:
case DIK_DELETE: case SDLK_DELETE:
{ {
NoteData temp; NoteData temp;
temp.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks; temp.m_iNumTracks = m_NoteFieldEdit.m_iNumTracks;
@@ -980,11 +981,11 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
int iPasteAtRow; int iPasteAtRow;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_INSERT: case SDLK_INSERT:
iTakeFromRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); iTakeFromRow = BeatToNoteRow( GAMESTATE->m_fSongBeat );
iPasteAtRow = BeatToNoteRow( GAMESTATE->m_fSongBeat+1 ); iPasteAtRow = BeatToNoteRow( GAMESTATE->m_fSongBeat+1 );
break; break;
case DIK_DELETE: case SDLK_DELETE:
iTakeFromRow = BeatToNoteRow( GAMESTATE->m_fSongBeat+1 ); iTakeFromRow = BeatToNoteRow( GAMESTATE->m_fSongBeat+1 );
iPasteAtRow = BeatToNoteRow( GAMESTATE->m_fSongBeat ); iPasteAtRow = BeatToNoteRow( GAMESTATE->m_fSongBeat );
break; 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 ); m_NoteFieldEdit.CopyRange( &temp, 0, MAX_TAP_NOTE_ROWS-iTakeFromRow, iPasteAtRow );
} }
break; break;
case DIK_X: case SDLK_x:
if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 ) if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 )
{ {
m_soundInvalid.Play(); m_soundInvalid.Play();
@@ -1008,7 +1009,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
m_NoteFieldEdit.ClearRange( iFirstRow, iLastRow ); m_NoteFieldEdit.ClearRange( iFirstRow, iLastRow );
} }
break; break;
case DIK_C: case SDLK_c:
if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 ) if( m_NoteFieldEdit.m_fBeginMarker == -1 || m_NoteFieldEdit.m_fEndMarker == -1 )
{ {
m_soundInvalid.Play(); m_soundInvalid.Play();
@@ -1021,7 +1022,7 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
m_Clipboard.CopyRange( &m_NoteFieldEdit, iFirstRow, iLastRow ); m_Clipboard.CopyRange( &m_NoteFieldEdit, iFirstRow, iLastRow );
} }
break; break;
case DIK_V: case SDLK_v:
{ {
int iSrcFirstRow = 0; int iSrcFirstRow = 0;
int iSrcLastRow = BeatToNoteRow( m_Clipboard.GetLastBeat() ); int iSrcLastRow = BeatToNoteRow( m_Clipboard.GetLastBeat() );
@@ -1031,18 +1032,18 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
} }
break; break;
case DIK_D: case SDLK_d:
{ {
Difficulty &dc = m_pNotes->m_Difficulty; Difficulty &dc = m_pNotes->m_Difficulty;
dc = Difficulty( (dc+1)%NUM_DIFFICULTIES ); dc = Difficulty( (dc+1)%NUM_DIFFICULTIES );
} }
break; 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 ); SCREENMAN->TextEntry( SM_None, "Edit notes description.\nPress Enter to confirm,\nEscape to cancel.", m_pNotes->m_sDescription, ChangeDescription, NULL );
break; break;
case DIK_B: case SDLK_b:
{ {
CString sOldBackground; CString sOldBackground;
unsigned i; unsigned i;
@@ -1058,22 +1059,22 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
} }
break; break;
case DIK_I: case SDLK_i:
if( GAMESTATE->m_SongOptions.m_AssistType==SongOptions::ASSIST_TICK ) if( GAMESTATE->m_SongOptions.m_AssistType==SongOptions::ASSIST_TICK )
GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_NONE; GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_NONE;
else else
GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_TICK; GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_TICK;
break; break;
case DIK_F7: case SDLK_F7:
case DIK_F8: case SDLK_F8:
{ {
float fBPM = m_pSong->GetBPMAtBeat( GAMESTATE->m_fSongBeat ); float fBPM = m_pSong->GetBPMAtBeat( GAMESTATE->m_fSongBeat );
float fDeltaBPM; float fDeltaBPM;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_F7: fDeltaBPM = - 0.020f; break; case SDLK_F7: fDeltaBPM = - 0.020f; break;
case DIK_F8: fDeltaBPM = + 0.020f; break; case SDLK_F8: fDeltaBPM = + 0.020f; break;
default: ASSERT(0); return; default: ASSERT(0); return;
} }
switch( type ) switch( type )
@@ -1103,14 +1104,14 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
} }
} }
break; break;
case DIK_F9: case SDLK_F9:
case DIK_F10: case SDLK_F10:
{ {
float fStopDelta; float fStopDelta;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_F9: fStopDelta = -0.02f; break; case SDLK_F9: fStopDelta = -0.02f; break;
case DIK_F10: fStopDelta = +0.02f; break; case SDLK_F10: fStopDelta = +0.02f; break;
default: ASSERT(0); return; default: ASSERT(0); return;
} }
switch( type ) switch( type )
@@ -1141,14 +1142,14 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
} }
} }
break; break;
case DIK_F11: case SDLK_F11:
case DIK_F12: case SDLK_F12:
{ {
float fOffsetDelta; float fOffsetDelta;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_F11: fOffsetDelta = -0.02f; break; case SDLK_F11: fOffsetDelta = -0.02f; break;
case DIK_F12: fOffsetDelta = +0.02f; break; case SDLK_F12: fOffsetDelta = +0.02f; break;
default: ASSERT(0); return; default: ASSERT(0); return;
} }
switch( type ) switch( type )
@@ -1160,18 +1161,18 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
m_pSong->m_fBeat0OffsetInSeconds += fOffsetDelta; m_pSong->m_fBeat0OffsetInSeconds += fOffsetDelta;
} }
break; break;
case DIK_M: case SDLK_m:
MUSIC->Load( m_pSong->GetMusicPath() ); MUSIC->Load( m_pSong->GetMusicPath() );
MUSIC->Play( false, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds ); MUSIC->Play( false, m_pSong->m_fMusicSampleStartSeconds, m_pSong->m_fMusicSampleLengthSeconds );
break; break;
case DIK_LBRACKET: case SDLK_LEFTBRACKET:
case DIK_RBRACKET: case SDLK_RIGHTBRACKET:
{ {
float fDelta; float fDelta;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_LBRACKET: fDelta = -0.02f; break; case SDLK_LEFTBRACKET: fDelta = -0.02f; break;
case DIK_RBRACKET: fDelta = +0.02f; break; case SDLK_RIGHTBRACKET: fDelta = +0.02f; break;
default: ASSERT(0); return; default: ASSERT(0); return;
} }
switch( type ) switch( type )
@@ -1180,8 +1181,8 @@ void ScreenEdit::InputEdit( const DeviceInput& DeviceI, const InputEventType typ
case IET_FAST_REPEAT: fDelta *= 40; break; case IET_FAST_REPEAT: fDelta *= 40; break;
} }
if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || if( INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT))) INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT)))
{ {
m_pSong->m_fMusicSampleLengthSeconds += fDelta; m_pSong->m_fMusicSampleLengthSeconds += fDelta;
m_pSong->m_fMusicSampleLengthSeconds = max(m_pSong->m_fMusicSampleLengthSeconds,0); 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 ) 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(); TransitionFromRecordToEdit();
return; return;
@@ -1240,23 +1241,23 @@ void ScreenEdit::InputActionMenu( const DeviceInput& DeviceI, const InputEventTy
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_UP: case SDLK_UP:
MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] ); MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] );
m_iMenuSelection = (m_iMenuSelection-1+NUM_ACTION_MENU_ITEMS) % NUM_ACTION_MENU_ITEMS; m_iMenuSelection = (m_iMenuSelection-1+NUM_ACTION_MENU_ITEMS) % NUM_ACTION_MENU_ITEMS;
printf( "%d\n", m_iMenuSelection ); printf( "%d\n", m_iMenuSelection );
MenuItemGainFocus( &m_textActionMenu[m_iMenuSelection] ); MenuItemGainFocus( &m_textActionMenu[m_iMenuSelection] );
break; break;
case DIK_DOWN: case SDLK_DOWN:
MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] ); MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] );
m_iMenuSelection = (m_iMenuSelection+1) % NUM_ACTION_MENU_ITEMS; m_iMenuSelection = (m_iMenuSelection+1) % NUM_ACTION_MENU_ITEMS;
printf( "%d\n", m_iMenuSelection ); printf( "%d\n", m_iMenuSelection );
MenuItemGainFocus( &m_textActionMenu[m_iMenuSelection] ); MenuItemGainFocus( &m_textActionMenu[m_iMenuSelection] );
break; break;
case DIK_RETURN: case SDLK_RETURN:
case DIK_ESCAPE: case SDLK_ESCAPE:
TransitionToEdit(); TransitionToEdit();
MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] ); MenuItemLoseFocus( &m_textActionMenu[m_iMenuSelection] );
if( DeviceI.button == DIK_RETURN ) if( DeviceI.button == SDLK_RETURN )
{ {
SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") ); SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") );
int iMenuKey = ACTION_MENU_ITEM_KEY[m_iMenuSelection]; 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 if(type == IET_RELEASE) return; // don't care
bool translit = forceShiftPressed || bool translit = forceShiftPressed ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT)); INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT));
switch( DeviceI.button ) { switch( DeviceI.button ) {
case DIK_M: case SDLK_m:
case DIK_S: case SDLK_s:
case DIK_A: case SDLK_a:
case DIK_ESCAPE: case SDLK_ESCAPE:
case DIK_RETURN: case SDLK_RETURN:
TransitionToEdit(); TransitionToEdit();
MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] ); MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] );
break; break;
@@ -1301,7 +1302,7 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_M: case SDLK_m:
if(translit) { if(translit) {
SCREENMAN->TextEntry( SM_None, "Edit song main title transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sMainTitleTranslit, ChangeMainTitleTranslit, NULL); SCREENMAN->TextEntry( SM_None, "Edit song main title transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sMainTitleTranslit, ChangeMainTitleTranslit, NULL);
} else { } else {
@@ -1309,7 +1310,7 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy
} }
break; break;
case DIK_S: case SDLK_s:
if(translit) { if(translit) {
SCREENMAN->TextEntry( SM_None, "Edit song sub title transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sSubTitleTranslit, ChangeSubTitleTranslit, NULL); SCREENMAN->TextEntry( SM_None, "Edit song sub title transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sSubTitleTranslit, ChangeSubTitleTranslit, NULL);
} else { } else {
@@ -1317,7 +1318,7 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy
} }
break; break;
case DIK_A: case SDLK_a:
if(translit) { if(translit) {
SCREENMAN->TextEntry( SM_None, "Edit song artist transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sArtistTranslit, ChangeArtistTranslit, NULL); SCREENMAN->TextEntry( SM_None, "Edit song artist transliteration.\nPress Enter to confirm,\nEscape to cancel.", m_pSong->m_sArtistTranslit, ChangeArtistTranslit, NULL);
} else { } else {
@@ -1325,19 +1326,19 @@ void ScreenEdit::InputNamingMenu( const DeviceInput& DeviceI, const InputEventTy
} }
break; break;
case DIK_UP: case SDLK_UP:
MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] ); MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] );
m_iMenuSelection = (m_iMenuSelection-1+NUM_NAMING_MENU_ITEMS) % NUM_NAMING_MENU_ITEMS; m_iMenuSelection = (m_iMenuSelection-1+NUM_NAMING_MENU_ITEMS) % NUM_NAMING_MENU_ITEMS;
printf( "%d\n", m_iMenuSelection ); printf( "%d\n", m_iMenuSelection );
MenuItemGainFocus( &m_textNamingMenu[m_iMenuSelection] ); MenuItemGainFocus( &m_textNamingMenu[m_iMenuSelection] );
break; break;
case DIK_DOWN: case SDLK_DOWN:
MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] ); MenuItemLoseFocus( &m_textNamingMenu[m_iMenuSelection] );
m_iMenuSelection = (m_iMenuSelection+1) % NUM_NAMING_MENU_ITEMS; m_iMenuSelection = (m_iMenuSelection+1) % NUM_NAMING_MENU_ITEMS;
printf( "%d\n", m_iMenuSelection ); printf( "%d\n", m_iMenuSelection );
MenuItemGainFocus( &m_textNamingMenu[m_iMenuSelection] ); MenuItemGainFocus( &m_textNamingMenu[m_iMenuSelection] );
break; break;
case DIK_RETURN: case SDLK_RETURN:
SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") ); SOUND->PlayOnceStreamed( THEME->GetPathTo("Sounds","menu start") );
const std::pair<int, bool>& pairMenuKey = NAMING_MENU_ITEM_KEY[m_iMenuSelection]; const std::pair<int, bool>& pairMenuKey = NAMING_MENU_ITEM_KEY[m_iMenuSelection];
InputNamingMenu( DeviceInput(DEVICE_KEYBOARD,pairMenuKey.first), IET_FIRST_PRESS, GameInput(), MenuInput(), StyleInput(), pairMenuKey.second ); 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 ) switch( DeviceI.button )
{ {
case DIK_ESCAPE: case SDLK_ESCAPE:
TransitionToEdit(); TransitionToEdit();
break; break;
case DIK_F11: case SDLK_F11:
case DIK_F12: case SDLK_F12:
{ {
float fOffsetDelta; float fOffsetDelta;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_F11: fOffsetDelta = -0.020f; break; case SDLK_F11: fOffsetDelta = -0.020f; break;
case DIK_F12: fOffsetDelta = +0.020f; break; case SDLK_F12: fOffsetDelta = +0.020f; break;
default: ASSERT(0); return; default: ASSERT(0); return;
} }
switch( type ) switch( type )
+12 -12
View File
@@ -868,7 +868,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
if( GAMESTATE->m_bDemonstration ) if( GAMESTATE->m_bDemonstration )
{ {
/* Special case:always allow escape. */ /* 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 ); this->SendScreenMessage( SM_BeginFadingToTitleMenu, 0 );
} }
@@ -890,7 +890,7 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
{ {
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_F6: case SDLK_F6:
m_bChangedOffsetOrBPM = true; m_bChangedOffsetOrBPM = true;
if (GAMESTATE->m_SongOptions.m_AutoAdjust == SongOptions::ADJUST_ON) { 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.BeginTweening( 0.5f ); // fade out
m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) ); m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) );
break; break;
case DIK_F7: case SDLK_F7:
if( GAMESTATE->m_SongOptions.m_AssistType == SongOptions::ASSIST_NONE ) if( GAMESTATE->m_SongOptions.m_AssistType == SongOptions::ASSIST_NONE )
GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_TICK; GAMESTATE->m_SongOptions.m_AssistType = SongOptions::ASSIST_TICK;
else else
@@ -918,19 +918,19 @@ void ScreenGameplay::Input( const DeviceInput& DeviceI, const InputEventType typ
m_textDebug.BeginTweening( 0.5f ); // fade out m_textDebug.BeginTweening( 0.5f ); // fade out
m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) ); m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) );
break; break;
case DIK_F8: case SDLK_F8:
PREFSMAN->m_bAutoPlay = !PREFSMAN->m_bAutoPlay; PREFSMAN->m_bAutoPlay = !PREFSMAN->m_bAutoPlay;
break; break;
case DIK_F9: case SDLK_F9:
case DIK_F10: case SDLK_F10:
{ {
m_bChangedOffsetOrBPM = true; m_bChangedOffsetOrBPM = true;
float fOffsetDelta; float fOffsetDelta;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_F9: fOffsetDelta = -0.025f; break; case SDLK_F9: fOffsetDelta = -0.025f; break;
case DIK_F10: fOffsetDelta = +0.025f; break; case SDLK_F10: fOffsetDelta = +0.025f; break;
default: ASSERT(0); return; default: ASSERT(0); return;
} }
if( type == IET_FAST_REPEAT ) 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) ); m_textDebug.SetTweenDiffuse( RageColor(1,1,1,0) );
} }
break; break;
case DIK_F11: case SDLK_F11:
case DIK_F12: case SDLK_F12:
{ {
m_bChangedOffsetOrBPM = true; m_bChangedOffsetOrBPM = true;
float fOffsetDelta; float fOffsetDelta;
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_F11: fOffsetDelta = -0.02f; break; case SDLK_F11: fOffsetDelta = -0.02f; break;
case DIK_F12: fOffsetDelta = +0.02f; break; case SDLK_F12: fOffsetDelta = +0.02f; break;
default: ASSERT(0); return; default: ASSERT(0); return;
} }
if( type == IET_FAST_REPEAT ) if( type == IET_FAST_REPEAT )
+9 -9
View File
@@ -178,9 +178,9 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
/* We only advertise space as doing this, but most games /* We only advertise space as doing this, but most games
* use either backspace or delete, and I find them more * use either backspace or delete, and I find them more
* intuitive, so allow them, too. -gm */ * intuitive, so allow them, too. -gm */
case DIK_SPACE: case SDLK_SPACE:
case DIK_DELETE: case SDLK_DELETE:
case DIK_BACK: /* Clear the selected input mapping. */ case SDLK_BACKSPACE: /* Clear the selected input mapping. */
{ {
GameInput curGameI( (GameController)m_iCurController, (GameButton)m_iCurButton ); GameInput curGameI( (GameController)m_iCurController, (GameButton)m_iCurButton );
INPUTMAPPER->ClearFromInputMap( curGameI, m_iCurSlot ); INPUTMAPPER->ClearFromInputMap( curGameI, m_iCurSlot );
@@ -189,7 +189,7 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
INPUTMAPPER->SaveMappingsToDisk(); INPUTMAPPER->SaveMappingsToDisk();
} }
break; 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 ) if( m_iCurSlot == 0 && m_iCurController == 0 )
break; // can't go left any more break; // can't go left any more
m_iCurSlot--; m_iCurSlot--;
@@ -199,7 +199,7 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
m_iCurController--; m_iCurController--;
} }
break; 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 ) if( m_iCurSlot == NUM_CHANGABLE_SLOTS-1 && m_iCurController == MAX_GAME_CONTROLLERS-1 )
break; // can't go right any more break; // can't go right any more
m_iCurSlot++; m_iCurSlot++;
@@ -209,20 +209,20 @@ void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventTy
m_iCurController++; m_iCurController++;
} }
break; break;
case DIK_UP: /* Move the selection up. */ case SDLK_UP: /* Move the selection up. */
if( m_iCurButton == 0 ) if( m_iCurButton == 0 )
break; // can't go up any more break; // can't go up any more
m_iCurButton--; m_iCurButton--;
break; break;
case DIK_DOWN: /* Move the selection down. */ case SDLK_DOWN: /* Move the selection down. */
if( m_iCurButton == GAMESTATE->GetCurrentGameDef()->m_iButtonsPerController-1 ) if( m_iCurButton == GAMESTATE->GetCurrentGameDef()->m_iButtonsPerController-1 )
break; // can't go down any more break; // can't go down any more
m_iCurButton++; m_iCurButton++;
break; break;
case DIK_ESCAPE: /* Quit the screen. */ case SDLK_ESCAPE: /* Quit the screen. */
m_Menu.TweenOffScreenToBlack( SM_GoToNextScreen, true ); m_Menu.TweenOffScreenToBlack( SM_GoToNextScreen, true );
break; break;
case DIK_RETURN: /* Change the selection. */ case SDLK_RETURN: /* Change the selection. */
m_bWaitingForPress = true; m_bWaitingForPress = true;
break; break;
} }
+6 -6
View File
@@ -55,26 +55,26 @@ void ScreenSandbox::Input( const DeviceInput& DeviceI, const InputEventType type
case DEVICE_KEYBOARD: case DEVICE_KEYBOARD:
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_LEFT: case SDLK_LEFT:
obj.SetX(obj.GetX() - 10); obj.SetX(obj.GetX() - 10);
break; break;
case DIK_RIGHT: case SDLK_RIGHT:
obj.SetX(obj.GetX() + 10); obj.SetX(obj.GetX() + 10);
break; break;
case DIK_UP: case SDLK_UP:
obj.SetY(obj.GetY() - 10); obj.SetY(obj.GetY() - 10);
break; break;
case DIK_DOWN: case SDLK_DOWN:
obj.SetY(obj.GetY() + 10); obj.SetY(obj.GetY() + 10);
break; break;
case DIK_T: case SDLK_t:
{ {
SDL_Event *event; SDL_Event *event;
event = (SDL_Event *) malloc(sizeof(event)); event = (SDL_Event *) malloc(sizeof(event));
event->type = SDL_QUIT; event->type = SDL_QUIT;
SDL_PushEvent(event); SDL_PushEvent(event);
} }
case DIK_ESCAPE: case SDLK_ESCAPE:
{ {
SCREENMAN->SetNewScreen( "ScreenTitleMenu" ); SCREENMAN->SetNewScreen( "ScreenTitleMenu" );
} }
+5 -5
View File
@@ -83,14 +83,14 @@ void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType ty
switch( DeviceI.button ) switch( DeviceI.button )
{ {
case DIK_ESCAPE: case SDLK_ESCAPE:
m_bCancelled = true; m_bCancelled = true;
MenuStart(PLAYER_1); MenuStart(PLAYER_1);
break; break;
case DIK_RETURN: case SDLK_RETURN:
MenuStart(PLAYER_1); MenuStart(PLAYER_1);
break; break;
case DIK_BACK: case SDLK_BACKSPACE:
m_sAnswer = m_sAnswer.Left( max(0,m_sAnswer.GetLength()-1) ); m_sAnswer = m_sAnswer.Left( max(0,m_sAnswer.GetLength()-1) );
m_textAnswer.SetText( m_sAnswer ); m_textAnswer.SetText( m_sAnswer );
break; break;
@@ -99,8 +99,8 @@ void ScreenTextEntry::Input( const DeviceInput& DeviceI, const InputEventType ty
c = DeviceI.ToChar(); c = DeviceI.ToChar();
bool bHoldingShift = bool bHoldingShift =
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_LSHIFT)) || INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_LSHIFT)) ||
INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, DIK_RSHIFT)); INPUTFILTER->IsBeingPressed(DeviceInput(DEVICE_KEYBOARD, SDLK_RSHIFT));
// International keyboards often have other keys mapped to shifted keys, and always // 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. // using a US layout is a bit gimped. This is better than nothing though.
-8
View File
@@ -46,14 +46,6 @@
using namespace std; using namespace std;
// Don't include these everywhere. They're big. -Chris
//#include <d3d8.h>
//#include <d3dx8math.h>
#ifndef DIRECTINPUT_VERSION
#define DIRECTINPUT_VERSION 0x0800
#endif
#include <dinput.h>
#if 1 #if 1
+11 -11
View File
@@ -353,7 +353,7 @@ int main(int argc, char* argv[])
throw RageException( "SDL_GetWMInfo failed" ); throw RageException( "SDL_GetWMInfo failed" );
HWND hwnd = info.window; HWND hwnd = info.window;
INPUTMAN = new RageInput( hwnd ); INPUTMAN = new RageInput();
// SOUNDMAN = new RageSoundManager(); // SOUNDMAN = new RageSoundManager();
// These things depend on the TextureManager, so do them after! // 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 // See ScreenManager::Update comments for why we shouldn't do this. -glenn
//if( fDeltaTime > 0.050f ) // we dropped a bunch of frames //if( fDeltaTime > 0.050f ) // we dropped a bunch of frames
// fDeltaTime = 0.050f; // fDeltaTime = 0.050f;
if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_TAB) ) ) { if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_TAB) ) ) {
if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_GRAVE) ) ) if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_QUOTEDBL) ) )
fDeltaTime = 0; /* both; stop time */ fDeltaTime = 0; /* both; stop time */
else else
fDeltaTime *= 4; fDeltaTime *= 4;
} else } else
if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_GRAVE) ) ) if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_QUOTEDBL) ) )
fDeltaTime /= 4; fDeltaTime /= 4;
TEXTUREMAN->Update( fDeltaTime ); TEXTUREMAN->Update( fDeltaTime );
@@ -506,10 +506,10 @@ void GameLoop()
/* ALT-F4 -> quit (better place for this? in ScreenManager perhaps?) */ /* ALT-F4 -> quit (better place for this? in ScreenManager perhaps?) */
/* Nah. this is fine. -Chris */ /* 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)) || if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_RALT)) ||
INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_LMENU)) ) INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LALT)) )
{ {
// pressed Alt+F4 // pressed Alt+F4
SDL_Event *event; SDL_Event *event;
@@ -526,7 +526,7 @@ void GameLoop()
// fall through // 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. // pressed F5. Toggle detail.
if(PREFSMAN->m_iDisplayWidth != 640) 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)) || if( INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_RALT)) ||
INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, DIK_LMENU)) ) INPUTMAN->IsBeingPressed( DeviceInput(DEVICE_KEYBOARD, SDLK_LALT)) )
{ {
/* alt-enter */ /* alt-enter */
PREFSMAN->m_bWindowed = !PREFSMAN->m_bWindowed; PREFSMAN->m_bWindowed = !PREFSMAN->m_bWindowed;