-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdefinitions.dtsi
247 lines (217 loc) · 7.22 KB
/
definitions.dtsi
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
// shortcut definitions
#include "key_positions.dtsi"
/ {
compatible = "zmk,bindings";
#define NORMAL_TIMEOUT_MS 50
#define LONG_TIMEOUT_MS 200
#define NORMAL_LAYERS ALP NUM SYM CRD
#define NORMAL_LAYERS_MAC 3 4
#define NORMAL_LAYERS_WIN 5 6
#define LOCK_LAYER 7
behaviors {
skq: sticky_key_quick_release {
compatible = "zmk,behavior-sticky-key";
label = "STICKY_KEY_QUICK_RELEASE";
#binding-cells = <1>;
bindings = <&kp>;
release-after-ms = <1000>;
quick-release;
};
skl: sticky_key_long_pressed {
compatible = "zmk,behavior-sticky-key";
label = "STICKY_KEY_QUICK_RELEASE";
#binding-cells = <1>;
bindings = <&kp>;
release-after-ms = <10000>;
};
};
};
#define HOLD_TAP_BEHAVIORS(NAME, HOLD_BEHAVIOR, TAP_BEHAVIOR) \
/ {\
behaviors {\
ht_##NAME: ht_behavior_##NAME {\
compatible = "zmk,behavior-hold-tap";\
label = str(hold_tap_ht_behavior_##NAME);\
#binding-cells = <2>;\
flavor = "hold-preferred";\
retro-tap;\
tapping-term-ms = <280>;\
bindings = <HOLD_BEHAVIOR>, <TAP_BEHAVIOR>;\
};\
};\
};
#define COMBO(NAME, BINDINGS, KEYPOS, LAYERS, TIME_OUT) \
/ {\
combos {\
compatible = "zmk,combos";\
combo_##NAME { \
bindings = <BINDINGS>; \
key-positions = <KEYPOS>; \
layers = <LAYERS>; \
timeout-ms = <TIME_OUT>; \
};\
};\
};
#define COMBO_NORMAL(NAME, BINDINGS, KEYPOS) \
COMBO(NAME, BINDINGS, KEYPOS, NORMAL_LAYERS, NORMAL_TIMEOUT_MS)
#define COMBO_LAYER(NAME, BINDINGS, KEYPOS, LAYERS) \
COMBO(NAME, BINDINGS, KEYPOS, LAYERS, NORMAL_TIMEOUT_MS)
#define COMBO_LONG(NAME, BINDINGS, KEYPOS) \
COMBO(NAME, BINDINGS, KEYPOS, NORMAL_LAYERS, LONG_TIMEOUT_MS)
#define COMBO_LONG_MAC(NAME, BINDINGS, KEYPOS) \
COMBO(NAME, BINDINGS, KEYPOS, NORMAL_LAYERS NORMAL_LAYERS_MAC, LONG_TIMEOUT_MS)
#define COMBO_LONG_WIN(NAME, BINDINGS, KEYPOS) \
COMBO(NAME, BINDINGS, KEYPOS, NORMAL_LAYERS NORMAL_LAYERS NORMAL_LAYERS_WIN, LONG_TIMEOUT_MS)
#define str(s) #s
#define MACRO(NAME, BINDINGS) \
/ { \
macros { \
macro_##NAME: macro_##NAME { \
compatible = "zmk,behavior-macro"; \
label = str(macro_##NAME); \
#binding-cells = <0>; \
wait-ms = <0>; \
tap-ms = <10>; \
bindings = <BINDINGS>; \
};\
};\
};
#define CHORD(NAME, BINDINGS, KEYPOS, LAYER, TIME_OUT) \
MACRO(chord_##NAME, BINDINGS) \
COMBO(chord_##NAME, ¯o_chord_##NAME, KEYPOS, LAYER, TIME_OUT)
#define CHORD_NORMAL(NAME, BINDINGS, KEYPOS) \
CHORD(NAME, BINDINGS, KEYPOS, NORMAL_LAYERS, NORMAL_TIMEOUT_MS)
#define CHORD_LAYER(NAME, BINDINGS, KEYPOS, LAYER) \
MACRO(chord_##NAME, BINDINGS) \
COMBO(chord_##NAME, ¯o_chord_##NAME, KEYPOS, LAYER, NORMAL_TIMEOUT_MS)
#define CHORD_SHIFT(NAME, FIRST_LETTER, BINDINGS, KEYPOS, LAYER) \
MACRO(chord_##NAME, &kp FIRST_LETTER BINDINGS) \
MACRO(chord_shift_##NAME, &kp LS(FIRST_LETTER) BINDINGS) \
MOD_MORPH_SHIFT(NAME, ¯o_chord_##NAME, ¯o_chord_shift_##NAME) \
COMBO(chord_##NAME, &mm_s_##NAME, KEYPOS, LAYER, NORMAL_TIMEOUT_MS)
#define MOD_MORPH_KEEP(NAME, BINDING_PURE, BINDING_MODED, MODS, KEEP_MODS) \
/ { \
behaviors { \
mm_##NAME: mod_morph_##NAME {\
compatible = "zmk,behavior-mod-morph";\
label = str(mod_morph_##NAME);\
#binding-cells = <0>;\
bindings = <BINDING_PURE>, <BINDING_MODED>;\
mods = <(MODS)>;\
keep-mods = <(KEEP_MODS)>;\
};\
};\
};
#define MOD_MORPH(NAME, BINDING_PURE, BINDING_MODED, MODS) \
MOD_MORPH_KEEP(NAME, BINDING_PURE, BINDING_MODED, MODS, 0)
// / { \
// behaviors { \
// mm_##NAME: mod_morph_##NAME {\
// compatible = "zmk,behavior-mod-morph";\
// label = str(mod_morph_##NAME);\
// #binding-cells = <0>;\
// bindings = <BINDING_PURE>, <BINDING_MODED>;\
// mods = <(MODS)>;\
// };\
// };\
// };
#define MOD_MORPH_SHIFT(NAME, BINDING_PURE, BINDING_MODED) \
MOD_MORPH(s_##NAME, BINDING_PURE, BINDING_MODED, MOD_LSFT|MOD_RSFT)
// a high taping-terms value is ok, as REP should be used for repeated key presses
#define TAP_DANCE(NAME, ...) \
/ {\
behaviors {\
td_##NAME: tap_dance_##NAME {\
compatible = "zmk,behavior-tap-dance";\
label = str(tap_dance_##NAME);\
#binding-cells = <0>;\
tapping-term-ms = <200>;\
bindings = __VA_ARGS__;\
};\
};\
};
#define TAP_DANCE_SHIFT(KEY) \
TAP_DANCE(s_##KEY, <&kp KEY>, <&kp LS(KEY)>)
// retro-tap;\
// timeless-homerow-mods from UROB: https://github.com/urob/zmk-config#timeless-homerow-mods
// tapping-term-ms = <280>; ==> trigger hold after these ms - only if HRM one handed
// hold-trigger-key-positions = HOLD_KEYS; ==> trigger tap if these keys are pressed (so same side rolling doesn't trigger mod)
// hold-trigger-on-release; ==> delay positional check until key-release
#define HOME_ROW_MOD_BEHAVIOR(NAME, BEHAVIOR, HOLD_KEYS) \
/ {\
behaviors {\
hrm_##NAME: home_row_mod_##NAME {\
compatible = "zmk,behavior-hold-tap";\
label = str(ht_hrm_##NAME);\
#binding-cells = <2>;\
flavor = "balanced";\
tapping-term-ms = <280>;\
quick-tap-ms = <175>;\
require-prior-idle-ms = <150>;\
bindings = <&kp>, <BEHAVIOR>;\
hold-trigger-key-positions = HOLD_KEYS;\
hold-trigger-on-release;\
};\
};\
};
#define HOME_ROW_MOD(NAME, HOLD_KEYS) \
HOME_ROW_MOD_BEHAVIOR(NAME, &kp, HOLD_KEYS)
// left-hand HRMs
HOME_ROW_MOD(l, RIGHT_SIDE_KEYS)
// right-hand HRMs
HOME_ROW_MOD(r, LEFT_SIDE_KEYS)
// alternative: RTI as mod key for HRM keys
// #define MOD_MORPH_HRM(NAME, BINDING_PURE, BINDING_MODED) \
// MOD_MORPH(hrm_##NAME, BINDING_PURE, BINDING_MODED, MOD_RSFT)
// mod-layer, which holds mod keys until exited
// layers/hold_mod.dtsi
/ {\
behaviors {\
exit_to_ALP: release_mod_and_leave_layer {
label = "release_mod_and_leave_layer";
compatible = "zmk,behavior-macro";
#binding-cells = <0>;
wait-ms = <10>;
tap-ms = <20>;
bindings =
<¯o_release &kp LSHIFT>,
<¯o_release &kp LCTRL>,
<¯o_release &kp LALT>,
<¯o_release &kp LCMD>,
<¯o_tap &to ALP>;
};
alt_tab: alt_tab_enter {
label = "alt_tab_enter";
compatible = "zmk,behavior-macro";
#binding-cells = <0>;
wait-ms = <10>;
tap-ms = <20>;
bindings =
<¯o_press &kp LALT>,
<¯o_tap &kp TAB &to MOD>;
};
cmd_tab: cmd_tab_enter {
label = "cmd_tab_enter";
compatible = "zmk,behavior-macro";
#binding-cells = <0>;
wait-ms = <10>;
tap-ms = <20>;
bindings =
<¯o_press &kp LCMD>,
<¯o_tap &kp TAB &to MOD>;
};
// enters a layer and exits it to ALP (disabling all holded mods, using the MOD layer)
mo_alp: mo_layer_exit_mod_layer {
label = str(mo_ALP_exit_mod_layer);
compatible = "zmk,behavior-macro-one-param";
#binding-cells = <1>;
wait-ms = <0>;
tap-ms = <0>;
bindings =
<¯o_param_1to1>,
<¯o_tap &to MACRO_PLACEHOLDER>,
<¯o_pause_for_release>,
<&exit_to_ALP>;
};
};
};