KeyboardHardware: add a 'previousPressedKeyswitchCount'

to enable the test mode

Signed-off-by: Jesse Vincent <jesse@keyboard.io>
pull/595/head
Jesse Vincent 6 years ago
parent 813bd5a06d
commit ba7144669f

@ -277,6 +277,14 @@ class Hardware {
return false; return false;
} }
/**
* Check the number of key switches pressed in the previous scan.
*
* @returns the number of keys pressed.
*/
uint8_t previousPressedKeyswitchCount() {
return 0;
}
/** @} */ /** @} */

@ -86,6 +86,14 @@ bool ATMegaKeyboard::isKeyswitchPressed(uint8_t keyIndex) {
} }
uint8_t ATMegaKeyboard::previousPressedKeyswitchCount() {
uint8_t count = 0;
for (int8_t r = 0; r < KeyboardHardware.matrix_rows; r++) {
count += __builtin_popcount(KeyboardHardware.previousKeyState_[r]);
}
return count;
}
bool ATMegaKeyboard::wasKeyswitchPressed(uint8_t row, byte col) { bool ATMegaKeyboard::wasKeyswitchPressed(uint8_t row, byte col) {
return (bitRead(KeyboardHardware.previousKeyState_[row], col) != 0); return (bitRead(KeyboardHardware.previousKeyState_[row], col) != 0);

@ -86,6 +86,7 @@ class ATMegaKeyboard : public kaleidoscope::Hardware {
bool isKeyswitchPressed(uint8_t row, byte col); bool isKeyswitchPressed(uint8_t row, byte col);
bool isKeyswitchPressed(uint8_t keyIndex); bool isKeyswitchPressed(uint8_t keyIndex);
uint8_t previousPressedKeyswitchCount();
bool wasKeyswitchPressed(uint8_t row, byte col); bool wasKeyswitchPressed(uint8_t row, byte col);
bool wasKeyswitchPressed(uint8_t keyIndex); bool wasKeyswitchPressed(uint8_t keyIndex);

@ -241,6 +241,14 @@ bool ErgoDox::wasKeyswitchPressed(uint8_t keyIndex) {
return wasKeyswitchPressed(keyIndex / COLS, keyIndex % COLS); return wasKeyswitchPressed(keyIndex / COLS, keyIndex % COLS);
} }
uint8_t ErgoDox::previousPressedKeyswitchCount() {
uint8_t count = 0;
for (uint8_t r = 0; r < ROWS; r++) {
count += __builtin_popcount(previousKeyState_[r]);
}
return count;
}
uint8_t ErgoDox::pressedKeyswitchCount() { uint8_t ErgoDox::pressedKeyswitchCount() {
uint8_t count = 0; uint8_t count = 0;

@ -71,6 +71,7 @@ class ErgoDox : public kaleidoscope::Hardware {
bool wasKeyswitchPressed(byte row, byte col); bool wasKeyswitchPressed(byte row, byte col);
bool wasKeyswitchPressed(uint8_t keyIndex); bool wasKeyswitchPressed(uint8_t keyIndex);
uint8_t previousPressedKeyswitchCount();
// ErgoDox-specific stuff // ErgoDox-specific stuff
void setStatusLED(uint8_t led, bool state = true); void setStatusLED(uint8_t led, bool state = true);

@ -323,6 +323,10 @@ uint8_t Model01::pressedKeyswitchCount() {
return __builtin_popcountl(leftHandState.all) + __builtin_popcountl(rightHandState.all); return __builtin_popcountl(leftHandState.all) + __builtin_popcountl(rightHandState.all);
} }
uint8_t Model01::previousPressedKeyswitchCount() {
return __builtin_popcountl(previousLeftHandState.all) + __builtin_popcountl(previousRightHandState.all);
}
} }
} }
} }

@ -74,6 +74,7 @@ class Model01 : public kaleidoscope::Hardware {
bool wasKeyswitchPressed(byte row, byte col); bool wasKeyswitchPressed(byte row, byte col);
bool wasKeyswitchPressed(uint8_t keyIndex); bool wasKeyswitchPressed(uint8_t keyIndex);
uint8_t previousPressedKeyswitchCount();
keydata_t leftHandState; keydata_t leftHandState;
keydata_t rightHandState; keydata_t rightHandState;

Loading…
Cancel
Save