From 849ed5a6a03b14defa94a50b66169abac89b9c08 Mon Sep 17 00:00:00 2001 From: Jeremiah Date: Sat, 13 May 2017 08:51:20 -0700 Subject: anti-ghost improvement for older keyboards with empty spots in matrix --- tmk_core/common/keyboard.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'tmk_core/common/keyboard.h') diff --git a/tmk_core/common/keyboard.h b/tmk_core/common/keyboard.h index 7738251b6..fe2a8fe81 100644 --- a/tmk_core/common/keyboard.h +++ b/tmk_core/common/keyboard.h @@ -57,7 +57,7 @@ static inline bool IS_RELEASED(keyevent_t event) { return (!IS_NOEVENT(event) && .time = (timer_read() | 1) \ } - +void make_ghost_check_array(void); /* it runs once at early stage of startup before keyboard_init. */ void keyboard_setup(void); /* it runs once after initializing host side protocol, debug and MCU peripherals. */ -- cgit v1.2.3 From b9895771edb4cca2bb17f5872a0e6ee068c91500 Mon Sep 17 00:00:00 2001 From: Jeremiah Date: Sat, 13 May 2017 13:19:28 -0700 Subject: improvements --- tmk_core/common/keyboard.c | 39 ++++++++++++++++----------------------- tmk_core/common/keyboard.h | 1 - 2 files changed, 16 insertions(+), 24 deletions(-) (limited to 'tmk_core/common/keyboard.h') diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 93a066e57..116914e1a 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -62,12 +62,21 @@ along with this program. If not, see . #endif - #ifdef MATRIX_HAS_GHOST -static uint16_t matrix_ghost_check[MATRIX_ROWS]; +extern const uint16_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; +// bit map of true keys and empty spots in matrix, each row is reversed +static uint16_t get_row_ghost_check(uint16_t row){ + for (int col = 0; col < MATRIX_COLS; col++) { + if (keymaps[0][row][col]) + row &= 1< 1){ + if (i != row && __builtin_popcount( + get_row_ghost_check(matrix_get_row(i)) & matrix_row + ) > 1){ return true; } } return false; - return false; } - -extern const uint8_t keymaps[][MATRIX_ROWS][MATRIX_COLS]; -// bit map of true keys and empty spots in matrix, each row is reversed -void make_ghost_check_array(){ - for (int row = 0; row < MATRIX_ROWS; row++) { - for (int col = 0; col < MATRIX_COLS; col++) { - if (keymaps[0][row][col] & 0xFF) - matrix_ghost_check[row] |= 1<