Skip to content

macOS: Bluetooth HID devices have the same path #127

Closed

Description

@erikmwerner

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.

Activity

  1. added
    macOS
    on Dec 1, 2019
  2. Youw commented on Dec 1, 2019

    @Youw
    Member

    It looks like the same issue as signal11/hidapi#379

    @erikmwerner try if you can apply flirc/hidapi@8d251c3 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

  3. erikmwerner commented on Dec 4, 2019

    @erikmwerner
    Author

    I can confirm that flirc/hidapi@8d251c3 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 erikmwerner@1d65b88

  4. added
    bug
    on Dec 4, 2019
  5. Youw commented on Dec 4, 2019

    @Youw
    Member

    Thanks.

    Yes, it seems like erikmwerner/hidapi@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 ?

  6. mcuee commented on Jun 19, 2021

    @mcuee
    Member

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

  7. Youw commented on Jun 19, 2021

    @Youw
    Member

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

  8. added 2 commits that reference this issue on Aug 14, 2021
    eeeefd0
    180d331
  9. added a commit that references this issue on Aug 23, 2021
    4d63a50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmacOS

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions