WICG / webhid

Web API for accessing Human Interface Devices (HID)
Other
142 stars 35 forks source link

Usage Page should not be per HIDCollectionInfo but per HIDReportItem #76

Open toyoshim opened 3 years ago

toyoshim commented 3 years ago

Current WebHID spec expects Usage Page appears once per HIDCollectionInfo, but there is no such restriction in the USB HID spec AFAIK. Usage Page is just a Global Item like other global ones such as Logical Minimum, etc. These field appear per HIDReportItem, and Usage Page should be so too.

HID1_11.pdf, Device Class Definition for Human Interface Devices (HID) Firmware Specification Version 1.11, P.25 shows an example report that contains the case.

toyoshim commented 3 years ago

Hum..., does the spec expect Usage Page is encoded as an upper 16-bits of Usage if it is different from collection wide global value?

nondebug commented 3 years ago

Yes, the Usage Page will be in the upper 16-bits of the usages, usageMinimum, and usageMaximum members of HIDReportItem. If no Usage Page has been set when the Input, Output, or Feature item is encountered then the value in the upper 16-bits should be zero.

It looks like the spec is missing an initialization step in the "parse the report descriptor" steps so it never actually gets initialized to zero.