Skip to content

Commit

Permalink
Fix one-shot locked modifiers (qmk#16114)
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
denis-savran authored and zykrah committed Jul 2, 2022
1 parent d9d7399 commit 353b35e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
4 changes: 0 additions & 4 deletions keyboards/chickenman/ciel/ciel.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,7 @@
k400, k401, k402, k407, k411, k413, k414 \
) { \
{ k000, k001, k002, k003, k004, k005, k006, k007, k008, k009, k010, k011, k012, k013, k014 }, \
<<<<<<< HEAD
{ k100, k101, k102, k103, k104, k105, k106, k107, k108, k109, k110, k111, k112, KC_NO, k114 }, \
=======
{ k100, k101, k102, k103, k104, k105, k106, k107, k108, k109, k110, k111, k112, KC_NO, k414 }, \
>>>>>>> 8826a1dea5 ([Keyboard] Add the Ciel (#16816))
{ k200, k201, k202, k203, k204, k205, k206, k207, k208, k209, k210, k211, KC_NO, k213, KC_NO}, \
{ k300, KC_NO, k302, k303, k304, k305, k306, k307, k308, k309, k310, k311, KC_NO, k313, k314 }, \
{ k400, k401, k402, KC_NO, KC_NO, KC_NO, KC_NO, k407, KC_NO, KC_NO, KC_NO, k411, KC_NO, k413, k414 } \
Expand Down
9 changes: 3 additions & 6 deletions quantum/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,7 @@ void process_action(keyrecord_t *record, action_t action) {
} else if (QS_oneshot_tap_toggle > 1 && tap_count == QS_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);
} else {
register_mods(mods | get_oneshot_mods());
Expand All @@ -417,8 +417,8 @@ void process_action(keyrecord_t *record, action_t action) {
// Retain Oneshot mods
if (QS_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);
}
}
Expand Down Expand Up @@ -622,7 +622,6 @@ if (QS_oneshot_tap_toggle > 1) {
if (QS_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);
Expand All @@ -632,10 +631,8 @@ if (QS_oneshot_tap_toggle > 1) {
set_oneshot_layer(action.layer_tap.val, ONESHOT_START);
}
} else {
add_mods(get_oneshot_locked_mods());
if (tap_count >= QS_oneshot_tap_toggle) {
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);
Expand Down

0 comments on commit 353b35e

Please sign in to comment.