keymap.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. /*
  2. * Keyboard: Ergodox
  3. * Keymap: replicaJunction
  4. * Version: 1.2
  5. *
  6. * This keymap is designed to complement my Atreus keyboard layout, found in keyboards/atreus.
  7. * The Atreus keyboard is a 40% board whose design was heavily influenced by the Ergodox, and I now
  8. * have both keyboards, so I've designed these layouts in an effort to make switching between the
  9. * two as easy as possible.
  10. *
  11. * The default key layout in this keymap is Colemak-ModDH. Information on that layout can be found
  12. * here: https://colemakmods.github.io/mod-dh/
  13. */
  14. #include "ergodox.h"
  15. #include "debug.h"
  16. #include "action_layer.h"
  17. #define _CO 0 // Colemak
  18. #define _QW 1 // QWERTY
  19. #define _ME 2 // media keys
  20. #define _NU 3 // numpad
  21. #define _EX 4 // extend
  22. #define _GA 5 // mouse overlay for gaming
  23. // Some quick aliases, just to make it look pretty
  24. #define _______ KC_TRNS
  25. #define KCX_CGR LCTL(KC_GRV)
  26. #define KX_STAB LSFT(KC_TAB)
  27. #define KX_COPY LCTL(KC_C)
  28. #define KX_CUT LCTL(KC_X)
  29. #define KX_PAST LCTL(KC_V)
  30. #define KX_UNDO LCTL(KC_Z)
  31. ; // This doesn't do anything. It's just for VSCode because its syntax highlighting is weird for the above #define statements.
  32. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  33. /*
  34. * Keymap: Colemak-ModDH
  35. *
  36. * ,--------------------------------------------------. ,--------------------------------------------------.
  37. * | ` | 1 | 2 | 3 | 4 | 5 | Esc | | | 6 | 7 | 8 | 9 | 0 | = |
  38. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  39. * | LCtrl | Q | W | F | P | B | Home | | BkSp | J | L | U | Y | ; | - |
  40. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  41. * | Tab | A | R | S | T | G |------| |------| M | N | E | I | O | ' |
  42. * |--------+------+------+------+------+------| Hyper| | \ |------+------+------+------+------+--------|
  43. * | LShft | Z | X | C | D | V | | | | K | H | , | , | / | RShft |
  44. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  45. * | LGui | [ | ] |CtlShf| LAlt | | _EX | - | ' | = | \ |
  46. * `----------------------------------' `----------------------------------'
  47. * ,-------------. ,-------------.
  48. * | LCtrl| ~GA | | Left | Right|
  49. * ,------|------|------| |------+------+------.
  50. * |LCtrl/| LAlt/| Home | | Up | Alt/| _NU/ |
  51. * | BkSp | Del |------| |------| Enter| Space|
  52. * | | | _NU | | Down | | |
  53. * `--------------------' `--------------------'
  54. */
  55. [_CO] = KEYMAP(
  56. // left hand
  57. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_ESC,
  58. KC_LCTL,KC_Q, KC_W, KC_F, KC_P, KC_B, KC_HOME,
  59. KC_TAB, KC_A, KC_R, KC_S, KC_T, KC_G,
  60. KC_LSFT,KC_Z, KC_X, KC_C, KC_D, KC_V, ALL_T(KC_NO),
  61. KC_LGUI,KC_LBRC,KC_RBRC, LCTL(KC_LSFT), KC_LALT,
  62. KC_LCTL, TG(_GA),
  63. KC_HOME,
  64. CTL_T(KC_BSPC), ALT_T(KC_DEL), MO(_NU),
  65. // right hand
  66. KC_ESC, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL,
  67. KC_BSPC, KC_J, KC_L, KC_U, KC_Y, KC_SCLN,KC_MINS,
  68. KC_M, KC_N, KC_E, KC_I, KC_O, KC_QUOT,
  69. KC_BSLS, KC_K, KC_H, KC_COMM,KC_DOT, KC_SLSH,KC_RSFT,
  70. MO(_EX),KC_MINS,KC_QUOT,KC_EQL, KC_BSLS,
  71. KC_LEFT, KC_RGHT,
  72. KC_UP,
  73. KC_DOWN, ALT_T(KC_ENT), LT(_NU,KC_SPC)
  74. ),
  75. /*
  76. * Keymap: QWERTY layout.
  77. *
  78. * This is optimized for gaming, not typing, so there aren't as many macros
  79. * as the Dvorak layer. Some of the keys have also been moved to "game-
  80. * like" locations, such as making the spacebar available to the left thumb,
  81. * and repositioning the arrow keys at the bottom right corner.
  82. *
  83. * ,--------------------------------------------------. ,--------------------------------------------------.
  84. * | ` | 1 | 2 | 3 | 4 | 5 | Esc | | | 6 | 7 | 8 | 9 | 0 | = |
  85. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  86. * | LCtrl | Q | W | E | R | T | Home | | BkSp | Y | U | I | O | P | - |
  87. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  88. * | Tab | A | S | D | F | G |------| |------| H | J | K | L | ; | ' |
  89. * |--------+------+------+------+------+------| Hyper| | \ |------+------+------+------+------+--------|
  90. * | LShft | Z | X | C | V | B | | | | N | M | , | . | / | RShft |
  91. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  92. * | LGui | ` | \ |CtlShf| _NU | | _EX | - | ' | = | \ |
  93. * `----------------------------------' `----------------------------------'
  94. * ,-------------. ,-------------.
  95. * | LCtrl| ~GA | | Left | Right|
  96. * ,------|------|------| |------+------+------.
  97. * |LCtrl/| LAlt/| Home | | Up | Alt/| _NU/ |
  98. * | BkSp | Del |------| |------| Enter| Space|
  99. * | | | _NU | | Down | | |
  100. * `--------------------' `--------------------'
  101. */
  102. [_QW] = KEYMAP( // Layer1: QWERTY
  103. // left hand
  104. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_ESC,
  105. KC_LCTL,KC_Q, KC_W, KC_E, KC_R, KC_T, KC_HOME,
  106. KC_TAB, KC_A, KC_S, KC_D, KC_F, KC_G,
  107. KC_LSFT,KC_Z, KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO),
  108. KC_LCTL,KC_GRV, KC_SLSH,LCTL(KC_LSFT), MO(_NU),
  109. KC_LCTL,TG(_GA),
  110. KC_HOME,
  111. CTL_T(KC_BSPC), ALT_T(KC_DEL), MO(_NU),
  112. // right hand
  113. KC_ESC, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL,
  114. KC_BSPC, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_MINS,
  115. KC_H, KC_J, KC_K, KC_L, KC_SCLN,KC_QUOT,
  116. KC_BSLS, KC_N, KC_M, KC_COMM,KC_DOT, KC_SLSH,KC_RSFT,
  117. MO(_EX),KC_MINS,KC_QUOT,KC_EQL, KC_BSLS,
  118. KC_LEFT, KC_RGHT,
  119. KC_UP,
  120. KC_DOWN, ALT_T(KC_ENT), LT(_NU,KC_SPC)
  121. ),
  122. /*
  123. * Keymap: Numbers and symbols
  124. *
  125. * Note that the number keys here are actually numpad keystrokes. This often doesn't matter, but it may be relevant in a few cases.
  126. * That's why the Num Lock key exists on this layer - just in case.
  127. *
  128. * This layer also contains the layout switches.
  129. *
  130. * ,--------------------------------------------------. ,--------------------------------------------------.
  131. * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | |
  132. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  133. * | | ! | @ | { | } | & | | | | / | 7 | 8 | 9 | * | |
  134. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  135. * | | # | $ | ( | ) | ~ |------| |------| | | 4 | 5 | 6 | - | |
  136. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  137. * | | % | ^ | [ | ] | ` | | | | \ | 1 | 2 | 3 | + | |
  138. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  139. * | |QWERTY|Colemk| | | | 0 | . | = | | |
  140. * `----------------------------------' `----------------------------------'
  141. * ,-------------. ,-------------.
  142. * |NumLck| RESET| | | |
  143. * ,------|------|------| |------+------+------.
  144. * | | | | | | | |
  145. * | | |------| |------| | |
  146. * | | | | | | | |
  147. * `--------------------' `--------------------'
  148. */
  149. [_NU] = KEYMAP(
  150. // left hand
  151. _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______,
  152. _______, KC_EXLM, KC_AT, KC_LCBR, KC_RCBR, KC_AMPR, _______,
  153. _______, KC_HASH, KC_DLR, KC_LPRN, KC_RPRN, KC_TILD,
  154. _______, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_GRV, _______,
  155. _______, DF(_QW), DF(_CO), _______, _______,
  156. KC_NLCK,RESET,
  157. _______,
  158. _______,_______,_______,
  159. // right hand
  160. _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, _______,
  161. _______, KC_SLSH, KC_P7, KC_P8, KC_P9, KC_PAST, _______,
  162. KC_PIPE, KC_P4, KC_P5, KC_P6, KC_PMNS, _______,
  163. _______, KC_BSLS, KC_P1, KC_P2, KC_P3, KC_PPLS, _______,
  164. KC_P0, KC_PDOT, KC_EQL, _______, _______,
  165. _______, _______,
  166. _______,
  167. _______, _______, _______
  168. ),
  169. /*
  170. * Keymap: Extend
  171. *
  172. * ,--------------------------------------------------. ,--------------------------------------------------.
  173. * | | F11 | F12 | F13 | F14 | F15 | Mute | | | F16 | F17 | F18 | F19 | F20 | |
  174. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  175. * | | | | | | Ctrl`| Vol | | | PgUp | Home | Up | End | Del | |
  176. * |--------+------+------+------+------+------| Up | | |------+------+------+------+------+--------|
  177. * | | | Gui | Alt | Ctrl | |------| |------| PgDn | Left | Down | Right| BkSp | Menu |
  178. * |--------+------+------+------+------+------| Vol | | |------+------+------+------+------+--------|
  179. * | | Undo | Cut | Copy | | Paste| Down | | | | ^Tab | Tab | |Insert| PrntScr|
  180. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  181. * | | | | | | | | | | | |
  182. * `----------------------------------' `----------------------------------'
  183. * ,-------------. ,-------------.
  184. * | | | | | |
  185. * ,------|------|------| |------+------+------.
  186. * | | | | | | | |
  187. * | | |------| |------| | |
  188. * | | | | | | | |
  189. * `--------------------' `--------------------'
  190. *
  191. * Ctrl+` is a keyboard shortcut for the program ConEmu, which provides a Quake-style drop-down command prompt.
  192. *
  193. */
  194. [_EX] = KEYMAP(
  195. // left hand
  196. _______, KC_F11, KC_F12, KC_F13, KC_F14, KC_F15, KC_MUTE,
  197. _______, _______, _______, _______, _______, KCX_CGR, KC_VOLU,
  198. _______, _______, KC_LGUI, KC_LALT, KC_LCTL, _______,
  199. _______, KX_UNDO, KX_CUT, KX_COPY, _______, KX_PAST, KC_VOLD,
  200. _______, _______, _______, _______, _______,
  201. _______,_______,
  202. _______,
  203. _______,_______,_______,
  204. // right hand
  205. _______, KC_F16, KC_F17, KC_F18, KC_F19, KC_F20, _______,
  206. _______, KC_PGUP, KC_HOME, KC_UP, KC_END, KC_DEL, _______,
  207. KC_PGDN, KC_LEFT, KC_DOWN, KC_RGHT, KC_BSPC, KC_MENU,
  208. _______, _______, KX_STAB, KC_TAB, _______, KC_INS, KC_PSCR,
  209. _______, _______, _______, _______, _______,
  210. _______, _______,
  211. _______,
  212. _______, _______, _______
  213. ),
  214. /*
  215. * Keymap: Gaming
  216. *
  217. * Provides a mouse overlay for the right hand, and also moves some "gamer friendly" keys to the left, such as space.
  218. * This layer also removes a lot of dual-role keys, as when gaming, it's nicer not to need to keep track of those.
  219. *
  220. * ,--------------------------------------------------. ,--------------------------------------------------.
  221. * | | | | | | | | | | | | | | | |
  222. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  223. * | | | | | | | | | | |WhlUp | MsUp |WhlDn | | |
  224. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  225. * | | | | | | |------| |------| |MsLeft|MsDown|MsRght| | |
  226. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  227. * | | | | | | | | | | | | | | | |
  228. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  229. * | LCtrl| | | | | | | | | | |
  230. * `----------------------------------' `----------------------------------'
  231. * ,-------------. ,-------------.
  232. * | | ~_GA | | |MClick|
  233. * ,------|------|------| |------+------+------.
  234. * | | | | | | | |
  235. * | Space| |------| |------|RClick|LClick|
  236. * | | | | | | | |
  237. * `--------------------' `--------------------'
  238. */
  239. [_GA] = KEYMAP(
  240. // left hand
  241. _______, _______, _______, _______, _______, _______, _______,
  242. _______, _______, _______, _______, _______, _______, _______,
  243. _______, _______, _______, _______, _______, _______,
  244. _______, _______, _______, _______, _______, _______, _______,
  245. KC_LCTL, _______, _______, _______, _______,
  246. _______,_______,
  247. _______,
  248. KC_SPC, _______,_______,
  249. // right hand
  250. _______, _______, _______, _______, _______, _______, _______,
  251. _______, _______, KC_WH_U, KC_MS_U, KC_WH_D, _______, _______,
  252. _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______,
  253. _______, _______, _______, _______, _______, _______, _______,
  254. _______, _______, _______, _______, _______,
  255. _______, KC_BTN3,
  256. _______,
  257. _______, KC_BTN2, KC_BTN1
  258. ),
  259. };
  260. const uint16_t PROGMEM fn_actions[] = {
  261. [1] = ACTION_LAYER_TAP_TOGGLE(_NU) // FN1 - Momentary Layer 1 (Numbers and symbols)
  262. };
  263. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  264. {
  265. // MACRODOWN only works in this function
  266. switch(id) {
  267. case 0:
  268. if (record->event.pressed) {
  269. register_code(KC_RSFT);
  270. } else {
  271. unregister_code(KC_RSFT);
  272. }
  273. break;
  274. }
  275. return MACRO_NONE;
  276. };
  277. // Runs just one time when the keyboard initializes.
  278. void matrix_init_user(void) {
  279. };
  280. // Runs constantly in the background, in a loop.
  281. void matrix_scan_user(void) {
  282. uint8_t layer = biton32(layer_state);
  283. // uint8_t default_layer = biton32(layer_state);
  284. ergodox_board_led_off();
  285. ergodox_right_led_1_off();
  286. ergodox_right_led_2_off();
  287. ergodox_right_led_3_off();
  288. switch (layer) {
  289. case _CO:
  290. ergodox_right_led_1_on();
  291. break;
  292. case _QW:
  293. ergodox_right_led_2_on();
  294. break;
  295. case _NU:
  296. ergodox_right_led_3_on();
  297. break;
  298. case _GA:
  299. ergodox_right_led_1_on();
  300. ergodox_right_led_2_on();
  301. default:
  302. // none
  303. break;
  304. }
  305. };