summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhathach <[email protected]>2021-07-01 22:54:57 +0700
committerhathach <[email protected]>2021-07-01 22:54:57 +0700
commit6de023d54b944bb467327062e79f3854e79b71a2 (patch)
tree4ab76ed92f5caa04dcf58b7c9fd31b4b158f1494
parentca98996e1f9ac802c60d9da4c28ab0e16ca640d6 (diff)
update hid_composite freertos with capslock as well
-rw-r--r--examples/device/hid_composite/src/main.c3
-rw-r--r--examples/device/hid_composite_freertos/src/main.c29
2 files changed, 26 insertions, 6 deletions
diff --git a/examples/device/hid_composite/src/main.c b/examples/device/hid_composite/src/main.c
index 6ddad5aae..d2a8a28fa 100644
--- a/examples/device/hid_composite/src/main.c
+++ b/examples/device/hid_composite/src/main.c
@@ -274,7 +274,8 @@ void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t rep
board_led_write(true);
}else
{
- // Caplocks Off: back to normal link
+ // Caplocks Off: back to normal blink
+ board_led_write(false);
blink_interval_ms = BLINK_MOUNTED;
}
}
diff --git a/examples/device/hid_composite_freertos/src/main.c b/examples/device/hid_composite_freertos/src/main.c
index 47f976427..a61710858 100644
--- a/examples/device/hid_composite_freertos/src/main.c
+++ b/examples/device/hid_composite_freertos/src/main.c
@@ -315,12 +315,31 @@ uint16_t tud_hid_get_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t
// received data on OUT endpoint ( Report ID = 0, Type = 0 )
void tud_hid_set_report_cb(uint8_t itf, uint8_t report_id, hid_report_type_t report_type, uint8_t const* buffer, uint16_t bufsize)
{
- // TODO set LED based on CAPLOCK, NUMLOCK etc...
(void) itf;
- (void) report_id;
- (void) report_type;
- (void) buffer;
- (void) bufsize;
+
+ if (report_type == HID_REPORT_TYPE_OUTPUT)
+ {
+ // Set keyboard LED e.g Capslock, Numlock etc...
+ if (report_id == REPORT_ID_KEYBOARD)
+ {
+ // bufsize should be (at least) 1
+ if ( bufsize < 1 ) return;
+
+ uint8_t const kbd_leds = buffer[0];
+
+ if (kbd_leds & KEYBOARD_LED_CAPSLOCK)
+ {
+ // Capslock On: disable blink, turn led on
+ xTimerStop(blinky_tm, portMAX_DELAY);
+ board_led_write(true);
+ }else
+ {
+ // Caplocks Off: back to normal blink
+ board_led_write(false);
+ xTimerStart(blinky_tm, portMAX_DELAY);
+ }
+ }
+ }
}
//--------------------------------------------------------------------+