Skip to content

Commit

Permalink
[Core] Optimize matrix processing (qmk#7621)
Browse files Browse the repository at this point in the history
  • Loading branch information
drashna authored and patrl committed Dec 29, 2019
1 parent f6b8432 commit f0a5ab6
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions tmk_core/common/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -297,13 +297,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)
Expand Down

0 comments on commit f0a5ab6

Please sign in to comment.