Do not mask one-shot modifiers, only layers

The goal is to have one-shot modified symbols repeat (without modifier) when
held, but mask out one-shot layer interrupting keys, similar to how momentary
layers are masked out.

This fixes #11.

Signed-off-by: Gergely Nagy <algernon@madhouse-project.org>
pull/389/head
Gergely Nagy 7 years ago
parent 37ac11bb49
commit 52c8402006

@ -31,6 +31,7 @@ OneShot::state_t OneShot::pressed_state_;
Key OneShot::prev_key_;
bool OneShot::should_cancel_ = false;
bool OneShot::should_cancel_stickies_ = false;
bool OneShot::should_mask_on_interrupt_ = false;
// --- helper macros ------
@ -99,6 +100,10 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st
setOneShot(idx);
saveAsPrevious(mapped_key);
if (mapped_key >= ranges::OSL_FIRST && mapped_key <= ranges::OSL_LAST) {
should_mask_on_interrupt_ = true;
}
activateOneShot(idx);
}
@ -148,7 +153,8 @@ Key OneShot::eventHandlerHook(Key mapped_key, byte row, byte col, uint8_t key_st
// ordinary key here, with some event
if (keyIsPressed(key_state)) {
KeyboardHardware.maskKey(row, col);
if (should_mask_on_interrupt_)
KeyboardHardware.maskKey(row, col);
saveAsPrevious(mapped_key);
should_cancel_ = true;
}
@ -183,6 +189,7 @@ void OneShot::loopHook(bool is_post_clear) {
if (is_cancelled) {
should_cancel_ = false;
should_cancel_stickies_ = false;
should_mask_on_interrupt_ = false;
}
} else {
for (uint8_t i = 0; i < 8; i++) {

@ -59,6 +59,7 @@ class OneShot : public KaleidoscopePlugin {
static Key prev_key_;
static bool should_cancel_;
static bool should_cancel_stickies_;
static bool should_mask_on_interrupt_;
static void injectNormalKey(uint8_t idx, uint8_t key_state);
static void activateOneShot(uint8_t idx);

Loading…
Cancel
Save