From 33df7b4f4e68afd1f2c9cb3b56725ba460f11ea2 Mon Sep 17 00:00:00 2001 From: me-no-dev Date: Wed, 2 Oct 2024 14:46:55 +0300 Subject: [PATCH] fix(hid): Fix OUTPUT report not received Fixes an issue where the keyboard LEDs will not trigger the proper event --- cores/esp32/esp32-hal-tinyusb.c | 10 +++++++++- libraries/USB/src/USBHID.cpp | 2 +- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cores/esp32/esp32-hal-tinyusb.c b/cores/esp32/esp32-hal-tinyusb.c index 4b39da82641..f7225425913 100644 --- a/cores/esp32/esp32-hal-tinyusb.c +++ b/cores/esp32/esp32-hal-tinyusb.c @@ -453,7 +453,15 @@ __attribute__((weak)) int32_t tud_msc_scsi_cb(uint8_t lun, uint8_t const scsi_cm __attribute__((weak)) bool tud_msc_is_writable_cb(uint8_t lun) { return false; } - +#endif +#if CFG_TUD_NCM +__attribute__((weak)) bool tud_network_recv_cb(const uint8_t *src, uint16_t size) { + return false; +} +__attribute__((weak)) uint16_t tud_network_xmit_cb(uint8_t *dst, void *ref, uint16_t arg) { + return 0; +} +__attribute__((weak)) void tud_network_init_cb(void) {} #endif /* diff --git a/libraries/USB/src/USBHID.cpp b/libraries/USB/src/USBHID.cpp index 995700de4c9..75f37ef5df3 100644 --- a/libraries/USB/src/USBHID.cpp +++ b/libraries/USB/src/USBHID.cpp @@ -259,7 +259,7 @@ uint16_t tud_hid_get_report_cb(uint8_t instance, uint8_t report_id, hid_report_t // Invoked when received SET_REPORT control request or // received data on OUT endpoint ( Report ID = 0, Type = 0 ) void tud_hid_set_report_cb(uint8_t instance, uint8_t report_id, hid_report_type_t report_type, uint8_t const *buffer, uint16_t bufsize) { - if (!report_id && !report_type) { + if (!report_id && (!report_type || report_type == HID_REPORT_TYPE_OUTPUT)) { if (!tinyusb_on_set_output(0, buffer, bufsize) && !tinyusb_on_set_output(buffer[0], buffer + 1, bufsize - 1)) { log_d( "instance: %u, report_id: %u, report_type: %s, bufsize: %u", instance, buffer[0], tinyusb_hid_device_report_types[HID_REPORT_TYPE_OUTPUT], bufsize - 1