Make the debounce counters count down

This commit is contained in:
Eric Tang
2018-06-26 21:58:48 -07:00
parent ff99c2e734
commit cdfabaec42
2 changed files with 4 additions and 4 deletions

View File

@@ -11,8 +11,8 @@ void PIT_KEY_DEBOUNCER_HANDLER(void)
for (uint8_t slotId=0; slotId<SLOT_COUNT; slotId++) {
for (uint8_t keyId=0; keyId<MAX_KEY_COUNT_PER_MODULE; keyId++) {
uint8_t *debounceCounter = &KeyStates[slotId][keyId].debounceCounter;
if (*debounceCounter < 0xff) {
(*debounceCounter)++;
if (*debounceCounter) {
--(*debounceCounter);
}
}
}

View File

@@ -324,10 +324,10 @@ static void updateActiveUsbReports(void)
key_state_t *keyState = &KeyStates[slotId][keyId];
key_action_t *action = &CurrentKeymap[activeLayer][slotId][keyId];
if (keyState->debounceCounter < KEY_DEBOUNCER_TIMEOUT_MSEC) {
if (keyState->debounceCounter) {
keyState->current = keyState->previous;
} else if (keyState->previous != keyState->current) {
keyState->debounceCounter = 0;
keyState->debounceCounter = KEY_DEBOUNCER_TIMEOUT_MSEC + 1;
}
if (keyState->current) {