keymap.c 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335
  1. #include QMK_KEYBOARD_H
  2. #include "debug.h"
  3. #include "action_layer.h"
  4. #include "version.h"
  5. #include "333fred.h"
  6. enum custom_keycodes {
  7. PLACEHOLDER = SAFE_RANGE, // can always be here
  8. EPRM,
  9. VRSN,
  10. };
  11. enum custom_macros {
  12. // Windows macros
  13. DLEFT,
  14. DRIGHT,
  15. PSCREEN_APP,
  16. LSFT_TAB,
  17. // KeePass macros
  18. KEEPASS_OPEN,
  19. KEEPASS_TYPE,
  20. // Terminal Copy/Paste
  21. TERM_CP,
  22. TERM_PT
  23. };
  24. // NOTE: Cells marked with ACCESS must remain transparent, they're the keys that actually get to that layer
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. /* Keymap 0: Basic layer
  27. *
  28. * ,--------------------------------------------------. ,--------------------------------------------------.
  29. * | ` | 1 | 2 | 3 | 4 | 5 | F5 | | F6 | 6 | 7 | 8 | 9 | 0 | - |
  30. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  31. * | TAB | Q | W | E | R | T | GAME | |GAMEA | Y | U | I | O | P | \ |
  32. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  33. * | Esc | A | S | D | F | G |------| |------| H | J | K | L | ; | ' |
  34. * |--------+------+------+------+------+------| SYMB | |MEDIA |------+------+------+------+------+--------|
  35. * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift |
  36. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  37. * |LCTRL | F4 | F5 | LGUI | LALT | | Left | Down | = | Right| RGUI |
  38. * `----------------------------------' `----------------------------------'
  39. * ,-------------. ,-------------.
  40. * | Copy | Paste| | Copy | Paste |
  41. * ,------|------|------| |------+--------+------.
  42. * | | | PgUp | | Up | | |
  43. * | Bcksp|OSL(2)|------| |------| Ent |Space |
  44. * | | VIM | Del | | Down | | |
  45. * `--------------------' `----------------------'
  46. */
  47. [BASE] = LAYOUT_ergodox_pretty( // layer 0 : default
  48. // left hand
  49. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_F5, KC_F6, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
  50. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(GAME), TG(GAME_ARROW), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
  51. KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT,
  52. OSM(MOD_LSFT), CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, TG(SYMB), MO(MDIA), KC_N, KC_M, KC_COMM, KC_DOT, CTL_T(KC_SLSH), OSM(MOD_RSFT),
  53. OSM(MOD_LCTL), KC_F4, KC_F5, KC_LGUI, KC_LALT, KC_LEFT, KC_DOWN, KC_EQL, KC_RIGHT, KC_RGUI,
  54. LCTL(KC_C), LCTL(KC_V), LCTL(KC_C), LCTL(KC_V),
  55. KC_PGUP, KC_UP,
  56. KC_BSPC, TD(TD_SYM_VIM), KC_DEL, KC_DOWN, KC_ENT, KC_SPC
  57. ),
  58. /* Keymap 2: Codeflow Layer
  59. *
  60. * ,--------------------------------------------------. ,--------------------------------------------------.
  61. * | | | | | | | | | | | | | | | |
  62. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  63. * | | | | | | | | | | | | | | | |
  64. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  65. * | | | | | | |------| |------| | | | | | |
  66. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  67. * | | | | | | | | | | | | | | | |
  68. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  69. * | | | | | | | F7 | F8 | | | |
  70. * `----------------------------------' `----------------------------------'
  71. * ,-------------. ,---------------.
  72. * | |ACCESS| | | |
  73. * ,------|------|------| |------+--------+------.
  74. * | | | | | | | |
  75. * | | |------| |------| | |
  76. * | | | | | | | |
  77. * `--------------------' `----------------------'
  78. */
  79. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  80. // Otherwise, it needs KC_*
  81. [CODEFLOW] = LAYOUT_ergodox( // layer 1 : code
  82. // left hand
  83. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  84. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  85. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  86. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  87. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  88. KC_TRNS, KC_TRNS,
  89. KC_TRNS,
  90. KC_TRNS, KC_TRNS, KC_TRNS,
  91. // right han
  92. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  93. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  94. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  95. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  96. KC_F7, KC_F8, KC_TRNS, KC_TRNS, KC_TRNS,
  97. KC_TRNS, KC_TRNS,
  98. KC_TRNS,
  99. KC_TRNS, KC_TRNS, KC_TRNS
  100. ),
  101. /* Keymap 3: Symbol Layer
  102. *
  103. * ,---------------------------------------------------. ,--------------------------------------------------.
  104. * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
  105. * |---------+------+------+------+------+------+------| |------+------+------+------+------+------+--------|
  106. * | | ! | @ | ( | ) | | | | | | Up | 7 | 8 | 9 | * | F12 |
  107. * |---------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  108. * | | # | $ | { | } | ` |------| |------| Down | 4 | 5 | 6 | + | |
  109. * |---------+------+------+------+------+------|ACCESS| | |------+------+------+------+------+--------|
  110. * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | |
  111. * `---------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  112. * | | | | | | | 0 | 0 | . | = | |
  113. * `-----------------------------------' `----------------------------------'
  114. * ,-------------. ,-------------.
  115. * | | | | | |
  116. * ,------|------|------| |------+------+------.
  117. * | | |APScr | | | | |
  118. * | |ACCESS|------| |------| | |
  119. * | | | PScr | | | | |
  120. * `--------------------' `--------------------'
  121. */
  122. [SYMB] = LAYOUT_ergodox_pretty(
  123. // left hand
  124. KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS, KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
  125. KC_TRNS, KC_EXLM, KC_AT, KC_LPRN, KC_RPRN, KC_PIPE, KC_TRNS, KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
  126. KC_TRNS, KC_HASH, KC_DLR, KC_LCBR, KC_RCBR, KC_GRV, KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS,
  127. KC_TRNS, KC_PERC, KC_CIRC, KC_LBRC, KC_RBRC, KC_TILD, KC_TRNS, KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS,
  128. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_0, KC_0, KC_DOT, KC_EQL, KC_TRNS,
  129. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  130. M(PSCREEN_APP), KC_TRNS,
  131. KC_TRNS, KC_TRNS, KC_PSCR, KC_TRNS, KC_TRNS, KC_TRNS
  132. ),
  133. /* Keymap 3: Media and mouse keys
  134. *
  135. * ,--------------------------------------------------. ,--------------------------------------------------.
  136. * | | | | | | | | | | | | | | | |
  137. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  138. * | | | | MsUp | | | | | | | | | | | |
  139. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  140. * | | |MsLeft|MsDown|MsRght| |------| |------| | | | | | |
  141. * |--------+------+------+------+------+------| | |ACCESS|------+------+------+------+------+--------|
  142. * | | | | | | | | | | | | | | | |
  143. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  144. * | | | | Lclk | Rclk | | | | | | |
  145. * `----------------------------------' `----------------------------------'
  146. * ,-------------. ,-------------.
  147. * | Back+| Back-| | Vol+ | |
  148. * ,------|------|------| |------+------+------.
  149. * | | |BackTg| | Vol- | | |
  150. * | | |------| |------| PL/PS| Next |
  151. * | | | | | Back | | |
  152. * `--------------------' `--------------------'
  153. */
  154. [MDIA] = LAYOUT_ergodox_pretty(
  155. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  156. KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  157. KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  158. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  159. KC_TRNS, KC_TRNS, KC_TRNS, KC_BTN1, KC_BTN2, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  160. BL_INC, BL_DEC, KC_VOLU, KC_TRNS,
  161. BL_TOGG, KC_VOLD,
  162. KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MPLY, KC_MNXT
  163. ),
  164. /* Keymap 4: Movement
  165. *
  166. * ,--------------------------------------------------. ,--------------------------------------------------.
  167. * | | | | | | | | | | | | | | | |
  168. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  169. * | |KOpen |KType |TERMCP|TERMPT| | | | | Copy | | | | Paste| |
  170. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  171. * | |DLeft |DRight|LCTRL | LGUI | |------| |------| Left | Down | Up | Right| | |
  172. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  173. * | |SFT_TB| TAB | | | | | | | | | | | | |
  174. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  175. * | | | | | | | | | | | |
  176. * `----------------------------------' `----------------------------------'
  177. * ,-------------. ,-------------.
  178. * | | | | Home | End |
  179. * ,------|------|------| |------+------+------.
  180. * | | | | | | | |
  181. * | |ACCESS|------| |------| | |
  182. * | | | | | | | |
  183. * `--------------------' `--------------------'
  184. */
  185. // MEDIA AND MOUSE
  186. [VIM] = LAYOUT_ergodox_pretty(
  187. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  188. KC_TRNS, M(KEEPASS_OPEN), M(KEEPASS_TYPE), TERM_CP, TERM_PT, KC_TRNS, KC_TRNS, KC_TRNS, LCTL(KC_C), KC_TRNS, KC_TRNS, KC_TRNS, LCTL(KC_V), KC_TRNS,
  189. KC_TRNS, M(DLEFT), M(DRIGHT), KC_LCTL, KC_LGUI, KC_TRNS, KC_LEFT, KC_DOWN, KC_UP, KC_RIGHT, KC_TRNS, KC_TRNS,
  190. KC_TRNS, M(LSFT_TAB), KC_TAB, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  191. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  192. KC_TRNS, KC_TRNS, KC_HOME, KC_END,
  193. KC_TRNS, KC_TRNS,
  194. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS
  195. ),
  196. /* Keymap 1: Game Layer
  197. *
  198. * ,--------------------------------------------------. ,--------------------------------------------------.
  199. * | ESC | | | | | | | | | | | | | | |
  200. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  201. * | | | | | | |ACCESS| | | | | | | | |
  202. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  203. * | CTRL | | | | | |------| |------| | | | | | |
  204. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  205. * | SHIFT | Z | | | | | | | | | | | | | |
  206. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  207. * |ENTER | | | LOCK | BSPC | | | | | | |
  208. * `----------------------------------' `----------------------------------'
  209. * ,-------------. ,---------------.
  210. * | F5 | F6 | | | |
  211. * ,------|------|------| |------+--------+------.
  212. * | | | | | | | |
  213. * | ALT | SPC |------| |------| | |
  214. * | | | SYMB | | | | |
  215. * `--------------------' `----------------------'
  216. */
  217. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  218. // Otherwise, it needs KC_*
  219. [GAME] = LAYOUT_ergodox_pretty( // layer 1 : code
  220. // left hand
  221. KC_ESC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  222. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  223. KC_LCTL, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  224. KC_LSFT, KC_Z, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  225. KC_ENT, KC_TRNS, KC_TRNS, KC_LOCK, KC_BSPC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  226. KC_F5, KC_F6, LCTL(KC_C), LCTL(KC_V),
  227. KC_TRNS, KC_UP,
  228. KC_LALT, KC_SPC, OSM(SYMB), KC_DOWN, KC_TRNS, KC_TRNS
  229. ),
  230. /* Keymap 1: Game Arrow Layer
  231. *
  232. * ,--------------------------------------------------. ,--------------------------------------------------.
  233. * | ESC | | | | | | | | | | | | | | |
  234. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  235. * | | | Up | | | | | |ACCESS| | | | | | |
  236. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  237. * | CTRL | Left | Down |Right | | |------| |------| | | | | | |
  238. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  239. * | SHIFT | Z | | | | | | | | | | | | | |
  240. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  241. * |ENTER | | | LOCK | BSPC | | | | | | |
  242. * `----------------------------------' `----------------------------------'
  243. * ,-------------. ,---------------.
  244. * | F5 | F6 | | | |
  245. * ,------|------|------| |------+--------+------.
  246. * | | | | | | | |
  247. * | ALT | SPC |------| |------| | |
  248. * | | | SYMB | | | | |
  249. * `--------------------' `----------------------'
  250. */
  251. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  252. // Otherwise, it needs KC_*
  253. [GAME_ARROW] = LAYOUT_ergodox_pretty( // layer 1 : code
  254. // left hand
  255. KC_ESC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  256. KC_TRNS, KC_TRNS, KC_UP, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  257. KC_LCTL, KC_LEFT, KC_DOWN, KC_RIGHT, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  258. KC_LSFT, KC_Z, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  259. KC_ENT, KC_TRNS, KC_TRNS, KC_LOCK, KC_BSPC, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  260. KC_F5, KC_F6, LCTL(KC_C), LCTL(KC_V),
  261. KC_TRNS, KC_UP,
  262. KC_LALT, KC_SPC, OSM(SYMB), KC_DOWN, KC_TRNS, KC_TRNS
  263. )
  264. };
  265. const uint16_t PROGMEM fn_actions[] = {
  266. [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
  267. };
  268. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  269. {
  270. // MACRODOWN only works in this function
  271. switch(id) {
  272. case DLEFT:
  273. if (record->event.pressed) { // Windows move desktop left
  274. return MACRO(D(LCTL), D(LGUI), T(LEFT), U(LGUI), U(LCTL), END);
  275. }
  276. break;
  277. case DRIGHT:
  278. if (record->event.pressed) { // Windows move desktop right
  279. return MACRO(D(LCTL), D(LGUI), T(RIGHT), U(LGUI), U(LCTL), END);
  280. }
  281. break;
  282. case PSCREEN_APP:
  283. if (record->event.pressed) {
  284. return MACRO(D(LALT), T(PSCR), U(LALT), END);
  285. }
  286. break;
  287. case LSFT_TAB:
  288. if (record->event.pressed) {
  289. return MACRO(D(LSFT), T(TAB), U(LSFT), END);
  290. }
  291. case KEEPASS_OPEN:
  292. if (record->event.pressed) { // Keepass open application
  293. return MACRO(D(LCTL), D(LALT), T(K), U(LALT), U(LCTL), END);
  294. }
  295. break;
  296. case KEEPASS_TYPE:
  297. if (record->event.pressed) { // Keepass autotype
  298. return MACRO(D(LCTL), D(LALT), T(A), U(LALT), U(LCTL), END);
  299. }
  300. break;
  301. case TERM_CP:
  302. if (record->event.pressed) { // Terminal Copy
  303. return MACRO(D(LCTL), T(INSERT), U(LCTL), END);
  304. }
  305. break;
  306. case TERM_PT:
  307. if (record->event.pressed) { // Terminal Paste
  308. return MACRO(D(LSFT), T(INSERT), U(LSFT), END);
  309. }
  310. break;
  311. }
  312. return MACRO_NONE;
  313. };
  314. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  315. tap_dance_process_record(keycode);
  316. return true;
  317. }
  318. // Runs constantly in the background, in a loop.
  319. void matrix_scan_user_keyboard(void) {
  320. ergodox_board_led_on();
  321. ergodox_led_all_on();
  322. }