diff options
| author | Scott Shawcroft <scott@adafruit.com> | 2020-09-10 17:35:04 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-09-10 17:35:04 -0700 |
| commit | 9256e6b376c5a8a6c185e6a4ab25e01987e04445 (patch) | |
| tree | 498cdf5d73baa4316b90e4199cbfb7bebbfd0a03 /shared-module | |
| parent | 9e722c8c99d1c31d8ac1c009aef8e2da31f401b9 (diff) | |
| parent | f0bb9635bf311013e7b1ff69d1a0542575cf9d0a (diff) | |
Merge pull request #3302 from xiongyihui/main
support to get HID OUT report
Diffstat (limited to 'shared-module')
| -rw-r--r-- | shared-module/usb_hid/Device.c | 17 | ||||
| -rw-r--r-- | shared-module/usb_hid/Device.h | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/shared-module/usb_hid/Device.c b/shared-module/usb_hid/Device.c index 8e9df6f04..943c9bfed 100644 --- a/shared-module/usb_hid/Device.c +++ b/shared-module/usb_hid/Device.c @@ -84,14 +84,17 @@ uint16_t tud_hid_get_report_cb(uint8_t report_id, hid_report_type_t report_type, // Callbacks invoked when receive Set_Report request through control endpoint void tud_hid_set_report_cb(uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize) { + if (report_type == HID_REPORT_TYPE_INVALID) { + report_id = buffer[0]; + buffer++; + bufsize--; + } else if (report_type != HID_REPORT_TYPE_OUTPUT) { + return; + } + usb_hid_device_obj_t* hid_device = get_hid_device(report_id); - if ( report_type == HID_REPORT_TYPE_OUTPUT ) { - // Check if it is Keyboard device - if (hid_device->usage_page == HID_USAGE_PAGE_DESKTOP && - hid_device->usage == HID_USAGE_DESKTOP_KEYBOARD) { - // This is LED indicator (CapsLock, NumLock) - // TODO Light up some LED here - } + if (hid_device && hid_device->out_report_length >= bufsize) { + memcpy(hid_device->out_report_buffer, buffer, bufsize); } } diff --git a/shared-module/usb_hid/Device.h b/shared-module/usb_hid/Device.h index 10f2ee897..93c3518b4 100644 --- a/shared-module/usb_hid/Device.h +++ b/shared-module/usb_hid/Device.h @@ -43,6 +43,8 @@ typedef struct { uint8_t report_length; uint8_t usage_page; uint8_t usage; + uint8_t* out_report_buffer; + uint8_t out_report_length; } usb_hid_device_obj_t; |
