ugh, joystick fix

This commit is contained in:
Glenn Maynard
2003-02-16 20:15:33 +00:00
parent 18f7088b0e
commit 657b16cce2
2 changed files with 15 additions and 2 deletions
+10 -2
View File
@@ -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 );
}
+5
View File
@@ -12,10 +12,15 @@
#include "SDL_utils.h"
#include "arch/arch.h"
struct _SDL_Joystick;
typedef struct _SDL_Joystick SDL_Joystick;
class RageInput
{
vector<InputHandler *> Devices;
vector<SDL_Joystick *> Joysticks;
public:
RageInput();
~RageInput();