From b5413fb99c1aa5f2b3ba3d45b38c2c87cc309929 Mon Sep 17 00:00:00 2001 From: Dom H Date: Fri, 16 Apr 2021 22:57:31 +0100 Subject: [PATCH] Configure macros for multi-key combos This makes use of the functionality in the following PR: https://github.com/zmkfirmware/zmk/pull/685 --- Makefile | 24 +++++++++++++++++----- config/combos.dtsi | 37 ++++++++++++++++++++++++++++++++++ config/cradio.keymap | 6 ++++++ config/macros.dtsi | 48 ++++++++++++++++++++++++++++++++++++++++++++ config/west.yml | 11 ---------- 5 files changed, 110 insertions(+), 16 deletions(-) create mode 100644 config/macros.dtsi delete mode 100644 config/west.yml diff --git a/Makefile b/Makefile index 6dd6c63..63db09f 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,14 @@ board=nice_nano shield=cradio -zmk_app=${HOME}/code/zmk/app zmk_config=${HOME}/zmk-config -build=${zmk_config}/.build +zmk=${zmk_config}/zmk +zmk_image=zmkfirmware/zmk-dev-arm:2.4 +build=${zmk}/build bootloader=/media/${USER}/NICENANO define do_build mkdir -pv "${build}/${shield}_$(1)" - cd "${zmk_app}" && \ + cd "${zmk}/app" && \ west build --pristine -d "${build}/${shield}_$(1)" -b "${board}" \ -- -DSHIELD="${shield}_$(1)" -DZMK_CONFIG="${zmk_config}/config" endef @@ -21,7 +22,20 @@ endef .PHONY: build flash clean -build: +zmk: + # Get ZMK codebase: + git clone https://github.com/zmkfirmware/zmk ${zmk} + # Apply patches: + git -C ${zmk} remote add -ft macros okke-formsa https://github.com/okke-formsma/zmk + git -C ${zmk} remote add -ft cradio-v2 davidphilipbarr https://github.com/davidphilipbarr/zmk + git -C ${zmk} merge davidphilipbarr/cradio-v2 --no-edit --no-gpg-sign + git -C ${zmk} merge okke-formsa/macros --no-edit --no-gpg-sign + # Set up workspace: + docker run --rm --userns=host --user=$(shell id -u) \ + --workdir="/zmk" --volume="${zmk}:/zmk" "${zmk_image}" \ + sh -c 'west init -l app; west update' + +build: zmk $(call do_build,left) $(call do_build,right) @@ -32,4 +46,4 @@ flash-right: $(call do_flash,right) clean: - rm -rf ${build} + rm -rf ${build} ${zmk} diff --git a/config/combos.dtsi b/config/combos.dtsi index 689092d..820c6d1 100644 --- a/config/combos.dtsi +++ b/config/combos.dtsi @@ -136,4 +136,41 @@ combos { key-positions = <32 17>; }; + // Common patterns + + combo_double_dash { + bindings = <¯o_double_dash>; + key-positions = <31 11 12>; + }; + + combo_double_ampersand { + bindings = <¯o_double_ampersand>; + key-positions = <32 28 29>; + }; + + combo_brackets { + bindings = <¯o_brackets>; + key-positions = <32 7 8>; + }; + + combo_code_fence { + bindings = <¯o_code_fence>; + key-positions = <31 12 13>; + }; + + combo_double_pipe { + bindings = <¯o_double_pipe>; + key-positions = <31 21 22>; + }; + + combo_parentheses { + bindings = <¯o_parentheses>; + key-positions = <31 1 2>; + }; + + combo_shell_command { + bindings = <¯o_shell_command>; + key-positions = <31 1 2 3>; + }; + }; diff --git a/config/cradio.keymap b/config/cradio.keymap index 202389e..411ca1e 100644 --- a/config/cradio.keymap +++ b/config/cradio.keymap @@ -19,6 +19,12 @@ #include "combos.dtsi" + behaviors { + + #include "macros.dtsi" + + }; + keymap { compatible = "zmk,keymap"; diff --git a/config/macros.dtsi b/config/macros.dtsi new file mode 100644 index 0000000..3271e16 --- /dev/null +++ b/config/macros.dtsi @@ -0,0 +1,48 @@ +macro_double_dash: macro_double_dash { + compatible = "zmk,behavior-macro"; + label = "macro_double_dash"; + #binding-cells = <0>; + bindings = <&kp MINUS>, <&kp MINUS>; +}; + +macro_double_ampersand: macro_double_ampersand { + compatible = "zmk,behavior-macro"; + label = "macro_double_ampersand"; + #binding-cells = <0>; + bindings = <&kp AMPERSAND>, <&kp AMPERSAND>; +}; + +macro_brackets: macro_brackets { + compatible = "zmk,behavior-macro"; + label = "macro_brackets"; + #binding-cells = <0>; + bindings = <&kp LEFT_BRACKET>, <&kp RIGHT_BRACKET>, <&kp LEFT>; +}; + +macro_code_fence: macro_code_fence { + compatible = "zmk,behavior-macro"; + label = "macro_code_fence"; + #binding-cells = <0>; + bindings = <&kp GRAVE>, <&kp GRAVE>, <&kp GRAVE>; +}; + +macro_double_pipe: macro_double_pipe { + compatible = "zmk,behavior-macro"; + label = "macro_double_pipe"; + #binding-cells = <0>; + bindings = <&kp PIPE>, <&kp PIPE>, <&kp LEFT>; +}; + +macro_parentheses: macro_parentheses { + compatible = "zmk,behavior-macro"; + label = "macro_parentheses"; + #binding-cells = <0>; + bindings = <&kp LEFT_PARENTHESIS>, <&kp RIGHT_PARENTHESIS>, <&kp LEFT>; +}; + +macro_shell_command: macro_shell_command { + compatible = "zmk,behavior-macro"; + label = "macro_shell_command"; + #binding-cells = <0>; + bindings = <&kp DOLLAR>, <&kp LEFT_PARENTHESIS>, <&kp RIGHT_PARENTHESIS>, <&kp LEFT>; +}; diff --git a/config/west.yml b/config/west.yml deleted file mode 100644 index 379d291..0000000 --- a/config/west.yml +++ /dev/null @@ -1,11 +0,0 @@ -manifest: - remotes: - - name: zmkfirmware - url-base: https://github.com/zmkfirmware - projects: - - name: zmk - remote: zmkfirmware - revision: main - import: app/west.yml - self: - path: config