SDL: Special case for k_eControllerType_XInputSwitchController in the raw input path

From c7f4103807c77b09815979d7023c9830a3a2f564 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Thu, 9 Jun 2022 13:47:29 -0700
Subject: [PATCH] Special case for k_eControllerType_XInputSwitchController in
 the raw input path

---
 src/joystick/SDL_gamecontroller.c |  6 +++---
 src/joystick/SDL_joystick.c       | 12 ------------
 src/joystick/SDL_joystick_c.h     |  3 ---
 3 files changed, 3 insertions(+), 18 deletions(-)

diff --git a/src/joystick/SDL_gamecontroller.c b/src/joystick/SDL_gamecontroller.c
index b2a51d15469..97aeaa73edc 100644
--- a/src/joystick/SDL_gamecontroller.c
+++ b/src/joystick/SDL_gamecontroller.c
@@ -28,6 +28,7 @@
 #include "SDL_sysjoystick.h"
 #include "SDL_joystick_c.h"
 #include "SDL_gamecontrollerdb.h"
+#include "controller_type.h"
 #include "usb_ids.h"
 
 #if !SDL_EVENTS_DISABLED
@@ -648,14 +649,13 @@ static ControllerMapping_t *SDL_CreateMappingForRAWINPUTController(SDL_JoystickG
 {
     Uint16 vendor;
     Uint16 product;
-    Uint16 version;
     SDL_bool existing;
     char mapping_string[1024];
 
-    SDL_GetJoystickGUIDInfo(guid, &vendor, &product, &version);
+    SDL_GetJoystickGUIDInfo(guid, &vendor, &product, NULL);
 
     SDL_strlcpy(mapping_string, "none,*,", sizeof(mapping_string));
-    if (SDL_JoystickUsesButtonLabelHint(vendor, product) &&
+    if (GuessControllerType(vendor, product) == k_eControllerType_XInputSwitchController &&
         SDL_GetHintBoolean(SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS, SDL_TRUE)) {
         SDL_strlcat(mapping_string, "a:b1,b:b0,x:b3,y:b2,back:b6,guide:b10,start:b7,leftstick:b8,rightstick:b9,leftshoulder:b4,rightshoulder:b5,dpup:h0.1,dpdown:h0.4,dpleft:h0.8,dpright:h0.2,leftx:a0,lefty:a1,rightx:a2,righty:a3,lefttrigger:a4,righttrigger:a5,", sizeof(mapping_string));
     } else {
diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 51f5611dee0..2d31578e8c3 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -2186,18 +2186,6 @@ SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id)
             eType == k_eControllerType_SteamControllerV2);
 }
 
-SDL_bool
-SDL_JoystickUsesButtonLabelHint(Uint16 vendor_id, Uint16 product_id)
-{
-    EControllerType eType = GuessControllerType(vendor_id, product_id);
-    return (eType == k_eControllerType_SwitchProController ||
-            eType == k_eControllerType_SwitchInputOnlyController ||
-            eType == k_eControllerType_XInputSwitchController ||
-            (vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_SWITCH_JOY_CON_GRIP) ||
-            (vendor_id == USB_VENDOR_NINTENDO && product_id == USB_PRODUCT_NINTENDO_GAMECUBE_ADAPTER) ||
-            (vendor_id == USB_VENDOR_SHENZHEN && product_id == USB_PRODUCT_EVORETRO_GAMECUBE_ADAPTER));
-}
-
 SDL_bool
 SDL_IsJoystickXInput(SDL_JoystickGUID guid)
 {
diff --git a/src/joystick/SDL_joystick_c.h b/src/joystick/SDL_joystick_c.h
index b0d215edd75..d6f3888e162 100644
--- a/src/joystick/SDL_joystick_c.h
+++ b/src/joystick/SDL_joystick_c.h
@@ -90,9 +90,6 @@ extern SDL_bool SDL_IsJoystickNintendoSwitchJoyConRight(Uint16 vendor_id, Uint16
 /* Function to return whether a joystick is a Steam Controller */
 extern SDL_bool SDL_IsJoystickSteamController(Uint16 vendor_id, Uint16 product_id);
 
-/* Function to return whether a joystick uses SDL_HINT_GAMECONTROLLER_USE_BUTTON_LABELS */
-extern SDL_bool SDL_JoystickUsesButtonLabelHint(Uint16 vendor_id, Uint16 product_id);
-
 /* Function to return whether a joystick guid comes from the XInput driver */
 extern SDL_bool SDL_IsJoystickXInput(SDL_JoystickGUID guid);