ugh, joystick fix
This commit is contained in:
@@ -51,8 +51,12 @@ RageInput::RageInput()
|
|||||||
SDL_JoystickNumAxes(pJoystick),
|
SDL_JoystickNumAxes(pJoystick),
|
||||||
SDL_JoystickNumHats(pJoystick),
|
SDL_JoystickNumHats(pJoystick),
|
||||||
SDL_JoystickNumButtons(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 );
|
SDL_JoystickEventState( SDL_ENABLE );
|
||||||
|
|
||||||
/* Init optional devices. */
|
/* Init optional devices. */
|
||||||
@@ -62,9 +66,13 @@ RageInput::RageInput()
|
|||||||
RageInput::~RageInput()
|
RageInput::~RageInput()
|
||||||
{
|
{
|
||||||
/* Delete optional devices. */
|
/* Delete optional devices. */
|
||||||
for(unsigned i = 0; i < Devices.size(); ++i)
|
unsigned i;
|
||||||
|
for(i = 0; i < Devices.size(); ++i)
|
||||||
delete Devices[i];
|
delete Devices[i];
|
||||||
|
|
||||||
|
for(i = 0; i < Joysticks.size(); ++i)
|
||||||
|
SDL_JoystickClose(Joysticks[i]);
|
||||||
|
|
||||||
SDL_QuitSubSystem( SDL_INIT_JOYSTICK );
|
SDL_QuitSubSystem( SDL_INIT_JOYSTICK );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -12,10 +12,15 @@
|
|||||||
#include "SDL_utils.h"
|
#include "SDL_utils.h"
|
||||||
#include "arch/arch.h"
|
#include "arch/arch.h"
|
||||||
|
|
||||||
|
struct _SDL_Joystick;
|
||||||
|
typedef struct _SDL_Joystick SDL_Joystick;
|
||||||
|
|
||||||
class RageInput
|
class RageInput
|
||||||
{
|
{
|
||||||
vector<InputHandler *> Devices;
|
vector<InputHandler *> Devices;
|
||||||
|
|
||||||
|
vector<SDL_Joystick *> Joysticks;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
RageInput();
|
RageInput();
|
||||||
~RageInput();
|
~RageInput();
|
||||||
|
|||||||
Reference in New Issue
Block a user