From dacdb1c310d97ca3c3e6492cae0611f86b281b34 Mon Sep 17 00:00:00 2001 From: Sam Lantinga Date: Tue, 3 Jan 2023 15:12:18 -0800 Subject: [PATCH] Added support for the ThrustMaster eSwap PRO Controller Xbox --- src/hidapi/libusb/hid.c | 1 + src/joystick/SDL_joystick.c | 5 +++++ src/joystick/controller_type.c | 1 + src/joystick/hidapi/SDL_hidapi_xboxone.c | 5 +++++ src/joystick/hidapi/SDL_hidapijoystick.c | 1 + src/joystick/usb_ids.h | 1 + 6 files changed, 14 insertions(+) diff --git a/src/hidapi/libusb/hid.c b/src/hidapi/libusb/hid.c index 8d0f101c1..9d66a1a13 100644 --- a/src/hidapi/libusb/hid.c +++ b/src/hidapi/libusb/hid.c @@ -704,6 +704,7 @@ static int is_xboxone(unsigned short vendor_id, const struct libusb_interface_de static const int XB1_IFACE_SUBCLASS = 71; static const int XB1_IFACE_PROTOCOL = 208; static const int SUPPORTED_VENDORS[] = { + 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ 0x0e6f, /* PDP */ diff --git a/src/joystick/SDL_joystick.c b/src/joystick/SDL_joystick.c index cc98e7639..5b1c6a2c0 100644 --- a/src/joystick/SDL_joystick.c +++ b/src/joystick/SDL_joystick.c @@ -2190,6 +2190,11 @@ SDL_bool SDL_IsJoystickXboxSeriesX(Uint16 vendor_id, Uint16 product_id) return SDL_TRUE; } } + if (vendor_id == USB_VENDOR_THRUSTMASTER) { + if (product_id == USB_PRODUCT_THRUSTMASTER_ESWAPX_PRO) { + return SDL_TRUE; + } + } if (vendor_id == USB_VENDOR_8BITDO) { if (product_id == USB_PRODUCT_8BITDO_XBOX_CONTROLLER) { return SDL_TRUE; diff --git a/src/joystick/controller_type.c b/src/joystick/controller_type.c index 1845e54aa..44b5c8ed7 100644 --- a/src/joystick/controller_type.c +++ b/src/joystick/controller_type.c @@ -295,6 +295,7 @@ static const ControllerDescription_t arrControllers[] = { { MAKE_CONTROLLER_ID( 0x24c6, 0xfafd ), k_eControllerType_XBox360Controller, NULL }, // Afterglow Gamepad 3 { MAKE_CONTROLLER_ID( 0x24c6, 0xfafe ), k_eControllerType_XBox360Controller, NULL }, // Rock Candy Gamepad for Xbox 360 + { MAKE_CONTROLLER_ID( 0x044f, 0xd012 ), k_eControllerType_XBoxOneController, NULL }, // ThrustMaster eSwap PRO Controller Xbox { MAKE_CONTROLLER_ID( 0x045e, 0x02d1 ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft X-Box One pad { MAKE_CONTROLLER_ID( 0x045e, 0x02dd ), k_eControllerType_XBoxOneController, "Xbox One Controller" }, // Microsoft X-Box One pad (Firmware 2015) { MAKE_CONTROLLER_ID( 0x045e, 0x02e0 ), k_eControllerType_XBoxOneController, "Xbox One S Controller" }, // Microsoft X-Box One S pad (Bluetooth) diff --git a/src/joystick/hidapi/SDL_hidapi_xboxone.c b/src/joystick/hidapi/SDL_hidapi_xboxone.c index 6812d0db8..f0aebb3d6 100644 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c @@ -684,6 +684,7 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D * 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 + * ThrustMaster eSwap PRO Controller Xbox, report is 64 bytes, share button is in byte 46 */ if (size < 48) { if (ctx->last_state[18] != data[18]) { @@ -697,6 +698,10 @@ static void HIDAPI_DriverXboxOne_HandleStatePacket(SDL_Joystick *joystick, SDL_D if (ctx->last_state[32] != data[32]) { SDL_SendJoystickButton(timestamp, joystick, SDL_GAMEPAD_BUTTON_MISC1, (data[32] & 0x01) ? SDL_PRESSED : SDL_RELEASED); } + } else if (size == 64) { + if (ctx->last_state[46] != data[46]) { + SDL_PrivateJoystickButton(joystick, SDL_CONTROLLER_BUTTON_MISC1, (data[46] & 0x01) ? SDL_PRESSED : SDL_RELEASED); + } } } diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c index fdf7228fe..12fe92592 100644 --- a/src/joystick/hidapi/SDL_hidapijoystick.c +++ b/src/joystick/hidapi/SDL_hidapijoystick.c @@ -181,6 +181,7 @@ static SDL_GamepadType SDL_GetJoystickGameControllerProtocol(const char *name, U interface_protocol == XBONE_IFACE_PROTOCOL) { static const int SUPPORTED_VENDORS[] = { + 0x044f, /* Thrustmaster */ 0x045e, /* Microsoft */ 0x0738, /* Mad Catz */ 0x0e6f, /* PDP */ diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h index c74d0f2e7..9d5e25b9d 100644 --- a/src/joystick/usb_ids.h +++ b/src/joystick/usb_ids.h @@ -107,6 +107,7 @@ #define USB_PRODUCT_SONY_DS4_STRIKEPAD 0x05c5 #define USB_PRODUCT_SONY_DS5 0x0ce6 #define USB_PRODUCT_SONY_DS5_EDGE 0x0df2 +#define USB_PRODUCT_THRUSTMASTER_ESWAPX_PRO 0xd012 #define USB_PRODUCT_VICTRIX_FS_PRO_V2 0x0207 #define USB_PRODUCT_XBOX360_XUSB_CONTROLLER 0x02a1 /* XUSB driver software PID */ #define USB_PRODUCT_XBOX360_WIRED_CONTROLLER 0x028e