hidapi icon indicating copy to clipboard operation
hidapi copied to clipboard

Unable to retrieve bus_type for some devices on Windows

Open AlexGuo1998 opened this issue 1 year ago • 6 comments

On windows, we currently inspect the parent devnode to get bus_type:

https://github.com/libusb/hidapi/blob/4ebce6b5059b086d05ca7e091ce04a5fd08ac3ac/windows/hid.c#L498-L552

However, some filtered HID device (e.g. imbushuo/mac-precision-touchpad) whose parent is the filter driver, which don't have a correct compatible_id. The device tree is like this:

...                                           (page usage)
Microsoft Bluetooth Enumerator
|- Bluetooth HID device                                   <- 3
   |- Apple Multi-touch Auxiliary Services    (FF00 0014)
   |- Apple Multi-touch Trackpad HID Filter               <- 2
      |- Microsoft Input Configuration Device (000D 000E)
      |- HID Compactible Trackpad             (000D 0005) <- 1

If we want to know the bus_type for (1), according to the code, we're inspecting the compatible_id for (2), which is empty.

However if we go one step further we hit (3), which has the correct compatible_id: BTHENUM\{GUID}. Now we know it's a Bluetooth device.


I suggest we go all the way up, until to the root to find a recognizable compatible_id, and stop after we found one.

I don't really know if this is the correct / sane thing to do. Could you give me some ideas?


BTW, on a UEFI laptop some devices have a ancestor with a compatible_id like *PNP0A03, but no more recognizable value. Do you know what that is? (Maybe we can open another issue for this?)

AlexGuo1998 avatar Feb 04 '23 17:02 AlexGuo1998

is #464 of any relevance to the issue described here?

Youw avatar Feb 04 '23 23:02 Youw

I'm not quite sure but maybe no.

In this situation, we don't even find USB in any of the compatible_ids, while #464 attempts to add some extra logic in if(wcsstr(compatible_id, L"USB") != NULL)

AlexGuo1998 avatar Feb 05 '23 00:02 AlexGuo1998

@DJm00n can you help with this Bluetooth bus_type issue?

JoergAtGithub avatar Feb 05 '23 08:02 JoergAtGithub

I suggest we go all the way up, until to the root to find a recognizable compatible_id, and stop after we found one.

This does sounds like a good solution. But I guess i has to be in line with other changes (including #464).

Youw avatar Feb 05 '23 14:02 Youw

@AlexGuo1998 thank you for reporting. I'll review cr = CM_Get_Parent(&dev_node, dev_node, 0); after #464 get merged.

PS: according to the C:\Windows\INF\pci.inf PNP0A03 is a "PCI Bus".

DJm00n avatar Mar 13 '23 20:03 DJm00n

@DJm00n

#464 has been merged. Maybe you want to take a look at this issue now.

mcuee avatar May 02 '23 03:05 mcuee