From a6093d87082d919ae8d205445efb56389f3cfeb0 Mon Sep 17 00:00:00 2001 From: Evan Lojewski Date: Fri, 1 May 2020 20:32:58 -0600 Subject: [PATCH] keymap: Allow ghost keys to be pressed once the ghost is removed - Don't record a ghost key as pressed - Debouce on ghost release to allow ghosts to settle. - Reduce debounce time from 20ms to 15ms. Signed-off-by: Evan Lojewski --- src/board/system76/common/kbscan.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/board/system76/common/kbscan.c b/src/board/system76/common/kbscan.c index 9faf885..d6f3277 100644 --- a/src/board/system76/common/kbscan.c +++ b/src/board/system76/common/kbscan.c @@ -30,7 +30,7 @@ void kbscan_init(void) { } // Debounce time in milliseconds -#define DEBOUNCE_DELAY 20 +#define DEBOUNCE_DELAY 15 static uint8_t kbscan_get_row(int i) { // Set current line as output @@ -192,7 +192,7 @@ bool kbscan_press(uint16_t key, bool pressed, uint8_t * layer) { if (pressed) { uint8_t sci = SCI_EXTRA; sci_extra = (uint8_t)(key & 0xFF); - + // HACK FOR HARDWARE HOTKEYS switch (sci_extra) { case SCI_EXTRA_KBD_BKL: @@ -215,6 +215,7 @@ void kbscan_event(void) { uint8_t layer = kbscan_layer; static uint8_t kbscan_last[KM_OUT] = { 0 }; static uint8_t kbscan_last_layer[KM_OUT][KM_IN] = { { 0 } }; + static bool kbscan_ghost[KM_OUT] = { false }; static bool debounce = false; static uint32_t debounce_time = 0; @@ -242,8 +243,12 @@ void kbscan_event(void) { uint8_t last = kbscan_last[i]; if (new != last) { if (kbscan_has_ghost_in_row(i, new)) { - kbscan_last[i] = new; + kbscan_ghost[i] = true; continue; + } else if (kbscan_ghost[i]) { + kbscan_ghost[i] = false; + // Debounce to allow remaining ghosts to settle. + debounce = true; } // A key was pressed or released