keymap.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258
  1. /* TypeMatrix-2030-like keymap */
  2. #include "ergodox_ez.h"
  3. #include "debug.h"
  4. #include "action_layer.h"
  5. #include "led.h"
  6. #define BASE 0 // default layer
  7. #define DVRK 1 // Dvorak layer
  8. #define NUMR 8 // numeric layer
  9. #define FNLR 9 // fn layer
  10. #define MDBL0 1
  11. #define MFNLR 2
  12. #define MCUT 3
  13. #define MCOPY 4
  14. #define MPSTE 5
  15. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  16. /* Basic layer
  17. *
  18. * ,--------------------------------------------------. ,--------------------------------------------------.
  19. * | ` | 1 | 2 | 3 | 4 | 5 | Del | | Del | 6 | 7 | 8 | 9 | 0 | ] |
  20. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  21. * | Tab | Q | W | E | R | T |Backsp| |Backsp| Y | U | I | O | P | [ |
  22. * |--------+------+------+------+------+------|ace | |ace |------+------+------+------+------+--------|
  23. * | LShift | A | S | D | F | G |------| |------| H | J | K | L | ; | '/Shift|
  24. * |--------+------+------+------+------+------|Enter | |Enter |------+------+------+------+------+--------|
  25. * | LShift | Z | X | C | V | B | | | | N | M | , | . | / | \/Shift|
  26. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  27. * |LCtrl | fn | LGui | Play |App/Alt| | RAlt | - | Home | = |End/Ctl|
  28. * `-----------------------------------' `-----------------------------------'
  29. * ,--------------. ,-------------.
  30. * |Esc/Alt| num | | Left |Right |
  31. * ,------+-------+------| |------+------+------.
  32. * | | | PgUp | | Up | | |
  33. * |Space |LShift |------| |------|RShift|Space |
  34. * | | | PgDn | | Down | | |
  35. * `---------------------' `--------------------'
  36. */
  37. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  38. // Otherwise, it needs KC_*
  39. [BASE] = KEYMAP( // layer 0 : default
  40. // left hand
  41. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_DELT,
  42. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_BSPC,
  43. KC_LSFT, KC_A, KC_S, KC_D, KC_F, KC_G,
  44. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_ENT,
  45. KC_LCTL, M(MFNLR), KC_LGUI,KC_MPLY,ALT_T(KC_APP),
  46. ALT_T(KC_ESC), TG(NUMR),
  47. KC_PGUP,
  48. KC_SPC, KC_LSFT, KC_PGDN,
  49. // right hand
  50. KC_DELT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_RBRC,
  51. KC_BSPC, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC,
  52. KC_H, KC_J, KC_K, KC_L, KC_SCLN, SFT_T(KC_QUOT),
  53. KC_ENT, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, SFT_T(KC_BSLS),
  54. KC_RALT, KC_MINS, KC_HOME, KC_EQL, CTL_T(KC_END),
  55. KC_LEFT, KC_RGHT,
  56. KC_UP,
  57. KC_DOWN, KC_RSFT, KC_SPC
  58. ),
  59. /* Dvorak layer
  60. *
  61. * ,--------------------------------------------------. ,--------------------------------------------------.
  62. * | ` | 1 | 2 | 3 | 4 | 5 | Del | | Del | 6 | 7 | 8 | 9 | 0 | = |
  63. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  64. * | Tab | ' | , | . | P | Y |Backsp| |Backsp| F | G | C | R | L | / |
  65. * |--------+------+------+------+------+------|ace | |ace |------+------+------+------+------+--------|
  66. * | LShift | A | O | E | U | I |------| |------| D | H | T | N | S | -/Shift|
  67. * |--------+------+------+------+------+------|Enter | |Enter |------+------+------+------+------+--------|
  68. * | LShift | ; | Q | J | K | X | | | | B | M | W | V | Z | \/Shift|
  69. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  70. * |LCtrl | fn | LGui | Play |App/Alt| | RAlt | [ | Home | ] |End/Ctl|
  71. * `-----------------------------------' `-----------------------------------'
  72. * ,--------------. ,-------------.
  73. * |Esc/Alt| num | | Left |Right |
  74. * ,------+-------+------| |------+------+------.
  75. * | | | PgUp | | Up | | |
  76. * |Space |LShift |------| |------|RShift|Space |
  77. * | | | PgDn | | Down | | |
  78. * `---------------------' `--------------------'
  79. */
  80. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  81. // Otherwise, it needs KC_*
  82. [DVRK] = KEYMAP( // layer 0 : default
  83. // left hand
  84. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_DELT,
  85. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_BSPC,
  86. KC_LSFT, KC_A, KC_O, KC_E, KC_U, KC_I,
  87. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_ENT,
  88. KC_LCTL, M(MFNLR), KC_LGUI, KC_MPLY, ALT_T(KC_APP),
  89. ALT_T(KC_ESC), TG(NUMR),
  90. KC_PGUP,
  91. KC_SPC, KC_LSFT, KC_PGDN,
  92. // right hand
  93. KC_DELT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_EQL,
  94. KC_BSPC, KC_F, KC_G, KC_C, KC_R, KC_L, KC_SLSH,
  95. KC_D, KC_H, KC_T, KC_N, KC_S, SFT_T(KC_MINS),
  96. KC_ENT, KC_B, KC_M, KC_W, KC_V, KC_Z, SFT_T(KC_BSLS),
  97. KC_RALT, KC_LBRC, KC_HOME, KC_RBRC, CTL_T(KC_END),
  98. KC_LEFT, KC_RGHT,
  99. KC_UP,
  100. KC_DOWN, KC_RSFT, KC_SPC
  101. ),
  102. /* Numeric Layer
  103. *
  104. * ,--------------------------------------------------. ,--------------------------------------------------.
  105. * | | F1 | F2 | F3 | F4 | F5 | | | | | | Tab | / | * | - |
  106. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  107. * | | F6 | F7 | F8 | F9 | F10 | | | | | Home | 7 | 8 | 9 | + |
  108. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  109. * | | F11 | F12 | | | |------| |------| Up | End | 4 | 5 | 6 | + |
  110. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  111. * | | | | | | | | | Left | Down | Right| 1 | 2 | 3 |KpEnter |
  112. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  113. * | | | | | | | | 0 | 00 | . |Etr/Ctl|
  114. * `----------------------------------' `-----------------------------------'
  115. * ,-------------. ,-------------.
  116. * | | | |n.lock|c.lock|
  117. * ,------|------|------| |------+------+------.
  118. * | | | | | | | |
  119. * | | |------| |------| | |
  120. * | | | | | | | |
  121. * `--------------------' `--------------------'
  122. */
  123. // SYMBOLS
  124. [NUMR] = KEYMAP(
  125. // left hand
  126. KC_TRNS, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
  127. KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_TRNS,
  128. KC_TRNS, KC_F11, KC_F12, KC_TRNS, KC_TRNS, KC_TRNS,
  129. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  130. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  131. KC_TRNS,KC_TRNS,
  132. KC_TRNS,
  133. KC_TRNS, KC_TRNS,KC_TRNS,
  134. // right hand
  135. KC_INS, KC_F6, KC_F7, KC_TAB, KC_PSLS, KC_PAST, KC_PMNS,
  136. KC_TRNS, KC_TRNS, KC_HOME, KC_P7, KC_P8, KC_P9, KC_PPLS,
  137. KC_UP, KC_END, KC_P4, KC_P5, KC_P6, KC_PPLS,
  138. KC_LEFT, KC_DOWN, KC_RGHT, KC_P1, KC_P2, KC_P3, KC_PENT,
  139. KC_TRNS, KC_P0, M(MDBL0),KC_PDOT, CTL_T(KC_PENT),
  140. KC_NLCK, KC_CAPS,
  141. KC_TRNS,
  142. KC_TRNS, KC_TRNS, KC_TRNS
  143. ),
  144. /* fn layer
  145. *
  146. * ,--------------------------------------------------. ,--------------------------------------------------.
  147. * | | | | | | |Insert| |Insert|Eject |Power |Sleep | Wake |PrtScr|ScrollLk|
  148. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  149. * | | | | | | |VolUp | | | | | | | | Pause |
  150. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  151. * | | | | Calc | Mail |Browsr|------| |------| | | | | | |
  152. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  153. * | | | cut | copy |paste | Mute |VolDn | | | | | | | | |
  154. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  155. * | | | | | | | | | | | |
  156. * `----------------------------------' `----------------------------------'
  157. * ,-------------. ,-------------.
  158. * | | | | | |
  159. * ,------|------|------| |------+------+------.
  160. * | | | | | Next | | |
  161. * | Mute | |------| |------| | |
  162. * | | | | | Prev | | |
  163. * `--------------------' `--------------------'
  164. */
  165. // MEDIA AND MOUSE
  166. [FNLR] = KEYMAP(
  167. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_INS,
  168. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_VOLU,
  169. KC_TRNS, KC_TRNS, KC_TRNS, KC_CALC, KC_MAIL, KC_WHOM,
  170. KC_TRNS, KC_TRNS, M(MCUT), M(MCOPY), M(MPSTE), KC_MUTE, KC_VOLD,
  171. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  172. KC_TRNS, KC_TRNS,
  173. KC_TRNS,
  174. KC_MUTE, KC_TRNS, KC_TRNS,
  175. // right hand
  176. KC_INS, KC_EJCT, KC_PWR, KC_SLEP, KC_WAKE, KC_PSCR, KC_SLCK,
  177. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_PAUS,
  178. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  179. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  180. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  181. KC_TRNS, KC_TRNS,
  182. KC_MPRV,
  183. KC_MNXT, KC_TRNS, KC_TRNS
  184. ),
  185. };
  186. const uint16_t PROGMEM fn_actions[] = {
  187. };
  188. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  189. {
  190. // MACRODOWN only works in this function
  191. switch(id) {
  192. case MDBL0:
  193. if (record->event.pressed) {
  194. return MACRO( I(25), T(P0), T(P0), END );
  195. }
  196. break;
  197. case MFNLR:
  198. layer_state ^= (1 << NUMR) | (1 << FNLR);
  199. break;
  200. case MCUT:
  201. if (record->event.pressed) {
  202. return MACRO(D(LSFT), T(DELT), U(LSFT), END);
  203. }
  204. break;
  205. case MCOPY:
  206. if (record->event.pressed) {
  207. return MACRO(D(LCTL), T(INS), U(LCTL), END);
  208. }
  209. break;
  210. case MPSTE:
  211. if (record->event.pressed) {
  212. return MACRO(D(LSFT), T(INS), U(LSFT), END);
  213. }
  214. break;
  215. }
  216. return MACRO_NONE;
  217. };
  218. // Runs just one time when the keyboard initializes.
  219. void * matrix_init_user(void) {
  220. };
  221. // Runs constantly in the background, in a loop.
  222. void * matrix_scan_user(void) {
  223. ergodox_board_led_off();
  224. ergodox_right_led_1_off();
  225. ergodox_right_led_2_off();
  226. ergodox_right_led_3_off();
  227. // led 1: numeric layer
  228. if (layer_state & (1 << NUMR)) {
  229. ergodox_right_led_1_on();
  230. }
  231. // led 2: Dvorak layer
  232. if (default_layer_state == 1 << DVRK) {
  233. ergodox_right_led_2_on();
  234. }
  235. // led 3: caps lock
  236. if (host_keyboard_leds() & (1<<USB_LED_CAPS_LOCK)) {
  237. ergodox_right_led_3_on();
  238. }
  239. };