macOS: Bluetooth HID devices have the same path #127
Labels
No labels
3rdparty
Android
API
Author does not respond
bsd
bug
build system/CI
ci-virtual-device
CMake
Contributions Welcome
Core
dependencies
device-specific
documentation
don't_merge
duplicate
enhancement
Example
Haiku
hidraw
hotplug
info required
invalid
libusb
macOS
Misc
Not an issue
question
Release
Test
Test GUI
Windows
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
gh-libusb/hidapi#127
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
hidapi returns the same path IOService:/IOResources/IOBluetoothHCIController/AppleBroadcomBluetoothHostController/IOBluetoothDevice/IOBluetoothL2CAPChannel/IOBluetoothHIDDriver
For every Bluetooth HID device connected. Tested with:
Nintendo Switch JoyCon (L)
Nintendo Switch JoyCon (R)
Nintendo Switch ProController
Microsoft Bluetooth Mouse 5000
(all devices have unique product IDs and serial numbers)
As a result, hid_open(vendor_id, product_id, serial_number) does not open the correct device if there is more than one bluetooth device paired since it eventually calls hid_open_path, and all the paths are identical. It looks like it will always try to open the device that was paired first.
I can open the correct device if I store a copy of the IOHIDDeviceRef in hid_device_info and create an IOHIDDevice with the reference rather than looking up the IORegistry entry from the path.
This is on a MacBookPro11,1 running macOS 10.14.6.
It looks like the same issue as https://github.com/signal11/hidapi/issues/379
@erikmwerner try if you can apply
github.com/flirc/hidapi@8d251c3854locally and check if it fixes your issueIt seems like patch by @flirc preserves backward compatibility and adds stability/reliability to
hid_open_pathon macOS, but before submitting it to master, I'd love to head some alternative opinionsI can confirm that
github.com/flirc/hidapi@8d251c3854fixes the issue for me. Thanks for pointing me in the right direction.As an alternative, the solution that I described above also fixed the issue. I uploaded it at
github.com/erikmwerner/hidapi@1d65b88edbThanks.
Yes, it seems like erikmwerner@1d65b88 would fix your issue, but having same API for all 4 backends is more a bit more preferable to me.
@jdk do you think you could prepare a PR to master with flirc/hidapi@8d251c3 ?
So #127 and #236 have the same fix in
github.com/flirc/hidapi@8d251c3but that fix needs some modification to be accepted, right?Right. flirc/hidapi@8d251c3 has a leak in the implementation, that's for sure, but the idea is fine.