diff options
Diffstat (limited to 'quantum/debounce/eager_pk.c')
| -rw-r--r-- | quantum/debounce/eager_pk.c | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/quantum/debounce/eager_pk.c b/quantum/debounce/eager_pk.c index aa0f63a9d..c07be18f8 100644 --- a/quantum/debounce/eager_pk.c +++ b/quantum/debounce/eager_pk.c | |||
| @@ -39,6 +39,7 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred. | |||
| 39 | 39 | ||
| 40 | static debounce_counter_t *debounce_counters; | 40 | static debounce_counter_t *debounce_counters; |
| 41 | static bool counters_need_update; | 41 | static bool counters_need_update; |
| 42 | static bool matrix_need_update; | ||
| 42 | 43 | ||
| 43 | #define DEBOUNCE_ELAPSED 251 | 44 | #define DEBOUNCE_ELAPSED 251 |
| 44 | #define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1) | 45 | #define MAX_DEBOUNCE (DEBOUNCE_ELAPSED - 1) |
| @@ -63,7 +64,7 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool | |||
| 63 | update_debounce_counters(num_rows, current_time); | 64 | update_debounce_counters(num_rows, current_time); |
| 64 | } | 65 | } |
| 65 | 66 | ||
| 66 | if (changed) { | 67 | if (changed || matrix_need_update) { |
| 67 | transfer_matrix_values(raw, cooked, num_rows, current_time); | 68 | transfer_matrix_values(raw, cooked, num_rows, current_time); |
| 68 | } | 69 | } |
| 69 | } | 70 | } |
| @@ -88,16 +89,21 @@ void update_debounce_counters(uint8_t num_rows, uint8_t current_time) { | |||
| 88 | 89 | ||
| 89 | // upload from raw_matrix to final matrix; | 90 | // upload from raw_matrix to final matrix; |
| 90 | void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) { | 91 | void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) { |
| 92 | matrix_need_update = false; | ||
| 91 | debounce_counter_t *debounce_pointer = debounce_counters; | 93 | debounce_counter_t *debounce_pointer = debounce_counters; |
| 92 | for (uint8_t row = 0; row < num_rows; row++) { | 94 | for (uint8_t row = 0; row < num_rows; row++) { |
| 93 | matrix_row_t delta = raw[row] ^ cooked[row]; | 95 | matrix_row_t delta = raw[row] ^ cooked[row]; |
| 94 | matrix_row_t existing_row = cooked[row]; | 96 | matrix_row_t existing_row = cooked[row]; |
| 95 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { | 97 | for (uint8_t col = 0; col < MATRIX_COLS; col++) { |
| 96 | matrix_row_t col_mask = (ROW_SHIFTER << col); | 98 | matrix_row_t col_mask = (ROW_SHIFTER << col); |
| 97 | if ((delta & col_mask) && *debounce_pointer == DEBOUNCE_ELAPSED) { | 99 | if (delta & col_mask) { |
| 98 | *debounce_pointer = current_time; | 100 | if (*debounce_pointer == DEBOUNCE_ELAPSED) { |
| 99 | counters_need_update = true; | 101 | *debounce_pointer = current_time; |
| 100 | existing_row ^= col_mask; // flip the bit. | 102 | counters_need_update = true; |
| 103 | existing_row ^= col_mask; // flip the bit. | ||
| 104 | } else { | ||
| 105 | matrix_need_update = true; | ||
| 106 | } | ||
| 101 | } | 107 | } |
| 102 | debounce_pointer++; | 108 | debounce_pointer++; |
| 103 | } | 109 | } |
