diff options
author | Drashna Jaelre <drashna@live.com> | 2019-12-16 08:31:59 -0800 |
---|---|---|
committer | Florian Didron <fdidron@users.noreply.github.com> | 2020-01-09 08:57:11 +0900 |
commit | 455f9e9d1f2459f8d830118f6cb661ff2dcb0ee3 (patch) | |
tree | 41d325c203cecf6b4788b5de2a3ac8ecf75aa9c8 /tmk_core | |
parent | 6a7b6815de398553be79d35a3a808e4781596d6b (diff) |
[Core] Optimize matrix processing (#7621)
Backport of tmk/tmk_keyboard@ad6059adc7039a54d1db75da783068654906a679
Diffstat (limited to 'tmk_core')
-rw-r--r-- | tmk_core/common/keyboard.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c index 96f7b5ffe4..091b76bdfa 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c @@ -292,13 +292,14 @@ void keyboard_task(void) { } #endif if (debug_matrix) matrix_print(); - for (uint8_t c = 0; c < MATRIX_COLS; c++) { - if (matrix_change & ((matrix_row_t)1 << c)) { + matrix_row_t col_mask = 1; + for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { + if (matrix_change & col_mask) { action_exec((keyevent_t){ - .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & ((matrix_row_t)1 << c)), .time = (timer_read() | 1) /* time should not be 0 */ + .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ }); // record a processed key - matrix_prev[r] ^= ((matrix_row_t)1 << c); + matrix_prev[r] ^= col_mask; #ifdef QMK_KEYS_PER_SCAN // only jump out if we have processed "enough" keys. if (++keys_processed >= QMK_KEYS_PER_SCAN) |