Added identifiers for the Xbox One Elite Series 2 controller
authorSam Lantinga
Mon, 18 Nov 2019 11:44:51 -0800
changeset 132553ea086e43015
parent 13254 3656eb60941b
child 13256 745f1355a80e
Added identifiers for the Xbox One Elite Series 2 controller
src/joystick/controller_type.h
src/joystick/hidapi/SDL_hidapi_xboxone.c
     1.1 --- a/src/joystick/controller_type.h	Mon Nov 18 10:48:14 2019 -0800
     1.2 +++ b/src/joystick/controller_type.h	Mon Nov 18 11:44:51 2019 -0800
     1.3 @@ -83,6 +83,8 @@
     1.4  	{ MAKE_CONTROLLER_ID( 0x045e, 0x02ea ), k_eControllerType_XBoxOneController },	// Microsoft X-Box One S pad
     1.5  	{ MAKE_CONTROLLER_ID( 0x045e, 0x02fd ), k_eControllerType_XBoxOneController },	// Microsoft X-Box One S pad (Bluetooth)
     1.6  	{ MAKE_CONTROLLER_ID( 0x045e, 0x02ff ), k_eControllerType_XBoxOneController },	// Microsoft X-Box One Elite pad
     1.7 +	{ MAKE_CONTROLLER_ID( 0x045e, 0x0b00 ), k_eControllerType_XBoxOneController },	// Microsoft X-Box One Elite Series 2 pad
     1.8 +	{ MAKE_CONTROLLER_ID( 0x045e, 0x0b05 ), k_eControllerType_XBoxOneController },	// Microsoft X-Box One Elite Series 2 pad (Bluetooth)
     1.9  	{ MAKE_CONTROLLER_ID( 0x045e, 0x0719 ), k_eControllerType_XBox360Controller },	// Xbox 360 Wireless Receiver
    1.10  	{ MAKE_CONTROLLER_ID( 0x046d, 0xc21d ), k_eControllerType_XBox360Controller },	// Logitech Gamepad F310
    1.11  	{ MAKE_CONTROLLER_ID( 0x046d, 0xc21e ), k_eControllerType_XBox360Controller },	// Logitech Gamepad F510
     2.1 --- a/src/joystick/hidapi/SDL_hidapi_xboxone.c	Mon Nov 18 10:48:14 2019 -0800
     2.2 +++ b/src/joystick/hidapi/SDL_hidapi_xboxone.c	Mon Nov 18 11:44:51 2019 -0800
     2.3 @@ -131,11 +131,24 @@
     2.4  
     2.5  
     2.6  static SDL_bool
     2.7 +IsBluetoothXboxOneController(Uint16 vendor_id, Uint16 product_id)
     2.8 +{
     2.9 +    /* Check to see if it's the Xbox One S or Xbox One Elite Series 2 in Bluetooth mode */
    2.10 +    const Uint16 USB_VENDOR_MICROSOFT = 0x045e;
    2.11 +    const Uint16 USB_PRODUCT_XBOX_ONE_S = 0x02fd;
    2.12 +    const Uint16 USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2 = 0x0b05;
    2.13 +
    2.14 +    if (vendor_id == USB_VENDOR_MICROSOFT && (product_id == USB_PRODUCT_XBOX_ONE_S || product_id == USB_PRODUCT_XBOX_ONE_ELITE_SERIES_2)) {
    2.15 +        return SDL_TRUE;
    2.16 +    }
    2.17 +    return SDL_FALSE;
    2.18 +}
    2.19 +
    2.20 +static SDL_bool
    2.21  HIDAPI_DriverXboxOne_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
    2.22  {
    2.23  #ifdef __LINUX__
    2.24 -    /* Check to see if it's the Xbox One S in Bluetooth mode */
    2.25 -    if (vendor_id == 0x045e && product_id == 0x02fd) {
    2.26 +    if (IsBluetoothXboxOneController(vendor_id, product_id)) {
    2.27          /* We can't do rumble on this device, hid_write() fails, so don't try to open it here */
    2.28          return SDL_FALSE;
    2.29      }
    2.30 @@ -155,7 +168,6 @@
    2.31      SDL_DriverXboxOne_Context *ctx;
    2.32      int i;
    2.33      Uint8 init_packet[USB_PACKET_LENGTH];
    2.34 -    SDL_bool is_bluetooth = SDL_FALSE;
    2.35  
    2.36      ctx = (SDL_DriverXboxOne_Context *)SDL_calloc(1, sizeof(*ctx));
    2.37      if (!ctx) {
    2.38 @@ -164,10 +176,7 @@
    2.39      }
    2.40      *context = ctx;
    2.41  
    2.42 -    if (vendor_id == 0x045e && product_id == 0x02fd) {
    2.43 -        is_bluetooth = SDL_TRUE;
    2.44 -    }
    2.45 -    if (!is_bluetooth) {
    2.46 +    if (!IsBluetoothXboxOneController(vendor_id, product_id)) {
    2.47          /* Send the controller init data */
    2.48          for (i = 0; i < SDL_arraysize(xboxone_init_packets); ++i) {
    2.49              const SDL_DriverXboxOne_InitPacket *packet = &xboxone_init_packets[i];