zmkfirmware / zmk

ZMK Firmware Repository
https://zmk.dev/
MIT License
2.72k stars 2.77k forks source link

[BUG] Mod-taps getting stuck #2001

Open w0uld opened 11 months ago

w0uld commented 11 months ago

Reviving issue #986 | I've encountered a very similar issue, but instead of combos, it's paired with layer switching.

Configuration here: /config/corneish_zen.keymap Layers involved are DVRK and ACNT.

Long story short:

Notes:

I decided to switch to mod-morphs to see if the issue persisted. With mod-morphs instead of layer switches, the issue is non-existent. This is my workaround for the time being.


Log after pressing & releasing layer switch, mod-tap, and a third key (to trigger the hold behavior) in a very short timeframe, causing the issue to occur:

[00:07:19.739,654] zmk: peripheral_event_work_callback: Trigger key position state change for 40 [00:07:19.739,685] zmk: position_state_changed_listener: 40 bubble (no undecided hold_tap active) [00:07:19.739,776] zmk: zmk_keymap_apply_position_state: layer: 0 position: 40, binding name: STICKY_LAYER [00:07:19.739,807] zmk: on_sticky_key_binding_released: Another key was pressed while the sticky key was pressed. Act like a normal key. [00:07:19.739,837] zmk: mo_keymap_binding_released: position 40 layer 3 [00:07:19.739,868] zmk: set_layer_state: layer_changed: layer 3 state 0 [00:07:19.773,162] zmk: kscan_matrix_read: Sending event at 0,1 state off [00:07:19.773,345] zmk: zmk_kscan_process_msgq: Row: 0, col: 1, position: 1, pressed: false [00:07:19.773,376] zmk: position_state_changed_listener: 1 bubble (no undecided hold_tap active) [00:07:19.773,437] zmk: zmk_keymap_apply_position_state: layer: 3 position: 1, binding name: KEY_PRESS [00:07:19.773,468] zmk: on_keymap_binding_released: position 1 keycode 0x7006F [00:07:19.773,529] zmk: hid_listener_keycode_released: usage_page 0x07 keycode 0x6F implicit_mods 0x00 explicit_mods 0x00 [00:07:19.773,529] zmk: zmk_hid_implicit_modifiers_release: Modifiers set to 0x00 [00:07:19.773,559] zmk: zmk_endpoints_send_report: usage page 0x07 [00:07:20.424,163] zmk: kscan_matrix_read: Sending event at 0,1 state on [00:07:20.424,316] zmk: zmk_kscan_process_msgq: Row: 0, col: 1, position: 1, pressed: true [00:07:20.424,377] zmk: position_state_changed_listener: 1 bubble (no undecided hold_tap active) [00:07:20.424,407] zmk: position_state_down: combo: capturing position event 1 [00:07:20.424,438] zmk: zmk_event_manager_handle_from: Listener captured the event [00:07:20.444,519] zmk: filter_timed_out_candidates: after filtering out timed out combo candidates: remaining_candidates=1 timestamp=440444 [00:07:20.474,639] zmk: filter_timed_out_candidates: after filtering out timed out combo candidates: remaining_candidates=0 timestamp=440474 [00:07:20.474,670] zmk: release_pressed_keys: combo: releasing position event 1 [00:07:20.474,731] zmk: zmk_keymap_apply_position_state: layer: 0 position: 1, binding name: KEY_PRESS [00:07:20.474,761] zmk: on_keymap_binding_pressed: position 1 keycode 0x70034 [00:07:20.474,822] zmk: hid_listener_keycode_pressed: usage_page 0x07 keycode 0x34 implicit_mods 0x00 explicit_mods 0x00 [00:07:20.474,822] zmk: zmk_hid_implicit_modifiers_press: Modifiers set to 0x00 [00:07:20.474,853] zmk: zmk_endpoints_send_report: usage page 0x07 [00:07:20.502,166] zmk: kscan_matrix_read: Sending event at 0,1 state off [00:07:20.502,288] zmk: zmk_kscan_process_msgq: Row: 0, col: 1, position: 1, pressed: false [00:07:20.502,349] zmk: position_state_changed_listener: 1 bubble (no undecided hold_tap active) [00:07:20.502,410] zmk: zmk_keymap_apply_position_state: layer: 0 position: 1, binding name: KEY_PRESS [00:07:20.502,441] zmk: on_keymap_binding_released: position 1 keycode 0x70034 [00:07:20.502,502] zmk: hid_listener_keycode_released: usage_page 0x07 keycode 0x34 implicit_mods 0x00 explicit_mods 0x00 [00:07:20.502,502] zmk: zmk_hid_implicit_modifiers_release: Modifiers set to 0x00 [00:07:20.502,532] zmk: zmk_endpoints_send_report: usage page 0x07

caksoylar commented 11 months ago

Can you note the exact order of key presses and releases and position of the key for the keymap that you linked? I am having a bit of trouble understanding you reproduce it, maybe others would be confused as well.

As a bonus, that info would make it much easier to create a test that would reproduce the issue, which in turn makes it easier to debug and fix.

w0uld commented 11 months ago

The keys involved are:

  1. [position 40] &sl ACNT (right thumb cluster middle key)
  2. [position 35] &mt LSHFT EQUAL (bottom row rightmost key)
  3. [postions 1-4 | 13-17] any of the ACNT layer's F15-F23 keys on the left hand side

Order of pressing: 1, 2, 3 Order of release: can't tell exactly, the issue occurs only if I release them almost immediately and pretty much at the same time.

Is this what you're looking for, or you'd need me to be more specific in some areas? Happy to provide more information, but with me being new to this I'm not sure what's deemed useful. :)


Relevant layers:

                dvorak_layer {
                        label = "DVRK";
                        bindings = <
// ╭───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────╮   ╭───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────╮
      &lt NAVI TAB      &kp APOS        &kp COMMA       &kp DOT         &kp P           &kp Y               &kp F           &kp G           &kp C           &kp R           &kp L           &kp FSLH
// ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤   ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤
        &kp LCTRL       &kp A           &kp O           &kp E           &kp U           &kp I               &kp D           &kp H           &kp T           &kp N           &kp S           &kp MINUS
// ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤   ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤
        &kp LSHFT       &kp SEMI        &kp Q           &kp J           &kp K           &kp X               &kp B           &kp M           &kp W           &kp V           &kp Z       &mt LSHFT EQUAL
// ╰───────────────┴───────────────┴───────────────┼───────────────┼───────────────┼───────────────┤   ├───────────────┼───────────────┼───────────────┼───────────────┴───────────────┴───────────────╯
                                                        &kp LALT        &kp SPACE   &_lt NMBR SPACE      &lt NAVI BSPC      &sl ACNT      &mt LGUI RET
//                                                 ╰───────────────┴───────────────┴───────────────╯   ╰───────────────┴───────────────┴───────────────╯
                        >;
                };
                accent_layer {
                        label = "ACNT";
                        bindings = <
// ╭───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────╮   ╭───────────────┬───────────────┬───────────────┬───────────────┬───────────────┬───────────────╮
        &trans          &kp F20         &kp F21         &kp F22         &kp F23         &trans              &trans          &trans          &trans          &trans          &trans          &trans
// ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤   ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤
        &trans          &kp F15         &kp F16         &kp F17         &kp F18         &kp F19             &trans          &trans          &trans          &trans          &trans          &trans
// ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤   ├───────────────┼───────────────┼───────────────┼───────────────┼───────────────┼───────────────┤
        &trans          &trans          &trans          &trans          &trans          &trans              &trans          &trans          &trans          &trans          &trans          &trans
// ╰───────────────┴───────────────┴───────────────┼───────────────┼───────────────┼───────────────┤   ├───────────────┼───────────────┼───────────────┼───────────────┴───────────────┴───────────────╯
                                                        &caps_word      &trans          &trans              &trans          &trans          &trans
//                                                 ╰───────────────┴───────────────┴───────────────╯   ╰───────────────┴───────────────┴───────────────╯
                        >;
                };

Timings:

#define _QUIKTAP_MS 250
#define _TAPTERM_MS 200

&mt settings:

    &mt {
        quick_tap_ms = <_QUIKTAP_MS>;
        tapping_term_ms = <_TAPTERM_MS>;
        // flavor = "balanced";
        flavor = "hold-preferred";
        retro-tap;
    };
caksoylar commented 11 months ago

That is helpful, thanks.

If you wanted to go the extra mile, you could try writing a test like I mentioned. What I usually try to do is reproduce the issue, then start simplifying the setup until it no longer reproduces. Simplifying involves e.g. removing combos, reducing the layer size to only contain the necessary keys, remove extra properties from behaviors, etc. This is much easier to do with a test since you don't have to flash your keyboard everytime and try to reproduce press/release timings manually.

w0uld commented 11 months ago

Looking at the description it doesn't look like I'd be able to actually run the test. I'm on Windows, and as far as I understand the guide I'd need to set up a Linux environment to do this. :(

caksoylar commented 11 months ago

I see, I use WSL2 on Windows with Ubuntu/Debian for ZMK work, but it is up to you whether you want to invest in it or not.

w0uld commented 11 months ago

That part is somewhat over my level of expertise. I apologize, I think I'll have to pass on that. :/