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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
|
#include QMK_KEYBOARD_H
extern keymap_config_t keymap_config;
// where the 'T_' communicates how the key does something different when tapped.
enum planck_keycodes {
//DVORAK = SAFE_RANGE,
KC_T_LALT = SAFE_RANGE,
KC_T_RALT,
KC_T_LGUI,
KC_T_RGUI,
KC_T_LCTL,
KC_T_RCTL,
KC_T_LSFT,
KC_T_RSFT,
KC_T_LRSE,
KC_T_RRSE,
KC_EZRGHT,
KC_EZLEFT,
KC_EZUP,
KC_EZDOWN,
KC_EZUNDO,
KC_EZCOPY,
KC_EZCUT,
KC_EZPSTE,
KC_EZSHFT,
KC_EZCTRL,
KC_EZGUI,
KC_EZALT,
KC_DVORAK,
KC_QWERTY,
KC_COM
};
enum planck_layers {
_DVORAK,
_QWERTY,
_RISE,
_COMMAND
};
const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[_DVORAK] = LAYOUT_planck_grid(
KC_T_LRSE, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_T_RRSE,
KC_T_LSFT, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_T_RSFT,
KC_T_LCTL, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_T_RCTL,
KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_SPC, KC_EQL, KC_GRAVE, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_T_RGUI
),
[_QWERTY] = LAYOUT_planck_grid(
KC_T_LRSE, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_T_RRSE,
KC_T_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_T_RSFT,
KC_T_LCTL, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_QUOT, KC_T_RCTL,
KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_SPC, KC_EQL, KC_GRAVE, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_DVORAK
),
[_RISE] = LAYOUT_planck_grid(
KC_TRANSPARENT, KC_EZUNDO, KC_EZCOPY, KC_EZCUT, KC_EZPSTE, KC_INS, KC_ASTR, KC_7, KC_8, KC_9, KC_TRANSPARENT, KC_TRANSPARENT,
KC_EZSHFT, KC_ESC, KC_CAPS, KC_PGUP, KC_PGDN, KC_HOME, KC_AMPR, KC_4, KC_5, KC_6, KC_0, KC_EZSHFT,
KC_EZCTRL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_1, KC_2, KC_3, KC_COM, KC_EZCTRL,
KC_EZGUI, KC_EZALT, KC_EZUP, KC_EZDOWN, KC_SPC, KC_PIPE, KC_BSLASH, KC_END, KC_EZLEFT, KC_EZRGHT, KC_EZALT, KC_EZGUI
),
[_COMMAND] = LAYOUT_planck_grid(
KC_TRANSPARENT, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRANSPARENT,
KC_TRANSPARENT, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRANSPARENT,
KC_TRANSPARENT, KC_F21, KC_F22, KC_F23, KC_F24, KC_QWERTY, KC_DVORAK, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT,
KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT
)
};
static uint16_t tap_timer = 0;
char last_mod = 10;
void mod_press(uint16_t tap_code, uint16_t hold_code, int id) {
/* this first if body makes double modified keys impossible, but stops the */
/* delay when modifying a tap key which would result in the tap key not */
/* getting modified. */
if (last_mod != id && last_mod != 10) {
tap_code16(tap_code);
last_mod = 10;
} else {
tap_timer = timer_read();
last_mod = id;
register_code(hold_code);
}
}
void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) {
unregister_code(hold_code);
if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(tap_code);
}
last_mod = 10;
}
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
switch (keycode) {
case KC_DVORAK:
if (record->event.pressed) {
set_single_persistent_default_layer(_DVORAK);
}
return true;
break;
case KC_QWERTY:
if (record->event.pressed) {
set_single_persistent_default_layer(_QWERTY);
}
return true;
break;
case KC_COM:
if (record->event.pressed) {
layer_on(_COMMAND);
set_oneshot_layer(_COMMAND, ONESHOT_START);
last_mod = 10;
} else {
clear_oneshot_layer_state (ONESHOT_PRESSED);
}
return false;
break;
case KC_T_LALT:
if (record->event.pressed) {
mod_press(KC_LPRN, KC_LALT, 0);
} else {
mod_lift(KC_LPRN, KC_LALT, 0);
}
return false;
break;
case KC_T_RALT:
if (record->event.pressed) {
mod_press(KC_RPRN, KC_RALT, 1);
} else {
mod_lift(KC_RPRN, KC_RALT, 1);
}
return false;
break;
case KC_T_LGUI:
if (record->event.pressed) {
mod_press(KC_SLASH, KC_LGUI, 2);
} else {
mod_lift(KC_SLASH, KC_LGUI, 2);
}
return false;
break;
case KC_T_RGUI:
if (record->event.pressed) {
mod_press(KC_MINS, KC_RGUI, 3);
} else {
mod_lift(KC_MINS, KC_RGUI, 3);
}
return false;
break;
case KC_T_LCTL:
if (record->event.pressed) {
mod_press(KC_LEFT_BRACKET, KC_LCTL, 4);
} else {
mod_lift(KC_LEFT_BRACKET, KC_LCTL, 4);
}
return false;
break;
case KC_T_RCTL:
if (record->event.pressed) {
mod_press(KC_RIGHT_BRACKET, KC_RCTL, 5);
} else {
mod_lift(KC_RIGHT_BRACKET, KC_RCTL, 5);
}
return false;
break;
case KC_T_LSFT:
if (record->event.pressed) {
mod_press(KC_TAB, KC_LSFT, 6);
} else {
mod_lift(KC_TAB, KC_LSFT, 6);
}
return false;
break;
case KC_T_RSFT:
if (record->event.pressed) {
mod_press(KC_ENTER, KC_RSFT, 7);
} else {
mod_lift(KC_ENTER, KC_RSFT, 7);
}
return false;
break;
case KC_T_LRSE:
if (record->event.pressed) {
tap_timer = timer_read();
last_mod = 8;
layer_on(_RISE);
} else {
layer_off(_RISE);
if (last_mod == 8 && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(KC_DELETE);
last_mod = 10;
}
}
return false;
break;
case KC_T_RRSE:
if (record->event.pressed) {
tap_timer = timer_read();
last_mod = 9;
layer_on(_RISE);
} else {
layer_off(_RISE);
if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) {
tap_code16(KC_BSPACE);
last_mod = 10;
}
}
return false;
break;
case KC_EZSHFT:
if (record->event.pressed) {
set_oneshot_mods(MOD_LSFT);
last_mod = 10;
}
return false;
break;
case KC_EZCTRL:
if (record->event.pressed) {
set_oneshot_mods(MOD_LCTL);
last_mod = 10;
}
return false;
break;
case KC_EZALT:
if (record->event.pressed) {
set_oneshot_mods(MOD_LALT);
last_mod = 10;
}
return false;
break;
case KC_EZGUI:
if (record->event.pressed) {
set_oneshot_mods(MOD_LGUI);
last_mod = 10;
}
return false;
break;
case KC_EZRGHT:
if (record->event.pressed) {
register_code(KC_LCTL);
tap_code16(S(KC_RGHT));
unregister_code(KC_LCTL);
last_mod = 10;
}
return false;
break;
case KC_EZLEFT:
if (record->event.pressed) {
register_code(KC_LCTL);
tap_code16(S(KC_LEFT));
unregister_code(KC_LCTL);
last_mod = 10;
}
return false;
break;
case KC_EZDOWN:
if (record->event.pressed) {
register_code(KC_LCTL);
tap_code16(S(KC_DOWN));
unregister_code(KC_LCTL);
last_mod = 10;
}
return false;
break;
case KC_EZUP:
if (record->event.pressed) {
register_code(KC_LCTL);
tap_code16(S(KC_UP));
unregister_code(KC_LCTL);
last_mod = 10;
}
return false;
break;
case KC_EZUNDO:
if (record->event.pressed) {
tap_code16(C(KC_Z));
last_mod = 10;
}
return false;
break;
case KC_EZCOPY:
if (record->event.pressed) {
tap_code16(C(KC_C));
last_mod = 10;
}
return false;
break;
case KC_EZCUT:
if (record->event.pressed) {
tap_code16(C(KC_X));
last_mod = 10;
}
return false;
break;
case KC_EZPSTE:
if (record->event.pressed) {
tap_code16(C(KC_V));
last_mod = 10;
}
return false;
break;
}
last_mod = 10;
return true;
}
|