Implement getKeyswitchStateAtPosition

Signed-off-by: Gergely Nagy <algernon@keyboard.io>
pull/427/head^2
Gergely Nagy 7 years ago
parent 9b6cf1ce14
commit 0e57322903

@ -225,6 +225,15 @@ void ErgoDox::attachToHost() {
UDCON &= ~(1 << DETACH);
}
uint8_t ErgoDox::getKeyswitchStateAtPosition(byte row, byte col) {
return bitRead(keyState_[row], col);
}
uint8_t ErgoDox::getKeyswitchStateAtPosition(uint8_t keyIndex) {
keyIndex--;
return getKeyswitchStateAtPosition(keyIndex / COLS, keyIndex % COLS);
}
}
}

@ -87,6 +87,18 @@ class ErgoDox {
void unMaskKey(byte row, byte col);
bool isKeyMasked(byte row, byte col);
/** Key switch state
*
* These two methods return the state of the keyswitch at any given position,
* regardless of which half they are on. This is a hardware-agnostic access to
* the key switch states.
*
* The first variant requires a row and a column, the second an index, as
* returned by `keyIndex`.
*/
uint8_t getKeyswitchStateAtPosition(byte row, byte col);
uint8_t getKeyswitchStateAtPosition(uint8_t keyIndex);
// ErgoDox-specific stuff
void setStatusLED(uint8_t led, bool state = true);
void setStatusLEDBrightness(uint8_t led, uint8_t brightness);

Loading…
Cancel
Save