I'm trying to port some windows code that uses HidD_GetInputReport to linux using libusb. From what I can tell I need to make a call to usb_control_msg but I'm having problems figuring out what parameters to pass in.
The report id I'm after is 0x01. Here is what I have so far.
#define HID_GET_REPORT 0x01
#define HID_REPORT_TYPE_INPUT 0x01
#define INTERFACE_NUMBER 0x00
int reportId = 0x01;
int bytesSent = usb_control_msg(
devHandle,
USB_ENDPOINT_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE,
HID_GET_REPORT,
(HID_REPORT_TYPE_INPUT << 8) | reportId,
INTERFACE_NUMBER,
buf,
sizeof(buf),
10000);
I'm really not sure about HID_GET_REPORT, HID_REPORT_TYPE_INPUT, and INTERFACE_NUMBER. I found them in an example on the web. Changing the various values does result in different return codes but those don't appear to be documented anywhere either.
Looks like you need to detach the kernel and claim the interface before calling other functions. I made calls to the following and it fixed the problem.
usb_detach_kernel_driver_np
usb_claim_interface