Fixed RAWINPUT_IsDevicePresent() not returning TRUE for Xbox One controllers

Sam Lantinga 2020-11-27 10:44:49 -08:00
parent 8a449de20d
commit ce77966da8
3 changed files with 10 additions and 1 deletions

View File

@ -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;
}

View File

@ -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

View File

@ -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;