Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
589 views
in Technique[技术] by (71.8m points)

USB HID report descriptor, multiple reports

I am trying to emulate USB Multimedia keyboard, but stuck at HID report descriptor. I am manage to define "single report" descriptor, but then stuck when I am trying to add additional report id. Below example was minimized, in final application I am trying to put more data in single report, also MUTE function is choosen to make it testing simple.

0x09, 0x01,        // Usage (Consumer Control)
0xA1, 0x01,        // Collection (Application)

0x85, 0x01,        //   Report ID (1)
0x05, 0x0C,        //   Usage Page (Consumer)
0x15, 0x00,        //   Logical Minimum (0)
0x25, 0x01,        //   Logical Maximum (1)
0x75, 0x01,        //   Report Size (1)
0x95, 0x01,        //   Report Count (1)
0x09, 0xE2,        //   Usage (Mute)
0x81, 0x62,        //   Input (Data,Var,Abs,No Wrap,Linear,No Preferred State,Null State)

0x85, 0x02,        //   Report ID (2)
0x05, 0x0C,        //   Usage Page (Consumer)
0x15, 0x00,        //   Logical Minimum (0)
0x25, 0x01,        //   Logical Maximum (1)
0x75, 0x01,        //   Report Size (1)
0x95, 0x01,        //   Report Count (1)
0x09, 0xE2,        //   Usage (Mute)
0x81, 0x62,        //   Input (Data,Var,Abs,No Wrap,Linear,No Preferred State,Null State)
0xC0,              // End Collection

The result is, when I sent 0x01 0x01 (request 1, bit 1) computer (Windows) mute sounds, but when the USB device sent 0x02 0x01 (request 2, bit 2) over same endpoint, computer ignore it. I tried to group reports into Logical Collection, but it does not chane anything.

How this descriptor should look like?

PS there was obvious mistake in descriptor (missing Input entity for report #2) on the first post, but it was done when I simplified the descriptor for purpose of this question.

question from:https://stackoverflow.com/questions/65846159/usb-hid-report-descriptor-multiple-reports

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Accidently I solved the problem. More, the minimal example shown above is not working, but the issue was same as in my full implementation.

For some reason for Windows each report must be aligned to 8 bits, otherway the last byte which is "not complete" does not trigger expected action. The solution is to add byte alignment bits to the report.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...