From aeacf42e0659e3fee1e00730193f63125dc41594 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 15 May 2026 11:00:11 -0700 Subject: [PATCH] gameinput: only add the share button for known Xbox Series X controllers The HID descriptor for the latest firmware always includes the share button, and GameInput will report it as always available, so double check against our list of classic Xbox One controllers and don't include the button on controllers that don't have it. --- src/joystick/gdk/SDL_gameinputjoystick.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/joystick/gdk/SDL_gameinputjoystick.cpp b/src/joystick/gdk/SDL_gameinputjoystick.cpp index 0c04592ac5..1c099236c8 100644 --- a/src/joystick/gdk/SDL_gameinputjoystick.cpp +++ b/src/joystick/gdk/SDL_gameinputjoystick.cpp @@ -49,6 +49,8 @@ typedef struct GAMEINPUT_InternalDevice SDL_GUID guid; // generated by SDL SDL_JoystickID device_instance; // generated by SDL const GameInputDeviceInfo *info; + Uint16 vendor; + Uint16 product; int raw_type; int steam_virtual_gamepad_slot; bool isAdded; @@ -279,6 +281,8 @@ static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice) elem->guid = SDL_CreateJoystickGUID(bus, vendor, product, version, NULL, product_string, driver_signature, subtype); elem->device_instance = SDL_GetNextObjectID(); elem->info = info; + elem->vendor = vendor; + elem->product = product; elem->raw_type = raw_type; #if GAMEINPUT_API_VERSION >= 1 elem->steam_virtual_gamepad_slot = GetSteamVirtualGamepadSlot(info->pnpPath); @@ -609,11 +613,15 @@ static bool GAMEINPUT_JoystickOpen(SDL_Joystick *joystick, int device_index) #if GAMEINPUT_API_VERSION >= 1 if (info->supportedSystemButtons != GameInputSystemButtonNone) { - if (info->supportedSystemButtons & GameInputSystemButtonShare) { + GameInputSystemButtons buttons = GameInputSystemButtonGuide; + + if (SDL_IsJoystickXboxSeriesX(elem->vendor, elem->product) && + (info->supportedSystemButtons & GameInputSystemButtonShare)) { ++joystick->nbuttons; + buttons |= GameInputSystemButtonShare; } - g_pGameInput->RegisterSystemButtonCallback(elem->device, (GameInputSystemButtonGuide | GameInputSystemButtonShare), joystick, GAMEINPUT_InternalSystemButtonCallback, &hwdata->system_button_callback_token); + g_pGameInput->RegisterSystemButtonCallback(elem->device, buttons, joystick, GAMEINPUT_InternalSystemButtonCallback, &hwdata->system_button_callback_token); } #endif // GAMEINPUT_API_VERSION >= 1 } else { @@ -990,7 +998,8 @@ static bool GAMEINPUT_JoystickGetGamepadMapping(int device_index, SDL_GamepadMap out->guide.target = SDL_GAMEPAD_BUTTON_GUIDE; } - if (elem->info->supportedSystemButtons & GameInputSystemButtonShare) { + if (SDL_IsJoystickXboxSeriesX(elem->vendor, elem->product) && + (elem->info->supportedSystemButtons & GameInputSystemButtonShare)) { out->misc1.kind = EMappingKind_Button; out->misc1.target = SDL_GAMEPAD_BUTTON_GAMEINPUT_SHARE; }