Skip to content

Commit

Permalink
Configure macros for multi-key combos
Browse files Browse the repository at this point in the history
This makes use of the functionality in the following PR:
zmkfirmware/zmk#685
  • Loading branch information
dxmh authored and Dom H committed Apr 16, 2021
1 parent 5784959 commit b5413fb
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 16 deletions.
24 changes: 19 additions & 5 deletions 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
Expand All @@ -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)

Expand All @@ -32,4 +46,4 @@ flash-right:
$(call do_flash,right)

clean:
rm -rf ${build}
rm -rf ${build} ${zmk}
37 changes: 37 additions & 0 deletions config/combos.dtsi
Expand Up @@ -136,4 +136,41 @@ combos {
key-positions = <32 17>;
};

// Common patterns

combo_double_dash {
bindings = <&macro_double_dash>;
key-positions = <31 11 12>;
};

combo_double_ampersand {
bindings = <&macro_double_ampersand>;
key-positions = <32 28 29>;
};

combo_brackets {
bindings = <&macro_brackets>;
key-positions = <32 7 8>;
};

combo_code_fence {
bindings = <&macro_code_fence>;
key-positions = <31 12 13>;
};

combo_double_pipe {
bindings = <&macro_double_pipe>;
key-positions = <31 21 22>;
};

combo_parentheses {
bindings = <&macro_parentheses>;
key-positions = <31 1 2>;
};

combo_shell_command {
bindings = <&macro_shell_command>;
key-positions = <31 1 2 3>;
};

};
6 changes: 6 additions & 0 deletions config/cradio.keymap
Expand Up @@ -19,6 +19,12 @@

#include "combos.dtsi"

behaviors {

#include "macros.dtsi"

};

keymap {
compatible = "zmk,keymap";

Expand Down
48 changes: 48 additions & 0 deletions 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>;
};
11 changes: 0 additions & 11 deletions config/west.yml

This file was deleted.

0 comments on commit b5413fb

Please sign in to comment.