diff --git a/stepmania/src/RageInput.cpp b/stepmania/src/RageInput.cpp index ec9a57680b..7b43e93b66 100644 --- a/stepmania/src/RageInput.cpp +++ b/stepmania/src/RageInput.cpp @@ -43,8 +43,12 @@ struct RageInput::pump_t pump_t(); ~pump_t(); + bool Active() const { return h != INVALID_HANDLE_VALUE; } + void Update(); bool init(int devno); int GetPadEvent(); + + bool current_state[NUM_PUMP_PAD_BUTTONS]; }; int DeviceInput::NumButtons(InputDevice device) @@ -222,12 +226,7 @@ RageInput::RageInput() SDL_InitSubSystem( SDL_INIT_JOYSTICK ); // 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) ); + memset( state, 0, sizeof(state) ); // @@ -302,9 +301,7 @@ void RageInput::Update( float fDeltaTime ) // // 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) ); + memcpy( &state[LAST], &state[CURRENT], sizeof(state[LAST]) ); // @@ -312,14 +309,14 @@ void RageInput::Update( float fDeltaTime ) // SDL_PumpEvents(); Uint8* keystate = SDL_GetKeyState(NULL); - memcpy( m_keys, keystate, sizeof(m_keys) ); + memcpy( state[CURRENT].m_keys, keystate, sizeof(state[CURRENT].m_keys) ); // // Update Joystick // SDL_JoystickUpdate(); - memset( m_joyState, 0, sizeof(m_joyState) ); // clear current state + memset( state[CURRENT].m_joyState, 0, sizeof(state[CURRENT].m_joyState) ); // clear current state for( int joy=0; joy +16000 ) { JoystickButton b = (JoystickButton)(JOY_RIGHT+2*axis); - m_joyState[joy].button[b] = true; + state[CURRENT].m_joyState[joy].button[b] = true; } } @@ -348,17 +345,17 @@ void RageInput::Update( float fDeltaTime ) for( int hat=0; hat