SDL: Added support for the Razer Kitsune in PS5 mode (5cc06)

From 5cc0644aa024ee6fd0e35d7fbc9a4c6c7e4c1df0 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

(cherry picked from commit e3beaa1972f3eda462a30481b1efb095f25c43a0)
(cherry picked from commit 35d719ef2522385a4950ca4900f95808eb47dc5f)
---
 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 15d3902782129..27cacc5aeb3a3 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 afefa3dd4f56b..dfdbc81201d75 100644
--- a/src/joystick/hidapi/SDL_hidapi_ps5.c
+++ b/src/joystick/hidapi/SDL_hidapi_ps5.c
@@ -499,6 +499,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 1584a2cf9df43..3f793fc9d2dc1 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -190,7 +190,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 19ca22710eeab..ef6cdb843dc31 100644
--- a/src/joystick/usb_ids.h
+++ b/src/joystick/usb_ids.h
@@ -90,6 +90,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