Click here to Skip to main content
15,889,034 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Calling HidD_GetFeature() returns TRUE on success. It does not return in any way the number of bytes in the report.

I decided there must be a function in the HID.dll API which would give me the number of bytes in each report (as parsed from the HID Descriptor). Keep in mind, what I'm looking for is the number of bytes contained in a specific report, ie: Feature Report #1.

HidD_GetCaps() will give me the Maximum number of bytes in all reports of a given type (ie: max feature report length). It will not give me the length of a specific report.

I found no functions which will give me this information. I decided maybe I could just get the Report Descriptor, and figure it out myself. I found no funcitons which would give me the report descriptor either. I can get the Physical Descriptor, but not the Report Descriptor.

I'm stuck. Anyone have any ideas?
Posted

1 solution

When calling HidD_GetFeature you set the first byte in the buffer to the Report ID of the feature report you want to get (if the top-level collection doesn't specify a Report ID, you set that bit to zero). Then you can parse the rest of the buffer according to the Report ID. Since you know the Report ID you should know how the data is laid out in the buffer.
As far as I know, if you don't know the layout of the data or even the Report IDs, you can use the HIDClass Support Routines[^] (HidD_GetPreparsedData, HidP_GetValueCaps, HidP_GetButtonCaps...) to discover the preparsed data of the top-level collection you're interested in and deal with the report. Preparsed data represents a top-level collection's part of the report descriptor.
 
Share this answer
 
Comments
Alan Ott 14-Aug-10 14:20pm    
I understand that for an application, I don't strictly _need_ to know the length of the report, as I should know ahead of time exactly what it is that I have to parse. However, I'm making a cross-platform library (Windows,Linux,Mac). The other platforms will give me a length, which I'd like to return to the user.

Further, I've developed a test GUI. For a generic GUI, I can't know the length beforehand.

I've been all through the HID Support Routines. To the ones you listed:

HidD_GetPreparsedData():
Returns an opaque blob of data which is used by other functions. None of these other functions seem to actually give me report lengths.

HidP_GetValueCaps():
Has to do with the actual values returned from the HID device (like joystick range, etc).

HidP_GetButtonCaps():
Same as above, but with buttons.

I ended up getting what I needed by using DeviceIoControl() instead of HidD_GetFeature(). See
http://github.com/signal11/hidapi/blob/master/windows/hid.cpp for details if you're interested.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900