kbscan: Return early if debouncing
A single timer is used for debouncing all keys, so there is no reason to perform any operations if the matrix is being debounced. Just return early and remove some of the convoluted logic. Signed-off-by: Tim Crawford <tcrawford@system76.com>
This commit is contained in:
committed by
Jeremy Soller
parent
8a1adc2bdc
commit
546458e368
@ -328,8 +328,11 @@ void kbscan_event(void) {
|
||||
if (debounce) {
|
||||
uint32_t time = time_get();
|
||||
if ((time - debounce_time) >= DEBOUNCE_DELAY) {
|
||||
// Finish debounce
|
||||
// Debounce time elapsed: Read new state
|
||||
debounce = false;
|
||||
} else {
|
||||
// If still debouncing, don't do anything.
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -338,11 +341,11 @@ void kbscan_event(void) {
|
||||
uint8_t last = kbscan_matrix[i];
|
||||
if (new != last) {
|
||||
if (kbscan_has_ghost_in_row(i, new)) {
|
||||
kbscan_ghost[i] = true;
|
||||
continue;
|
||||
} else if (kbscan_ghost[i]) {
|
||||
kbscan_ghost[i] = false;
|
||||
// Debounce to allow remaining ghosts to settle.
|
||||
}
|
||||
|
||||
// Some key has changed state: Start debounce
|
||||
if (!debounce) {
|
||||
debounce = true;
|
||||
debounce_time = time_get();
|
||||
}
|
||||
@ -356,15 +359,6 @@ void kbscan_event(void) {
|
||||
if (new_b != last_b) {
|
||||
bool reset = false;
|
||||
|
||||
// If debouncing
|
||||
if (debounce) {
|
||||
// Debounce presses and releases
|
||||
reset = true;
|
||||
} else {
|
||||
// Begin debounce
|
||||
debounce = true;
|
||||
debounce_time = time_get();
|
||||
|
||||
// Check keys used for config reset
|
||||
if (matrix_position_is_esc(i, j))
|
||||
kbscan_esc_held = new_b;
|
||||
@ -399,7 +393,6 @@ void kbscan_event(void) {
|
||||
} else {
|
||||
WARN("KB %d, %d, %d missing\n", i, j, kbscan_layer);
|
||||
}
|
||||
}
|
||||
|
||||
// Reset bit to last state
|
||||
if (reset) {
|
||||
|
Reference in New Issue
Block a user