From 86c29ffaa35592f16f6b1624002dcd97daf73511 Mon Sep 17 00:00:00 2001 From: "Luke T. Shumaker" Date: Mon, 16 Sep 2024 12:03:41 -0600 Subject: fix repeated chars --- usb_keyboard.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'usb_keyboard.c') 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; } } -- cgit v1.2.3-2-g168b