From b1ceb4bb6abe01e98b9ae0a36b7b87cdb383884a Mon Sep 17 00:00:00 2001 From: Denis Savran Date: Mon, 18 Apr 2022 12:12:25 +0300 Subject: Fix one-shot locked modifiers (#16114) * Fix state updates of one-shot locked modifiers Activating additional one-shot locked modifiers removed previously enabled locked modifiers from the state. `get_oneshot_locked_mods` returned zero when two or more one-shot locked modifiers were enabled and then one was disabled. * Do not delete one-shot locked modifiers on a one-shot layer toggle Non-locked one-shot modifiers are not removed so this behavior adds inconsistency. Also the one-shot locked modifiers state was reset without unregistering any modifiers. --- quantum/action.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/quantum/action.c b/quantum/action.c index ef059f0e2a..4e81a5466f 100644 --- a/quantum/action.c +++ b/quantum/action.c @@ -404,7 +404,7 @@ void process_action(keyrecord_t *record, action_t action) { } else if (tap_count == ONESHOT_TAP_TOGGLE) { dprint("MODS_TAP: Toggling oneshot"); clear_oneshot_mods(); - set_oneshot_locked_mods(mods); + set_oneshot_locked_mods(mods | get_oneshot_locked_mods()); register_mods(mods); # endif } else { @@ -418,8 +418,8 @@ void process_action(keyrecord_t *record, action_t action) { // Retain Oneshot mods # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 if (mods & get_mods()) { - clear_oneshot_locked_mods(); clear_oneshot_mods(); + set_oneshot_locked_mods(~mods & get_oneshot_locked_mods()); unregister_mods(mods); } } else if (tap_count == ONESHOT_TAP_TOGGLE) { @@ -623,7 +623,6 @@ void process_action(keyrecord_t *record, action_t action) { # if defined(ONESHOT_TAP_TOGGLE) && ONESHOT_TAP_TOGGLE > 1 do_release_oneshot = false; if (event.pressed) { - del_mods(get_oneshot_locked_mods()); if (get_oneshot_layer_state() == ONESHOT_TOGGLED) { reset_oneshot_layer(); layer_off(action.layer_tap.val); @@ -633,10 +632,8 @@ void process_action(keyrecord_t *record, action_t action) { set_oneshot_layer(action.layer_tap.val, ONESHOT_START); } } else { - add_mods(get_oneshot_locked_mods()); if (tap_count >= ONESHOT_TAP_TOGGLE) { reset_oneshot_layer(); - clear_oneshot_locked_mods(); set_oneshot_layer(action.layer_tap.val, ONESHOT_TOGGLED); } else { clear_oneshot_layer_state(ONESHOT_PRESSED); -- cgit v1.2.1