- matrix_row_t cols = read_cols(i);
- if (matrix_debouncing[i] != cols) {
- matrix_debouncing[i] = cols;
- if (debouncing) {
- debug("bounce!: "); debug_hex(debouncing); debug("\n");
- }
- debouncing = DEBOUNCE;
- }
+ // and select on left hand
+ select_row(i + MATRIX_ROWS_PER_SIDE);
+ // we don't need a 30us delay anymore, because selecting a
+ // left-hand row requires more than 30us for i2c.
+ matrix_row_t mask = debounce_mask(i);
+ matrix_row_t cols = (read_cols(i) & mask) | (matrix[i] & ~mask);
+ debounce_report(cols ^ matrix[i], i);
+ matrix[i] = cols;
+ // grab cols from right hand
+ mask = debounce_mask(i + MATRIX_ROWS_PER_SIDE);
+ cols = (read_cols(i + MATRIX_ROWS_PER_SIDE) & mask) | (matrix[i + MATRIX_ROWS_PER_SIDE] & ~mask);
+ debounce_report(cols ^ matrix[i + MATRIX_ROWS_PER_SIDE], i + MATRIX_ROWS_PER_SIDE);
+ matrix[i + MATRIX_ROWS_PER_SIDE] = cols;