Fixed duplicating a device between XInput and HIDAPI
parent
59f28b7f4b
commit
1031231b29
|
@ -902,11 +902,18 @@ 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 we're looking for the raw input Xbox One controller, match it against any other Xbox One controller */
|
||||||
if (vendor_id == USB_VENDOR_MICROSOFT &&
|
if (product_id == USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER &&
|
||||||
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) {
|
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;
|
return SDL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* If we're looking for an XInput controller, match it against any other Xbox controller */
|
||||||
|
if (product_id == USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER) {
|
||||||
|
SDL_GameControllerType type = SDL_GetJoystickGameControllerType(device->name, device->vendor_id, device->product_id, device->interface_number, device->interface_class, device->interface_subclass, device->interface_protocol);
|
||||||
|
if (type == SDL_CONTROLLER_TYPE_XBOX360 || type == SDL_CONTROLLER_TYPE_XBOXONE) {
|
||||||
|
return SDL_TRUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return SDL_FALSE;
|
return SDL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
#define USB_PRODUCT_XBOX_ONE_SERIES_X 0x0b12
|
#define USB_PRODUCT_XBOX_ONE_SERIES_X 0x0b12
|
||||||
#define USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH 0x0b13
|
#define USB_PRODUCT_XBOX_ONE_SERIES_X_BLUETOOTH 0x0b13
|
||||||
#define USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER 0x02ff
|
#define USB_PRODUCT_XBOX_ONE_RAW_INPUT_CONTROLLER 0x02ff
|
||||||
|
#define USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER 0x02fe /* Made up product ID for XInput */
|
||||||
|
|
||||||
/* USB usage pages */
|
/* USB usage pages */
|
||||||
#define USB_USAGEPAGE_GENERIC_DESKTOP 0x0001
|
#define USB_USAGEPAGE_GENERIC_DESKTOP 0x0001
|
||||||
|
|
|
@ -294,7 +294,8 @@ AddXInputDevice(Uint8 userid, BYTE SubType, JoyStick_DeviceData **pContext)
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef SDL_JOYSTICK_HIDAPI
|
#ifdef SDL_JOYSTICK_HIDAPI
|
||||||
if (HIDAPI_IsDevicePresent(vendor, product, version, pNewJoystick->joystickname)) {
|
/* Since we're guessing about the VID/PID, use a hard-coded VID/PID to represent XInput */
|
||||||
|
if (HIDAPI_IsDevicePresent(USB_VENDOR_MICROSOFT, USB_PRODUCT_XBOX_ONE_XINPUT_CONTROLLER, version, pNewJoystick->joystickname)) {
|
||||||
/* The HIDAPI driver is taking care of this device */
|
/* The HIDAPI driver is taking care of this device */
|
||||||
SDL_free(pNewJoystick);
|
SDL_free(pNewJoystick);
|
||||||
return;
|
return;
|
||||||
|
|
Loading…
Reference in New Issue