Make sure the Xbox 360 driver doesn't try to talk to the wireless controllers
authorSam Lantinga <slouken@libsdl.org>
Thu, 19 Dec 2019 21:45:44 -0800
changeset 1336501f16d7f36cb
parent 13364 e0633ed9c498
child 13366 4f5bef55183c
Make sure the Xbox 360 driver doesn't try to talk to the wireless controllers
Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
Xcode/SDL/SDL.xcodeproj/project.pbxproj
src/joystick/hidapi/SDL_hidapi_xbox360.c
     3.1 --- a/src/joystick/hidapi/SDL_hidapi_xbox360.c	Thu Dec 19 18:03:28 2019 -0800
     3.2 +++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c	Thu Dec 19 21:45:44 2019 -0800
     3.3 @@ -250,11 +250,19 @@
     3.4  HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
     3.5  {
     3.6      SDL_GameControllerType type = SDL_GetJoystickGameControllerType(vendor_id, product_id, name);
     3.7 +    const Uint16 MICROSOFT_USB_VID = 0x045e;
     3.8 +    const Uint16 NVIDIA_USB_VID = 0x0955;
     3.9  
    3.10 -    if (vendor_id == 0x0955) {
    3.11 +    if (vendor_id == NVIDIA_USB_VID) {
    3.12          /* This is the NVIDIA Shield controller which doesn't talk Xbox controller protocol */
    3.13          return SDL_FALSE;
    3.14      }
    3.15 +    if (vendor_id == MICROSOFT_USB_VID) {
    3.16 +        if (product_id == 0x0291 || product_id == 0x0719) {
    3.17 +            /* This is the wireless dongle, which talks a different protocol */
    3.18 +            return SDL_FALSE;
    3.19 +        }
    3.20 +    }
    3.21      if (interface_number > 0) {
    3.22          /* This is the chatpad or other input interface, not the Xbox 360 interface */
    3.23          return SDL_FALSE;
    3.24 @@ -282,7 +290,8 @@
    3.25  
    3.26  static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot)
    3.27  {
    3.28 -    const Uint8 led_packet[] = { 0x01, 0x03, (2 + slot) };
    3.29 +    Uint8 mode = 0x02 + slot;
    3.30 +    const Uint8 led_packet[] = { 0x01, 0x03, mode };
    3.31  
    3.32      if (hid_write(dev, led_packet, sizeof(led_packet)) != sizeof(led_packet)) {
    3.33          return SDL_FALSE;