Skip to content

Support HID devices with multiple report id's for one device #4868

@dhalbert

Description

@dhalbert

The dynamic USB support in 7.0.0 alpha currently assumes that a single HID device (usb_hid.Device) has a single report ID. There are HID devices that need multiple report ID's, such as eye tracking devices.

Currently the API asks for the position of the report ID in the report descriptor, and renumbers the report ID's consecutively. This is unnecessary. The report ID's just need to be distinct in the different devices.

Plan (updated 2021-08-14):

  • Require that the report ID the user wants is in the report descriptor. It will not be changed.
  • Remove the Device() constructor argument that is the report ID index.
  • Add multiple IN and OUT report sizes for each of the report ID's the user supplies. The code will not parse the report descriptor to validate that the number of report ID's and report sizes matches.
  • Still handle the case that a single report ID for a lone device is removed if that is the only device in the HID interface. (see below *)
  • Make sure "feature" (bidirectional) reports are supported properly. Moved to Support "feature" reports in HID #5197.
  • Change the .last_received_report API for OUT reports to something like get_last_received_report(report_id). Maybe make this backward compatible for now.
  • Rework the IN buffer management to share a single buffer. This is probably possible, because the TinyUSB copies the report when it's passed to be sent. For OUT (received) reports, we probably still need a buffer per report, so we can support get_last_received_report().**

Tagging @ATMakersBill.

*The "requirement" that a single report ID for a lone device is removed if that is the only device in the HID interface does not seem to be true, at least for USB HID. @hathach believes this may be an idiosyncrasy of iOS BLE HID, and we should retest this. I tested a keyboard as the sole device in an interface, and gave it a non-zero report ID, and it worked fine on Windows 10, Linux (Ubuntu 20.04), iOS 14.7.1 and 15 beta, and Android 11.

**The IN buffer is not needed when sending reports directly but USB can send a "GET REPORT" request over the control interface, so I am leaving the IN buffers in place for that possibility.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions