Commit 6af6950dbc5a7f8551cda873f102f0664709a5f4

Sam Lantinga 2021-07-30T18:23:42

Added support for the Victrix Gambit Tournament Controller

diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c
index 37e73d1..f143218 100644
--- a/src/joystick/SDL_joystick.c
+++ b/src/joystick/SDL_joystick.c
@@ -1963,8 +1963,9 @@ SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id)
         }
     }
     if (vendor_id == USB_VENDOR_PDP) {
-        if (product_id == USB_PRODUCT_XBOX_SERIES_X_PDP_AFTERGLOW ||
-            product_id == USB_PRODUCT_XBOX_SERIES_X_PDP_BLUE) {
+        if (product_id == USB_PRODUCT_XBOX_SERIES_X_VICTRIX_GAMBIT ||
+            product_id == USB_PRODUCT_XBOX_SERIES_X_PDP_BLUE ||
+            product_id == USB_PRODUCT_XBOX_SERIES_X_PDP_AFTERGLOW) {
             return SDL_TRUE;
         }
     }
diff --git a/src/joystick/controller_type.h b/src/joystick/controller_type.h
index 3b33d6e..16df5f2 100644
--- a/src/joystick/controller_type.h
+++ b/src/joystick/controller_type.h
@@ -394,6 +394,7 @@ static const ControllerDescription_t arrControllers[] = {
 	{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0346 ), k_eControllerType_XBoxOneController, "PDP Xbox One RC Gamepad" },	// PDP RC Gamepad for Xbox One
 	{ MAKE_CONTROLLER_ID( 0x0e6f, 0x0446 ), k_eControllerType_XBoxOneController, "PDP Xbox One RC Gamepad" },	// PDP RC Gamepad for Xbox One
 	{ MAKE_CONTROLLER_ID( 0x0e6f, 0x02da ), k_eControllerType_XBoxOneController, "PDP Xbox Series X Afterglow" },	// PDP Xbox Series X Afterglow
+	{ MAKE_CONTROLLER_ID( 0x0e6f, 0x02d6 ), k_eControllerType_XBoxOneController, "Victrix Gambit Tournament Controller" },	// Victrix Gambit Tournament Controller
 	{ MAKE_CONTROLLER_ID( 0x0e6f, 0x02d9 ), k_eControllerType_XBoxOneController, "PDP Xbox Series X Midnight Blue" },	// PDP Xbox Series X Midnight Blue
 	{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0063 ), k_eControllerType_XBoxOneController, NULL },	// Hori Real Arcade Pro Hayabusa (USA) Xbox One
 	{ MAKE_CONTROLLER_ID( 0x0f0d, 0x0067 ), k_eControllerType_XBoxOneController, NULL },	// HORIPAD ONE
diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c
index 0f3c49d..ffec1c9 100644
--- a/src/joystick/hidapi/SDL_hidapi_xboxone.c
+++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c
@@ -486,15 +486,20 @@ HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_DriverXboxOne
         /* Xbox Series X firmware version 5.0, report is 36 bytes, share button is in byte 18
          * Xbox Series X firmware version 5.1, report is 44 bytes, share button is in byte 18
          * Xbox Series X firmware version 5.5, report is 48 bytes, share button is in byte 22
+         * Victrix Gambit Tournament Controller, report is 50 bytes, share button is in byte 32
          */
         if (size < 48) {
             if (ctx->last_state[18] != data[18]) {
                 SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[18] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
             }
-        } else {
+        } else if (size == 48) {
             if (ctx->last_state[22] != data[22]) {
                 SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[22] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
             }
+        } else if (size == 50) {
+            if (ctx->last_state[32] != data[32]) {
+                SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[32] & 0x01) ? SDL_PRESSED : SDL_RELEASED);
+            }
         }
     }
 
diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h
index b226a5e..34a815d 100644
--- a/src/joystick/usb_ids.h
+++ b/src/joystick/usb_ids.h
@@ -64,8 +64,9 @@
 #define USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH           0x02fd
 #define USB_PRODUCT_XBOX_SERIES_X                       0x0b12
 #define USB_PRODUCT_XBOX_SERIES_X_BLUETOOTH             0x0b13
-#define USB_PRODUCT_XBOX_SERIES_X_PDP_AFTERGLOW         0x02da
+#define USB_PRODUCT_XBOX_SERIES_X_VICTRIX_GAMBIT        0x02d6
 #define USB_PRODUCT_XBOX_SERIES_X_PDP_BLUE              0x02d9
+#define USB_PRODUCT_XBOX_SERIES_X_PDP_AFTERGLOW         0x02da
 #define USB_PRODUCT_XBOX_SERIES_X_POWERA_FUSION_PRO2    0x4001
 #define USB_PRODUCT_XBOX_SERIES_X_POWERA_SPECTRA        0x4002
 #define USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER         0x02ff    /* XBOXGIP driver software PID */