Skip to content

Commit e43270e

Browse files
authored
Merge pull request #9322 from dhalbert/tinyusb-out-report-changes
Update `tud_hid_set_report_cb()` report handling
2 parents c6da0a4 + 8b39b3b commit e43270e

File tree

1 file changed

+7
-4
lines changed

1 file changed

+7
-4
lines changed

shared-module/usb_hid/Device.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,12 @@ void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t rep
282282
usb_hid_device_obj_t *hid_device = NULL;
283283
size_t id_idx;
284284

285-
if (report_id == 0 && report_type == HID_REPORT_TYPE_INVALID) {
285+
// As of https://github.com/hathach/tinyusb/pull/2253, HID_REPORT_TYPE_INVALID reports are not
286+
// sent to this callback, but are instead sent to tud_hid_report_fail_cb(), which we don't bother
287+
// to implement.
288+
// So this callback is only going to see HID_REPORT_TYPE_OUTPUT.
289+
// HID_REPORT_TYPE_FEATURE is not used yet.
290+
if (report_id == 0) {
286291
// This could be a report with a non-zero report ID in the first byte, or
287292
// it could be for report ID 0.
288293
// Heuristic: see if there's a device with report ID 0, and if its report length matches
@@ -299,12 +304,10 @@ void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t rep
299304
buffer++;
300305
bufsize--;
301306
}
302-
} else if (report_type != HID_REPORT_TYPE_OUTPUT && report_type != HID_REPORT_TYPE_FEATURE) {
303-
return;
304307
}
305308

306309
// report_id might be changed due to parsing above, so test again.
307-
if ((report_id == 0 && report_type == HID_REPORT_TYPE_INVALID) ||
310+
if ((report_id == 0) ||
308311
// Fetch the matching device if we don't already have the report_id 0 device.
309312
(usb_hid_get_device_with_report_id(report_id, &hid_device, &id_idx) &&
310313
hid_device &&

0 commit comments

Comments
 (0)