Skip to content

Commit

Permalink
matrix: wait for row signal to go HIGH for every row (qmk#12945)
Browse files Browse the repository at this point in the history
I noticed this discrepancy (last row of the matrix treated differently than the
others) when optimizing the input latency of my keyboard controller, see also
https://michael.stapelberg.ch/posts/2021-05-08-keyboard-input-latency-qmk-kinesis/

Before this commit, when tuning the delays I noticed ghost key presses when
pressing the F2 key, which is on the last row of the keyboard matrix: the
dead_grave key, which is on the first row of the keyboard matrix, would be
incorrectly detected as pressed.

After this commit, all keyboard matrix rows are interpreted correctly.

I suspect that my setup is more susceptible to this nuance than others because I
use GPIO_INPUT_PIN_DELAY=0 and hence don’t have another delay that might mask
the problem.
  • Loading branch information
stapelberg authored and nhongooi committed Dec 5, 2021
1 parent a3e92b7 commit fe34c5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 12 deletions.
8 changes: 2 additions & 6 deletions quantum/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)

// Unselect row
unselect_row(current_row);
if (current_row + 1 < MATRIX_ROWS) {
matrix_output_unselect_delay(); // wait for row signal to go HIGH
}
matrix_output_unselect_delay(); // wait for all Col signals to go HIGH

// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
Expand Down Expand Up @@ -178,9 +176,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)

// Unselect col
unselect_col(current_col);
if (current_col + 1 < MATRIX_COLS) {
matrix_output_unselect_delay(); // wait for col signal to go HIGH
}
matrix_output_unselect_delay(); // wait for all Row signals to go HIGH

return matrix_changed;
}
Expand Down
8 changes: 2 additions & 6 deletions quantum/split_common/matrix.c
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,7 @@ static bool read_cols_on_row(matrix_row_t current_matrix[], uint8_t current_row)

// Unselect row
unselect_row(current_row);
if (current_row + 1 < MATRIX_ROWS) {
matrix_output_unselect_delay(); // wait for row signal to go HIGH
}
matrix_output_unselect_delay(); // wait for all Col signals to go HIGH

// If the row has changed, store the row and return the changed flag.
if (current_matrix[current_row] != current_row_value) {
Expand Down Expand Up @@ -192,9 +190,7 @@ static bool read_rows_on_col(matrix_row_t current_matrix[], uint8_t current_col)

// Unselect col
unselect_col(current_col);
if (current_col + 1 < MATRIX_COLS) {
matrix_output_unselect_delay(); // wait for col signal to go HIGH
}
matrix_output_unselect_delay(); // wait for all Row signals to go HIGH

return matrix_changed;
}
Expand Down

0 comments on commit fe34c5c

Please sign in to comment.