isActive() should take pressed & sticky states into consideration

If a one-shot key is held, or is sticky, then we do not care about the timeout.
The `isActive()` method was adjusted to do so.

Signed-off-by: Gergely Nagy <kaleidoscope@gergo.csillger.hu>
pull/389/head
Gergely Nagy 7 years ago
parent 1ef65294ed
commit a5883b4b2e

@ -210,12 +210,13 @@ void OneShot::begin(void) {
}
bool OneShot::isActive(void) {
return (state_.all && !hasTimedOut());
return (state_.all && !hasTimedOut()) || (pressed_state_.all) || (sticky_state_.all);
}
bool OneShot::isActive(Key key) {
uint8_t idx = key.raw - ranges::OS_FIRST;
return bitRead(state_.all, idx) && !hasTimedOut();
return (bitRead(state_.all, idx) && !hasTimedOut()) || (isPressed(idx)) || (isSticky(idx));
}
bool OneShot::isModifierActive(Key key) {

Loading…
Cancel
Save