nsyshid/libusb: Don't attempt kernel driver detach on MacOS (#1736)

This commit is contained in:
Joshua de Reeper 2025-11-27 17:42:00 +01:00 committed by GitHub
parent 85c8f95b69
commit bb3fb81fb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -763,6 +763,9 @@ namespace nsyshid::backend::libusb
int DeviceLibusb::ClaimAllInterfaces(uint8 config_num) int DeviceLibusb::ClaimAllInterfaces(uint8 config_num)
{ {
const int ret = DoForEachInterface(m_config_descriptors, config_num, [this](uint8 i) { 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)) if (libusb_kernel_driver_active(this->m_libusbHandle, i))
{ {
const int ret2 = libusb_detach_kernel_driver(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; return ret2;
} }
} }
#endif
return libusb_claim_interface(this->m_libusbHandle, i); return libusb_claim_interface(this->m_libusbHandle, i);
}); });
if (ret < LIBUSB_SUCCESS) if (ret < LIBUSB_SUCCESS)