diff options
author | Stefan Kerkmann <karlk90@pm.me> | 2022-07-07 10:00:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-07-07 10:00:40 +0200 |
commit | 8224f62806b66f0825b68fd8c00436ee57a28e9a (patch) | |
tree | 33e16a84a05073fd439e6a86f09631132a546794 /quantum/debounce/sym_defer_pr.c | |
parent | cca5d3532128a9d1aa2ab39405d935fc132c752d (diff) |
Make debounce() signal changes in the cooked matrix as return value (#17554)
Diffstat (limited to 'quantum/debounce/sym_defer_pr.c')
-rw-r--r-- | quantum/debounce/sym_defer_pr.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/quantum/debounce/sym_defer_pr.c b/quantum/debounce/sym_defer_pr.c index ce24f0922f..452c4599d0 100644 --- a/quantum/debounce/sym_defer_pr.c +++ b/quantum/debounce/sym_defer_pr.c @@ -46,11 +46,12 @@ void debounce_free(void) { last_raw = NULL; } -void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { - uint16_t now = timer_read(); - uint16_t elapsed16 = TIMER_DIFF_16(now, last_time); - last_time = now; - uint8_t elapsed = (elapsed16 > 255) ? 255 : elapsed16; +bool debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool changed) { + uint16_t now = timer_read(); + uint16_t elapsed16 = TIMER_DIFF_16(now, last_time); + last_time = now; + uint8_t elapsed = (elapsed16 > 255) ? 255 : elapsed16; + bool cooked_changed = false; uint8_t* countdown = countdowns; @@ -63,10 +64,13 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool } else if (*countdown > elapsed) { *countdown -= elapsed; } else if (*countdown) { + cooked_changed |= cooked[row] ^ raw_row; cooked[row] = raw_row; *countdown = 0; } } + + return cooked_changed; } bool debounce_active(void) { |