summaryrefslogtreecommitdiff
path: root/quantum/debounce/sym_defer_g.c
diff options
context:
space:
mode:
authorStefan Kerkmann <karlk90@pm.me>2022-07-07 10:00:40 +0200
committerGitHub <noreply@github.com>2022-07-07 10:00:40 +0200
commit8224f62806b66f0825b68fd8c00436ee57a28e9a (patch)
tree33e16a84a05073fd439e6a86f09631132a546794 /quantum/debounce/sym_defer_g.c
parentcca5d3532128a9d1aa2ab39405d935fc132c752d (diff)
Make debounce() signal changes in the cooked matrix as return value (#17554)
Diffstat (limited to 'quantum/debounce/sym_defer_g.c')
-rw-r--r--quantum/debounce/sym_defer_g.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/quantum/debounce/sym_defer_g.c b/quantum/debounce/sym_defer_g.c
index 47450992a4..d04310a761 100644
--- a/quantum/debounce/sym_defer_g.c
+++ b/quantum/debounce/sym_defer_g.c
@@ -20,6 +20,7 @@ When no state changes have occured for DEBOUNCE milliseconds, we push the state.
#include "matrix.h"
#include "timer.h"
#include "quantum.h"
+#include <string.h>
#ifndef DEBOUNCE
# define DEBOUNCE 5
#endif
@@ -30,18 +31,23 @@ static fast_timer_t debouncing_time;
void debounce_init(uint8_t num_rows) {}
-void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) {
+ bool cooked_changed = false;
+
if (changed) {
debouncing = true;
debouncing_time = timer_read_fast();
}
if (debouncing && timer_elapsed_fast(debouncing_time) >= DEBOUNCE) {
- for (int i = 0; i < num_rows; i++) {
- cooked[i] = raw[i];
+ if (memcmp(cooked, raw, sizeof(matrix_row_t) * num_rows) != 0) {
+ memcpy(cooked, raw, sizeof(matrix_row_t) * num_rows);
+ cooked_changed = true;
}
debouncing = false;
}
+
+ return cooked_changed;
}
void debounce_free(void) {}