Skip to content

hid_enumerate with hidraw backend returns lots of duplicate hid_device_infos #298

Closed

Description

@Be-ing

Calling hid_enumerate with the hidraw Linux backend returns lots of duplicate hid_device_infos for the same device. I have to filter out duplicates by comparing the paths of the devices: https://github.com/mixxxdj/mixxx/pull/4054/files/6dd77b1fa61a2101e2dfac7cb7af85bf5eab168b#r663541357

Activity

  1. Youw commented on Jul 4, 2021

    @Youw
    Member

    Do those devices have the same usage/usage_page pairs? Have you tried the same device on Windows?

  2. added
    hidraw
    on Jul 4, 2021
  3. Be-ing commented on Jul 5, 2021

    @Be-ing
    ContributorAuthor

    Some do, some do not. Here is the output from Mixxx:

    info [Controller] Scanning USB HID devices
    info [Controller] Found HID device: { 17cc:1720 r60 | Usage: ff01:0000 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0001 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0001 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0030 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0001 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0030 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0030 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0030 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0080 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0080 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0080 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:0080 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:00d8 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:00d8 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:00f0 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:00f0 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:00e0 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Duplicate HID device, excluding { 17cc:1720 r60 | Usage: ff01:00e0 | Interface: #3 | Manufacturer: Native Instruments | Product: Traktor Kontrol S4 MK3 | S/N: 69DDA7A8 }
    info [Controller] Found HID device: { 056a:5110 r0 | Usage: 000d:0004 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0022 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0022 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0022 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0022 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0022 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: ff11:0011 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:000e | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0023 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0002 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 000d:0020 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: ff11:0002 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: ff11:0020 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 0001:0002 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Duplicate HID device, excluding { 056a:5110 r0 | Usage: 0001:0001 | Product: WCOM5110:00 056A:5110 }
    info [Controller] Found HID device: { 06cb:7f8b r0 | Usage: 0001:0002 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 0001:0001 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0005 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0022 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0022 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0022 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0022 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0022 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:000e | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0022 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: 000d:0022 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Duplicate HID device, excluding { 06cb:7f8b r0 | Usage: ff00:0001 | Product: SYNA2B31:00 06CB:7F8B }
    info [Controller] Found HID device: { 046d:b020 r0 | Usage: 0001:0002 | Product: MX Vertical | S/N: ed:39:60:f6:c3:e4 }
    info [Controller] Duplicate HID device, excluding { 046d:b020 r0 | Usage: 0001:0001 | Product: MX Vertical | S/N: ed:39:60:f6:c3:e4 }
    info [Controller] Duplicate HID device, excluding { 046d:b020 r0 | Usage: ff43:0202 | Product: MX Vertical | S/N: ed:39:60:f6:c3:e4 }
    
  4. Be-ing commented on Jul 5, 2021

    @Be-ing
    ContributorAuthor

    I have not tested these devices on Windows.

  5. Youw commented on Jul 5, 2021

    @Youw
    Member

    some do not

    This is unexpected.

    Some do

    That is expected. That is the only way to check supported usage/usage_page-s of the device - report same device multiple times with the same path but different usage/usage_page pair

    I have not tested these devices on Windows.

    I see.

  6. mcuee commented on Jul 13, 2021

    @mcuee
    Member

    Interesting, I have not seen such issue under Windows 10 Dell PC and macOS (Mac Mini M1). But I have not done much testing on Linux side (my Raspberry Pi 400 is my Linux computer now).

  7. mcuee commented on Aug 2, 2021

    @mcuee
    Member

    @Be-ing It will be good to post the output of hidtest and the report descriptors (eg: under Linux or macOS). That may give some clues about the devices. Windows will create multiple devices with each for TLC (top level collections) and may even have some virtual device created on top.

    Windows: https://docs.microsoft.com/en-us/windows-hardware/drivers/hid/top-level-collections

  8. mcuee commented on Aug 2, 2021

    @mcuee
    Member

    @Be-ing It seems that it is not really an issue under Windows to have "multiple individual enabled devices for my singular mouse and keyboard". That is kind of expected under windows with devices with multiple TLCs, same for hidraw and macOS.

    Maybe Mixxx code has wrong assumptions in this asepct.

    Relevant discussion: #287

  9. Be-ing commented on Aug 2, 2021

    @Be-ing
    ContributorAuthor

    Maybe Mixxx code has wrong assumptions in this asepct.

    Perhaps, but besides potential functional implications, there is an issue of user confusion showing the same device multiple times.

  10. mcuee commented on Aug 2, 2021

    @mcuee
    Member

    Maybe Mixxx code has wrong assumptions in this asepct.

    Perhaps, but besides potential functional implications, there is an issue of user confusion showing the same device multiple times.

    That you can not change. hidapi is designed this way. You have to change mixxx.

  11. Be-ing commented on Aug 2, 2021

    @Be-ing
    ContributorAuthor

    I already did: mixxxdj/mixxx@5c58257

    But I wasn't sure if the problem was in Mixxx's use of hidapi or in hidapi.

  12. mcuee commented on Aug 2, 2021

    @mcuee
    Member

    In order to debug, please post the output of hidapi hidtest and the report descriptors.

  13. mcuee commented on Aug 2, 2021

    @mcuee
    Member

    @Be-ing As @Youw mentioned, if the device does not have the "same usage/usage_page pairs", then the behavior is not expected with Linux hidraw backend. Then that could be a hidapi bug. Please post the output of hidtest and the report descriptor to debug the issue with hidraw.

  14. mcuee commented on Aug 2, 2021

    @mcuee
    Member

    Similar for Windows, if the device is listed in Windows Device Manager as different device due to fact that is has multiple TLCs, then it will be listed by HIDAPI as multiple devices and that is expected. If that is not the case, then it could be a HIDAPI bug. Again please post the output of hidtest under Windows and the HID report descriptors of the device (using Linux or macOS as it is difficult to do under Windows)

  15. 27 remaining items

  16. Youw commented on Mar 18, 2023

    @Youw
    Member

    I apologise for not getting back to this for so long.
    I've checked the logs and have a working theory of what's wrong going on here (spoiler - a HIDAPI issue).
    To check my theory, would be nice to get the output of hidtest on macOS as well for the same device (17cc:1720).
    @Be-ing any chance you could provide that now?

  17. Be-ing commented on Mar 18, 2023

    @Be-ing
    ContributorAuthor

    Sorry, I don't have access to any computers running macOS currently.

  18. Youw commented on Mar 18, 2023

    @Youw
    Member

    What about Windows?
    Will you be able to use the latest master's hidtest (and you'd have to modify it a bit) to print the output of hid_get_report_descriptor ? On Windows it would likely give a bit different output than you've already provied from a Linux machine (due to Windows Report Recostruction mechanism from PP Data).

    And the HID Descriptor output you've provided earlier - if you could provide it in raw hex format I'd appreciate it, so I can experiment the fix on it.

  19. Be-ing commented on Mar 18, 2023

    @Be-ing
    ContributorAuthor

    I have a Windows VM I could use to run hidtest if you make a build with the modifications you alluded to.

  20. Youw commented on Mar 19, 2023

    @Youw
    Member

    I've just checked - no changes to hidtest required. I've already applied those some while ago.
    Simply run the hidtest from latest master on both Windows and Linux/hidraw.

  21. mcuee commented on May 1, 2023

    @mcuee
    Member

    I have a Windows VM I could use to run hidtest if you make a build with the modifications you alluded to.

    @Be-ing
    Any update on this topic?

  22. added 3 commits that reference this issue on Jul 23, 2023
    988e3cc
    3ef6cf4
    8edfc52
  23. Youw commented on Jul 23, 2023

    @Youw
    Member

    @Be-ing see if you could test #601

  24. added a commit that references this issue on Jul 23, 2023
    78c6ade
  25. added a commit that references this issue on Aug 26, 2023
    8a4de63
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

    hidraw

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions