2 // Inspired by MicroDox:
3 // http://geekhack.org/index.php?topic=42231.msg1062851#msg1062851
4 // https://www.massdrop.com/ext/ergodox/?referer=CTL63V&hash=9ff8ddbb75e03e517aaa39acabc81669
6 #include <util/delay.h>
7 #include "bootloader.h"
8 #include "keymap_common.h"
11 const uint8_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
13 * Keymap: Default Layer in QWERTY
15 * ,--------------------------------------------------. ,--------------------------------------------------.
16 * | | | | | | | | | | | | | | | |
17 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
18 * | Tab | Q | W | E | R | T | | | | Y | U | I | O | P | [ |
19 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
20 * | Tab/Shf| A | S | D | F | G |------| |------| H | J | K | L | ; | ' |
21 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
22 * | LCtrl/~| Z | X | C | V | B | | | | N | M | , | . | / | ] |
23 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
24 * | | | Caps | LAlt | LGui | | RGui | | | | |
25 * | | | | Spc | Esc | | | | | | |
26 * `----------------------------------' `----------------------------------'
27 * ,-------------. ,-------------.
29 * ,------|------|------| |------+------+------.
31 * | BkSp | Del |------| |------| Enter| Space|
32 * | | | Esc | | Ins | | |
33 * | LCtl | LSft | LAlt | | RAlt | RSft | RCtl |
34 * `--------------------' `--------------------'
38 ****************************************************************************************************
40 * Under XOrg, I use my own mapping from QWERTY to "Workman for Programmers"
41 * See XOrg files in ./addons/ subdirectory.
43 * I have to do so, because of two things:
44 * 1) my native language is Russian, and XOrg keymap for it is based on QWERTY layout
45 * 2) I want to have non-standart shifted keys, like $ (as normal) and @ (as shifted), or _ and -
47 * And even if (2) could be solved using FN* keys (but there is limit in firmware for only 32 such
48 * keys), then (1) can't be solved at firmware level at all.
50 * So, I have to stick with QWERTY as my main layout + my own XOrg keyboard layout for English.
51 * But sometimes I have to input something when XOrg is not active - for example, in Linux console,
52 * or in firmware console (while debugging firmware), or when keyboard is connected to not my computer.
54 * For such cases I have Layer1 :)
55 * // hint: switch to Layer1 is only at Layer6
57 ****************************************************************************************************
61 * Keymap: Default Layer in Workman
63 * ,--------------------------------------------------. ,--------------------------------------------------.
64 * | | | | | | | | | | | | | | | |
65 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
66 * | Tab | Q | D | R | W | B | | | | J | F | U | P | $ | : |
67 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
68 * | Tab/Shf| A | S | H | T | G |------| |------| Y | N | E | O | I | - |
69 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
70 * | LCtrl | Z | X | M | C | V | | | | K | L | , | . | / | | |
71 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
72 * | | | Caps | LAlt | LGui | | RGui | | | | |
73 * | | | | Spc | Esc | | | | | | |
74 * `----------------------------------' `----------------------------------'
75 * ,-------------. ,-------------.
77 * ,------|------|------| |------+------+------.
79 * | BkSp | Del |------| |------| Enter| Space|
80 * | | | Esc | | Ins | | |
81 * | LCtl | LSft | LAlt | | RAlt | RSft | RCtl |
82 * `--------------------' `--------------------'
84 * Keymap: Default Layer in Workman / with Shift
86 * ,--------------------------------------------------. ,--------------------------------------------------.
87 * | | | | | | | | | | | | | | | |
88 * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
89 * | Tab | Q | D | R | W | B | | | | J | F | U | P | @ | % |
90 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
91 * | Tab/Shf| A | S | H | T | G |------| |------| Y | N | E | O | I | _ |
92 * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
93 * | LCtrl | Z | X | M | C | V | | | | K | L | , | . | / | & |
94 * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
95 * | | | Caps | LAlt | LGui | | RGui | | | | |
96 * | | | | Spc | Esc | | | | | | |
97 * `----------------------------------' `----------------------------------'
98 * ,-------------. ,-------------.
100 * ,------|------|------| |------+------+------.
102 * | BkSp | Del |------| |------| Enter| Space|
103 * | | | Esc | | Ins | | |
104 * | LCtl | LSft | LAlt | | RAlt | RSft | RCtl |
105 * `--------------------' `--------------------'
107 * | ~ | ; | ! | # | { | } | ' | | ^ | [ | ] | * | ( | ) | = |
108 * | ` | 1 | 2 | 3 | 4 | 5 | " | | \ | 6 | 7 | 8 | 9 | 0 | + |
111 KEYMAP( // Layer0: default, leftled:none
113 NO, NO, NO, NO, NO, NO, NO,
114 TAB, Q, W, E, R, T, NO,
115 FN11,FN28,FN29,FN30,FN21,G,
116 FN12,FN24,FN25,FN26,FN27,B, NO,
117 NO, NO, CAPS,FN13,FN14,
122 NO, NO, NO, NO, NO, NO, NO,
123 NO, Y, U, I, O, P, LBRC,
124 H, J, K, L, FN22,FN15,
125 NO, N, M, COMM,DOT, SLSH,FN16,
126 RGUI,FN17,NO, NO, NO,
132 KEYMAP( // Layer1: Workman layout, leftled:all
134 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
135 TRNS,Q, D, R, W, B, TRNS,
137 TRNS,Z, X, M, C, V, TRNS,
138 TRNS,TRNS,TRNS,TRNS,TRNS,
143 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
144 TRNS,J, F, U, P, 4, TRNS,
146 TRNS,K, L, TRNS,TRNS,TRNS,TRNS,
147 TRNS,TRNS,TRNS,TRNS,TRNS,
153 KEYMAP( // Layer2: numpad, leftled:blue
155 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
156 TRNS,NO, NO, NO, NO, NO, TRNS,
157 TRNS,NO, NO, NO, TRNS,NO,
158 TRNS,NO, NO, NO, TRNS,NO, TRNS,
159 TRNS,TRNS,TRNS,TRNS,TRNS,
164 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
165 TRNS,NLCK,P7, P8, P9, PMNS,PGUP,
166 PAST,P4, P5, P6, PPLS,PGDN,
167 TRNS,FN17,P1, P2, P3, PSLS,PENT,
168 P0, PDOT,SLSH,NO, NO,
174 KEYMAP( // Layer3: F-keys + PgUp/PgDn on right hand, leftled:green
176 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
177 TRNS,NO, NO, NO, NO, NO, TRNS,
178 TRNS,NO, TRNS,NO, NO, NO,
179 TRNS,NO, TRNS,NO, NO, NO, TRNS,
180 TRNS,TRNS,TRNS,LALT,LGUI,
185 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
186 TRNS,PSCR,F1, F2, F3, F4, PGUP,
187 SLCK,F5, F6, F7, F8, PGDN,
188 TRNS,PAUS,F9, F10, F11, F12, APP,
189 RGUI,RALT,TRNS,TRNS,TRNS,
195 KEYMAP( // Layer4: unconvenient keys on right hand, leftled:red
197 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
198 TRNS,NO, NO, NO, NO, NO, TRNS,
199 TRNS,TRNS,NO, NO, NO, NO,
200 TRNS,TRNS,NO, NO, NO, NO, TRNS,
201 TRNS,TRNS,TRNS,TRNS,TRNS,
206 /* in Workman right hand will be:
214 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
215 TRNS,MINS,4, 5, 9, 0, PPLS,
216 BSLS,2, P, FN1, 1, EQL,
217 TRNS,3, 6, FN3, FN4, 7, FN2,
218 TRNS,TRNS,TRNS,TRNS,TRNS,
224 KEYMAP( // Layer5: cursor, leftled:red
226 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
227 TRNS,NO, NO, NO, NO, NO, TRNS,
228 TRNS,NO, NO, NO, TRNS,NO,
229 TRNS,NO, NO, NO, NO, NO, TRNS,
230 TRNS,TRNS,TRNS,TRNS,TRNS,
235 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
236 TRNS,PGUP,HOME,END, DEL, INS, PGUP,
237 PGDN,LEFT,UP, DOWN,RGHT,PGDN,
238 TRNS,NO, HOME,END, DEL, INS, TRNS,
239 TRNS,TRNS,TRNS,TRNS,TRNS,
245 KEYMAP( // Layer6: F1-F10, Workman-layer switch, Teensy, layer switches, leftled:red+onboard
247 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
248 FN0, F1, F2, F3, F4, F5, TRNS,
249 TRNS,FN18,NO, NO, FN19,NO,
250 TRNS,NO, NO, NO, FN19,NO, TRNS,
251 TRNS,TRNS,TRNS,TRNS,TRNS,
256 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
257 TRNS,F6, F7, F8, F9, F10, FN0,
258 FN0, NO, NO, NO, TRNS,TRNS,
259 TRNS,NO, NO, NO, NO, NO, TRNS,
260 TRNS,TRNS,TRNS,TRNS,TRNS,
270 KEYMAP( // Layer7: F-keys only, leftled:red
272 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
273 TRNS,F13, F14, F15, F16, NO, TRNS,
274 TRNS,F17, F18, F19, F20, NO,
275 TRNS,F21, F22, F23, F24, NO, TRNS,
276 TRNS,TRNS,TRNS,TRNS,TRNS,
281 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
282 TRNS,NO, F1, F2, F3, F4, TRNS,
283 NO, F5, F6, F7, F8, TRNS,
284 TRNS,NO, F9, F10, F11, F12, TRNS,
285 TRNS,TRNS,TRNS,TRNS,TRNS,
291 KEYMAP( // Layer8: mouse and navigation, leftled:blue and green
293 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
294 TRNS,NO, NO, NO, NO, NO, TRNS,
295 TRNS,NO, NO, TRNS,NO, NO,
296 TRNS,NO, NO, TRNS,NO, NO, TRNS,
297 TRNS,TRNS,TRNS,TRNS,TRNS,
303 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
304 TRNS,BTN2,WH_L,WH_U,WH_D,WH_R,PGUP,
305 BTN1,MS_L,MS_U,MS_D,MS_R,PGDN,
306 TRNS,BTN3,HOME,END, DEL, INS, NO,
307 TRNS,TRNS,TRNS,TRNS,TRNS,
314 // templates to copy from
316 KEYMAP( // LayerN: transparent on edges + hard-defined thumb keys, all others are empty
318 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
319 TRNS,NO, NO, NO, NO, NO, TRNS,
320 TRNS,NO, NO, NO, NO, NO,
321 TRNS,NO, NO, NO, NO, NO, TRNS,
322 TRNS,TRNS,TRNS,LALT,LGUI,
327 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
328 TRNS,NO, NO, NO, NO, NO, TRNS,
329 NO, NO, NO, NO, NO, TRNS,
330 TRNS,NO, NO, NO, NO, NO, TRNS,
331 RGUI,RALT,TRNS,TRNS,TRNS,
336 KEYMAP( // LayerN: fully transparent
338 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
339 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
340 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
341 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
342 TRNS,TRNS,TRNS,TRNS,TRNS,
347 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
348 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
349 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
350 TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,TRNS,
351 TRNS,TRNS,TRNS,TRNS,TRNS,
360 /* id for user defined functions */
366 * Fn action definition
368 const uint16_t PROGMEM fn_actions[] = {
369 ACTION_FUNCTION(TEENSY_KEY), // FN0 - Teensy key
371 // Layer4: unconvenient keys on right hand
372 ACTION_MODS_KEY(MOD_LSFT, KC_BSLS), // FN1 = Shifted BackSlash // " in Workman
373 ACTION_MODS_KEY(MOD_LSFT, KC_MINS), // FN2 = Shifted Minus // \ in Workman
374 ACTION_MODS_KEY(MOD_LSFT, KC_COMM), // FN3 = Shifted comma // < in Workman
375 ACTION_MODS_KEY(MOD_LSFT, KC_DOT), // FN4 = Shifted dot // > in Workman
377 // Dual-role keys on thumbs
378 ACTION_MODS_TAP_KEY(MOD_LCTL, KC_BSPC), // FN5 = LShift with tap BackSpace
379 ACTION_MODS_TAP_KEY(MOD_LSFT, KC_DEL), // FN6 = LCtrl with tap Delete
380 ACTION_MODS_TAP_KEY(MOD_LALT, KC_ESC), // FN7 = LAlt with tap Escape
381 ACTION_MODS_TAP_KEY(MOD_RALT, KC_INS), // FN8 = RAlt with tap Ins
382 ACTION_MODS_TAP_KEY(MOD_RSFT, KC_ENT), // FN9 = RShift with tap Enter
383 ACTION_MODS_TAP_KEY(MOD_RCTL, KC_SPC), // FN10 = RCtrl with tap Space
385 // Dual-role keys on pinkies
386 ACTION_MODS_TAP_KEY(MOD_LSFT, KC_TAB), // FN11 = LShift with tap Tab
387 ACTION_MODS_TAP_KEY(MOD_LCTL, KC_GRV), // FN12 = LCtrl with tap Tilda
388 ACTION_MODS_TAP_KEY(MOD_LALT, KC_SPC), // FN13 = LAlt with tap Space
389 ACTION_MODS_TAP_KEY(MOD_LGUI, KC_ESC), // FN14 = LGui with tap Escape
390 ACTION_MODS_TAP_KEY(MOD_RSFT, KC_QUOT), // FN15 = RShift with tap quotes
391 ACTION_MODS_TAP_KEY(MOD_RCTL, KC_RBRC), // FN16 = RCtrl with tap ]
394 ACTION_LAYER_SET(0, ON_BOTH), // FN17 - set Layer0
395 ACTION_LAYER_SET(1, ON_BOTH), // FN18 - set Layer1, to use Workman layout at firmware level
396 ACTION_LAYER_SET(2, ON_BOTH), // FN19 - set Layer2, to use with Numpad keys
398 ACTION_LAYER_MOMENTARY(2), // UNUSED: FN20 - momentary Layer2, to use with Numpad keys
399 ACTION_LAYER_TAP_KEY(5, KC_F), // FN21 - momentary Layer5, to use with cursor
400 ACTION_LAYER_TAP_KEY(6, KC_SCLN), // FN22 - tapping ; Layer6, to use with F1-F10, Workman-layer switch, Teensy, layer switches
401 ACTION_LAYER_MOMENTARY(7), // UNUSED: FN23 - momentary Layer7, to use with F* keys (F1-F24)
403 ACTION_LAYER_TAP_KEY(4, KC_Z), // FN24 = momentary Layer4 on Z key, to use with unconvenient keys
404 ACTION_LAYER_TAP_KEY(3, KC_X), // FN25 = momentary Layer3 on X key, to use with F* keys
405 ACTION_LAYER_TAP_KEY(8, KC_C), // FN26 = momentary Layer8 on C key, to use with mouse and navigation keys
406 ACTION_LAYER_TAP_KEY(2, KC_V), // FN27 = momentary Layer2 on V key, to use with Numpad keys
408 // i'd like to remove this - will try to get used to live without this and convert them to usual keys
409 ACTION_LAYER_TAP_KEY(4, KC_A), // FN28 = momentary Layer4 on A key, to use with unconvenient keys
410 ACTION_LAYER_TAP_KEY(3, KC_S), // FN29 = momentary Layer3 on S key, to use with F* keys
411 ACTION_LAYER_TAP_KEY(8, KC_D), // FN30 = momentary Layer8 on D key, to use with mouse and navigation keys
412 ACTION_LAYER_TAP_KEY(2, KC_F), // UNUSED: FN31 = momentary Layer2 on F key, to use with Numpad keys
415 void action_function(keyrecord_t *event, uint8_t id, uint8_t opt)
417 print("action_function called\n");
418 print("id = "); phex(id); print("\n");
419 print("opt = "); phex(opt); print("\n");
420 if (id == TEENSY_KEY) {
422 print("\n\nJump to bootloader... ");
424 bootloader_jump(); // should not return
425 print("not supported.\n");