Add `OneShot_ActiveStickyKey`

This key makes any held key (or otherwise active key, most likely OneShot keys)
sticky when it toggles on.

Signed-off-by: Michael Richters <gedankenexperimenter@gmail.com>
pull/1024/head
Michael Richters 4 years ago
parent 52c1aef362
commit 58f56236a1
No known key found for this signature in database
GPG Key ID: 1288FD13E4EEF0C0

@ -50,6 +50,18 @@ EventHandlerResult ActiveModColorEffect::onKeyswitchEvent(
::OneShot.isActive(key_addr)) {
mod_key_bits_.set(key_addr);
}
if (key == OneShot_ActiveStickyKey) {
for (KeyAddr entry_addr : KeyAddr::all()) {
// Get the entry from the keymap cache
Key entry_key = Layer.lookup(entry_addr);
// Skip empty entries
if (entry_key == Key_Transparent || entry_key == Key_NoKey) {
continue;
}
// Highlight everything else
mod_key_bits_.set(entry_addr);
}
}
} else if (keyToggledOff(key_state)) {
// Things get a bit ugly here because this plugin might come
// before OneShot in the order, so we can't just count on OneShot

@ -210,6 +210,26 @@ EventHandlerResult OneShot::onKeyswitchEvent(
if (keyToggledOn(key_state)) {
// Make all held keys sticky if `OneShot_ActiveStickyKey` toggles on.
if (key == OneShot_ActiveStickyKey) {
// Skip the stickify key itself
for (KeyAddr entry_addr : KeyAddr::all()) {
if (entry_addr == key_addr) {
continue;
}
// Get the entry from the keymap cache
Key entry_key = live_keys[entry_addr];
// Skip empty entries
if (entry_key == Key_Transparent || entry_key == Key_NoKey) {
continue;
}
// Make everything else sticky
temp_addrs_.clear(entry_addr);
glue_addrs_.set(entry_addr);
}
return EventHandlerResult::OK;
}
if (!temp && !glue) {
// This key_addr is not in a OneShot state.
#ifndef ONESHOT_WITHOUT_METASTICKY

@ -63,6 +63,7 @@
// ----------------------------------------------------------------------------
// Key constants
constexpr Key OneShot_MetaStickyKey {kaleidoscope::ranges::OS_META_STICKY};
constexpr Key OneShot_ActiveStickyKey {kaleidoscope::ranges::OS_ACTIVE_STICKY};
namespace kaleidoscope {
namespace plugin {

@ -79,6 +79,7 @@ enum : uint16_t {
DYNAMIC_MACRO_FIRST,
DYNAMIC_MACRO_LAST = DYNAMIC_MACRO_FIRST + 31,
OS_META_STICKY,
OS_ACTIVE_STICKY,
OS_CANCEL,
SAFE_START,

Loading…
Cancel
Save