diff options
| author | Drashna Jaelre <drashna@live.com> | 2019-12-16 08:31:59 -0800 |
|---|---|---|
| committer | Joel Challis <git@zvecr.com> | 2019-12-16 16:31:59 +0000 |
| commit | 85f4c3ebb456c2d6feebf8934ab014436d7f8f17 (patch) | |
| tree | 5a817cf65085107ada0565e8c6133cf2ccc83ed1 /tmk_core | |
| parent | 853b99954ed021d52ae4d7afe17651437fce4df9 (diff) | |
| download | qmk_firmware-85f4c3ebb456c2d6feebf8934ab014436d7f8f17.tar.gz qmk_firmware-85f4c3ebb456c2d6feebf8934ab014436d7f8f17.zip | |
[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 125f00ccf..af2b2fd48 100644 --- a/tmk_core/common/keyboard.c +++ b/tmk_core/common/keyboard.c | |||
| @@ -297,13 +297,14 @@ void keyboard_task(void) { | |||
| 297 | } | 297 | } |
| 298 | #endif | 298 | #endif |
| 299 | if (debug_matrix) matrix_print(); | 299 | if (debug_matrix) matrix_print(); |
| 300 | for (uint8_t c = 0; c < MATRIX_COLS; c++) { | 300 | matrix_row_t col_mask = 1; |
| 301 | if (matrix_change & ((matrix_row_t)1 << c)) { | 301 | for (uint8_t c = 0; c < MATRIX_COLS; c++, col_mask <<= 1) { |
| 302 | if (matrix_change & col_mask) { | ||
| 302 | action_exec((keyevent_t){ | 303 | action_exec((keyevent_t){ |
| 303 | .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & ((matrix_row_t)1 << c)), .time = (timer_read() | 1) /* time should not be 0 */ | 304 | .key = (keypos_t){.row = r, .col = c}, .pressed = (matrix_row & col_mask), .time = (timer_read() | 1) /* time should not be 0 */ |
| 304 | }); | 305 | }); |
| 305 | // record a processed key | 306 | // record a processed key |
| 306 | matrix_prev[r] ^= ((matrix_row_t)1 << c); | 307 | matrix_prev[r] ^= col_mask; |
| 307 | #ifdef QMK_KEYS_PER_SCAN | 308 | #ifdef QMK_KEYS_PER_SCAN |
| 308 | // only jump out if we have processed "enough" keys. | 309 | // only jump out if we have processed "enough" keys. |
| 309 | if (++keys_processed >= QMK_KEYS_PER_SCAN) | 310 | if (++keys_processed >= QMK_KEYS_PER_SCAN) |
