Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/src/joystick/hidapi/SDL_hidapijoystick.c b/src/joystick/hidapi/SDL_hidapijoystick.c
index a9ad61a..9aaf4c3 100644
--- a/src/joystick/hidapi/SDL_hidapijoystick.c
+++ b/src/joystick/hidapi/SDL_hidapijoystick.c
@@ -902,7 +902,8 @@ HIDAPI_IsEquivalentToDevice(Uint16 vendor_id, Uint16 product_id, SDL_HIDAPI_Devi
}
/* If we're looking for the raw input Xbox One controller, match it against any other Xbox One controller */
- if (product_id == 0x02ff &&
+ if (vendor_id == USB_VENDOR_MICROSOFT &&
+ product_id == USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER &&
SDL_GetJoystickGameControllerType(device->name, device->vendor_id, device->product_id, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol) == SDL_CONTROLLER_TYPE_XBOXONE) {
return SDL_TRUE;
}
diff --git a/src/joystick/usb_ids.h b/src/joystick/usb_ids.h
index 3b37a77..32e7362 100644
--- a/src/joystick/usb_ids.h
+++ b/src/joystick/usb_ids.h
@@ -52,6 +52,7 @@
#define USB_PRODUCT_XBOX_ONE_S_REV2_BLUETOOTH 0x02fd
#define USB_PRODUCT_XBOX_ONE_SERIES_X 0x0b12
#define USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH 0x0b13
+#define USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER 0x02ff
/* USB usage pages */
#define USB_USAGEPAGE_GENERIC_DESKTOP 0x0001
diff --git a/src/joystick/windows/SDL_rawinputjoystick.c b/src/joystick/windows/SDL_rawinputjoystick.c
index 77a1f3d..9d63487 100644
--- a/src/joystick/windows/SDL_rawinputjoystick.c
+++ b/src/joystick/windows/SDL_rawinputjoystick.c
@@ -942,6 +942,13 @@ RAWINPUT_IsDevicePresent(Uint16 vendor_id, Uint16 product_id, Uint16 version, co
return SDL_TRUE;
}
+ /* The Xbox One controller shows up as a hardcoded raw input VID/PID */
+ if (name && SDL_strcmp(name, "Xbox One Game Controller") == 0 &&
+ device->vendor_id == USB_VENDOR_MICROSOFT &&
+ device->product_id == USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER) {
+ return SDL_TRUE;
+ }
+
device = device->next;
}
return SDL_FALSE;