SDL: Fixed detecting Steam Deck controller on Proton 9.04 (964b9)

From 964b9da5190262c0e77a591082fb779084405597 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
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

(cherry picked from commit da0cf3f634cef5ab87bc60d689b0adc260298780)
---
 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 7a1eabff5f82f..fffc010411903 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)) {