adafruit / Adafruit_TinyUSB_Arduino

Arduino library for TinyUSB
MIT License
449 stars 119 forks source link

add HID getProtocol method #381

Closed tlyu closed 4 months ago

tlyu commented 5 months ago

Is your feature request related to a problem? Please describe.

I have a keyboard HID that I want to dynamically switch report formats between Boot Protocol and Report Protocol. Unfortunately, there is no method to get the current HID protocol setting from Adafruit_USBD_HID.

Describe the solution you'd like

Add a getProtocol method to Adafruit_USBD_HID.

Describe alternatives you've considered

I'm attempting a workaround that adds a tud_set_protocol_cb hook, but this only works when there's a single boot HID, because Adafruit_USBD_HID also doesn't expose the _instance variable.

Additional context

This seems easy enough to add by calling into tud_hid_n_get_protocol. I can submit a PR for this.