Browse Source

Fixed the Xbox 360 wireless adapter showing up as a controller

Sam Lantinga 1 day ago
parent
commit
47403eccd2
1 changed files with 14 additions and 1 deletions
  1. 14 1
      src/joystick/gdk/SDL_gameinputjoystick.cpp

+ 14 - 1
src/joystick/gdk/SDL_gameinputjoystick.cpp

@@ -173,6 +173,18 @@ static int GetSteamVirtualGamepadSlot(const char *device_path)
 }
 }
 #endif // GAMEINPUT_API_VERSION >= 1
 #endif // GAMEINPUT_API_VERSION >= 1
 
 
+static bool IsXbox360WirelessAdapter(Uint16 vendor, Uint16 product)
+{
+    if (vendor == USB_VENDOR_MICROSOFT) {
+        if (product == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER ||
+            product == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY1 ||
+            product == USB_PRODUCT_XBOX360_WIRELESS_RECEIVER_THIRDPARTY2) {
+            return true;
+        }
+    }
+    return false;
+}
+
 static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
 static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
 {
 {
     GAMEINPUT_InternalDevice **devicelist = NULL;
     GAMEINPUT_InternalDevice **devicelist = NULL;
@@ -220,7 +232,8 @@ static bool GAMEINPUT_InternalAddOrFind(IGameInputDevice *pDevice)
     }
     }
 #endif
 #endif
 
 
-    if (SDL_ShouldIgnoreJoystick(vendor, product, version, product_string) ||
+    if (IsXbox360WirelessAdapter(vendor, product) ||
+        SDL_ShouldIgnoreJoystick(vendor, product, version, product_string) ||
         SDL_JoystickHandledByAnotherDriver(&SDL_GAMEINPUT_JoystickDriver, vendor, product, version, product_string)) {
         SDL_JoystickHandledByAnotherDriver(&SDL_GAMEINPUT_JoystickDriver, vendor, product, version, product_string)) {
         return true;
         return true;
     }
     }