Skip to content

Commit cfb841b

Browse files
committed
Joystick: Button Cound Fix
1 parent df6191e commit cfb841b

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/Joystick/JoystickSDL.cc

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -210,18 +210,17 @@ bool JoystickSDL::_update()
210210
bool JoystickSDL::_getButton(int idx) const
211211
{
212212
// First try the standardized gamepad set if idx is inside that set
213-
#ifdef SDL_GAMEPAD_BUTTON_COUNT
214-
if (_sdlGamepad && idx >= 0 && idx < SDL_GAMEPAD_BUTTON_COUNT) {
215-
if (SDL_GetGamepadButton(_sdlGamepad,
216-
static_cast<SDL_GamepadButton>(idx)) == 1) {
213+
if (_sdlGamepad && (idx >= 0) && (idx < SDL_GAMEPAD_BUTTON_COUNT)) {
214+
if (SDL_GetGamepadButton(_sdlGamepad, static_cast<SDL_GamepadButton>(idx))) {
217215
return true;
218216
}
219217
}
220-
#endif
218+
221219
// Fall back to raw joystick buttons (covers unmapped/extras)
222-
if (_sdlJoystick && idx >= 0 && idx < SDL_GetNumJoystickButtons(_sdlJoystick)) {
223-
return SDL_GetJoystickButton(_sdlJoystick, idx) == 1;
220+
if (_sdlJoystick && (idx >= 0) && (idx < SDL_GetNumJoystickButtons(_sdlJoystick))) {
221+
return SDL_GetJoystickButton(_sdlJoystick, idx);
224222
}
223+
225224
return false;
226225
}
227226

0 commit comments

Comments
 (0)