Skip to content

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

Merged
slouken merged 1 commit into
libsdl-org:mainfrom
tmkk:libusb-enumeration-fix
Jun 17, 2026
Merged

hidapi: do not enumerate XInput devices owned by a kernel driver via libusb on macOS#15841
slouken merged 1 commit into
libsdl-org:mainfrom
tmkk:libusb-enumeration-fix

Conversation

@tmkk

@tmkk tmkk commented Jun 17, 2026

Copy link
Copy Markdown
Contributor
  • I confirm that I am the author of this code and release it to the SDL project under the Zlib license. This contribution does not contain code from other sources, including code generated by a Large Language Model ("AI").

Description

With commit 18fc4d9 now XInput devices on macOS are enumerated by libusb in hidapi. Since devices enumerated by libusb are not enumerated by the platform backend:

SDL/src/hidapi/SDL_hidapi.c

Lines 1440 to 1445 in da8aa39

for (dev = usb_devs; dev; dev = dev->next) {
AddDeviceToEnumeration("libusb", dev, &devs, &last);
#ifdef HAVE_PLATFORM_BACKEND
RemoveDeviceFromEnumeration("raw", dev, &raw_devs, PLATFORM_hid_free_enumeration);
#endif
}

When a device is enumerated by libusb but it cannot be opened (usually due to libusb_claim_interface failure), it doesn't fallback to the platform backend. This is ok for GCController devices but it is a problem for devices which work with the hidapi platform backend. XInput controllers working with 360Controller driver are examples.

This PR adds checking if a device is already owned by KEXT by libusb_kernel_driver_active function when enumerating devices.

@slouken slouken merged commit cee2cb8 into libsdl-org:main Jun 17, 2026
46 checks passed
@slouken

slouken commented Jun 17, 2026

Copy link
Copy Markdown
Collaborator

Merged, thanks!

@slouken slouken added this to the 3.4.12 milestone Jun 17, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants