Shane Holloway
Shane Holloway

Reputation: 7852

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

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?

Upvotes: 6

Views: 5273

Answers (3)

L.R.
L.R.

Reputation: 1092

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.

Upvotes: 1

eatonphil
eatonphil

Reputation: 13702

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.

Upvotes: 3

Shane Holloway
Shane Holloway

Reputation: 7852

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.

Upvotes: 7

Related Questions