Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MODS_KEY variant to invert modifiers #540

Open
tmk opened this issue Mar 11, 2018 · 0 comments
Open

MODS_KEY variant to invert modifiers #540

tmk opened this issue Mar 11, 2018 · 0 comments

Comments

@tmk
Copy link
Owner

tmk commented Mar 11, 2018

[NOT COMPLETED. STILL WORKING ON]

Let's think about emulating number row of Porgrammer Dvorak or French AZERTY
https://www.kaufmann.no/roland/dvorak/
https://en.wikipedia.org/wiki/AZERTY

const actionactionmaps[][][] PROGMEM = {
    [0] = {{ ACTION_LAYER_MODS(1, MOD_LSFT),     ACTION_MODS_KEY(MOD_LSFT, KC_1) }},
    [1] = {{ ACTION_TRNS,                        ACTION_MODS_KEY(MOD_LST, KC_1) }}
};

Send key regardless of other modifier states

When right flag without any modifier, key is sent with canceling current modifier state.

MODS_KEY(MOD_RIGHT | MOD_NONE, KC_1)

if (action.kind.id == ACT_RMODS && action.key.mod == 0) {
    if (event.pressed) {
        uint8_t r = get_real_mods();
        uint8_t w = get_weak_mods();
        // clear mods
        set_real_mods(0);
        send_keybaord_report();
        register_code(action.key.code);
        set_real_mods(r);
        set_weak_mods(w);
    } else {
    }

Repeating problem of MODS_KEY()

With enabling repetition of MODS_KEY() press MODS_KEY(MOD_LSFT, KC_1) and then KC_2, users expect '!!!222' but they will see '!!!@@@' instead.

Modifiers should effect only on target key, remove the modifiers immediately after send the target key.
Fix:

diff --git a/tmk_core/common/action.c b/tmk_core/common/action.c
index 9b139d4..63185f2 100644
--- a/tmk_core/common/action.c
+++ b/tmk_core/common/action.c
@@ -86,10 +86,12 @@ void process_action(keyrecord_t *record)
                         send_keyboard_report();
                     }
                     register_code(action.key.code);
+                    if (mods) {
+                        del_weak_mods(mods);
+                    }
                 } else {
                     unregister_code(action.key.code);
                     if (mods) {
-                        del_weak_mods(mods);
                         send_keyboard_report();
                     }
                 }
@tmk tmk mentioned this issue May 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant