Skip to content

Commit

Permalink
Include report ID in out report buffers
Browse files Browse the repository at this point in the history
tuh_hid_set_report() doesn't add the report ID so we have to do it
ourself.

Without it CapsLock LEDs etc. only worked on keyboards that don't use
report IDs.
  • Loading branch information
jfedor2 committed Jan 3, 2025
1 parent 5677203 commit ada340d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions firmware/src/out_report.cc
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,18 @@ void do_queue_out_report(const uint8_t* report, uint16_t len, uint8_t report_id,
printf("out overflow!\n");
return;
}
if (len > sizeof(outgoing_out_reports[oor_tail].report)) {
if ((len + ((report_id != 0) ? 1 : 0)) > sizeof(outgoing_out_reports[oor_tail].report)) {
return;
}
outgoing_out_reports[oor_tail].dev_addr = dev_addr;
outgoing_out_reports[oor_tail].interface = interface;
outgoing_out_reports[oor_tail].report_id = report_id;
outgoing_out_reports[oor_tail].len = len;
outgoing_out_reports[oor_tail].len = len + ((report_id != 0) ? 1 : 0);
outgoing_out_reports[oor_tail].type = type;
memcpy(outgoing_out_reports[oor_tail].report, report, len);
if (report_id != 0) {
outgoing_out_reports[oor_tail].report[0] = report_id;
}
memcpy(outgoing_out_reports[oor_tail].report + ((report_id != 0) ? 1 : 0), report, len);
oor_tail = (oor_tail + 1) % OOR_BUFSIZE;
oor_items++;
}
Expand Down

0 comments on commit ada340d

Please sign in to comment.