# SDL: Fixed Xbox One S controller buttons on some older firmware versions

**URL:** <https://discourse.libsdl.org/t/sdl-fixed-xbox-one-s-controller-buttons-on-some-older-firmware-versions/69495>\
**Category:** SDL Commits\
**Created:** [October 6, 2026, 1:45am UTC](https://discourse.libsdl.org/t/sdl-fixed-xbox-one-s-controller-buttons-on-some-older-firmware-versions/69495 "2026-10-06T01:45:53Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![SDLPushPostBot](https://discourse.libsdl.org/user_avatar/discourse.libsdl.org/sdlpushpostbot/32/4370_2.png) [@SDLPushPostBot](https://discourse.libsdl.org/u/SDLPushPostBot)\
**Post date:** [October 6, 2026, 1:45am UTC](https://discourse.libsdl.org/t/sdl-fixed-xbox-one-s-controller-buttons-on-some-older-firmware-versions/69495/1 "2026-10-06T01:45:53Z")

</div>

> <https://github.com/libsdl-org/SDL/commit/2296712f9f7ab4cb00678b55352c5bc9f43321ee>

```diff
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;

```
