Commit 6b767872090cb3c087b7a6056c82a2d682cbe36e

Sam Lantinga 2019-12-19T21:45:44

Make sure the Xbox 360 driver doesn't try to talk to the wireless controllers

diff --git a/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj b/Xcode-iOS/SDL/SDL.xcodeproj/project.pbxproj
old mode 100644
new mode 100755
diff --git a/Xcode/SDL/SDL.xcodeproj/project.pbxproj b/Xcode/SDL/SDL.xcodeproj/project.pbxproj
old mode 100644
new mode 100755
diff --git a/src/joystick/hidapi/SDL_hidapi_xbox360.c b/src/joystick/hidapi/SDL_hidapi_xbox360.c
index 56c1e6f..2fb5658 100644
--- a/src/joystick/hidapi/SDL_hidapi_xbox360.c
+++ b/src/joystick/hidapi/SDL_hidapi_xbox360.c
@@ -250,11 +250,19 @@ static SDL_bool
 HIDAPI_DriverXbox360_IsSupportedDevice(Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, const char *name)
 {
     SDL_GameControllerType type = SDL_GetJoystickGameControllerType(vendor_id, product_id, name);
+    const Uint16 MICROSOFT_USB_VID = 0x045e;
+    const Uint16 NVIDIA_USB_VID = 0x0955;
 
-    if (vendor_id == 0x0955) {
+    if (vendor_id == NVIDIA_USB_VID) {
         /* This is the NVIDIA Shield controller which doesn't talk Xbox controller protocol */
         return SDL_FALSE;
     }
+    if (vendor_id == MICROSOFT_USB_VID) {
+        if (product_id == 0x0291 || product_id == 0x0719) {
+            /* This is the wireless dongle, which talks a different protocol */
+            return SDL_FALSE;
+        }
+    }
     if (interface_number > 0) {
         /* This is the chatpad or other input interface, not the Xbox 360 interface */
         return SDL_FALSE;
@@ -282,7 +290,8 @@ HIDAPI_DriverXbox360_GetDeviceName(Uint16 vendor_id, Uint16 product_id)
 
 static SDL_bool SetSlotLED(hid_device *dev, Uint8 slot)
 {
-    const Uint8 led_packet[] = { 0x01, 0x03, (2 + slot) };
+    Uint8 mode = 0x02 + slot;
+    const Uint8 led_packet[] = { 0x01, 0x03, mode };
 
     if (hid_write(dev, led_packet, sizeof(led_packet)) != sizeof(led_packet)) {
         return SDL_FALSE;