SDL: Added support for the Razer Kitsune in PS5 mode

From e3beaa1972f3eda462a30481b1efb095f25c43a0 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Fri, 31 May 2024 15:18:15 -0700
Subject: [PATCH] Added support for the Razer Kitsune in PS5 mode

---
 src/joystick/controller_list.h           | 1 +
 src/joystick/hidapi/SDL_hidapi_ps5.c     | 6 ++++++
 src/joystick/hidapi/SDL_hidapijoystick.c | 2 +-
 src/joystick/usb_ids.h                   | 1 +
 4 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/joystick/controller_list.h b/src/joystick/controller_list.h
index 5f58880cb78f8..59421a728487f 100644
--- a/src/joystick/controller_list.h
+++ b/src/joystick/controller_list.h
@@ -157,6 +157,7 @@ static const ControllerDescription_t arrControllers[] = {
 	{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0184 ), k_eControllerType_PS5Controller, NULL },	// Hori Fighting Stick α
 	{ MAKE_CONTROLLER_ID( 0x1532, 0x100b ), k_eControllerType_PS5Controller, NULL },	// Razer Wolverine V2 Pro (Wired)
 	{ MAKE_CONTROLLER_ID( 0x1532, 0x100c ), k_eControllerType_PS5Controller, NULL },	// Razer Wolverine V2 Pro (Wireless)
+	{ MAKE_CONTROLLER_ID( 0x1532, 0x1012 ), k_eControllerType_PS5Controller, NULL },	// Razer Kitsune
 	{ MAKE_CONTROLLER_ID( 0x3285, 0x0d18 ), k_eControllerType_PS5Controller, NULL },	// NACON Revolution 5 Pro (PS5 mode with dongle)
 	{ MAKE_CONTROLLER_ID( 0x3285, 0x0d19 ), k_eControllerType_PS5Controller, NULL },	// NACON Revolution 5 Pro (PS5 mode wired)
 	{ MAKE_CONTROLLER_ID( 0x358a, 0x0104 ), k_eControllerType_PS5Controller, NULL },	// Backbone One PlayStation Edition for iOS
diff --git a/src/joystick/hidapi/SDL_hidapi_ps5.c b/src/joystick/hidapi/SDL_hidapi_ps5.c
index 323964386e2de..ecb78c410a90e 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -507,6 +507,12 @@ static SDL_bool HIDAPI_DriverPS5_InitDevice(SDL_HIDAPI_Device *device)
             ctx->sensors_supported = SDL_TRUE;
             ctx->touchpad_supported = SDL_TRUE;
             ctx->use_alternate_report = SDL_TRUE;
+        } else if (device->vendor_id == USB_VENDOR_RAZER &&
+                   device->product_id == USB_PRODUCT_RAZER_KITSUNE) {
+            /* The Razer Kitsune doesn't respond to the detection protocol, but has a touchpad */
+            joystick_type = SDL_JOYSTICK_TYPE_ARCADE_STICK;
+            ctx->touchpad_supported = SDL_TRUE;
+            ctx->use_alternate_report = SDL_TRUE;
         }
     }
     ctx->effects_supported = (ctx->lightbar_supported || ctx->vibration_supported || ctx->playerled_supported);
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index 7a898e5f922a4..07d8934f4f785 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -186,7 +186,7 @@ SDL_bool HIDAPI_SupportsPlaystationDetection(Uint16 vendor, Uint16 product)
         /* Most Razer devices are not game controllers, and some of them lock up
          * or reset when we send them the Sony third-party query feature report,
          * so don't include that vendor here. Instead add devices as appropriate
-         * to controller_type.c
+         * to controller_list.h
          *
          * Reference: https://github.com/libsdl-org/SDL/issues/6733
          *            https://github.com/libsdl-org/SDL/issues/6799
diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h
index e673bb8af6522..f913bc934f5cb 100644
--- a/src/joystick/usb_ids.h
+++ b/src/joystick/usb_ids.h
@@ -93,6 +93,7 @@
 #define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V103         0x7210
 #define USB_PRODUCT_NVIDIA_SHIELD_CONTROLLER_V104         0x7214
 #define USB_PRODUCT_RAZER_ATROX                           0x0a00
+#define USB_PRODUCT_RAZER_KITSUNE                         0x1012
 #define USB_PRODUCT_RAZER_PANTHERA                        0x0401
 #define USB_PRODUCT_RAZER_PANTHERA_EVO                    0x1008
 #define USB_PRODUCT_RAZER_RAIJU                           0x1000