macOS: Bluetooth HID devices have the same path #127

Closed
opened 2019-12-01 14:06:59 -06:00 by erikmwerner · 5 comments
erikmwerner commented 2019-12-01 14:06:59 -06:00 (Migrated from github.com)

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.

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.
Youw commented 2019-12-01 16:57:48 -06:00 (Migrated from github.com)

It looks like the same issue as https://github.com/signal11/hidapi/issues/379

@erikmwerner try if you can apply github.com/flirc/hidapi@8d251c3854 locally and check if it fixes your issue

It seems like patch by @flirc preserves backward compatibility and adds stability/reliability to hid_open_path on macOS, but before submitting it to master, I'd love to head some alternative opinions

It looks like the same issue as https://github.com/signal11/hidapi/issues/379 @erikmwerner try if you can apply https://github.com/flirc/hidapi/commit/8d251c3854c3b1877509ab07a623dafc8e803db5 locally and check if it fixes your issue It seems like patch by @flirc preserves backward compatibility and adds stability/reliability to `hid_open_path` on macOS, but before submitting it to master, I'd love to head some alternative opinions
erikmwerner commented 2019-12-03 23:48:36 -06:00 (Migrated from github.com)

I can confirm that github.com/flirc/hidapi@8d251c3854 fixes 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@1d65b88edb

I can confirm that https://github.com/flirc/hidapi/commit/8d251c3854c3b1877509ab07a623dafc8e803db5 fixes 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 https://github.com/erikmwerner/hidapi/commit/1d65b88edb3c40653c1f06f32f0ffeff4a175f11
Youw commented 2019-12-04 06:31:27 -06:00 (Migrated from github.com)

Thanks.

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 ?

Thanks. 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 ?
mcuee commented 2021-06-19 04:00:57 -05:00 (Migrated from github.com)

So #127 and #236 have the same fix in github.com/flirc/hidapi@8d251c3 but that fix needs some modification to be accepted, right?

So #127 and #236 have the same fix in https://github.com/flirc/hidapi/commit/8d251c3 but that fix needs some modification to be accepted, right?
Youw commented 2021-06-19 11:42:30 -05:00 (Migrated from github.com)

Right. flirc/hidapi@8d251c3 has a leak in the implementation, that's for sure, but the idea is fine.

Right. flirc/hidapi@8d251c3 has a leak in the implementation, that's for sure, but the idea is fine.
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-libusb/hidapi#127
No description provided.