Przeglądaj źródła

Fix the 8BitDo Ultimate 2D Wireless Controller showing up multiple times

This controller has 3 interfaces, one for the Xbox gamepad protocol, and two HID interfaces. We should only handle the Xbox interface in the Xbox driver.
Sam Lantinga 3 tygodni temu
rodzic
commit
9f8c70713a
1 zmienionych plików z 11 dodań i 0 usunięć
  1. 11 0
      src/joystick/hidapi/SDL_hidapi_xboxone.c

+ 11 - 0
src/joystick/hidapi/SDL_hidapi_xboxone.c

@@ -357,6 +357,10 @@ static bool HIDAPI_DriverXboxOne_IsEnabled(void)
 
 static bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, const char *name, SDL_GamepadType type, Uint16 vendor_id, Uint16 product_id, Uint16 version, int interface_number, int interface_class, int interface_subclass, int interface_protocol)
 {
+    static const int LIBUSB_CLASS_VENDOR_SPEC = 0xFF;
+    static const int XBONE_IFACE_SUBCLASS = 71;
+    static const int XBONE_IFACE_PROTOCOL = 208;
+
 #if defined(SDL_PLATFORM_MACOS) && defined(SDL_JOYSTICK_MFI)
     if (!SDL_IsJoystickBluetoothXboxOne(vendor_id, product_id)) {
         // On macOS we get a shortened version of the real report and
@@ -365,6 +369,13 @@ static bool HIDAPI_DriverXboxOne_IsSupportedDevice(SDL_HIDAPI_Device *device, co
         return false;
     }
 #endif
+    if (interface_class &&
+        (interface_class != LIBUSB_CLASS_VENDOR_SPEC ||
+         interface_subclass != XBONE_IFACE_SUBCLASS ||
+         interface_protocol != XBONE_IFACE_PROTOCOL)) {
+        // This isn't the Xbox gamepad interface
+        return false;
+    }
     return (type == SDL_GAMEPAD_TYPE_XBOXONE);
 }