开发者

Write something to linux hid device?

I am learning linux hid driver programming, i kno开发者_如何转开发w how to read a message from hid device

but, i am puzzled how to write something to the device ? such as usb hid keyboard, i can use xset or some other program to control the leds of the keyboard, how to archive that? Any tips please!

thanks advance.


USB HID devices are mostly input devices, so they don't usually provide an OUT endpoint (they are allowed by the HID specification but I've never seen one). If an OUT endpoint is not provided, then output reports are sent through the control endpoint (EP0). The URB should be something like this:

bmRequestType = 0x21     (To class interface)
bRequest = 0x09          (SET_REPORT)
wValue = 0x02 <report_code>
wIndex = <interface>     (Usually 0x0001)
wLength = <Data length>
Data = <report_code> <data>...

Naturally, there are functions that do just that. From kernel, you may look at hiddev_lookup_report/usbhid_submit_report. From userland, if you use /dev/usb/hiddev? you may try the HIDIOCSREPORT ioctl, and if you use /dev/hidraw? you simply write() into it.

HID also defines "Features", that are an output control mechanism, but I've never used them.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜