Browse Source

Fix Joystick Button Count

QGC4.4
Holden 3 years ago committed by Patrick José Pereira
parent
commit
25de7af957
  1. 13
      src/Joystick/JoystickSDL.cc

13
src/Joystick/JoystickSDL.cc

@ -14,7 +14,7 @@ JoystickSDL::JoystickSDL(const QString& name, int axisCount, int buttonCount, in
} }
bool JoystickSDL::init(void) { bool JoystickSDL::init(void) {
if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK | SDL_INIT_NOPARACHUTE) < 0) { if (SDL_InitSubSystem(SDL_INIT_GAMECONTROLLER | SDL_INIT_JOYSTICK) < 0) {
SDL_JoystickEventState(SDL_ENABLE); SDL_JoystickEventState(SDL_ENABLE);
qWarning() << "Couldn't initialize SimpleDirectMediaLayer:" << SDL_GetError(); qWarning() << "Couldn't initialize SimpleDirectMediaLayer:" << SDL_GetError();
return false; return false;
@ -37,16 +37,8 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
if (!ret.contains(name)) { if (!ret.contains(name)) {
int axisCount, buttonCount, hatCount; int axisCount, buttonCount, hatCount;
bool isGameController; bool isGameController = SDL_IsGameController(i);
if (SDL_IsGameController(i)) {
isGameController = true;
axisCount = SDL_CONTROLLER_AXIS_MAX;
buttonCount = SDL_CONTROLLER_BUTTON_MAX;
hatCount = 0;
} else {
isGameController = false;
if (SDL_Joystick* sdlJoystick = SDL_JoystickOpen(i)) { if (SDL_Joystick* sdlJoystick = SDL_JoystickOpen(i)) {
SDL_ClearError(); SDL_ClearError();
axisCount = SDL_JoystickNumAxes(sdlJoystick); axisCount = SDL_JoystickNumAxes(sdlJoystick);
@ -60,7 +52,6 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
qCWarning(JoystickLog) << "\t libsdl failed opening joystick" << qPrintable(name) << "error:" << SDL_GetError(); qCWarning(JoystickLog) << "\t libsdl failed opening joystick" << qPrintable(name) << "error:" << SDL_GetError();
continue; continue;
} }
}
qCDebug(JoystickLog) << "\t" << name << "axes:" << axisCount << "buttons:" << buttonCount << "hats:" << hatCount << "isGC:" << isGameController; qCDebug(JoystickLog) << "\t" << name << "axes:" << axisCount << "buttons:" << buttonCount << "hats:" << hatCount << "isGC:" << isGameController;

Loading…
Cancel
Save