update hid_composite freertos with capslock as well

This commit is contained in:
hathach 2021-07-01 22:54:57 +07:00
parent ca98996e1f
commit 6de023d54b
2 changed files with 26 additions and 6 deletions

View File

@ -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;
}
}

View File

@ -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);
}
}
}
}
//--------------------------------------------------------------------+