mirror of
git://projects.qi-hardware.com/gmenu2x.git
synced 2024-12-29 10:43:56 +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()
|
InputManager::InputManager()
|
||||||
{
|
{
|
||||||
#ifndef SDL_JOYSTICK_DISABLED
|
#ifndef SDL_JOYSTICK_DISABLED
|
||||||
if (SDL_NumJoysticks() > 0) {
|
int i;
|
||||||
joystick = SDL_JoystickOpen(0);
|
for (i = 0; i < SDL_NumJoysticks(); i++)
|
||||||
} else {
|
joysticks.push_back(SDL_JoystickOpen(i));
|
||||||
joystick = NULL;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
InputManager::~InputManager() {
|
InputManager::~InputManager()
|
||||||
|
{
|
||||||
#ifndef SDL_JOYSTICK_DISABLED
|
#ifndef SDL_JOYSTICK_DISABLED
|
||||||
if (joystick) {
|
for (std::vector<SDL_Joystick *>::iterator it = joysticks.begin();
|
||||||
SDL_JoystickClose(joystick);
|
it < joysticks.end(); it++)
|
||||||
}
|
SDL_JoystickClose(*it);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -139,10 +138,10 @@ bool InputManager::getEvent(ButtonEvent *bevent, bool wait) {
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
#ifndef SDL_JOYSTICK_DISABLED
|
#ifndef SDL_JOYSTICK_DISABLED
|
||||||
if (joystick) {
|
if (joysticks.size() > 0)
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
if (wait) {
|
if (wait) {
|
||||||
SDL_WaitEvent(&event);
|
SDL_WaitEvent(&event);
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
|
|
||||||
#include <SDL.h>
|
#include <SDL.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
class Menu;
|
class Menu;
|
||||||
|
|
||||||
@ -74,7 +75,7 @@ private:
|
|||||||
|
|
||||||
ButtonMapEntry buttonMap[BUTTON_TYPE_SIZE];
|
ButtonMapEntry buttonMap[BUTTON_TYPE_SIZE];
|
||||||
#ifndef SDL_JOYSTICK_DISABLED
|
#ifndef SDL_JOYSTICK_DISABLED
|
||||||
SDL_Joystick *joystick;
|
std::vector<SDL_Joystick *> joysticks;
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user