mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-28 05:29:33 +02:00
Open all available joysticks
This commit is contained in:
parent
50b3bb2b7f
commit
fcb2618286
@ -41,19 +41,18 @@ void InputManager::init(const string &conffile, Menu *menu) {
|
||||
InputManager::InputManager()
|
||||
{
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
if (SDL_NumJoysticks() > 0) {
|
||||
joystick = SDL_JoystickOpen(0);
|
||||
} else {
|
||||
joystick = NULL;
|
||||
}
|
||||
int i;
|
||||
for (i = 0; i < SDL_NumJoysticks(); i++)
|
||||
joysticks.push_back(SDL_JoystickOpen(i));
|
||||
#endif
|
||||
}
|
||||
|
||||
InputManager::~InputManager() {
|
||||
InputManager::~InputManager()
|
||||
{
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
if (joystick) {
|
||||
SDL_JoystickClose(joystick);
|
||||
}
|
||||
for (std::vector<SDL_Joystick *>::iterator it = joysticks.begin();
|
||||
it < joysticks.end(); it++)
|
||||
SDL_JoystickClose(*it);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -139,10 +138,10 @@ bool InputManager::getEvent(ButtonEvent *bevent, bool wait) {
|
||||
int i;
|
||||
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
if (joystick) {
|
||||
if (joysticks.size() > 0)
|
||||
SDL_JoystickUpdate();
|
||||
}
|
||||
#endif
|
||||
|
||||
SDL_Event event;
|
||||
if (wait) {
|
||||
SDL_WaitEvent(&event);
|
||||
|
@ -23,6 +23,7 @@
|
||||
|
||||
#include <SDL.h>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class Menu;
|
||||
|
||||
@ -74,7 +75,7 @@ private:
|
||||
|
||||
ButtonMapEntry buttonMap[BUTTON_TYPE_SIZE];
|
||||
#ifndef SDL_JOYSTICK_DISABLED
|
||||
SDL_Joystick *joystick;
|
||||
std::vector<SDL_Joystick *> joysticks;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user