tmk_keyboard icon indicating copy to clipboard operation
tmk_keyboard copied to clipboard

MODS_KEY variant to invert modifiers

Open tmk opened this issue 6 years ago • 0 comments

[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 avatar Mar 11 '18 01:03 tmk