diff options
author | dexter93 <d3xter93@gmail.com> | 2022-12-08 18:09:01 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-09 03:09:01 +1100 |
commit | f2a8a13dbad220cfb0dfbd72a90492a15a2e58bb (patch) | |
tree | 92c2389bba9eb8faa00b13e68b57f8196e87fc84 /quantum | |
parent | 6668a0adb0b482a4b9adfab6693fc1b98a7eb16c (diff) |
Core: Support inverted scan logic for optical switches (#19053)
Diffstat (limited to 'quantum')
-rw-r--r-- | quantum/matrix.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/quantum/matrix.c b/quantum/matrix.c index db683104ed..0de65c6cdd 100644 --- a/quantum/matrix.c +++ b/quantum/matrix.c @@ -46,6 +46,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. # define SPLIT_MUTABLE_COL const #endif +#ifndef MATRIX_INPUT_PRESSED_STATE +# define MATRIX_INPUT_PRESSED_STATE 0 +#endif + #ifdef DIRECT_PINS static SPLIT_MUTABLE pin_t direct_pins[ROWS_PER_HAND][MATRIX_COLS] = DIRECT_PINS; #elif (DIODE_DIRECTION == ROW2COL) || (DIODE_DIRECTION == COL2ROW) @@ -93,7 +97,7 @@ static inline void setPinInputHigh_atomic(pin_t pin) { static inline uint8_t readMatrixPin(pin_t pin) { if (pin != NO_PIN) { - return readPin(pin); + return (readPin(pin) == MATRIX_INPUT_PRESSED_STATE) ? 0 : 1; } else { return 1; } @@ -121,9 +125,7 @@ __attribute__((weak)) void matrix_read_cols_on_row(matrix_row_t current_matrix[] matrix_row_t row_shifter = MATRIX_ROW_SHIFTER; for (uint8_t col_index = 0; col_index < MATRIX_COLS; col_index++, row_shifter <<= 1) { pin_t pin = direct_pins[current_row][col_index]; - if (pin != NO_PIN) { - current_row_value |= readPin(pin) ? 0 : row_shifter; - } + current_row_value |= readMatrixPin(pin) ? 0 : row_shifter; } // Update the matrix |