From da0cf3f634cef5ab87bc60d689b0adc260298780 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Fri, 31 Jan 2025 15:32:33 -0800 Subject: [PATCH] Fixed detecting Steam Deck controller on Proton 9.04 Newer versions of Proton properly pass through the Steam virtual gamepad VID/PID, but older Proton (9.x and older) don't, so we have to rely on Steam and Proton hiding controllers we shouldn't have access to. Fixes https://github.com/libsdl-org/SDL/issues/12106 --- src/joystick/SDL_gamecontroller.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c index 7a1eabff5f..fffc010411 100644 --- a/src/joystick/SDL_gamecontroller.c +++ b/src/joystick/SDL_gamecontroller.c @@ -2126,9 +2126,16 @@ SDL_bool SDL_ShouldIgnoreGameController(const char *name, SDL_JoystickGUID guid) SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version, NULL); +#ifdef __WIN32__ + if (SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE)) { + /* We're running under Steam and it will hide any controllers that we shouldn't open */ + return FALSE; + } +#else if (SDL_IsJoystickSteamVirtualGamepad(vendor, product, version)) { return !SDL_GetHintBoolean("SDL_GAMECONTROLLER_ALLOW_STEAM_VIRTUAL_GAMEPAD", SDL_FALSE); } +#endif if (SDL_allowed_controllers.num_included_entries > 0) { if (SDL_VIDPIDInList(vendor, product, &SDL_allowed_controllers)) {