Skip to content

Commit 9021996

Browse files
joystick: Avoid dealing with hat for xbox controller
There is a bug libsdl-org/SDL#7976, where xbox series X controllers has dpads has hat buttons, resulting in duplicated buttons for dpad. Signed-off-by: Patrick José Pereira <patrickelectric@gmail.com>
1 parent f4455c0 commit 9021996

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/Joystick/JoystickSDL.cc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ QMap<QString, Joystick*> JoystickSDL::discover(MultiVehicleManager* _multiVehicl
4444
axisCount = SDL_JoystickNumAxes(sdlJoystick);
4545
buttonCount = SDL_JoystickNumButtons(sdlJoystick);
4646
hatCount = SDL_JoystickNumHats(sdlJoystick);
47+
#ifdef Q_OS_WIN
48+
if (name == QStringLiteral("Xbox Series X Controller") || name == QStringLiteral("Controller (Xbox One For Windows)")) {
49+
hatCount = 0;
50+
}
51+
#endif
4752
if (axisCount < 0 || buttonCount < 0 || hatCount < 0) {
4853
qCWarning(JoystickLog) << "\t libsdl error parsing joystick features:" << SDL_GetError();
4954
}

0 commit comments

Comments
 (0)