aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--keyboards/planck/keymaps/samuel/README.org509
-rw-r--r--keyboards/planck/keymaps/samuel/keymap.c372
2 files changed, 593 insertions, 288 deletions
diff --git a/keyboards/planck/keymaps/samuel/README.org b/keyboards/planck/keymaps/samuel/README.org
index d0750ee03..3c0f08a9d 100644
--- a/keyboards/planck/keymaps/samuel/README.org
+++ b/keyboards/planck/keymaps/samuel/README.org
@@ -5,7 +5,7 @@ This is my qmk firmware for my keyboard. I grew tired of organizing the keycode
5array in plain text so I made it a literate .org file. I've never done this 5array in plain text so I made it a literate .org file. I've never done this
6before, so bear with me. 6before, so bear with me.
7 7
8* Keymap 8* Layers
9 9
10#+BEGIN_COMMENT 10#+BEGIN_COMMENT
11#+NAME: empty-layer 11#+NAME: empty-layer
@@ -19,7 +19,7 @@ before, so bear with me.
19#+END_COMMENT 19#+END_COMMENT
20 20
21This is my "pretty" org mode organized table for my main dvorak layer. If you 21This is my "pretty" org mode organized table for my main dvorak layer. If you
22don't use org mode, it won't be that exiting, but if you enjoy working in org 22don't use org mode, it won't be that exciting, but if you enjoy working in org
23mode, you can edit this table directly, and this file is tangled to the actual 23mode, you can edit this table directly, and this file is tangled to the actual
24keymap. No more organizing spaces or converting to and from comments. 24keymap. No more organizing spaces or converting to and from comments.
25 25
@@ -31,23 +31,45 @@ keymap. No more organizing spaces or converting to and from comments.
31| T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | T_RGUI | 31| T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | T_RGUI |
32|--------+--------+------+------+------+-----+-----+-----+------+-------+--------+--------| 32|--------+--------+------+------+------+-----+-----+-----+------+-------+--------+--------|
33 33
34This qwerty layout is just so normal people can try out the board. Tap keys
35would need to be customized I think, more on that later. I also put another
36dvorak key here because I have nightmares of getting trapped in this forsaken
37layout.
38
39#+NAME: qwerty-layer
40|--------+--------+----+------+------+-----+-----+-----+------+-------+--------+--------|
41| T_LRSE | Q | W | E | R | T | Y | U | I | O | P | T_RRSE |
42| T_LSFT | A | S | D | F | G | H | J | K | L | SCLN | T_RSFT |
43| T_LCTL | Z | X | C | V | B | N | M | COMM | DOT | QUOT | T_RCTL |
44| T_LGUI | T_LALT | UP | DOWN | BSPC | TAB | ENT | SPC | LEFT | RIGHT | T_RALT | DVORAK |
45|--------+--------+----+------+------+-----+-----+-----+------+-------+--------+--------|
46
34I tried to keep my layout bare bones, just what would be available on a normal 47I tried to keep my layout bare bones, just what would be available on a normal
35keyboard, minus some keys I never used. The bottom left copies a normal 48keyboard, minus some keys I never used. This one secondary layer should cover a
49majority of the keys not found on the home layer. The bottom left copies a normal
36keyboards symbols from shifted numbers, and the rest is placed where convenient, 50keyboards symbols from shifted numbers, and the rest is placed where convenient,
37with some considerations for one handed use, hence the shortcuts in the top 51with some considerations for one handed use, hence the shortcuts in the top
38left. 52left.
39 53
40#+TODO: qwerty layer for ma friends
41
42#+NAME: secondary-layer 54#+NAME: secondary-layer
43|----+--------+--------+--------+--------+------+------+----+--------+--------+-----+----| 55|--------+--------+--------+--------+--------+------+------+-----+--------+--------+-------+--------|
44| -- | EZUNDO | EZCOPY | EZCUT | EZPSTE | INS | EQL | 7 | 8 | 9 | F11 | -- | 56| -- | EZUNDO | EZCOPY | EZCUT | EZPSTE | INS | EQL | 7 | 8 | 9 | -- | -- |
45| -- | ESC | CAPS | PGUP | PGDN | F4 | ASTR | 4 | 5 | 6 | 0 | -- | 57| EZSHFT | ESC | CAPS | PGUP | PGDN | HOME | ASTR | 4 | 5 | 6 | 0 | EZSHFT |
46| -- | EXLM | AT | HASH | DLR | PERC | CIRC | 1 | 2 | 3 | F12 | -- | 58| EZCTRL | EXLM | AT | HASH | DLR | PERC | CIRC | 1 | 2 | 3 | COM | EZCTRL |
47| -- | -- | EZUP | EZDOWN | -- | AMPR | PIPE | -- | EZLEFT | EZRGHT | -- | -- | 59| EZGUI | EZALT | EZUP | EZDOWN | SPC | AMPR | PIPE | END | EZLEFT | EZRGHT | EZALT | EZGUI |
48|----+--------+--------+--------+--------+------+------+----+--------+--------+-----+----| 60|--------+--------+--------+--------+--------+------+------+-----+--------+--------+-------+--------|
49 61
50But wait, we are missing several important keys!? yes, well, the modifier keys 62Basic command layer for one-shot macros and function keys.
63
64#+NAME: command-layer
65|----+-----+-----+-----+-----+--------+--------+------+-------+------+-----+----|
66| -- | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | -- |
67| -- | F11 | F12 | F13 | F14 | F15 | F16 | F17 | F18 | F19 | F20 | -- |
68| -- | F21 | F22 | F23 | F24 | QWERTY | DVORAK | USER | EMAIL | NAME | -- | -- |
69| -- | -- | -- | -- | -- | -- | -- | DIR | -- | -- | -- | -- |
70|----+-----+-----+-----+-----+--------+--------+------+-------+------+-----+----|
71
72But wait, we are missing several important keys? well, yes, but the modifier keys
51all do other keys when tapped. More about that in the keymap section. 73all do other keys when tapped. More about that in the keymap section.
52 74
53* Keymap Conversion in Python 75* Keymap Conversion in Python
@@ -55,7 +77,7 @@ all do other keys when tapped. More about that in the keymap section.
55This python can convert that table into the array needed for the keymap file. It 77This python can convert that table into the array needed for the keymap file. It
56simply prepends every key with "KC_". I used to use a dictionary to convert some 78simply prepends every key with "KC_". I used to use a dictionary to convert some
57keys from the table into qmk keycodes, but the double convertion was 79keys from the table into qmk keycodes, but the double convertion was
58unneccessary so I simply prepended all my macros with KC and moved all the 80unneccessary so I just prepended all my macros with KC and moved all the
59implementation to the `process-user-input` function. 81implementation to the `process-user-input` function.
60 82
61#+NAME:layer-to-array 83#+NAME:layer-to-array
@@ -84,55 +106,69 @@ return results
84 106
85* keymap.c 107* keymap.c
86 108
87Now that we have done all the hard work, lets layout our keymap file then define 109Now that we laid out our layout, lets lay out our kemap file.
88our macros.
89
90** Headers And Layer Declaration
91 110
92#+BEGIN_SRC C :noweb yes 111#+BEGIN_SRC C :noweb yes
93#include QMK_KEYBOARD_H 112#include QMK_KEYBOARD_H
94 113
95extern keymap_config_t keymap_config; 114extern keymap_config_t keymap_config;
96 115
97static uint16_t tap_timers[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; 116#+END_SRC
98
99char last_mod = -1;
100 117
101enum planck_layers { 118** Keycodes
102 _DVORAK,
103 _RISE
104};
105 119
120#+BEGIN_SRC C :noweb yes
106// where the 'T_' communicates how the key does something different when tapped. 121// where the 'T_' communicates how the key does something different when tapped.
107enum planck_keycodes { 122enum planck_keycodes {
108 DVORAK = SAFE_RANGE, 123//DVORAK = SAFE_RANGE,
109 KC_T_LALT, 124KC_T_LALT = SAFE_RANGE,
110 KC_T_RALT, 125KC_T_RALT,
111 KC_T_LGUI, 126KC_T_LGUI,
112 KC_T_RGUI, 127KC_T_RGUI,
113 KC_T_LCTL, 128KC_T_LCTL,
114 KC_T_RCTL, 129KC_T_RCTL,
115 KC_T_LSFT, 130KC_T_LSFT,
116 KC_T_RSFT, 131KC_T_RSFT,
117 KC_T_LRSE, 132KC_T_LRSE,
118 KC_T_RRSE, 133KC_T_RRSE,
119 KC_EZRGHT, 134KC_EZRGHT,
120 KC_EZLEFT, 135KC_EZLEFT,
121 KC_EZUP, 136KC_EZUP,
122 KC_EZDOWN, 137KC_EZDOWN,
123 KC_EZUNDO, 138KC_EZUNDO,
124 KC_EZCOPY, 139KC_EZCOPY,
125 KC_EZCUT, 140KC_EZCUT,
126 KC_EZPSTE 141KC_EZPSTE,
142KC_EZSHFT,
143KC_EZCTRL,
144KC_EZGUI,
145KC_EZALT,
146KC_DVORAK,
147KC_QWERTY,
148KC_USER,
149KC_EMAIL,
150KC_NAME,
151KC_DIR,
152KC_COM
127}; 153};
128 154
129const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
130
131#+END_SRC 155#+END_SRC
132 156
133** Import Key table 157** Import Key table
134 158
135#+BEGIN_SRC C :noweb yes 159#+BEGIN_SRC C :noweb yes
160enum planck_layers {
161_DVORAK,
162_QWERTY,
163_RISE,
164_COMMAND
165};
166
167const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
168
169#+END_SRC
170
171#+BEGIN_SRC C :noweb yes
136[_DVORAK] = 172[_DVORAK] =
137 173
138#+END_SRC 174#+END_SRC
@@ -143,6 +179,16 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
143#+END_SRC 179#+END_SRC
144 180
145#+BEGIN_SRC C :noweb yes 181#+BEGIN_SRC C :noweb yes
182[_QWERTY] =
183
184#+END_SRC
185
186#+BEGIN_SRC C :noweb yes
187<<layer-to-array(qwerty-layer)>>
188
189#+END_SRC
190
191#+BEGIN_SRC C :noweb yes
146[_RISE] = 192[_RISE] =
147 193
148#+END_SRC 194#+END_SRC
@@ -152,50 +198,96 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
152 198
153#+END_SRC 199#+END_SRC
154 200
155** Process User Input 201#+BEGIN_SRC C :noweb yes
156*** Tap Key Functionality 202[_COMMAND] =
157 203
158These methods define how I implemented the tap mechanic. Basically, I believe 204#+END_SRC
159that /pressing/ any other key should be grounds for the hold functionality to be 205
160assumed. My natuaral typing style experiences no delays from my method. 206#+BEGIN_SRC C :noweb yes
207<<layer-to-array(command-layer)>>
208
209#+END_SRC
161 210
162#+BEGIN_SRC C :noweb yes 211#+BEGIN_SRC C :noweb yes
163}; 212};
164 213
165void mod_press(uint16_t hold_code, int id) { 214#+END_SRC
166 tap_timers[id] = timer_read(); 215
167 last_mod = id; 216** Tap Keys
168 register_code(hold_code); 217
218I don't like tap keys coming out on release. When modified, I often let go of
219the modifier too early because the tap button doesn't come out untill release. I
220guess you could save the state of the board on press and then apply it after the
221timer, but what I really want is the keys to come out on press when they can and
222when it is most useful. For me, that is when they are modified a single time. So
223I kind "locked" the board into only doing single modifiers, making them faster.
224Disadvantages are double modified keys must be done with one shot keys (its
225actually not that bad, it feels like emacs!) and triple modified keys are
226impossible at the moment.
227
228#+BEGIN_SRC C :noweb yes
229
230static uint16_t tap_timer = 0;
231char last_mod = 10;
232
233void mod_press(uint16_t tap_code, uint16_t hold_code, int id) {
234 // this first if body makes double modified keys impossible, but stops the
235 // delay when modifying a tap key which would result in the tap key not
236 // getting modified.
237 if (last_mod != id && last_mod != 10) {
238 tap_code16(tap_code);
239 last_mod = 10;
240 } else {
241 tap_timer = timer_read();
242 last_mod = id;
243 register_code(hold_code);
244 }
169} 245}
170 246
171void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) { 247void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) {
172 unregister_code(hold_code); 248 unregister_code(hold_code);
173 if (last_mod == id && timer_elapsed(tap_timers[id]) < TAPPING_TERM) { 249 if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) {
174 tap_code16(tap_code); 250 tap_code16(tap_code);
175 last_mod = -1; 251 last_mod = 10;
176 } 252 }
177} 253}
178 254
179#+END_SRC 255#+END_SRC
180 256
181*** Set DVORAK layout 257** Process User Input
182
183The function that filter's user inputs and applies macros, the begginning is
184pretty basic, setting our main layer and configuring our secondary layer.
185 258
186#+BEGIN_SRC C :noweb yes 259#+BEGIN_SRC C :noweb yes
187bool process_record_user(uint16_t keycode, keyrecord_t *record) { 260bool process_record_user(uint16_t keycode, keyrecord_t *record) {
188 switch (keycode) { 261 switch (keycode) {
189 case DVORAK: 262#+END_SRC
190 if (record->event.pressed) { 263
191 set_single_persistent_default_layer(_DVORAK); 264** Layouts
192 } 265
193 return false; 266Set Dvorak layout
194 break; 267
268#+BEGIN_SRC C :noweb yes
269case KC_DVORAK:
270if (record->event.pressed) {
271 set_single_persistent_default_layer(_DVORAK);
272}
273return true;
274break;
275
276#+END_SRC
277
278Set Qwerty layout.
279
280#+BEGIN_SRC C :noweb yes
281case KC_QWERTY:
282if (record->event.pressed) {
283 set_single_persistent_default_layer(_QWERTY);
284}
285return true;
286break;
195 287
196#+END_SRC 288#+END_SRC
197 289
198*** Alt and () 290** Alt and ()
199 291
200Left and right alt are ( and ) when tapped. I put them on alt instead of a more 292Left and right alt are ( and ) when tapped. I put them on alt instead of a more
201conveniant key like control because parentheses do not need to be shift modified 293conveniant key like control because parentheses do not need to be shift modified
@@ -204,24 +296,24 @@ ever, unlike some other tap keys seen in the next sections.
204#+BEGIN_SRC C :noweb yes 296#+BEGIN_SRC C :noweb yes
205case KC_T_LALT: 297case KC_T_LALT:
206if (record->event.pressed) { 298if (record->event.pressed) {
207 mod_press(KC_LALT, 0); 299 mod_press(S(KC_9), KC_LALT, 0);
208 } else { 300} else {
209 mod_lift(S(KC_9), KC_LALT, 0); 301 mod_lift(S(KC_9), KC_LALT, 0);
210 } 302}
211return false; 303return false;
212break; 304break;
213case KC_T_RALT: 305case KC_T_RALT:
214if (record->event.pressed) { 306if (record->event.pressed) {
215 mod_press(KC_RALT, 1); 307 mod_press(S(KC_0), KC_RALT, 1);
216 } else { 308} else {
217 mod_lift(S(KC_0), KC_RALT, 1); 309 mod_lift(S(KC_0), KC_RALT, 1);
218 } 310}
219return false; 311return false;
220break; 312break;
221 313
222#+END_SRC 314#+END_SRC
223 315
224*** Gui and `\ 316** Gui and `\
225 317
226I place gui in the bottom corner because I believe it is the hardest key to 318I place gui in the bottom corner because I believe it is the hardest key to
227reach, so gui seemed like a good fit for a dedicated key that I never want to 319reach, so gui seemed like a good fit for a dedicated key that I never want to
@@ -231,24 +323,24 @@ number pad or shifted number keys.
231#+BEGIN_SRC C :noweb yes 323#+BEGIN_SRC C :noweb yes
232case KC_T_LGUI: 324case KC_T_LGUI:
233if (record->event.pressed) { 325if (record->event.pressed) {
234 mod_press(KC_LGUI, 2); 326 mod_press(KC_GRAVE, KC_LGUI, 2);
235 } else { 327} else {
236 mod_lift(KC_GRAVE, KC_LGUI, 2); 328 mod_lift(KC_GRAVE, KC_LGUI, 2);
237 } 329}
238return false; 330return false;
239break; 331break;
240case KC_T_RGUI: 332case KC_T_RGUI:
241if (record->event.pressed) { 333if (record->event.pressed) {
242 mod_press(KC_RGUI, 3); 334 mod_press(KC_BSLASH, KC_RGUI, 3);
243 } else { 335} else {
244 mod_lift(KC_BSLASH, KC_RGUI, 3); 336 mod_lift(KC_BSLASH, KC_RGUI, 3);
245 } 337}
246return false; 338return false;
247break; 339break;
248 340
249#+END_SRC 341#+END_SRC
250 342
251*** Ctrl and [] 343** Ctrl and []
252 344
253Left and right control are [] respectively when they are tapped, making { and } 345Left and right control are [] respectively when they are tapped, making { and }
254also very convenient. 346also very convenient.
@@ -256,24 +348,24 @@ also very convenient.
256#+BEGIN_SRC C :noweb yes 348#+BEGIN_SRC C :noweb yes
257case KC_T_LCTL: 349case KC_T_LCTL:
258if (record->event.pressed) { 350if (record->event.pressed) {
259 mod_press(KC_LCTL, 4); 351 mod_press(KC_LBRACKET, KC_LCTL, 4);
260 } else { 352} else {
261 mod_lift(KC_LBRACKET, KC_LCTL, 4); 353 mod_lift(KC_LBRACKET, KC_LCTL, 4);
262 } 354}
263return false; 355return false;
264break; 356break;
265case KC_T_RCTL: 357case KC_T_RCTL:
266if (record->event.pressed) { 358if (record->event.pressed) {
267 mod_press(KC_RCTL, 5); 359 mod_press(KC_RBRACKET, KC_RCTL, 5);
268 } else { 360} else {
269 mod_lift(KC_RBRACKET, KC_RCTL, 5); 361 mod_lift(KC_RBRACKET, KC_RCTL, 5);
270 } 362}
271return false; 363return false;
272break; 364break;
273 365
274#+END_SRC 366#+END_SRC
275 367
276*** Shft and =- 368** Shft and =-
277 369
278I place shift on the home row, so having '-' right of my pinkie is standard, and 370I place shift on the home row, so having '-' right of my pinkie is standard, and
279it only felt natural to put its opposite, '=/+' on the other side. I put an 371it only felt natural to put its opposite, '=/+' on the other side. I put an
@@ -282,24 +374,24 @@ extra one on the right side in the secondary layer for the num pad.
282#+BEGIN_SRC C :noweb yes 374#+BEGIN_SRC C :noweb yes
283case KC_T_LSFT: 375case KC_T_LSFT:
284if (record->event.pressed) { 376if (record->event.pressed) {
285 mod_press(KC_LSFT, 6); 377 mod_press(KC_EQUAL, KC_LSFT, 6);
286 } else { 378} else {
287 mod_lift(KC_EQUAL, KC_LSFT, 6); 379 mod_lift(KC_EQUAL, KC_LSFT, 6);
288 } 380}
289return false; 381return false;
290break; 382break;
291case KC_T_RSFT: 383case KC_T_RSFT:
292if (record->event.pressed) { 384if (record->event.pressed) {
293 mod_press(KC_RSFT, 7); 385 mod_press(KC_MINUS, KC_RSFT, 7);
294 } else { 386} else {
295 mod_lift(KC_MINUS, KC_RSFT, 7); 387 mod_lift(KC_MINUS, KC_RSFT, 7);
296 } 388}
297return false; 389return false;
298break; 390break;
299 391
300#+END_SRC 392#+END_SRC
301 393
302*** Rise, DEL, and / 394** Rise, DEL, and /
303 395
304I use the top corners as rise because I decided that I do not like using layers 396I use the top corners as rise because I decided that I do not like using layers
305with my thumbs. It feels uncomfortable to hold keys down with the side of my 397with my thumbs. It feels uncomfortable to hold keys down with the side of my
@@ -315,36 +407,78 @@ corner again mimicing a standard dvorak keyboard.
315#+BEGIN_SRC C :noweb yes 407#+BEGIN_SRC C :noweb yes
316case KC_T_LRSE: 408case KC_T_LRSE:
317if (record->event.pressed) { 409if (record->event.pressed) {
318 tap_timers[8] = timer_read(); 410 tap_timer = timer_read();
319 last_mod = 8; 411 last_mod = 8;
320 layer_on(_RISE); 412 layer_on(_RISE);
321 } else { 413} else {
322 layer_off(_RISE); 414 layer_off(_RISE);
323 if (last_mod == 8 && timer_elapsed(tap_timers[8]) < TAPPING_TERM) { 415 if (last_mod == 8 && timer_elapsed(tap_timer) < TAPPING_TERM) {
324 tap_code16(KC_DELETE); 416 tap_code16(KC_DELETE);
325 last_mod = -1; 417 last_mod = 10;
326 } 418 }
327 } 419}
328return false; 420return false;
329break; 421break;
330case KC_T_RRSE: 422case KC_T_RRSE:
331if (record->event.pressed) { 423if (record->event.pressed) {
332 tap_timers[9] = timer_read(); 424 tap_timer = timer_read();
333 last_mod = 9; 425 last_mod = 9;
334 layer_on(_RISE); 426 layer_on(_RISE);
335 } else { 427} else {
336 layer_off(_RISE); 428 layer_off(_RISE);
337 if (last_mod == 9 && timer_elapsed(tap_timers[9]) < TAPPING_TERM) { 429 if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) {
338 tap_code16(KC_SLASH); 430 tap_code16(KC_SLASH);
339 last_mod = -1; 431 last_mod = 10;
340 } 432 }
341 } 433}
342return false; 434return false;
343break; 435break;
344 436
345#+END_SRC 437#+END_SRC
346 438
347*** EZ keys 439** EZ Keys
440
441EZ or "easy" keys do things that can already be done on the board, but I want an
442easier way of doing them.
443
444*** One Shot Keys
445
446Since I made modified tap keys occur on press instead of release, I need one
447shot keys to press any key with more than one modifier.
448
449#+BEGIN_SRC C :noweb yes
450case KC_EZSHFT:
451if (record->event.pressed) {
452 set_oneshot_mods(MOD_LSFT);
453 last_mod = 10;
454}
455return false;
456break;
457case KC_EZCTRL:
458if (record->event.pressed) {
459 set_oneshot_mods(MOD_LCTL);
460 last_mod = 10;
461}
462return false;
463break;
464case KC_EZALT:
465if (record->event.pressed) {
466 set_oneshot_mods(MOD_LALT);
467 last_mod = 10;
468}
469return false;
470break;
471case KC_EZGUI:
472if (record->event.pressed) {
473 set_oneshot_mods(MOD_LGUI);
474 last_mod = 10;
475}
476return false;
477break;
478
479#+END_SRC
480
481*** Arrows
348 482
349I use ctrl+shift+arrows keys a lot, so when the layer key is pressed they became 483I use ctrl+shift+arrows keys a lot, so when the layer key is pressed they became
350lazy versions of themselves with control and shift already pressed. 484lazy versions of themselves with control and shift already pressed.
@@ -355,77 +489,134 @@ left hand like on a qwerty or colemek keyboard.
355#+BEGIN_SRC C :noweb yes 489#+BEGIN_SRC C :noweb yes
356case KC_EZRGHT: 490case KC_EZRGHT:
357if (record->event.pressed) { 491if (record->event.pressed) {
358 register_code(KC_LCTL); 492 register_code(KC_LCTL);
359 tap_code16(S(KC_RGHT)); 493 tap_code16(S(KC_RGHT));
360 unregister_code(KC_LCTL); 494 unregister_code(KC_LCTL);
361 last_mod = -1; 495 last_mod = 10;
362 } 496}
363return false; 497return false;
364break; 498break;
365case KC_EZLEFT: 499case KC_EZLEFT:
366if (record->event.pressed) { 500if (record->event.pressed) {
367 register_code(KC_LCTL); 501 register_code(KC_LCTL);
368 tap_code16(S(KC_LEFT)); 502 tap_code16(S(KC_LEFT));
369 unregister_code(KC_LCTL); 503 unregister_code(KC_LCTL);
370 last_mod = -1; 504 last_mod = 10;
371 } 505}
372return false; 506return false;
373break; 507break;
374case KC_EZDOWN: 508case KC_EZDOWN:
375if (record->event.pressed) { 509if (record->event.pressed) {
376 register_code(KC_LCTL); 510 register_code(KC_LCTL);
377 tap_code16(S(KC_DOWN)); 511 tap_code16(S(KC_DOWN));
378 unregister_code(KC_LCTL); 512 unregister_code(KC_LCTL);
379 last_mod = -1; 513 last_mod = 10;
380 } 514}
381return false; 515return false;
382break; 516break;
383case KC_EZUP: 517case KC_EZUP:
384if (record->event.pressed) { 518if (record->event.pressed) {
385 register_code(KC_LCTL); 519 register_code(KC_LCTL);
386 tap_code16(S(KC_UP)); 520 tap_code16(S(KC_UP));
387 unregister_code(KC_LCTL); 521 unregister_code(KC_LCTL);
388 last_mod = -1; 522 last_mod = 10;
389 } 523}
390return false; 524return false;
391break; 525break;
526#+END_SRC
527
528*** Undo, Copy, Cut, Paste
529
530#+BEGIN_SRC C :noweb yes
392case KC_EZUNDO: 531case KC_EZUNDO:
393if (record->event.pressed) { 532if (record->event.pressed) {
394 tap_code16(C(KC_Z)); 533 tap_code16(C(KC_Z));
395 last_mod = -1; 534 last_mod = 10;
396} 535}
397return false; 536return false;
398break; 537break;
399case KC_EZCOPY: 538case KC_EZCOPY:
400if (record->event.pressed) { 539if (record->event.pressed) {
401 tap_code16(C(KC_C)); 540 tap_code16(C(KC_C));
402 last_mod = -1; 541 last_mod = 10;
403} 542}
404return false; 543return false;
405break; 544break;
406case KC_EZCUT: 545case KC_EZCUT:
407if (record->event.pressed) { 546if (record->event.pressed) {
408 tap_code16(C(KC_X)); 547 tap_code16(C(KC_X));
409 last_mod = -1; 548 last_mod = 10;
410} 549}
411return false; 550return false;
412break; 551break;
413case KC_EZPSTE: 552case KC_EZPSTE:
414if (record->event.pressed) { 553if (record->event.pressed) {
415 tap_code16(C(KC_P)); 554 tap_code16(C(KC_V));
416 last_mod = -1; 555 last_mod = 10;
556}
557return false;
558break;
559#+END_SRC
560
561** Commands
562
563Start command layer one shot
564
565#+BEGIN_SRC C :noweb yes
566case KC_COM:
567if (record->event.pressed) {
568 layer_on(_COMMAND);
569 set_oneshot_layer(_COMMAND, ONESHOT_START);
570 last_mod = 10;
571} else {
572 clear_oneshot_layer_state (ONESHOT_PRESSED);
417} 573}
418return false; 574return false;
419break; 575break;
420#+END_SRC 576#+END_SRC
421 577
422*** Standard inputs interupt tap 578Just some strings I notice that I type a lot.
579
580#+BEGIN_SRC C :noweb yes
581case KC_USER:
582if (record->event.pressed) {
583 send_string("mhostley");
584 last_mod = 10;
585}
586return true;
587break;
588case KC_EMAIL:
589if (record->event.pressed) {
590 send_string("mhostley@gmail.com");
591 last_mod = 10;
592}
593return true;
594break;
595case KC_NAME:
596if (record->event.pressed) {
597 send_string("Samuel Jahnke");
598 last_mod = 10;
599}
600return true;
601break;
602case KC_DIR:
603if (record->event.pressed) {
604 send_string("home/mhostley/");
605 last_mod = 10;
606}
607return true;
608break;
609
610#+END_SRC
611
612** Standard inputs interupt tap
423 613
424Finally, if just a standard key is tapped, set the interupted flag. 614Finally, if just a standard key is tapped, set the interupted flag.
615Keep this last.
425 616
426#+BEGIN_SRC C :noweb yes 617#+BEGIN_SRC C :noweb yes
427 } 618}
428 last_mod = -1; 619last_mod = 10;
429 return true; 620return true;
430} 621}
431#+END_SRC 622#+END_SRC
diff --git a/keyboards/planck/keymaps/samuel/keymap.c b/keyboards/planck/keymaps/samuel/keymap.c
index 53760da76..ff1424489 100644
--- a/keyboards/planck/keymaps/samuel/keymap.c
+++ b/keyboards/planck/keymaps/samuel/keymap.c
@@ -2,36 +2,45 @@
2 2
3extern keymap_config_t keymap_config; 3extern keymap_config_t keymap_config;
4 4
5static uint16_t tap_timers[10] = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
6
7char last_mod = -1;
8
9enum planck_layers {
10 _DVORAK,
11 _RISE
12};
13
14// where the 'T_' communicates how the key does something different when tapped. 5// where the 'T_' communicates how the key does something different when tapped.
15enum planck_keycodes { 6enum planck_keycodes {
16 DVORAK = SAFE_RANGE, 7//DVORAK = SAFE_RANGE,
17 KC_T_LALT, 8KC_T_LALT = SAFE_RANGE,
18 KC_T_RALT, 9KC_T_RALT,
19 KC_T_LGUI, 10KC_T_LGUI,
20 KC_T_RGUI, 11KC_T_RGUI,
21 KC_T_LCTL, 12KC_T_LCTL,
22 KC_T_RCTL, 13KC_T_RCTL,
23 KC_T_LSFT, 14KC_T_LSFT,
24 KC_T_RSFT, 15KC_T_RSFT,
25 KC_T_LRSE, 16KC_T_LRSE,
26 KC_T_RRSE, 17KC_T_RRSE,
27 KC_EZRGHT, 18KC_EZRGHT,
28 KC_EZLEFT, 19KC_EZLEFT,
29 KC_EZUP, 20KC_EZUP,
30 KC_EZDOWN, 21KC_EZDOWN,
31 KC_EZUNDO, 22KC_EZUNDO,
32 KC_EZCOPY, 23KC_EZCOPY,
33 KC_EZCUT, 24KC_EZCUT,
34 KC_EZPSTE 25KC_EZPSTE,
26KC_EZSHFT,
27KC_EZCTRL,
28KC_EZGUI,
29KC_EZALT,
30KC_DVORAK,
31KC_QWERTY,
32KC_USER,
33KC_EMAIL,
34KC_NAME,
35KC_DIR,
36KC_COM
37};
38
39enum planck_layers {
40_DVORAK,
41_QWERTY,
42_RISE,
43_COMMAND
35}; 44};
36 45
37const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 46const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
@@ -44,202 +53,307 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
44{ KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_BSPC, KC_TAB, KC_ENT, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_T_RGUI} 53{ KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_BSPC, KC_TAB, KC_ENT, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_T_RGUI}
45}, 54},
46 55
56[_QWERTY] =
57
58{{ 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},
59{ 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},
60{ 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},
61{ KC_T_LGUI, KC_T_LALT, KC_UP, KC_DOWN, KC_BSPC, KC_TAB, KC_ENT, KC_SPC, KC_LEFT, KC_RIGHT, KC_T_RALT, KC_DVORAK}
62},
63
47[_RISE] = 64[_RISE] =
48 65
49{{ KC_TRANSPARENT, KC_EZUNDO, KC_EZCOPY, KC_EZCUT, KC_EZPSTE, KC_INS, KC_EQL, KC_7, KC_8, KC_9, KC_F11, KC_TRANSPARENT}, 66{{ KC_TRANSPARENT, KC_EZUNDO, KC_EZCOPY, KC_EZCUT, KC_EZPSTE, KC_INS, KC_EQL, KC_7, KC_8, KC_9, KC_TRANSPARENT, KC_TRANSPARENT},
50{ KC_TRANSPARENT, KC_ESC, KC_CAPS, KC_PGUP, KC_PGDN, KC_F4, KC_ASTR, KC_4, KC_5, KC_6, KC_0, KC_TRANSPARENT}, 67{ KC_EZSHFT, KC_ESC, KC_CAPS, KC_PGUP, KC_PGDN, KC_HOME, KC_ASTR, KC_4, KC_5, KC_6, KC_0, KC_EZSHFT},
51{ KC_TRANSPARENT, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_1, KC_2, KC_3, KC_F12, KC_TRANSPARENT}, 68{ KC_EZCTRL, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_1, KC_2, KC_3, KC_COM, KC_EZCTRL},
52{ KC_TRANSPARENT, KC_TRANSPARENT, KC_EZUP, KC_EZDOWN, KC_TRANSPARENT, KC_AMPR, KC_PIPE, KC_TRANSPARENT, KC_EZLEFT, KC_EZRGHT, KC_TRANSPARENT, KC_TRANSPARENT} 69{ KC_EZGUI, KC_EZALT, KC_EZUP, KC_EZDOWN, KC_SPC, KC_AMPR, KC_PIPE, KC_END, KC_EZLEFT, KC_EZRGHT, KC_EZALT, KC_EZGUI}
70},
71
72[_COMMAND] =
73
74{{ KC_TRANSPARENT, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRANSPARENT},
75{ KC_TRANSPARENT, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, KC_TRANSPARENT},
76{ KC_TRANSPARENT, KC_F21, KC_F22, KC_F23, KC_F24, KC_QWERTY, KC_DVORAK, KC_USER, KC_EMAIL, KC_NAME, KC_TRANSPARENT, KC_TRANSPARENT},
77{ KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_DIR, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT, KC_TRANSPARENT}
53}, 78},
54 79
55}; 80};
56 81
57void mod_press(uint16_t hold_code, int id) { 82static uint16_t tap_timer = 0;
58 tap_timers[id] = timer_read(); 83char last_mod = 10;
59 last_mod = id; 84
60 register_code(hold_code); 85void mod_press(uint16_t tap_code, uint16_t hold_code, int id) {
86 // this first if body makes double modified keys impossible, but stops the
87 // delay when modifying a tap key which would result in the tap key not
88 // getting modified.
89 if (last_mod != id && last_mod != 10) {
90 tap_code16(tap_code);
91 last_mod = 10;
92 } else {
93 tap_timer = timer_read();
94 last_mod = id;
95 register_code(hold_code);
96 }
61} 97}
62 98
63void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) { 99void mod_lift(uint16_t tap_code, uint16_t hold_code, int id) {
64 unregister_code(hold_code); 100 unregister_code(hold_code);
65 if (last_mod == id && timer_elapsed(tap_timers[id]) < TAPPING_TERM) { 101 if (last_mod == id && timer_elapsed(tap_timer) < TAPPING_TERM) {
66 tap_code16(tap_code); 102 tap_code16(tap_code);
67 last_mod = -1; 103 last_mod = 10;
68 } 104 }
69} 105}
70 106
71bool process_record_user(uint16_t keycode, keyrecord_t *record) { 107bool process_record_user(uint16_t keycode, keyrecord_t *record) {
72 switch (keycode) { 108 switch (keycode) {
73 case DVORAK: 109
74 if (record->event.pressed) { 110case KC_DVORAK:
75 set_single_persistent_default_layer(_DVORAK); 111if (record->event.pressed) {
76 } 112 set_single_persistent_default_layer(_DVORAK);
77 return false; 113}
78 break; 114return true;
115break;
116
117case KC_QWERTY:
118if (record->event.pressed) {
119 set_single_persistent_default_layer(_QWERTY);
120}
121return true;
122break;
79 123
80case KC_T_LALT: 124case KC_T_LALT:
81if (record->event.pressed) { 125if (record->event.pressed) {
82 mod_press(KC_LALT, 0); 126 mod_press(S(KC_9), KC_LALT, 0);
83 } else { 127} else {
84 mod_lift(S(KC_9), KC_LALT, 0); 128 mod_lift(S(KC_9), KC_LALT, 0);
85 } 129}
86return false; 130return false;
87break; 131break;
88case KC_T_RALT: 132case KC_T_RALT:
89if (record->event.pressed) { 133if (record->event.pressed) {
90 mod_press(KC_RALT, 1); 134 mod_press(S(KC_0), KC_RALT, 1);
91 } else { 135} else {
92 mod_lift(S(KC_0), KC_RALT, 1); 136 mod_lift(S(KC_0), KC_RALT, 1);
93 } 137}
94return false; 138return false;
95break; 139break;
96 140
97case KC_T_LGUI: 141case KC_T_LGUI:
98if (record->event.pressed) { 142if (record->event.pressed) {
99 mod_press(KC_LGUI, 2); 143 mod_press(KC_GRAVE, KC_LGUI, 2);
100 } else { 144} else {
101 mod_lift(KC_GRAVE, KC_LGUI, 2); 145 mod_lift(KC_GRAVE, KC_LGUI, 2);
102 } 146}
103return false; 147return false;
104break; 148break;
105case KC_T_RGUI: 149case KC_T_RGUI:
106if (record->event.pressed) { 150if (record->event.pressed) {
107 mod_press(KC_RGUI, 3); 151 mod_press(KC_BSLASH, KC_RGUI, 3);
108 } else { 152} else {
109 mod_lift(KC_BSLASH, KC_RGUI, 3); 153 mod_lift(KC_BSLASH, KC_RGUI, 3);
110 } 154}
111return false; 155return false;
112break; 156break;
113 157
114case KC_T_LCTL: 158case KC_T_LCTL:
115if (record->event.pressed) { 159if (record->event.pressed) {
116 mod_press(KC_LCTL, 4); 160 mod_press(KC_LBRACKET, KC_LCTL, 4);
117 } else { 161} else {
118 mod_lift(KC_LBRACKET, KC_LCTL, 4); 162 mod_lift(KC_LBRACKET, KC_LCTL, 4);
119 } 163}
120return false; 164return false;
121break; 165break;
122case KC_T_RCTL: 166case KC_T_RCTL:
123if (record->event.pressed) { 167if (record->event.pressed) {
124 mod_press(KC_RCTL, 5); 168 mod_press(KC_RBRACKET, KC_RCTL, 5);
125 } else { 169} else {
126 mod_lift(KC_RBRACKET, KC_RCTL, 5); 170 mod_lift(KC_RBRACKET, KC_RCTL, 5);
127 } 171}
128return false; 172return false;
129break; 173break;
130 174
131case KC_T_LSFT: 175case KC_T_LSFT:
132if (record->event.pressed) { 176if (record->event.pressed) {
133 mod_press(KC_LSFT, 6); 177 mod_press(KC_EQUAL, KC_LSFT, 6);
134 } else { 178} else {
135 mod_lift(KC_EQUAL, KC_LSFT, 6); 179 mod_lift(KC_EQUAL, KC_LSFT, 6);
136 } 180}
137return false; 181return false;
138break; 182break;
139case KC_T_RSFT: 183case KC_T_RSFT:
140if (record->event.pressed) { 184if (record->event.pressed) {
141 mod_press(KC_RSFT, 7); 185 mod_press(KC_MINUS, KC_RSFT, 7);
142 } else { 186} else {
143 mod_lift(KC_MINUS, KC_RSFT, 7); 187 mod_lift(KC_MINUS, KC_RSFT, 7);
144 } 188}
145return false; 189return false;
146break; 190break;
147 191
148case KC_T_LRSE: 192case KC_T_LRSE:
149if (record->event.pressed) { 193if (record->event.pressed) {
150 tap_timers[8] = timer_read(); 194 tap_timer = timer_read();
151 last_mod = 8; 195 last_mod = 8;
152 layer_on(_RISE); 196 layer_on(_RISE);
153 } else { 197} else {
154 layer_off(_RISE); 198 layer_off(_RISE);
155 if (last_mod == 8 && timer_elapsed(tap_timers[8]) < TAPPING_TERM) { 199 if (last_mod == 8 && timer_elapsed(tap_timer) < TAPPING_TERM) {
156 tap_code16(KC_DELETE); 200 tap_code16(KC_DELETE);
157 last_mod = -1; 201 last_mod = 10;
158 } 202 }
159 } 203}
160return false; 204return false;
161break; 205break;
162case KC_T_RRSE: 206case KC_T_RRSE:
163if (record->event.pressed) { 207if (record->event.pressed) {
164 tap_timers[9] = timer_read(); 208 tap_timer = timer_read();
165 last_mod = 9; 209 last_mod = 9;
166 layer_on(_RISE); 210 layer_on(_RISE);
167 } else { 211} else {
168 layer_off(_RISE); 212 layer_off(_RISE);
169 if (last_mod == 9 && timer_elapsed(tap_timers[9]) < TAPPING_TERM) { 213 if (last_mod == 9 && timer_elapsed(tap_timer) < TAPPING_TERM) {
170 tap_code16(KC_SLASH); 214 tap_code16(KC_SLASH);
171 last_mod = -1; 215 last_mod = 10;
172 } 216 }
173 } 217}
218return false;
219break;
220
221case KC_EZSHFT:
222if (record->event.pressed) {
223 set_oneshot_mods(MOD_LSFT);
224 last_mod = 10;
225}
226return false;
227break;
228case KC_EZCTRL:
229if (record->event.pressed) {
230 set_oneshot_mods(MOD_LCTL);
231 last_mod = 10;
232}
233return false;
234break;
235case KC_EZALT:
236if (record->event.pressed) {
237 set_oneshot_mods(MOD_LALT);
238 last_mod = 10;
239}
240return false;
241break;
242case KC_EZGUI:
243if (record->event.pressed) {
244 set_oneshot_mods(MOD_LGUI);
245 last_mod = 10;
246}
174return false; 247return false;
175break; 248break;
176 249
177case KC_EZRGHT: 250case KC_EZRGHT:
178if (record->event.pressed) { 251if (record->event.pressed) {
179 register_code(KC_LCTL); 252 register_code(KC_LCTL);
180 tap_code16(S(KC_RGHT)); 253 tap_code16(S(KC_RGHT));
181 unregister_code(KC_LCTL); 254 unregister_code(KC_LCTL);
182 last_mod = -1; 255 last_mod = 10;
183 } 256}
184return false; 257return false;
185break; 258break;
186case KC_EZLEFT: 259case KC_EZLEFT:
187if (record->event.pressed) { 260if (record->event.pressed) {
188 register_code(KC_LCTL); 261 register_code(KC_LCTL);
189 tap_code16(S(KC_LEFT)); 262 tap_code16(S(KC_LEFT));
190 unregister_code(KC_LCTL); 263 unregister_code(KC_LCTL);
191 last_mod = -1; 264 last_mod = 10;
192 } 265}
193return false; 266return false;
194break; 267break;
195case KC_EZDOWN: 268case KC_EZDOWN:
196if (record->event.pressed) { 269if (record->event.pressed) {
197 register_code(KC_LCTL); 270 register_code(KC_LCTL);
198 tap_code16(S(KC_DOWN)); 271 tap_code16(S(KC_DOWN));
199 unregister_code(KC_LCTL); 272 unregister_code(KC_LCTL);
200 last_mod = -1; 273 last_mod = 10;
201 } 274}
202return false; 275return false;
203break; 276break;
204case KC_EZUP: 277case KC_EZUP:
205if (record->event.pressed) { 278if (record->event.pressed) {
206 register_code(KC_LCTL); 279 register_code(KC_LCTL);
207 tap_code16(S(KC_UP)); 280 tap_code16(S(KC_UP));
208 unregister_code(KC_LCTL); 281 unregister_code(KC_LCTL);
209 last_mod = -1; 282 last_mod = 10;
210 } 283}
211return false; 284return false;
212break; 285break;
286
213case KC_EZUNDO: 287case KC_EZUNDO:
214if (record->event.pressed) { 288if (record->event.pressed) {
215 tap_code16(C(KC_Z)); 289 tap_code16(C(KC_Z));
216 last_mod = -1; 290 last_mod = 10;
217} 291}
218return false; 292return false;
219break; 293break;
220case KC_EZCOPY: 294case KC_EZCOPY:
221if (record->event.pressed) { 295if (record->event.pressed) {
222 tap_code16(C(KC_C)); 296 tap_code16(C(KC_C));
223 last_mod = -1; 297 last_mod = 10;
224} 298}
225return false; 299return false;
226break; 300break;
227case KC_EZCUT: 301case KC_EZCUT:
228if (record->event.pressed) { 302if (record->event.pressed) {
229 tap_code16(C(KC_X)); 303 tap_code16(C(KC_X));
230 last_mod = -1; 304 last_mod = 10;
231} 305}
232return false; 306return false;
233break; 307break;
234case KC_EZPSTE: 308case KC_EZPSTE:
235if (record->event.pressed) { 309if (record->event.pressed) {
236 tap_code16(C(KC_P)); 310 tap_code16(C(KC_V));
237 last_mod = -1; 311 last_mod = 10;
238} 312}
239return false; 313return false;
240break; 314break;
241 315
242 } 316case KC_COM:
243 last_mod = -1; 317if (record->event.pressed) {
244 return true; 318 layer_on(_COMMAND);
319 set_oneshot_layer(_COMMAND, ONESHOT_START);
320 last_mod = 10;
321} else {
322 clear_oneshot_layer_state (ONESHOT_PRESSED);
323}
324return false;
325break;
326
327case KC_USER:
328if (record->event.pressed) {
329 send_string("mhostley");
330 last_mod = 10;
331}
332return true;
333break;
334case KC_EMAIL:
335if (record->event.pressed) {
336 send_string("mhostley@gmail.com");
337 last_mod = 10;
338}
339return true;
340break;
341case KC_NAME:
342if (record->event.pressed) {
343 send_string("Samuel Jahnke");
344 last_mod = 10;
345}
346return true;
347break;
348case KC_DIR:
349if (record->event.pressed) {
350 send_string("home/mhostley/");
351 last_mod = 10;
352}
353return true;
354break;
355
356}
357last_mod = 10;
358return true;
245} 359}