Skip to content

Commit

Permalink
Fix MATRIX_HAS_GHOST when MATRIX_COL > 16
Browse files Browse the repository at this point in the history
When MATRIX_COL > 16 get_real_keys() does not work correctly because the
1 << col overflows, since matrix_row_t is uint32_t. This causes
  keypresses to be lost on keyboards with more than 16 columns.
  • Loading branch information
cberner committed Mar 12, 2023
1 parent 042e42d commit 59f278b
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quantum/keyboard.c
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata) {
matrix_row_t out = 0;
for (uint8_t col = 0; col < MATRIX_COLS; col++) {
// read each key in the row data and check if the keymap defines it as a real key
if (keycode_at_keymap_location(0, row, col) && (rowdata & (1 << col))) {
if (keycode_at_keymap_location(0, row, col) && (rowdata & (((matrix_row_t)1) << col))) {
// this creates new row data, if a key is defined in the keymap, it will be set here
out |= 1 << col;
out |= ((matrix_row_t)1) << col;
}
}
return out;
Expand Down

0 comments on commit 59f278b

Please sign in to comment.