Code: Select all
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;
// keyboard interface
if (instance == ITF_NUM_KEYBOARD)
{
// Set keyboard LED e.g Capslock, Numlock etc...
if (report_type == HID_REPORT_TYPE_OUTPUT)
{
// bufsize should be (at least) 1
if (bufsize < 1)
return;
uint8_t const kbd_leds = buffer[0];
// Cap_lock = 0;
if (kbd_leds & KEYBOARD_LED_CAPSLOCK)
{
// Capslock On: disable blink, turn led on
if (Cap_lock == false)
ESP_LOGI(TAG, "Capslock On");
Cap_lock = true;
}
else
{
// Caplocks Off: back to normal blink
if (Cap_lock == true)
ESP_LOGI(TAG, "Caplocks Off");
Cap_lock = false;
}
if (kbd_leds & KEYBOARD_LED_NUMLOCK)
{
if (Num_Lock == false)
ESP_LOGI(TAG, "Numlock On");
Num_Lock = true;
}
else
{
if (Num_Lock == true)
ESP_LOGI(TAG, "Numlock Off");
Num_Lock = false;
}
if (kbd_leds & KEYBOARD_LED_SCROLLLOCK)
{
if (Scroll_Lock == false)
ESP_LOGI(TAG, "Scroll Lock On");
Scroll_Lock = true;
}
else
{
if (Scroll_Lock == true)
ESP_LOGI(TAG, "Scroll Lock Off");
Scroll_Lock = false;
}
if (kbd_leds & KEYBOARD_LED_COMPOSE)
{
if (Compos_Mode == false)
ESP_LOGI(TAG, "Composition Mode On");
Compos_Mode = true;
}
else
{
if (Compos_Mode == true)
ESP_LOGI(TAG, "Composition Mode Off");
Compos_Mode = false;
}
if (kbd_leds & KEYBOARD_LED_KANA)
{
if (kana_Mode == false)
ESP_LOGI(TAG, "Kana Mode On");
kana_Mode = true;
}
else
{
if (kana_Mode == true)
ESP_LOGI(TAG, "Kana Mode Off");
kana_Mode = false;
}
}
}
}