From 657b16cce2c00b8ecf4fc6a19785f365e2bb7c40 Mon Sep 17 00:00:00 2001 From: Glenn Maynard Date: Sun, 16 Feb 2003 20:15:33 +0000 Subject: [PATCH] ugh, joystick fix --- stepmania/src/RageInput.cpp | 12 ++++++++++-- stepmania/src/RageInput.h | 5 +++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/stepmania/src/RageInput.cpp b/stepmania/src/RageInput.cpp index f2f6a07999..27ad8239d1 100644 --- a/stepmania/src/RageInput.cpp +++ b/stepmania/src/RageInput.cpp @@ -51,8 +51,12 @@ RageInput::RageInput() SDL_JoystickNumAxes(pJoystick), SDL_JoystickNumHats(pJoystick), SDL_JoystickNumButtons(pJoystick) ); - SDL_JoystickClose(pJoystick); + /* For some weird reason, we won't get any joystick events at all + * if we don't keep the joystick open. (Why? The joystick event + * API is completely separate from the SDL_Joystick polling API ...) */ + Joysticks.push_back(pJoystick); } + SDL_JoystickEventState( SDL_ENABLE ); /* Init optional devices. */ @@ -62,9 +66,13 @@ RageInput::RageInput() RageInput::~RageInput() { /* Delete optional devices. */ - for(unsigned i = 0; i < Devices.size(); ++i) + unsigned i; + for(i = 0; i < Devices.size(); ++i) delete Devices[i]; + for(i = 0; i < Joysticks.size(); ++i) + SDL_JoystickClose(Joysticks[i]); + SDL_QuitSubSystem( SDL_INIT_JOYSTICK ); } diff --git a/stepmania/src/RageInput.h b/stepmania/src/RageInput.h index 0d86f2e173..2ff4db21eb 100644 --- a/stepmania/src/RageInput.h +++ b/stepmania/src/RageInput.h @@ -12,10 +12,15 @@ #include "SDL_utils.h" #include "arch/arch.h" +struct _SDL_Joystick; +typedef struct _SDL_Joystick SDL_Joystick; + class RageInput { vector Devices; + vector Joysticks; + public: RageInput(); ~RageInput();