Browse Source

The GameInput driver handles Xbox controllers

Don't let the raw input driver handle them when GameInput is active
Sam Lantinga 1 year ago
parent
commit
eb9a7d97f9
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/joystick/gdk/SDL_gameinputjoystick.c

+ 7 - 0
src/joystick/gdk/SDL_gameinputjoystick.c

@@ -23,6 +23,7 @@
 #ifdef SDL_JOYSTICK_GAMEINPUT
 
 #include "../SDL_sysjoystick.h"
+#include "../usb_ids.h"
 
 #include <stdbool.h>
 #define COBJMACROS
@@ -281,6 +282,12 @@ static SDL_bool GAMEINPUT_JoystickIsDevicePresent(Uint16 vendor_id, Uint16 produ
     int idx = 0;
     GAMEINPUT_InternalDevice *elem = NULL;
 
+    if (vendor_id == USB_VENDOR_MICROSOFT &&
+        product_id == USB_PRODUCT_XBOX_ONE_XBOXGIP_CONTROLLER) {
+        /* The Xbox One controller shows up as a hardcoded raw input VID/PID, which we definitely handle */
+        return SDL_TRUE;
+    }
+
     for (idx = 0; idx < g_GameInputList.count; ++idx) {
         elem = g_GameInputList.devices[idx];
         if (elem && vendor_id == elem->vendor && product_id == elem->product) {