Skip to content

Commit

Permalink
kbscan: Remove comparing matrix to keymap
Browse files Browse the repository at this point in the history
Remove checking against the real keys declared in the keymap. It appears
to have no effect on behavior.

Signed-off-by: Tim Crawford <tcrawford@system76.com>
  • Loading branch information
crawfxrd authored and jackpot51 committed Jul 29, 2023
1 parent 0f2ff7e commit d4ecd8a
Showing 1 changed file with 2 additions and 19 deletions.
21 changes: 2 additions & 19 deletions src/board/system76/common/kbscan.c
Original file line number Diff line number Diff line change
Expand Up @@ -103,26 +103,10 @@ static inline bool popcount_more_than_one(uint8_t rowdata) {
return rowdata & (rowdata - 1);
}

static uint8_t kbscan_get_real_keys(uint8_t row, uint8_t rowdata) {
// Remove any "active" blanks from the matrix.
uint8_t realdata = 0;
for (uint8_t col = 0; col < KM_IN; col++) {
// This tests the default keymap intentionally, to avoid blanks in the
// dynamic keymap
if (KEYMAP[0][row][col] && (rowdata & BIT(col))) {
realdata |= BIT(col);
}
}

return realdata;
}

static bool kbscan_row_has_ghost(uint8_t *matrix, uint8_t col) {
uint8_t rowdata = matrix[col];

rowdata = kbscan_get_real_keys(col, matrix[col]);

// No ghosts exist when less than 2 keys in the row are active.
// No ghosts exist when less than 2 keys in the row are active.
if (!popcount_more_than_one(rowdata)) {
return false;
}
Expand All @@ -133,8 +117,7 @@ static bool kbscan_row_has_ghost(uint8_t *matrix, uint8_t col) {
continue;
}

uint8_t otherrow = kbscan_get_real_keys(i, matrix[i]);
uint8_t common = rowdata & otherrow;
uint8_t common = rowdata & matrix[i];
if (popcount_more_than_one(common)) {
return true;
}
Expand Down

0 comments on commit d4ecd8a

Please sign in to comment.