zmkfirmware / zmk

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

Keymap stopped working properly after charging #2601

Closed dimitrioschr closed 3 weeks ago

dimitrioschr commented 3 weeks ago

I have a nice!nano implementation of ErgoDash, and a keymap that I settled on. The keyboard and keymap have been unchanged and working properly for many days now.

Yesterday I plugged in both halfs of the keyboard to a powerbank to top up the batteries, and today a specific key misbehaves. In particular, the key normally is a layer-tap that taps Backspace and holds into the Numbers layer.

The behaviour since this morning is that the key has become a layer-tap of Backspace and Navigation layer. The keyboard / keymap behaves normally in all other aspects (layers, hold-taps, quicktap terms for keyrepeats, etc).

I reflashed with the settings-reset firmware and then the known working firmware with my keymap and the issue persists!

I made a trivial change in my repo and rebuilt the firmware, then reflashed with settings-reset and keymap firmware, and the issue persists again!

Please note again that there does not appear to be any wiring issue, as the keys respond normally and the tap action of the particular key is correct, only the hold has changed.

Any ideas? Thank you

PS The keymap is below, the offending key is dBSPC in the first layer (#define dBSPC &lt _NUMBER BSPC) and suddenly it behaves like &lt _NAVI BSPC .

/*
 * Copyright (c) 2020 The ZMK Contributors
 *
 * SPDX-License-Identifier: MIT
 */

#include <behaviors.dtsi>
#include <dt-bindings/zmk/keys.h>
#include <dt-bindings/zmk/bt.h>

#define _QWERTY   0
#define _NAVI     1
#define _NUMBER   2
#define _FUNCTION 3
#define _SYMBOL   4
#define _BLUE     5

#define dQ &ht EXCL Q
#define dW &ht AT W
#define dE &ht HASH E
#define dR &ht DOLLAR R
#define dT &ht PERCENT T

#define dA &ht LGUI A
#define dS &ht LALT S
#define dD &ht LCTRL D
#define dF &ht LSHIFT F
#define dG &ht PLUS G

#define dZ &kp Z
#define dX &ht LBRC X
#define dC &ht LBKT C
#define dV &ht LPAR V
#define dB &ht ASTERISK B

#define dTILD &ht GRAVE TILDE

#define dY &ht CARET Y
#define dU &ht AMPS U
#define dI &ht ASTERISK I
#define dO &ht UNDERSCORE O
#define dP &ht EQUAL P

#define dH &ht MINUS H
#define dJ &ht LSHIFT J
#define dK &ht LCTRL K
#define dL &ht LALT L
#define dCOLN &ht SEMICOLON COLON

#define dN &ht SLASH N
#define dM &ht RPAR M
#define dCOMM &ht RBKT COMMA
#define dDOT &ht RBRC DOT
#define dSLSH &ht QUESTION SLASH

#define dDQT &ht SQT DQT
#define dBSLS &ht PIPE BACKSLASH

#define dOSL &sl _SYMBOL

#define dBSPC &lt _NUMBER BSPC
#define dDEL &lt _FUNCTION DEL
#define dSPC &lt _NAVI SPACE

&mt {
        tapping-term-ms = <200>;
        quick-tap-ms = <200>;
        // default quick tap ms is 120
        // require-prior-idle-ms = <100>;
};

&lt {
        tapping-term-ms = <200>;
        quick-tap-ms = <200>;
        // default quick tap ms is 120
        // require-prior-idle-ms = <100>;
};

/ {

        behaviors {
            ht: hold_tap {
                compatible = "zmk,behavior-hold-tap";
                #binding-cells = <2>;
                flavor = "tap-preferred";
                tapping-term-ms = <200>;
                quick-tap-ms = <200>;
                // default quick tap ms is 120
                // require-prior-idle-ms = <100>;
                bindings = <&kp>, <&kp>;
            };
        };

        macros {
                cut: cut {
                        compatible = "zmk,behavior-macro";
                        #binding-cells = <0>;
                        bindings
                            = <&macro_press &kp LCTRL>
                            , <&macro_tap &kp X>
                            , <&macro_release &kp LCTRL>
                            ;
                };
                copy: copy {
                        compatible = "zmk,behavior-macro";
                        #binding-cells = <0>;
                        bindings
                            = <&macro_press &kp LCTRL>
                            , <&macro_tap &kp C>
                            , <&macro_release &kp LCTRL>
                            ;
                };
                paste: paste {
                        compatible = "zmk,behavior-macro";
                        #binding-cells = <0>;
                        bindings
                            = <&macro_press &kp LCTRL>
                            , <&macro_tap &kp V>
                            , <&macro_release &kp LCTRL>
                            ;
                };
                undo: undo {
                        compatible = "zmk,behavior-macro";
                        #binding-cells = <0>;
                        bindings
                            = <&macro_press &kp LCTRL>
                            , <&macro_tap &kp Z>
                            , <&macro_release &kp LCTRL>
                            ;
                };
                redo: redo {
                        compatible = "zmk,behavior-macro";
                        #binding-cells = <0>;
                        bindings
                            = <&macro_press &kp LCTRL>
                            , <&macro_tap &kp Y>
                            , <&macro_release &kp LCTRL>
                            ;
                };
        };

        keymap {
                compatible = "zmk,keymap";

                default_layer {
/* .----------------------------------------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      |      |                    |      |      |      |      |      |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * | ESC  |   ~  |   W  |   E  |   R  |   T  | @BT@ |                    |      |   Y  |   U  |   I  |   O  |   -  |   =  |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * | Tab  |   Q  |   S  |   D  |   F  |   G  |      |                    |      |   H  |   J  |   K  |   L  |   P  |   \  |
 * |------+------+------+------+------+------+---------------------------+------+------+------+------+------+------+------|
 * |OSL(S)|   A  |   X  |   C  |   V  |   B  |      |                    |      |   N  |   M  |   ,  |   .  |   :  |   "  |
 * |-------------+------+------+------+------+------+------+------+------+------+------+------+------+------+-------------|
 * |      |   Z  |      |      |||||||| @@@  | BSPC | DEL  |||||||| ENT  | SPC  | @@@  ||||||||      |      |   /  |      |
 * .----------------------------------------------------------------------------------------------------------------------.
 */
                        bindings = <
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &none         &none
&kp ESC       dTILD         dW            dE            dR            dT            &mo _BLUE              &none         dY            dU            dI            dO            &kp  MINUS    &kp  EQUAL
&kp TAB       dQ            dS            dD            dF            dG            &none                  &none         dH            dJ            dK            dL            dP            dBSLS
dOSL          dA            dX            dC            dV            dB            &none                  &none         dN            dM            dCOMM         dDOT          dCOLN         dDQT
&none         dZ            &none         &none         &mo _NAVI     dBSPC         dDEL                   &kp RET       dSPC          &to _NAVI     &none         &none         dSLSH         &none
                        >;
                };
                navi_layer {
/* .----------------------------------------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      |      |                    |      |      |      |      |      |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |  ESC |      |      |  TAB |      | C(Y) |      |                    |      |      | HOME |   UP | PGUP |   -  |   =  |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |  TAB |      | LALT | LCTL | LSHFT|      |      |                    |      |      | LEFT | DOWN | RGHT |      |      |
 * |------+------+------+------+------+------+---------------------------+------+------+------+------+------+------+------|
 * |OSL(S)| LGUI | C(X) | C(C) | C(V) |      |      |                    |      |      | END  |      | PGDN |      |      |
 * |-------------+------+------+------+------+------+------+------+------+------+------+------+------+------+-------------|
 * |      | C(Z) |      |      ||||||||  @@@ | BSPC |  DEL ||||||||  ENT |  SPC |  @@@ ||||||||      |      |      | RCtrl|
 * .----------------------------------------------------------------------------------------------------------------------.
 */
                        bindings = <
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &none         &none
&kp ESC       &none         &none         &kp TAB       &none         &redo         &none                  &none         &none         &kp HOME      &kp UP        &kp PG_UP     &kp MINUS     &kp EQUAL
&kp TAB       &none         &kp LALT      &kp LCTRL     &kp LSHFT     &none         &none                  &none         &none         &kp LEFT      &kp DOWN      &kp RIGHT     &none         &none
dOSL          &kp LGUI      &cut          &copy         &paste        &none         &none                  &none         &none         &kp END       &none         &kp PG_DN     &none         &trans
&none         &undo         &none         &none         &to _QWERTY   dBSPC         dDEL                   &kp RET       dSPC          &to _NAVI     &none         &none         &none         &trans
                        >;
                };
                number_layer {
/* .----------------------------------------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      |      |                    |      |      |      |      |      |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |      |      |      |      |      |      |                    |      |      |   7  |   8  |   9  |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |      | LALT | LCTL | LSHFT|    + |      |                    |      |   -  |   4  |   5  |   6  |      |   \  |
 * |------+------+------+------+------+------+---------------------------+------+------+------+------+------+------+------|
 * |      | LGUI |      |      |      |    * |      |                    |      |   /  |   1  |   2  |   3  |      |      |
 * |-------------+------+------+------+------+------+------+------+------+------+------+------+------+------+-------------|
 * |      |      |      |      ||||||||      |      |      ||||||||      |   0  |   0  ||||||||   0  |   .  |   /  |      |
 * .----------------------------------------------------------------------------------------------------------------------.
 */
                        bindings = <
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &none         &none
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &kp KP_N7     &kp KP_N8     &kp KP_N9     &none         &none
&none         &none         &kp LALT      &kp LCTRL     &kp LSHFT     &kp PLUS      &none                  &none         &kp MINUS     &kp KP_N4     &kp KP_N5     &kp KP_N6     &none         &kp BACKSLASH
&none         &kp LGUI      &none         &none         &none         &kp STAR      &none                  &none         &kp SLASH     &kp KP_N1     &kp KP_N2     &kp KP_N3     &none         &none
&none         &none         &none         &none         &none         &none         &none                  &none         &kp KP_N0     &kp KP_N0     &kp KP_N0     &kp DOT       &kp SLASH     &none
                        >;
                };
                function_layer {
/* .----------------------------------------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      |      |                    |      |      |      |      |      |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |      |      |      |      |      |      |                    |      |      |  F7  |  F8  |  F9  |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |      | LALT | LCTL | LSHFT|      |      |                    |      |      |  F4  |  F5  |  F6  |  F10 |      |
 * |------+------+------+------+------+------+---------------------------+------+------+------+------+------+------+------|
 * |      | LGUI |      |      |      |      |      |                    |      |      |  F1  |  F2  |  F3  |  F11 |      |
 * |-------------+------+------+------+------+------+------+------+------+------+------+------+------+------+-------------|
 * |      |      |      |      ||||||||      |      |      ||||||||      |      |      ||||||||      |      |  F12 |      |
 * .----------------------------------------------------------------------------------------------------------------------.
 */
                        bindings = <
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &none         &none
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &kp F7        &kp F8        &kp F9        &none         &none
&none         &none         &kp LALT      &kp LCTRL     &kp LSHFT     &kp PLUS      &none                  &none         &none         &kp F4        &kp F5        &kp F6        &kp F10       &none
&none         &kp LGUI      &none         &none         &none         &kp STAR      &none                  &none         &none         &kp F1        &kp F2        &kp F3        &kp F11       &none
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &kp F12       &none
                        >;
                };
                symbol_layer {
/* .----------------------------------------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      |      |                    |      |      |      |      |      |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |   ~  |   @  |   #  |   $  |   %  |      |                    |      |   ^  |   &  |   *  |   _  |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |   !  |   {  |   [  |   (  |   +  |      |                    |      |   -  |   )  |   ]  |   }  |   =  |   |  |
 * |------+------+------+------+------+------+---------------------------+------+------+------+------+------+------+------|
 * |--C_W-|   !  |      |      |      |      |      |                    |      |      |---<--|--->--|   :  |   "  |      |
 * |-------------+------+------+------+------+------+------+------+------+------+------+------+------+------+-------------|
 * |      |      |      |      ||||||||      |--C_L-|      ||||||||      |      |      ||||||||      |   ?  |      |      |
 * .----------------------------------------------------------------------------------------------------------------------.
 */
                        bindings = <
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &none         &none
&none         &kp TILDE     &kp AT        &kp HASH      &kp DOLLAR    &kp PERCENT   &none                  &none         &kp CARET     &kp AMPS      &kp STAR      &kp UNDER     &none         &none
&none         &kp EXCL      &kp LBRC      &kp LBKT      &kp LPAR      &kp PLUS      &none                  &none         &kp MINUS     &kp RPAR      &kp RBKT      &kp RBRC      &kp EQUAL     &kp PIPE
&caps_word    &kp EXCL      &none         &none         &none         &none         &none                  &none         &none         &none         &kp LT        &kp GT        &kp COLON     &kp DQT
&none         &none         &none         &none         &none         &kp CAPS      &none                  &none         &none         &none         &none         &kp QMARK     &none         &none
                        >;
                };
                bluetooth_layer {
/* .----------------------------------------------------------------------------------------------------------------------.
 * |      |      |      |      |      |      |      |                    |      |      |      |      |      |      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |      |      |      |      |      |      |                    |      |      |SEL(0)|SEL(1)|SEL(2)|      |      |
 * |------+------+------+------+------+------+------+--------------------+------+------+------+------+------+------+------|
 * |      |      |      |      |      |      |      |                    |      |      |DSC(0)|DSC(1)|DSC(2)|      |      |
 * |------+------+------+------+------+------+---------------------------+------+------+------+------+------+------+------|
 * |      |      |      |      |      |      |      |                    |      |      |  CLR |  CLR |  CLR |      |      |
 * |-------------+------+------+------+------+------+------+------+------+------+------+------+------+------+-------------|
 * |      |      |      |      ||||||||      |      |      ||||||||      |      |      ||||||||      |      |      |      |
 * .----------------------------------------------------------------------------------------------------------------------.
 */
                        bindings = <
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &none         &none
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &bt BT_SEL 0  &bt BT_SEL 1  &bt BT_SEL 2  &none         &none
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &bt BT_DISC 0 &bt BT_DISC 1 &bt BT_DISC 2 &none         &none
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &bt BT_CLR    &bt BT_CLR    &bt BT_CLR    &none         &none
&none         &none         &none         &none         &none         &none         &none                  &none         &none         &none         &none         &none         &none         &none
                        >;
                };
        };
};
dimitrioschr commented 3 weeks ago

Nothing was wrong except:

The keymap contained numpad keycodes but did not contain NumLock key. The host's NumLock changed and it was not evident / accessible.

Closing...