hidapi: do not enumerate XInput devices owned by a kernel driver via libusb on macOS

This commit is contained in:
tmkk 2026-06-17 15:57:07 +09:00 committed by Sam Lantinga
parent 2ebb96b881
commit cee2cb8ed1

View file

@ -1069,6 +1069,17 @@ struct hid_device_info HID_API_EXPORT *hid_enumerate(unsigned short vendor_id,
struct hid_device_info *tmp;
res = libusb_open(dev, &handle);
#ifdef SDL_PLATFORM_MACOS
if (res == 0) {
/* Do not enumerate XInput devices already owned by a kernel driver */
int is_xbox = is_xbox360(dev_vid, intf_desc) || is_xboxone(dev_vid, intf_desc);
if (is_xbox && libusb_kernel_driver_active(handle, intf_desc->bInterfaceNumber) == 1) {
libusb_close(handle);
handle = NULL;
continue;
}
}
#endif
#ifdef __ANDROID__
if (handle) {