Using HIDAPI, how can you query the raw report descriptor?
Asked Answered
R

3

6

I'd like to deconstruct the raw reports received from the hid_read function of hidapi.

As I understand, this can be achieved using the information from the device's report descriptors. But when trying to query for those descriptors, I get lost somewhere between the HID Spec and using the methods available in hidapi.

I would love to see a concrete C or node-hidapi based example that queries and enumerates all the report descriptors for a device — perhaps a mouse to keep things simple?

Roast answered 17/7, 2013 at 17:54 Comment(0)
R
7

I asked Alan Ott by email about this, and he responded with no as follows:

HIDAPI does not provide functions for getting or parsing the report descriptor. Since HIDAPI is for talking to a custom devices, these devices will likely contain all or mostly vendor-defined report items anyway.

Roast answered 2/8, 2013 at 23:18 Comment(1)
Thanks, this was not really apparent from their docs! I had spend a lot of time trying to understand what is going on =)Breadwinner
A
3

This isn't exactly what you're looking for, but it will get the same job done. I highly recommend you use libusbx over any other hid library. If you are willing to do so, here is a very blatant example of device enumeration.

Edit:

It appears that libusbx has been merged back into libusb. This is awesome! As the above link is broken, here is the new link.

Ameeameer answered 19/7, 2013 at 14:46 Comment(6)
That looks fantastic — I'll take a deeper dive into it.Roast
Feel free to check if you like it! :)Ameeameer
@Ameeameer link you posted seems promising, but its broken.Can you repost it.Crosswind
@ShaneHolloway did you get through the solution?How about using lsusb -vv in the linux and get the information you desire to get.Crosswind
@Raulp, sure thing, just edited my post. Apparently libusbx has been merged back into libusb!Ameeameer
@Ameeameer Can you please explain why you highly recommend using libusb over any other hid library? I would be curious to know what is the reason behind this recommendation.Negotiable
S
1

I had success with using both https://github.com/Orochimarufan/HIDRAW/tree/master/HIDRAW_test (that is hopefully the C code example that you asked about) and RDD! USB HID Report Descriptor Decoder for more descriptive output.

Singletree answered 14/4, 2016 at 7:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.