summaryrefslogtreecommitdiff
path: root/quantum/debounce/eager_pr.c
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2019-06-05 18:39:00 -0700
committerFlorian Didron <fdidron@users.noreply.github.com>2019-06-06 10:39:00 +0900
commitb2f15ce2646bd8a8123b6619bee5e29ccbed56ce (patch)
tree05cba579c5da606b83e633c68e80da10e356de43 /quantum/debounce/eager_pr.c
parentdc13f5f518887af9e34f044145f9095e26ea5d80 (diff)
Fix debouncing issue for eager algos (#73)
Diffstat (limited to 'quantum/debounce/eager_pr.c')
-rw-r--r--quantum/debounce/eager_pr.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/quantum/debounce/eager_pr.c b/quantum/debounce/eager_pr.c
index 26b17ed295..8dbfa3fcfa 100644
--- a/quantum/debounce/eager_pr.c
+++ b/quantum/debounce/eager_pr.c
@@ -28,6 +28,7 @@ No further inputs are accepted until DEBOUNCE milliseconds have occurred.
#endif
#define debounce_counter_t uint8_t
+static bool matrix_need_update;
static debounce_counter_t *debounce_counters;
static bool counters_need_update;
@@ -53,7 +54,7 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
update_debounce_counters(num_rows, current_time);
}
- if (changed || (needed_update && !counters_need_update)) {
+ if (changed || (needed_update && !counters_need_update) || matrix_need_update) {
transfer_matrix_values(raw, cooked, num_rows, current_time);
}
}
@@ -76,18 +77,22 @@ void update_debounce_counters(uint8_t num_rows, uint8_t current_time) {
// upload from raw_matrix to final matrix;
void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, uint8_t current_time) {
+ matrix_need_update = false;
debounce_counter_t *debounce_pointer = debounce_counters;
for (uint8_t row = 0; row < num_rows; row++) {
matrix_row_t existing_row = cooked[row];
matrix_row_t raw_row = raw[row];
// determine new value basd on debounce pointer + raw value
- if (*debounce_pointer == DEBOUNCE_ELAPSED && (existing_row != raw_row)) {
- *debounce_pointer = current_time;
- cooked[row] = raw_row;
- counters_need_update = true;
+ if (existing_row != raw_row) {
+ if (*debounce_pointer == DEBOUNCE_ELAPSED) {
+ *debounce_pointer = current_time;
+ cooked[row] = raw_row;
+ counters_need_update = true;
+ } else {
+ matrix_need_update = true;
+ }
}
-
debounce_pointer++;
}
}