From cd579141b5c1cebc67c0e79d5e73ff67f8765b7f Mon Sep 17 00:00:00 2001 From: Ryan Dortmans Date: Thu, 9 Sep 2004 08:50:16 +0000 Subject: [PATCH] Made controller mapping possible in Xbox --- stepmania/src/ScreenMapControllers.cpp | 30 ++++++++++++++++++++++++++ stepmania/src/ScreenMapControllers.h | 1 + 2 files changed, 31 insertions(+) diff --git a/stepmania/src/ScreenMapControllers.cpp b/stepmania/src/ScreenMapControllers.cpp index 5ff63395e7..730774b7e5 100644 --- a/stepmania/src/ScreenMapControllers.cpp +++ b/stepmania/src/ScreenMapControllers.cpp @@ -152,6 +152,36 @@ static bool IsAxis( const DeviceInput& DeviceI ) } void ScreenMapControllers::Input( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) +{ +#ifdef _XBOX + if(!m_iWaitingForPress && DeviceI.device == DEVICE_JOY1) + { + // map the xbox controller buttons to the keyboard equivalents + DeviceInput keymap; + keymap.device = DEVICE_KEYBOARD; + + if(DeviceI.button == JOY_HAT_LEFT) + keymap.button = SDLK_LEFT; + else if(DeviceI.button == JOY_HAT_RIGHT) + keymap.button = SDLK_RIGHT; + else if(DeviceI.button == JOY_HAT_UP) + keymap.button = SDLK_UP; + else if(DeviceI.button == JOY_HAT_DOWN) + keymap.button = SDLK_DOWN; + else if(DeviceI.button == JOY_9) + keymap.button = SDLK_RETURN; + else if(DeviceI.button == JOY_10) + keymap.button = SDLK_ESCAPE; + + + InputInternal(keymap, type, GameI, MenuI, StyleI); + return; + } +#endif + InputInternal(DeviceI, type, GameI, MenuI, StyleI); +} + +void ScreenMapControllers::InputInternal( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ) { if( type != IET_FIRST_PRESS && type != IET_SLOW_REPEAT ) return; // ignore diff --git a/stepmania/src/ScreenMapControllers.h b/stepmania/src/ScreenMapControllers.h index 83bf132acd..379e736723 100644 --- a/stepmania/src/ScreenMapControllers.h +++ b/stepmania/src/ScreenMapControllers.h @@ -32,6 +32,7 @@ private: void Refresh(); + void InputInternal( const DeviceInput& DeviceI, const InputEventType type, const GameInput &GameI, const MenuInput &MenuI, const StyleInput &StyleI ); int m_iCurController; int m_iCurButton;