-
Notifications
You must be signed in to change notification settings - Fork 386
/
Copy pathbase.keymap
263 lines (215 loc) · 21.7 KB
/
base.keymap
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
#include <behaviors.dtsi>
#include <behaviors/num_word.dtsi> // Requires auto-layer module.
#include <dt-bindings/zmk/keys.h>
#ifdef CONFIG_WIRELESS
#include <dt-bindings/zmk/bt.h>
#include <dt-bindings/zmk/outputs.h>
#define _BT_SEL_KEYS_ \
&bt BT_SEL 0 &bt BT_SEL 1 &bt BT_SEL 2 &bt BT_SEL 3 &bt BT_CLR
#else
#define _BT_SEL_KEYS_ &trans &trans &trans &trans &trans
#endif
#include "zmk-helpers/helper.h"
#include "zmk-helpers/unicode-chars/greek.dtsi"
#include "zmk-helpers/unicode-chars/german.dtsi"
#define DEF 0
#define NAV 1
#define FN 2
#define NUM 3
#define SYS 4
#define MOUSE 5
#define XXX &none
#define ___ &trans
/* Global defaults */
#define QUICK_TAP_MS 175
&sk {
release-after-ms = <900>;
quick-release;
};
&sl { // Allow sticky mods to chord across sticky layers.
ignore-modifiers;
};
< {
flavor = "balanced";
tapping-term-ms = <200>;
quick-tap-ms = <QUICK_TAP_MS>;
};
/* Homerow mods */
#define KEYS_L LT0 LT1 LT2 LT3 LT4 LM0 LM1 LM2 LM3 LM4 LB0 LB1 LB2 LB3 LB4
#define KEYS_R RT0 RT1 RT2 RT3 RT4 RM0 RM1 RM2 RM3 RM4 RB0 RB1 RB2 RB3 RB4
#ifndef LH2
#define THUMBS LH1 LH0 RH0 RH1 // Thumbs on 34 keys.
#else
#define THUMBS LH2 LH1 LH0 RH0 RH1 RH2 // Thumbs on 36+ keys.
#endif
#define MAKE_HRM(NAME, HOLD, TAP, TRIGGER_POS) \
ZMK_HOLD_TAP(NAME, bindings = <HOLD>, <TAP>; flavor = "balanced"; \
tapping-term-ms = <280>; quick-tap-ms = <QUICK_TAP_MS>; \
require-prior-idle-ms = <150>; hold-trigger-on-release; \
hold-trigger-key-positions = <TRIGGER_POS>;)
MAKE_HRM(hml, &kp, &kp, KEYS_R THUMBS) // Left-hand HRMs.
MAKE_HRM(hmr, &kp, &kp, KEYS_L THUMBS) // Right-hand HRMs.
// Hack: Make HRM combos tap-only (cf, ZMK issue #544).
#define ZMK_COMBO_8(NAME, TAP, POS, LAYERS, COMBO_MS, IDLE_MS, HOLD, SIDE) \
MAKE_HRM(hm_combo_##NAME, &kp, TAP, SIDE THUMBS) \
ZMK_COMBO_6(NAME, &hm_combo_##NAME HOLD 0, POS, LAYERS, COMBO_MS, IDLE_MS)
/* Combos, leader key sequences, mouse emulation */
#include "combos.dtsi" // Must be sourced after HRM-combo hack.
#include "leader.dtsi"
#include "mouse.dtsi"
/* Nav cluster */
// Trigger tap-action on all interrupts.
#define MT_CORE \
flavor = "tap-preferred"; \
tapping-term-ms = <220>; \
quick-tap-ms = <220>; \
hold-trigger-key-positions = <0>;
&mt { MT_CORE };
ZMK_HOLD_TAP(mt_home, bindings = <&masked_home>, <&kp>; MT_CORE)
ZMK_HOLD_TAP(mt_end, bindings = <&masked_end>, <&kp>; MT_CORE)
#define NAV_LEFT &mt_home 0 LEFT // Tap: left | Long-tap: start of line.
#define NAV_RIGHT &mt_end 0 RIGHT // Tap: right | Long-tap: end of line.
#define NAV_UP &mt LC(HOME) UP // Tap: up | Long-tap: start of doc.
#define NAV_DOWN &mt LC(END) DOWN // Tap: down | Long-tap: end of doc.
#define NAV_BSPC &mt LC(BSPC) BSPC // Tap: bspc | Long-tap: delete word bwd.
#define NAV_DEL &mt LC(DEL) DEL // Tap: del | Long-tap: delete word fwd.
// Mask CTRL on left/right hold to avoid accidental jumps to start/end of doc.
#define MASK_MODS(NAME, MODS, BINDING) \
ZMK_MOD_MORPH(NAME, bindings = <BINDING>, <BINDING>; mods = <MODS>;)
MASK_MODS(masked_home, (MOD_LCTL), &kp HOME)
MASK_MODS(masked_end, (MOD_LCTL), &kp END)
/* Caps-word & auto-layers */
// Tap: sticky-shift | Shift + tap/ double-tap: caps-word | Hold: shift.
ZMK_MOD_MORPH(smart_shft,
bindings = <&sk LSHFT>, <&caps_word>;
mods = <(MOD_LSFT)>;
)
&caps_word { // Mods deactivate caps-word, requires PR #1451. [TODO: rebase]
/delete-property/ ignore-modifiers;
};
// Tap: num-word | double-tap: sticky num-layer | Hold: num-layer.
#define SMART_NUM &smart_num NUM 0
ZMK_HOLD_TAP(smart_num, bindings = <&mo>, <&num_dance>; flavor = "balanced";
tapping-term-ms = <200>; quick-tap-ms = <QUICK_TAP_MS>;)
ZMK_TAP_DANCE(num_dance, bindings = <&num_word NUM>, <&sl NUM>;
tapping-term-ms = <200>;)
// Smart-mouse, requires tri-state module.
ZMK_TRI_STATE(
smart_mouse, bindings = <&tog MOUSE>, <&none>, <&tog MOUSE>;
ignored-key-positions =
<LT1 LT3 LH0 LH1 RT1 RT2 RT3 RM0 RM1 RM2 RM3 RM4 RB1 RB2 RB3 RH0 RH1>;
ignored-layers = <MOUSE NAV FN>;)
/* Custom behaviors */
// Alt+Tab swapper, requires tri-state module.
ZMK_TRI_STATE(swapper, bindings = <&kt LALT>, <&kp TAB>, <&kt LALT>;
ignored-key-positions = <LT2>;)
// Define mod-morph with a *single* mod trigger for less repetition.
#define SIMPLE_MORPH(NAME, MOD, BINDING1, BINDING2) \
ZMK_MOD_MORPH(NAME, mods = <(MOD_L##MOD | MOD_R##MOD)>; \
bindings = <BINDING1>, <BINDING2>;)
// Tap: comma | Shift + tap: semicolon | Ctrl + shift + tap: <.
SIMPLE_MORPH(comma_morph, SFT, &kp COMMA, &comma_inner_morph)
SIMPLE_MORPH(comma_inner_morph, CTL, &kp SEMICOLON, &kp LESS_THAN)
// Tap: dot | Shift + tap: colon | Ctrl + shift + tap: >.
SIMPLE_MORPH(dot_morph, SFT, &kp DOT, &dot_inner_morph)
SIMPLE_MORPH(dot_inner_morph, CTL, &kp COLON, &kp GREATER_THAN)
// Tap: qmark | Shift + tap: excl.
SIMPLE_MORPH(qexcl, SFT, &kp QMARK, &kp EXCL)
// Tap: left/right parenthesis | Shft + tap: less-than/greater-than.
SIMPLE_MORPH(lpar_lt, SFT, &kp LPAR, &kp LT)
SIMPLE_MORPH(rpar_gt, SFT, &kp RPAR, &kp GT)
// Tap: space | Shift + tap: dot -> space -> sticky shift | Hold: nav layer.
ZMK_HOLD_TAP(lt_spc, bindings = <&mo>, <&spc_morph>; flavor = "balanced";
tapping-term-ms = <200>; quick-tap-ms = <QUICK_TAP_MS>;)
SIMPLE_MORPH(spc_morph, SFT, &kp SPACE, &dot_spc)
ZMK_MACRO(dot_spc, bindings = <&kp DOT &kp SPACE &sk LSHFT>; wait-ms = <0>;
tap-ms = <5>;)
// Tap: backspace | Lshft + tap: delete | Rshft + tap: shift-delete.
ZMK_MOD_MORPH(bs_del, bindings = <&kp BSPC>, <&kp DEL>;
mods = <(MOD_LSFT|MOD_RSFT)>; keep-mods = <MOD_RSFT>;)
// Tap: copy | double-tap: cut.
ZMK_TAP_DANCE(copy_cut, bindings = <&kp LC(INS)>, <&kp LC(X)>;
tapping-term-ms = <200>;)
// Sticky shift + leader.
ZMK_MACRO(leader_sft, bindings = <&sk LSHFT &leader>;)
// Misc aliases. [TODO: clean up]
#define CANCEL &kp K_CANCEL // Cancel caps-word & auto-layers.
#define DSK_PREV &hmr LCTRL LG(LC(LEFT)) // Previous desktop.
#define DSK_NEXT &hmr LALT LG(LC(RIGHT)) // Next desktop.
#define PIN_WIN &kp LG(LC(LS(Q))) // Pin window across desktops.
#define PIN_APP &kp LG(LC(LS(A))) // Pin application across desktops.
#define DSK_MGR &kp LA(GRAVE) // Desktop manager.
#define VOL_DOWN &hmr RSHFT C_VOL_DN
/* Keymap */
ZMK_CONDITIONAL_LAYER(sys, FN NUM, SYS) // FN + NUM --> SYS.
#ifndef ZMK_BASE_LAYER
#define ZMK_BASE_LAYER(name, LT, RT, LM, RM, LB, RB, LH, RH) \
ZMK_LAYER(name, LT RT LM RM LB RB LH RH)
#endif
ZMK_BASE_LAYER(Base,
//╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
&kp Q &kp W &kp F &kp P &kp B , &kp J &kp L &kp U &kp Y &kp SQT ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
&hml LGUI A &hml LALT R &hml LSHFT S &hml LCTRL T &kp G , &kp M &hmr LCTRL N &hmr RSHFT E &hmr LALT I &hmr LGUI O ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
&kp Z &kp X &kp C &kp D &kp V , &kp K &kp H &comma_morph &dot_morph &qexcl ,
//╰─────────────┼─────────────┴─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┴───────────────────────────╯
<_spc NAV 0 < FN RET , SMART_NUM &smart_shft
// ╰─────────────┴─────────────╯ ╰─────────────┴─────────────╯
)
ZMK_BASE_LAYER(Nav,
//╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
___ ___ &kp LS(TAB) &swapper ___ , &kp PG_UP NAV_BSPC NAV_UP NAV_DEL ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
&sk LGUI &sk LALT &sk LSHFT &sk LCTRL ___ , &kp PG_DN NAV_LEFT NAV_DOWN NAV_RIGHT &kp RET ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
___ ___ ___ ___ ___ , &kp INS &kp TAB ___ ___ ___ ,
//╰─────────────┼─────────────┴─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┴───────────────────────────╯
___ ___ , ___ CANCEL
// ╰─────────────┴─────────────╯ ╰─────────────┴─────────────╯
)
ZMK_BASE_LAYER(Fn,
//╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
&kp F12 &kp F7 &kp F8 &kp F9 ___ , ___ &kp C_PREV &kp C_VOL_UP &kp C_NEXT ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
&hml LGUI F11 &hml LALT F4 &hml LSHFT F5 &hml LCTRL F6 ___ , ___ DSK_PREV VOL_DOWN DSK_NEXT ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
&kp F10 &kp F1 &kp F2 &kp F3 ___ , PIN_APP PIN_WIN DSK_MGR ___ ___ ,
//╰─────────────┼─────────────┴─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┴───────────────────────────╯
___ ___ , &kp C_MUTE &kp C_PP
// ╰─────────────┴─────────────╯ ╰─────────────┴─────────────╯
)
ZMK_BASE_LAYER(Num,
//╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
___ &kp N7 &kp N8 &kp N9 ___ , ___ ___ ___ ___ ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
&hml LGUI N0 &hml LALT N4 &hml LSHFT N5 &hml LCTRL N6 ___ , ___ ___ ___ ___ ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
___ &kp N1 &kp N2 &kp N3 ___ , ___ ___ ___ ___ ___ ,
//╰─────────────┼─────────────┴─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┴───────────────────────────╯
___ ___ , ___ ___
// ╰─────────────┴─────────────╯ ╰─────────────┴─────────────╯
)
ZMK_BASE_LAYER(Sys,
//╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
_BT_SEL_KEYS_ , ___ ___ ___ ___ ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
___ ___ ___ ___ &bootloader , &bootloader ___ ___ ___ ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
___ ___ ___ ___ &sys_reset , &sys_reset ___ ___ ___ ___ ,
//╰─────────────┼─────────────┴─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┴───────────────────────────╯
___ ___ , ___ ___
// ╰─────────────┴─────────────╯ ╰─────────────┴─────────────╯
)
ZMK_BASE_LAYER(Mouse,
//╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮ ╭─────────────┬─────────────┬─────────────┬─────────────┬─────────────╮
___ ___ ___ ___ ___ , ___ &kp PG_UP U_MS_U &kp PG_DN ___ ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
___ ___ ___ ___ ___ , U_WH_L U_MS_L U_MS_D U_MS_R U_WH_R ,
//├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┼─────────────┼─────────────┤
___ ___ ___ ___ ___ , ___ &mkp LCLK &mkp MCLK &mkp RCLK ___ ,
//╰─────────────┼─────────────┴─────────────┼─────────────┼─────────────┤ ├─────────────┼─────────────┼─────────────┴───────────────────────────╯
___ ___ , U_WH_U U_WH_D
// ╰─────────────┴─────────────╯ ╰─────────────┴─────────────╯
)
/* vim: set ft=c tw=146: */