From 2296712f9f7ab4cb00678b55352c5bc9f43321ee Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 5 Oct 2026 18:41:47 -0700
Subject: [PATCH] Fixed Xbox One S controller buttons on some older firmware
versions
---
src/joystick/hidapi/SDL_hidapi_xboxone.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c
index 328cbc05a3b03..da86c6719f6c2 100644
--- a/src/joystick/hidapi/SDL_hidapi_xboxone.c
+++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c
@@ -890,15 +890,18 @@ static bool HIDAPI_DriverXboxOne_HandleDescriptorReport(SDL_Joystick *joystick,
ctx->last_buttons = value;
const SDL_GamepadButton *button_map;
- if (field->bit_size == 12) {
+ int button_count;
+ if (field->bit_size == 12 || size == 15) {
button_map = button_map_12;
+ button_count = SDL_arraysize(button_map_12);
} else if (field->bit_size == 15) {
button_map = button_map_15;
+ button_count = SDL_arraysize(button_map_15);
} else {
// Should never happen
break;
}
- for (int button_index = 0; button_index < field->bit_size; ++button_index, value >>= 1) {
+ for (int button_index = 0; button_index < button_count; ++button_index, value >>= 1) {
SDL_GamepadButton button = button_map[button_index];
if (button == SDL_GAMEPAD_BUTTON_INVALID) {
continue;