From 17737c8672c1793245fc0d990c4750feeb128094 Mon Sep 17 00:00:00 2001 From: urob <978080+urob@users.noreply.github.com> Date: Wed, 13 Jul 2022 17:14:36 -0400 Subject: [PATCH] Squashed helper-macro branch commit 62e33866ccc009c645adda95297e147a6bb1b5d4 Author: urob <978080+urob@users.noreply.github.com> Date: Wed Jul 13 16:00:08 2022 -0400 Move helper.dtsi to subtree commit 635cffa0c1c0a87dadd929701225d30c119a1a9f Merge: d8dfef3 41c9041 Author: urob <978080+urob@users.noreply.github.com> Date: Wed Jul 13 16:56:44 2022 -0400 Merge commit '41c9041ccc102d7acbc4882434fa5780050a9455' as 'zmk-nodefree-config' commit 41c9041ccc102d7acbc4882434fa5780050a9455 Author: urob <978080+urob@users.noreply.github.com> Date: Wed Jul 13 16:56:44 2022 -0400 Squashed 'zmk-nodefree-config/' content from commit c7dc05e git-subtree-dir: zmk-nodefree-config git-subtree-split: c7dc05eb52b14b69ea48059ff418edad6484500e commit d8dfef3849436176bba1ff3da25ae59d1fa92abe Author: urob <978080+urob@users.noreply.github.com> Date: Mon Jul 11 23:15:51 2022 -0400 Convenience macros for a cleaner keymap config --- config/base.keymap | 171 +++++++++++------------------ zmk-nodefree-config/.gitattributes | 2 + zmk-nodefree-config/README.md | 111 +++++++++++++++++++ zmk-nodefree-config/example.keymap | 80 ++++++++++++++ zmk-nodefree-config/helper.dtsi | 32 ++++++ 5 files changed, 290 insertions(+), 106 deletions(-) create mode 100644 zmk-nodefree-config/.gitattributes create mode 100644 zmk-nodefree-config/README.md create mode 100644 zmk-nodefree-config/example.keymap create mode 100644 zmk-nodefree-config/helper.dtsi diff --git a/config/base.keymap b/config/base.keymap index 9481307..5698189 100644 --- a/config/base.keymap +++ b/config/base.keymap @@ -1,5 +1,7 @@ #include #include +#include "mouse.dtsi" +#include "../zmk-nodefree-config/helper.dtsi" #define XXX &none #define ___ &trans @@ -14,7 +16,6 @@ #define FN 4 #define UC 5 -#include "mouse.dtsi" #include "unicode.dtsi" #include "combos.dtsi" @@ -57,95 +58,67 @@ TODOs and ISSUES // global-quick-tap; }; -/* root node */ -/ { +/* homerow mods */ - behaviors { +#define LHM LM0 LM1 LM2 LM3 // left-hand HRMs +#define RHM RM1 RM2 RM3 RM4 // right-hand HRMs +#define LHK LT0 LT1 LT2 LT3 LT4 LHM LM4 LB0 LB1 LB2 LB3 LB4 // left-hand keys +#define RHK RT0 RT1 RT2 RT3 RT4 RM0 RHM RB0 RB1 RB2 RB3 RB4 // right-hand keys +#define THK LH0 LH1 LH2 RH0 RH1 RH2 // thumb keys - /* homerow mods */ +ZMK_BEHAVIOR(hml, hold_tap, + flavor = "balanced"; + tapping-term-ms = <280>; + quick-tap-ms = <125>; + global-quick-tap; + bindings = <&kp>, <&kp>; + hold-trigger-key-positions = ; // include left-hand HRMs for mod-chaining +) - #define LHM LM0 LM1 LM2 LM3 // left-hand HRMs - #define RHM RM1 RM2 RM3 RM4 // right-hand HRMs - #define LHK LT0 LT1 LT2 LT3 LT4 LHM LM4 LB0 LB1 LB2 LB3 LB4 // left-hand keys - #define RHK RT0 RT1 RT2 RT3 RT4 RM0 RHM RB0 RB1 RB2 RB3 RB4 // right-hand keys - #define THK LH0 LH1 LH2 RH0 RH1 RH2 // thumb keys +ZMK_BEHAVIOR(hmr, hold_tap, + flavor = "balanced"; + tapping-term-ms = <280>; + quick-tap-ms = <125>; + global-quick-tap; + bindings = <&kp>, <&kp>; + hold-trigger-key-positions = ; // include right-hand HRMs for mod-chaining +) - hml: left_hand_home_row_mods { - compatible = "zmk,behavior-hold-tap"; - label = "LEFT_HAND_HOME_ROW_MODS"; - flavor = "balanced"; - tapping-term-ms = <280>; - quick-tap-ms = <125>; - global-quick-tap; - #binding-cells = <2>; - bindings = <&kp>, <&kp>; - hold-trigger-key-positions = ; // include left-hand HRMs for mod-chaining - }; +/* custom keys and macros */ - hmr: right_hand_home_row_mods { - compatible = "zmk,behavior-hold-tap"; - label = "RIGHT_HAND_HOME_ROW_MODS"; - flavor = "balanced"; - tapping-term-ms = <280>; - quick-tap-ms = <125>; - global-quick-tap; - #binding-cells = <2>; - bindings = <&kp>, <&kp>; - hold-trigger-key-positions = ; // include right-hand HRMs for mod-chaining - }; +// sticky-shift that cancels capsword (used in ss_cw below). Alternatively: mod-morph ss_cw into CANCEL to swallow sticky-shift when capsword is active +ZMK_BEHAVIOR(sticky_shift, macro, + wait-ms = <0>; + tap-ms = <1>; + bindings = <¯o_tap CANCEL> // cancel caps_word; + , <¯o_press &sk LSHFT> // then tap sticky-shift and hold + , <¯o_pause_for_release> // until key release to enable + , <¯o_release &sk LSHFT>; // holding shift +) - /* custom keys and macros */ +// tap: sticky shift | double tap: capsword | triple tap: cancel capsword +ZMK_BEHAVIOR(ss_cw, tap_dance, + tapping-term-ms = <200>; + // bindings = <&sticky_shift>, <&caps_word>, ; + bindings = <&sk LSHFT>, <&caps_word>, ; +) - // sticky-shift that cancels capsword (used in ss_cw below). Alternatively: mod-morph ss_cw into CANCEL to swallow sticky-shift when capsword is active - sticky_shift: sticky_shift_cancel_capsword_macro { - compatible = "zmk,behavior-macro"; - label = "STICKY_SHIFT_CANCEL_CAPSWORD_MACRO"; - wait-ms = <0>; - tap-ms = <1>; - #binding-cells = <0>; - bindings = <¯o_tap CANCEL> // cancel caps_word; - , <¯o_press &sk LSHFT> // then tap sticky-shift and hold - , <¯o_pause_for_release> // until key release to enable - , <¯o_release &sk LSHFT>; // holding shift - }; +// tap: backspace | lshft + tap: delete | rshft + tap: shift-delete | hold: num layer +ZMK_BEHAVIOR(bs_del_num, mod_morph, + bindings = << NUM BSPC>, <&kp DEL>; + mods = <(MOD_LSFT|MOD_RSFT)>; + masked_mods = ; // requires PR #1114 +) - // tap: sticky shift | double tap: capsword | triple tap: cancel capsword - ss_cw: sticky_shift_capsword_key { - compatible = "zmk,behavior-tap-dance"; - label = "STICKY_SHIFT_CAPSWORD_KEY"; - tapping-term-ms = <200>; - #binding-cells = <0>; - // bindings = <&sticky_shift>, <&caps_word>, ; - bindings = <&sk LSHFT>, <&caps_word>, ; - }; +// Windows sleep key +ZMK_BEHAVIOR(win_sleep, macro, + wait-ms = <50>; + tap-ms = <5>; + bindings = <&kp LG(X) &kp U &kp S>; +) - // tap: backspace | lshft + tap: delete | rshft + tap: shift-delete | hold: num layer - bs_del_num: backspace_del_num_key { - compatible = "zmk,behavior-mod-morph"; - label = "BACKSPACE_DEL_NUM_KEY"; - #binding-cells = <0>; - bindings = << NUM BSPC>, <&kp DEL>; - mods = <(MOD_LSFT|MOD_RSFT)>; - masked_mods = ; // requires PR #1114 - }; - - // Windows sleep key - win_sleep: win_sleep_macro { - compatible = "zmk,behavior-macro"; - label = "WIN_SLEEP_MACRO"; - wait-ms = <50>; - tap-ms = <5>; - #binding-cells = <0>; - bindings = <&kp LG(X) &kp U &kp S>; - }; - - }; - - keymap { - compatible = "zmk,keymap"; - - default_layer { - bindings = < +/* keymap */ +ZMK_LAYER(default_layer, // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ &kp Q &kp W &kp F &kp P &kp B EXTRA_MID &kp J &kp L &kp U &kp Y &kp SQT // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ @@ -155,11 +128,9 @@ TODOs and ISSUES // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ EXTRA_BOT_L < UC ESC < NAV SPACE < SYS TAB EXTRA_MID < FN RET &ss_cw &bs_del_num EXTRA_BOT_R // ╰─────────────╯ ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────╯ ╰─────────────┴─────────────┴─────────────╯ ╰─────────────╯ - >; - }; +) - nav_layer { - bindings = < +ZMK_LAYER(nav_layer, // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ___ ___ ___ ___ ___ EXTRA_MID &kp PG_UP &kp HOME &kp UP &kp END &kp INS // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ @@ -169,11 +140,9 @@ TODOs and ISSUES // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ EXTRA_BOT_L ___ ___ ___ EXTRA_MID ___ ___ ___ EXTRA_BOT_R // ╰─────────────╯ ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────╯ ╰─────────────┴─────────────┴─────────────╯ ╰─────────────╯ - >; - }; +) - sys_layer { - bindings = < +ZMK_LAYER(sys_layer, // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ &kp LG(GRAVE) ___ ___ ___ &bootloader EXTRA_MID ___ &kp C_PREV &kp C_VOL_UP &kp C_NEXT &win_sleep // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ @@ -183,11 +152,9 @@ TODOs and ISSUES // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ EXTRA_BOT_L ___ ___ ___ EXTRA_MID &kp C_MUTE &kp C_PP ___ EXTRA_BOT_R // ╰─────────────╯ ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────╯ ╰─────────────┴─────────────┴─────────────╯ ╰─────────────╯ - >; - }; +) - num_layer { - bindings = < +ZMK_LAYER(num_layer, // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ &kp ESC &kp N7 &kp N8 &kp N9 &kp STAR EXTRA_MID ___ ___ ___ ___ ___ // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ @@ -197,11 +164,9 @@ TODOs and ISSUES // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ EXTRA_BOT_L &kp DOT &kp N0 &kp MINUS EXTRA_MID ___ ___ ___ EXTRA_BOT_R // ╰─────────────╯ ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────╯ ╰─────────────┴─────────────┴─────────────╯ ╰─────────────╯ - >; - }; +) - fn_layer { - bindings = < +ZMK_LAYER(fn_layer, // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ &kp F12 &kp F7 &kp F8 &kp F9 ___ EXTRA_MID ___ ___ ___ ___ ___ // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ @@ -211,11 +176,9 @@ TODOs and ISSUES // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ EXTRA_BOT_L &kp F10 &kp F11 &kp F12 EXTRA_MID ___ ___ ___ EXTRA_BOT_R // ╰─────────────╯ ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────╯ ╰─────────────┴─────────────┴─────────────╯ ╰─────────────╯ - >; - }; +) - uc_layer { - bindings = < +ZMK_LAYER(uc_layer, // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ___ &uc_omega &uc_phi &uc_pi &uc_beta EXTRA_MID ___ &uc_lambda &uc_upsilon &uc_psi &uc_eszett // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ @@ -225,9 +188,5 @@ TODOs and ISSUES // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ EXTRA_BOT_L ___ ___ ___ EXTRA_MID ___ ___ ___ EXTRA_BOT_R // ╰─────────────╯ ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────╯ ╰─────────────┴─────────────┴─────────────╯ ╰─────────────╯ - >; - }; - - }; -}; +) diff --git a/zmk-nodefree-config/.gitattributes b/zmk-nodefree-config/.gitattributes new file mode 100644 index 0000000..9b2b33d --- /dev/null +++ b/zmk-nodefree-config/.gitattributes @@ -0,0 +1,2 @@ +*.dtsi linguist-language=C++ +*.keymap linguist-language=C++ diff --git a/zmk-nodefree-config/README.md b/zmk-nodefree-config/README.md new file mode 100644 index 0000000..48111e6 --- /dev/null +++ b/zmk-nodefree-config/README.md @@ -0,0 +1,111 @@ +# zmk-nodefree-config + +ZMK lets user customize their keyboard layout by providing a Devicetree file +(`.keymap`). The specific syntax requirements of the Devicetree file format can, +however, make this process a bit daunting for new users. + +This repository provides simple convenience macros that simplify the configuration for +many common use cases. It results in a "node-free" user configuration with a more +streamlined syntax. Check out [example.keymap](example.keymap) to see it in action. + +## Usage overview + +1. Copy the file `helper.dtsi` from this repository into the "config" folder of your + private zmk-config repository +2. Source `helper.dtsi` near the top of your `.keymap` file: + ```C++ + #include + #include + #include "helper.dtsi" + ``` +3. Customize your keyboard's `.keymap` file. See [example.keymap](example.keymap) for a + complete example and read the documentation below for details. + +## Usage details + +`helper.dtsi` provides two convenience macros. `ZMK_BEHAVIOR` creates new behaviors, and +`ZMK_LAYER` adds new layers to your keymap. + +### ZMK\_BEHAVIOR + +The macro is invoked by calling `ZMK_BEHAVIOR(name, type, specification)`, expecting +3 arguments: +* `name` is a unique string chosen by the user (e.g., `my_behavior`). It can later be + used to reference the new behavior by preceding it by "&" (e.g., `&my_behavior`) +* `type` selects the behavior that is created. It must be one of the following: + `caps_word`, `hold_tap`, `key_repeat`, `macro`, `mod_morph`, `sticky_key` or + `tap_dance`. Note that two-word types use underscores ("\_") to separate words. +* `specification` contains the code customizing the new behavior. It should contain the + body of the corresponding [ZMK behavior configuration](https://zmk.dev/docs/config/behaviors) + without the `label`, `#binding-cells` and `compatible` properties and without the + surrounding node-specification. + +#### Example 1: Creating a custom "homerow mod" tap-hold behavior + +```C++ +ZMK_BEHAVIOR(hrm, hold_tap, + flavor = "balanced"; + tapping-term-ms = <280>; + quick-tap-ms = <125>; + global-quick-tap; + bindings = <&kp>, <&kp>; +) +``` + +The new behavior can be added to the keymap-layout using `&hrm` (e.g., `&hrm LSHIFT T` +creates a key that yields `T` on tap and `LSHIFT` on hold, using the custom +configuration above). + +#### Example 2: Creating a custom tap-dance key + +```C++ +ZMK_BEHAVIOR(ss_cw, tap_dance, + tapping-term-ms = <200>; + bindings = <&sk LSHFT>, <&caps_word>; +) +``` + +The new behavior can be added to the keymap-layout using `&ss_cw`. The key yields +sticky-shift on tap and caps-word on double tap; + +#### Example 3: Creating a custom "win-sleep" macro + +```C++ +ZMK_BEHAVIOR(win_sleep, macro, + wait-ms = <100>; + tap-ms = <5>; + bindings = <&kp LG(X) &kp U &kp S>; +) +``` + +This creates a "Windows sleep key" that can be added to the keymap-layout using +`&win_sleep`. + +### ZMK\_LAYER + +The function is invoked by calling `ZMK_LAYER(name, layout)`, expecting +2 arguments: +* `name` is a unique identifier string chosen by the user (it isn't used elsewhere) +* `layout` provides the layout specification using the same syntax as the `bindings` + property of the [ZMK keymap configuration](https://zmk.dev/docs/config/keymap) + +Multiple layers can be defined with repeated calls of `ZMK_LAYER`. They will be ordered +in the same order in which they are created, with the first-specified layer being +the "lowest" one ([see here for details](https://zmk.dev/docs/features/keymaps#layers)). + +#### Example usage +```C++ +ZMK_KEYMAP(default_layer, + // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ + &kp Q &kp W &kp F &kp P &kp B &kp J &kp L &kp U &kp Y &kp SQT + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &hrm LGUI A &hrm LALT R &hrm LCTRL S &hrm LSHFT T &kp G &kp M &hrm RSHFT N &hrm LCTRL E &hrm LALT I &hrm LGUI O + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &kp Z &kp X &kp C &kp D &kp V &kp K &kp H &kp COMMA &kp DOT &kp SEMI + // ╰─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &kp ESC < NAV SPACE &kp TAB &kp RET &ss_cw &bs_del_num + // ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────┴─────────────┴─────────────╯ +) + +``` + diff --git a/zmk-nodefree-config/example.keymap b/zmk-nodefree-config/example.keymap new file mode 100644 index 0000000..ae75ff3 --- /dev/null +++ b/zmk-nodefree-config/example.keymap @@ -0,0 +1,80 @@ +#include +#include +#include "helper.dtsi" + +/* layer and key shortcuts */ + +#define ___ &trans + +#define DEF 0 +#define NAV 1 +#define NUM 2 + +/* custom keys and macros */ + +// homerow mods +ZMK_BEHAVIOR(hrm, hold_tap, + flavor = "balanced"; + tapping-term-ms = <280>; + quick-tap-ms = <125>; + global-quick-tap; + bindings = <&kp>, <&kp>; +) + +// tap: sticky shift | double tap: capsword +ZMK_BEHAVIOR(ss_cw, tap_dance, + tapping-term-ms = <200>; + bindings = <&sk LSHFT>, <&caps_word>; +) + +// tap: backspace | shift + tap: delete | hold: num layer +ZMK_BEHAVIOR(bs_del_num, mod_morph, + bindings = << NUM BSPC>, <&kp DEL>; + mods = <(MOD_LSFT|MOD_RSFT)>; +) + +// windows sleep key +ZMK_BEHAVIOR(win_sleep, macro, + wait-ms = <100>; + tap-ms = <5>; + bindings = <&kp LG(X) &kp U &kp S>; +) + +/* keymap */ + +ZMK_LAYER(default_layer, + // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ + &kp Q &kp W &kp F &kp P &kp B &kp J &kp L &kp U &kp Y &kp SQT + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &hrm LGUI A &hrm LALT R &hrm LCTRL S &hrm LSHFT T &kp G &kp M &hrm RSHFT N &hrm LCTRL E &hrm LALT I &hrm LGUI O + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &kp Z &kp X &kp C &kp D &kp V &kp K &kp H &kp COMMA &kp DOT &kp SEMI + // ╰─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &kp ESC < NAV SPACE &kp TAB &kp RET &ss_cw &bs_del_num + // ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────┴─────────────┴─────────────╯ +) + +ZMK_LAYER(nav_layer, + // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ + ___ ___ ___ ___ ___ &kp PG_UP &kp HOME &kp UP &kp END &kp INS + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &sk LGUI &sk LALT &sk LCTRL &sk LSHFT ___ &kp PG_DN &kp LEFT &kp DOWN &kp RIGHT &kp DEL + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + ___ ___ ___ ___ ___ ___ &kp LC(X) &kp LC(INS) &kp LS(INS) ___ + // ╰─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + ___ ___ ___ ___ &win_sleep ___ + // ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────┴─────────────┴─────────────╯ +) + +ZMK_LAYER(num_layer, + // ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ + &kp ESC &kp N7 &kp N8 &kp N9 &kp STAR ___ ___ ___ ___ ___ + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &kp TAB &kp N4 &kp N5 &kp N6 &kp PLUS ___ &sk RSHFT &sk LCTRL &sk LALT &sk LGUI + // ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &kp RET &kp N1 &kp N2 &kp N3 &kp FSLH ___ ___ ___ ___ ___ + // ╰─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ + &kp DOT &kp N0 &kp MINUS ___ ___ ___ + // ╰─────────────┴──── ────────┴─────────────╯ ╰─────────────┴─────────────┴─────────────╯ +) + diff --git a/zmk-nodefree-config/helper.dtsi b/zmk-nodefree-config/helper.dtsi new file mode 100644 index 0000000..2814074 --- /dev/null +++ b/zmk-nodefree-config/helper.dtsi @@ -0,0 +1,32 @@ +/* helper.dtsi: convenience macros simplifying ZMK's keymap configuration */ + +#define ZMK_HELPER_CORE_caps_word compatible = "zmk,behavior-caps-word"; #binding-cells = <0> +#define ZMK_HELPER_CORE_hold_tap compatible = "zmk,behavior-hold-tap"; #binding-cells = <2> +#define ZMK_HELPER_CORE_key_repeat compatible = "zmk,behavior-key-repeat"; #binding-cells = <0> +#define ZMK_HELPER_CORE_macro compatible = "zmk,behavior-macro"; #binding-cells = <0> +#define ZMK_HELPER_CORE_mod_morph compatible = "zmk,behavior-mod-morph"; #binding-cells = <0> +#define ZMK_HELPER_CORE_sticky_key compatible = "zmk,behavior-sticky-key"; #binding-cells = <1> +#define ZMK_HELPER_CORE_tap_dance compatible = "zmk,behavior-tap-dance"; #binding-cells = <0> + +#define ZMK_BEHAVIOR_STRINGIFY(x) #x +#define ZMK_BEHAVIOR(name, type, ...) \ + / { \ + behaviors { \ + name: name { \ + label = ZMK_BEHAVIOR_STRINGIFY(ZB_ ## name); \ + ZMK_HELPER_CORE_ ## type; \ + __VA_ARGS__ \ + }; \ + }; \ + }; + +#define ZMK_LAYER(name, layout) \ + / { \ + keymap { \ + compatible = "zmk,keymap"; \ + name { \ + bindings = ; \ + }; \ + }; \ + }; +