Optimize matrix scanning (#343)

This commit is contained in:
Eric Tang 2016-05-23 20:42:21 -07:00 committed by Jack Humbert
parent d66aa0abf9
commit aaa758f1d3
21 changed files with 421 additions and 518 deletions

View file

@ -105,15 +105,13 @@ void bootmagic(void)
}
}
static bool scan_keycode(uint8_t keycode)
{
for (uint8_t r = 0; r < MATRIX_ROWS; r++) {
static bool scan_keycode(uint8_t keycode) {
for (int8_t r = MATRIX_ROWS - 1; r >= 0; --r) {
matrix_row_t matrix_row = matrix_get_row(r);
for (uint8_t c = 0; c < MATRIX_COLS; c++) {
if (matrix_row & ((matrix_row_t)1<<c)) {
if (keycode == keymap_key_to_keycode(0, (keypos_t){ .row = r, .col = c })) {
return true;
}
for (int8_t c = MATRIX_COLS - 1; c >= 0; --c) {
if (matrix_row & (matrix_row_t)1 << c) {
keypos_t key = (keypos_t){ .row = r, .col = c };
if (keycode == keymap_key_to_keycode(0, key)) return true;
}
}
}