Add Keyboard LED callback for USB and BT (not BLE) (#1265)

BLE seems to require some kind of characteristic callback that is not yeet
implemented here.  USB and BT tested and examples updated.
This commit was merged in pull request #1265.
This commit is contained in:
Earle F. Philhower, III
2023-03-04 14:18:40 -08:00
committed by GitHub
parent 173c44417c
commit 79e1af7bde
7 changed files with 51 additions and 1 deletions
+10
View File
@@ -46,4 +46,14 @@ void Keyboard_::sendReport(KeyReport* keys) {
tud_task();
}
extern "C" 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) {
(void) report_id;
(void) instance;
if ((report_type == HID_REPORT_TYPE_OUTPUT) && (bufsize > 0) && (Keyboard._ledCB)) {
uint8_t const kbd_leds = buffer[0];
Keyboard._ledCB(kbd_leds & KEYBOARD_LED_NUMLOCK, kbd_leds & KEYBOARD_LED_CAPSLOCK, kbd_leds & KEYBOARD_LED_SCROLLLOCK, kbd_leds & KEYBOARD_LED_COMPOSE, kbd_leds & KEYBOARD_LED_KANA, Keyboard._ledCBdata);
}
}
Keyboard_ Keyboard;