You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
libusb: fix using LIBUSB_DT_REPORT for HID Report Descriptor #438
Unfortunately not all devices have LIBUSB_DT_REPORT request implemented, even though raw USB descriptors contain the HID Report Descriptor.
UPD: probably the way HIDAPI uses LIBUSB_DT_REPORT is not correct.
Instead of using LIBUSB_DT_REPORT there are several possible alternatives:
get/parse HID interface descriptor from libusb (need to check if this is possible);
UPD: it only contains HID descriptor, and not the HID Report descriptor;
read/parse descriptors from sysfs - linux-specific solution;
UPD: same limitation as with libusb descriptors - HID Report descriptor is not part of the USB descriptors.
get/parse HID interface descriptor from libusb (need to check if this is possible);
From HID USB specification:
The HID class uses the standard request Get_Descriptor as described in the USB
Specification. When a Get_Descriptor(Configuration) request is issued, it
returns the Configuration descriptor, all Interface descriptors, all Endpoint
descriptors, and the HID descriptor for each interface. It shall not return the
String descriptor, HID Report descriptor or any of the optional HID class
descriptors.
It shall not return ... HID Report descriptor ... .
Tried this with libusb: true - with my devices the interface descriptor contains the HID descriptor, but it doesn't include the HID Report descriptor.
Hm, that information is available from Interface descriptor. Maybe that's what is missing to make it wokr.
I'll try it (passing the actual Report descriptors size) later today.
changed the title [-]libusb: avoid sending LIBUSB_DT_REPORT for HID Report Descriptor[/-][+]libusb: fix using LIBUSB_DT_REPORT for HID Report Descriptor[/+]on Aug 14, 2022
BTW: in the xusb example here - there is a bug: wIndex parameter is set to 0, which means the request will work only if the USB Interface №0 is a HID Interface. wIndex has to be set to the HID Interface index.
BTW: in the xusb example here - there is a bug: wIndex parameter is set to 0, which means the request will work only if the USB Interface №0 is a HID Interface. wIndex has to be set to the HID Interface index.
Activity
Youw commentedon Aug 13, 2022
From HID USB specification:
It shall not return ... HID Report descriptor ... .
Tried this with libusb: true - with my devices the interface descriptor contains the HID descriptor, but it doesn't include the HID Report descriptor.
Looks like it is not an option(
JoergAtGithub commentedon Aug 14, 2022
I wonder, what
means. What type of error do you get, if you try to gather the Report Descriptor?
Do you know, how operating system drivers of Windows or hidraw request the Report Descriptor from these devices?
I guess that usbutils (lsusb & usbhid-dump) fails for these devices too?
Youw commentedon Aug 14, 2022
libusb_control_transfer() for getting the HID report descriptor failed with -1: LIBUSB_ERROR_IOMaybe my assumption about
LIBUSB_DT_REPORTnot being supported by the device is not correct - that was my itinial thought.That's what I intent to find out. Not the first time I'll be going thru hidraw sources.
Youw commentedon Aug 14, 2022
sudo lsusb -vgives me a similar thing I got with libusb:Interestingly,
sudo usbhid-dumpactually gives me what I need:Maybe I just need to poke around its sources.
JoergAtGithub commentedon Aug 14, 2022
Both are based on libusb. I noticed, that usbhid-dump determines the size of the Report-Descriptor before reading it.
Youw commentedon Aug 14, 2022
Hm, that information is available from Interface descriptor. Maybe that's what is missing to make it wokr.
I'll try it (passing the actual Report descriptors size) later today.
[-]libusb: avoid sending LIBUSB_DT_REPORT for HID Report Descriptor[/-][+]libusb: fix using LIBUSB_DT_REPORT for HID Report Descriptor[/+]Youw commentedon Aug 14, 2022
Found this in kernel/hidusb driver.
Looks like it uses the
LIBUSB_DT_REPORTbut it specifically requests the size as per HID descriptor.JoergAtGithub commentedon Aug 14, 2022
I saw this code of usbhid-dump: https://github.com/gregkh/usbutils/blame/master/usbhid-dump/src/iface_list.c#L94
Youw commentedon Aug 14, 2022
Yeah, that's basically the same thing.
Youw commentedon Aug 14, 2022
I made an attempt to fix it here: https://github.com/libusb/hidapi/tree/libusb_report_descriptor_read
But it still doesn't wokr as expected.
I'll be able to check it some time later.
mcuee commentedon Aug 15, 2022
@Youw
libusb xusb may not handle atill the situations but it works to list the HID report descriptors (only for interface 0).
https://github.com/libusb/libusb/blob/master/examples/xusb.c#L609
Example run against teensy 2.0 RawHID device.
Youw commentedon Aug 15, 2022
Ah, sorry I didn't explicitly mention it here regarding:
#444 completely resolves the issue now.
The problem was about not sending the correct libusb request to get the HID Report descriptor.
Youw commentedon Aug 15, 2022
BTW: in the xusb example here - there is a bug:
wIndexparameter is set to0, which means the request will work only if the USB Interface №0 is a HID Interface.wIndexhas to be set to the HID Interface index.mcuee commentedon Aug 16, 2022
Yes that example is only meant for the particular HID device in reality :
// Microsoft Sidewinder Precision Pro Joystick - 1 HID interface(https://github.com/libusb/libusb/blob/b88f1441856a9ba481dc40c8c6d0415d8556514a/examples/xusb.c#L1054)
Youw commentedon Aug 16, 2022
Explicitly naming the parameter value as a variable would make a better sample. Just a thought.
mcuee commentedon Aug 16, 2022
Thanks. Yes I think this issue is sorted. You can also close #443 as there is a working work-around now.