diff options
author | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-16 12:03:41 -0600 |
---|---|---|
committer | Luke T. Shumaker <lukeshu@lukeshu.com> | 2024-09-16 12:04:43 -0600 |
commit | 86c29ffaa35592f16f6b1624002dcd97daf73511 (patch) | |
tree | 4b2186b81a77f3ff005177140815d9ff273655db /usb_keyboard.c | |
parent | 93f054683dd5fc5b79541f4922cb34a38cb5c341 (diff) |
fix repeated chars
Diffstat (limited to 'usb_keyboard.c')
-rw-r--r-- | usb_keyboard.c | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/usb_keyboard.c b/usb_keyboard.c index 5647403..6b5edec 100644 --- a/usb_keyboard.c +++ b/usb_keyboard.c @@ -42,12 +42,13 @@ static size_t kbd_buf_len = 0; static uint8_t ascii2keycode[128][2] = { HID_ASCII_TO_KEYCODE }; void usb_keyboard_task(void) { + static bool sent_key = false; if (tud_hid_n_ready(kbd_ifc)) { uint8_t const report_id = 0; uint8_t modifier = 0; uint8_t keycodes[6] = {0}; - if (kbd_buf_len) { + if (kbd_buf_len && !sent_key) { if (ascii2keycode[kbd_buf[kbd_buf_beg]][0]) modifier = KEYBOARD_MODIFIER_LEFTSHIFT; keycodes[0] = ascii2keycode[kbd_buf[kbd_buf_beg]][1]; @@ -59,6 +60,7 @@ void usb_keyboard_task(void) { } tud_hid_n_keyboard_report(kbd_ifc, report_id, modifier, keycodes); + sent_key = !sent_key; } } |