Libusb: don't attempt kernel driver detach on MacOS

This commit is contained in:
Joshua de Reeper 2025-11-25 13:09:21 +01:00
parent ad89b5ef37
commit c315853063

View file

@ -763,6 +763,9 @@ namespace nsyshid::backend::libusb
int DeviceLibusb::ClaimAllInterfaces(uint8 config_num)
{
const int ret = DoForEachInterface(m_config_descriptors, config_num, [this](uint8 i) {
// On macos detaching would fail without root or entitlement.
// We assume user is using GCAdapterDriver and therefore don't want to detach anything
#if !defined(__APPLE__)
if (libusb_kernel_driver_active(this->m_libusbHandle, i))
{
const int ret2 = libusb_detach_kernel_driver(this->m_libusbHandle, i);
@ -773,6 +776,7 @@ namespace nsyshid::backend::libusb
return ret2;
}
}
#endif
return libusb_claim_interface(this->m_libusbHandle, i);
});
if (ret < LIBUSB_SUCCESS)