Make debounce() signal changes in the cooked matrix as return value (#17554)
This commit is contained in:
@ -48,6 +48,7 @@ static bool matrix_need_update;
|
||||
static debounce_counter_t *debounce_counters;
|
||||
static fast_timer_t last_time;
|
||||
static bool counters_need_update;
|
||||
static bool cooked_changed;
|
||||
|
||||
# define DEBOUNCE_ELAPSED 0
|
||||
|
||||
@ -67,8 +68,9 @@ void debounce_free(void) {
|
||||
debounce_counters = NULL;
|
||||
}
|
||||
|
||||
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 updated_last = false;
|
||||
cooked_changed = false;
|
||||
|
||||
if (counters_need_update) {
|
||||
fast_timer_t now = timer_read_fast();
|
||||
@ -92,6 +94,8 @@ void debounce(matrix_row_t raw[], matrix_row_t cooked[], uint8_t num_rows, bool
|
||||
|
||||
transfer_matrix_values(raw, cooked, num_rows);
|
||||
}
|
||||
|
||||
return cooked_changed;
|
||||
}
|
||||
|
||||
// If the current time is > debounce counter, set the counter to enable input.
|
||||
@ -123,8 +127,9 @@ static void transfer_matrix_values(matrix_row_t raw[], matrix_row_t cooked[], ui
|
||||
// determine new value basd on debounce pointer + raw value
|
||||
if (existing_row != raw_row) {
|
||||
if (*debounce_pointer == DEBOUNCE_ELAPSED) {
|
||||
*debounce_pointer = DEBOUNCE;
|
||||
cooked[row] = raw_row;
|
||||
*debounce_pointer = DEBOUNCE;
|
||||
cooked[row] = raw_row;
|
||||
cooked_changed |= cooked[row] ^ raw[row];
|
||||
counters_need_update = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user