From 8696eafc0ebfac68de7ce5ead4c148f892845b9e Mon Sep 17 00:00:00 2001 From: Ryan Dortmans Date: Tue, 28 Sep 2004 05:06:47 +0000 Subject: [PATCH] Xbox handler now functions correctly. --- .../arch/InputHandler/InputHandler_Xbox.cpp | 25 +++++++++++-------- .../src/arch/InputHandler/InputHandler_Xbox.h | 6 ++--- 2 files changed, 18 insertions(+), 13 deletions(-) diff --git a/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp b/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp index d1527898e4..77a069807f 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp +++ b/stepmania/src/arch/InputHandler/InputHandler_Xbox.cpp @@ -33,10 +33,6 @@ byte buttonMasks[] = { XINPUT_GAMEPAD_DPAD_LEFT, * A, B, X, Y, BLACK, WHITE, Left trigger, right trigger */ -/* XXX: For some reason, with this input handler the input isn't handled on the gameplay screen! - * All other menus work, and the screen itself sees the input and bounces the arrow, but no step - * is actually registered. */ - InputHandler_Xbox::InputHandler_Xbox() { // @@ -44,13 +40,14 @@ InputHandler_Xbox::InputHandler_Xbox() // XDEVICE_PREALLOC_TYPE xdpt[] = {{XDEVICE_TYPE_GAMEPAD, 4}}; XInitDevices( sizeof(xdpt) / sizeof(XDEVICE_PREALLOC_TYPE), xdpt ); - - getHandles(); + ZeroMemory( joysticks, sizeof(joysticks) ); + + getHandles(); } InputHandler_Xbox::~InputHandler_Xbox() { - for(unsigned i = 0; i < NUM_PLAYERS; i++) + for(unsigned i = 0; i < NUM_JOYSTICKS; i++) { if(joysticks[i] != 0) XInputClose(joysticks[i]); @@ -88,7 +85,7 @@ void InputHandler_Xbox::Update(float fDeltaTime) return; } - for(unsigned i = 0; i < NUM_PLAYERS; i++) + for(unsigned i = 0; i < NUM_JOYSTICKS; i++) { if(joysticks[i] == 0) { @@ -159,11 +156,13 @@ void InputHandler_Xbox::Update(float fDeltaTime) memcpy(&lastState[i], &xis.Gamepad, sizeof(XINPUT_GAMEPAD)); } + + InputHandler::UpdateTimer(); } void InputHandler_Xbox::GetDevicesAndDescriptions(vector& vDevicesOut, vector& vDescriptionsOut) { - for( int i=0; i& vDevicesO void InputHandler_Xbox::getHandles() { + for(unsigned i = 0; i < NUM_JOYSTICKS; i++) + { + if(joysticks[i] != 0) + XInputClose(joysticks[i]); + } + ZeroMemory( joysticks, sizeof(joysticks) ); ZeroMemory( lastState, sizeof(lastState) ); @@ -190,7 +195,7 @@ void InputHandler_Xbox::getHandles() { if( devices.dwState & 1 << i) { - if(playersAllocated < NUM_PLAYERS) + if(playersAllocated < NUM_JOYSTICKS) { XINPUT_POLLING_PARAMETERS pollingParameters = {TRUE, TRUE, 0, 8, 8, 0,}; joysticks[playersAllocated] = XInputOpen(XDEVICE_TYPE_GAMEPAD, (DWORD)i, XDEVICE_NO_SLOT, &pollingParameters); diff --git a/stepmania/src/arch/InputHandler/InputHandler_Xbox.h b/stepmania/src/arch/InputHandler/InputHandler_Xbox.h index 401853037b..502c966417 100644 --- a/stepmania/src/arch/InputHandler/InputHandler_Xbox.h +++ b/stepmania/src/arch/InputHandler/InputHandler_Xbox.h @@ -6,15 +6,15 @@ #include #define NUM_PORTS 4 -#define NUM_PLAYERS 2 +#define NUM_JOYSTICKS 2 #define NUM_BUTTONS 8 #define NUM_ANALOG_BUTTONS 8 #define NUM_AXES 4 class InputHandler_Xbox: public InputHandler { - HANDLE joysticks[NUM_PLAYERS]; - XINPUT_GAMEPAD lastState[NUM_PLAYERS]; + HANDLE joysticks[NUM_JOYSTICKS]; + XINPUT_GAMEPAD lastState[NUM_JOYSTICKS]; public: void Update(float fDeltaTime);