2
0

keymap.c 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. #include "ergodox_ez.h"
  2. #include "debug.h"
  3. #include "action_layer.h"
  4. #define BASE 0 // default layer
  5. #define SYMB 1 // symbols
  6. #define MDIA 2 // media keys
  7. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  8. /* Keymap 0: Basic layer
  9. *
  10. * ,--------------------------------------------------. ,--------------------------------------------------.
  11. * | = | 1 | 2 | 3 | 4 | 5 | LEFT | | RIGHT| 6 | 7 | 8 | 9 | 0 | - |
  12. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  13. * | Tab | Q | W | E | R | T | L1 | | L1 | Y | U | I | O | P | \ |
  14. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  15. * |esc/ctrl| A | S | D | F | G |------| |------| H | J | K | L |; / L2|'/ ctrl |
  16. * |--------+------+------+------+------+------| Hyper| | Meh |------+------+------+------+------+--------|
  17. * | LShift |Z/Ctrl| X | C | V | B | | | | N | M | , | . |//Ctrl| RShift |
  18. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  19. * |Grv/L1| '" |AltShf| Left | Right| | Up | Down | [ | ] | ~L1 |
  20. * `----------------------------------' `----------------------------------'
  21. * ,-------------. ,-------------.
  22. * | App | LGui | | Alt |Ctrl/Esc|
  23. * ,------|------|------| |------+--------+------.
  24. * | | | Home | | PgUp | | |
  25. * | Space| Bksp |------| |------| Tab |Enter |
  26. * | ctrl | gui | Alt | | Alt | gui | ctrl |
  27. * `--------------------' `----------------------'
  28. */
  29. // TODO: somehow map shit so you can hold down a button to override the macro hold down feature (e.g. override control hold so that holding a key and space/bksp/ent/tab will repeat those) ~~~~~~ this might be taken care of.... you can just tap once, then hold, and it does this shit :::))) ... not sure if this is desirable for most use-cases / situations
  30. // TODO: maybe make almost identical layers but for wintdows and mac
  31. // TODO: find a do nothing key, so you aren't tempted by useless keys
  32. // TODO: add vi layer for arrow keys and shit on hjkl?
  33. // TODO: maybe look into changing the delay or whatever for the holding macros... not sure which way you would go with this. if the macro automatically kicks in if you hold it and press another button (no matter how long you held it for), then it wouldn't hurt to have a longer period i think... although if you hold a button and then decide not to, then you;ll register a space/bksp/etc. on accident. on the other hand, if it's too short of a delay, then you might be able to register spc/bksp/etc quickly enough, although i don't see this as big of an issue
  34. // not sure if gui is meta key or super... it says meta on the basic keycodes page, and i think that's consitent with other shit, but you should really figure out how to program the keyboard to have meta and super separately instead of hacking your init.el to recognize alt as meta... because shit will get fucked up beteween awesome and emacs and other shit i'm guessing
  35. // If it accepts an argument (i.e, is a function), it doesn't need KC_.
  36. // Otherwise, it needs KC_*
  37. [BASE] = KEYMAP( // layer 0 : default
  38. // left hand
  39. KC_EQL, KC_1, KC_2, KC_3, KC_4, KC_5, KC_LEFT,
  40. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
  41. CTL_T(KC_ESC), KC_A, KC_S, KC_D, KC_F, KC_G,
  42. KC_LSFT, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, ALL_T(KC_NO),
  43. LT(SYMB,KC_GRV), KC_QUOT, LALT(KC_LSFT), KC_LEFT,KC_RGHT,
  44. ALT_T(KC_APP), KC_LGUI,
  45. KC_HOME,
  46. CTL_T(KC_SPC),GUI_T(KC_BSPC),KC_LALT,
  47. // right hand
  48. KC_RGHT, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS,
  49. TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, KC_BSLS,
  50. KC_H, KC_J, KC_K, KC_L, LT(MDIA, KC_SCLN),CTL_T(KC_QUOT),
  51. MEH_T(KC_NO),KC_N, KC_M, KC_COMM,KC_DOT, CTL_T(KC_SLSH), KC_RSFT,
  52. KC_UP, KC_DOWN,KC_LBRC,KC_RBRC, KC_FN1,
  53. KC_LALT, CTL_T(KC_ESC),
  54. KC_PGUP,
  55. KC_RALT,GUI_T(KC_TAB), CTL_T(KC_ENT)
  56. ),
  57. /* Keymap 1: Symbol Layer
  58. *
  59. * ,--------------------------------------------------. ,--------------------------------------------------.
  60. * | | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
  61. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  62. * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 |
  63. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  64. * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | |
  65. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  66. * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | \ | |
  67. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  68. * | | | | | | | | . | 0 | = | |
  69. * `----------------------------------' `----------------------------------'
  70. * ,-------------. ,-------------.
  71. * | | | | | |
  72. * ,------|------|------| |------+------+------.
  73. * | | | | | | | |
  74. * | | |------| |------| | |
  75. * | | | | | | | |
  76. * `--------------------' `--------------------'
  77. */
  78. // SYMBOLS
  79. [SYMB] = KEYMAP(
  80. // left hand
  81. KC_TRNS,KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_TRNS,
  82. KC_TRNS,KC_EXLM,KC_AT, KC_LCBR,KC_RCBR,KC_PIPE,KC_TRNS,
  83. KC_TRNS,KC_HASH,KC_DLR, KC_LPRN,KC_RPRN,KC_GRV,
  84. KC_TRNS,KC_PERC,KC_CIRC,KC_LBRC,KC_RBRC,KC_TILD,KC_TRNS,
  85. KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,KC_TRNS,
  86. KC_TRNS,KC_TRNS,
  87. KC_TRNS,
  88. KC_TRNS,KC_TRNS,KC_TRNS,
  89. // right hand
  90. KC_TRNS, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
  91. KC_TRNS, KC_UP, KC_7, KC_8, KC_9, KC_ASTR, KC_F12,
  92. KC_DOWN, KC_4, KC_5, KC_6, KC_PLUS, KC_TRNS,
  93. KC_TRNS, KC_AMPR, KC_1, KC_2, KC_3, KC_BSLS, KC_TRNS,
  94. KC_TRNS,KC_DOT, KC_0, KC_EQL, KC_TRNS,
  95. KC_TRNS, KC_TRNS,
  96. KC_TRNS,
  97. KC_TRNS, KC_TRNS, KC_TRNS
  98. ),
  99. /* Keymap 2: Media and mouse keys
  100. *
  101. * ,--------------------------------------------------. ,--------------------------------------------------.
  102. * | | | | | | | | | | | | | | | |
  103. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  104. * | | | | MsUp | | | | | | | | | | | |
  105. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  106. * | | |MsLeft|MsDown|MsRght| |------| |------| | Lclk | Rclk | | | Play |
  107. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  108. * | | | | | | | | | | | | Prev | Next | | |
  109. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  110. * | | | | | | |VolUp |VolDn | Mute | | |
  111. * `----------------------------------' `----------------------------------'
  112. * ,-------------. ,-------------.
  113. * | | | | | |
  114. * ,------|------|------| |------+------+------.
  115. * | | | | | | |Brwser|
  116. * | | |------| |------| |Back |
  117. * | | | | | | | |
  118. * `--------------------' `--------------------'
  119. */
  120. // MEDIA AND MOUSE
  121. [MDIA] = KEYMAP(
  122. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  123. KC_TRNS, KC_TRNS, KC_TRNS, KC_MS_U, KC_TRNS, KC_TRNS, KC_TRNS,
  124. KC_TRNS, KC_TRNS, KC_MS_L, KC_MS_D, KC_MS_R, KC_TRNS,
  125. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  126. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  127. KC_TRNS, KC_TRNS,
  128. KC_TRNS,
  129. KC_TRNS, KC_TRNS, KC_TRNS,
  130. // right hand
  131. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  132. KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS, KC_TRNS,
  133. KC_TRNS, KC_BTN1, KC_BTN2, KC_TRNS, KC_TRNS, KC_MPLY,
  134. KC_TRNS, KC_TRNS, KC_TRNS, KC_MPRV, KC_MNXT, KC_TRNS, KC_TRNS,
  135. KC_VOLU, KC_VOLD, KC_MUTE, KC_TRNS, KC_TRNS,
  136. KC_TRNS, KC_TRNS,
  137. KC_TRNS,
  138. KC_TRNS, KC_TRNS, KC_WBAK
  139. ),
  140. };
  141. const uint16_t PROGMEM fn_actions[] = {
  142. [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
  143. };
  144. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  145. {
  146. // MACRODOWN only works in this function
  147. switch(id) {
  148. case 0:
  149. if (record->event.pressed) {
  150. register_code(KC_RSFT);
  151. } else {
  152. unregister_code(KC_RSFT);
  153. }
  154. break;
  155. }
  156. return MACRO_NONE;
  157. };
  158. // Runs just one time when the keyboard initializes.
  159. void matrix_init_user(void) {
  160. };
  161. // Runs constantly in the background, in a loop.
  162. void matrix_scan_user(void) {
  163. uint8_t layer = biton32(layer_state);
  164. ergodox_board_led_off();
  165. ergodox_right_led_1_off();
  166. ergodox_right_led_2_off();
  167. ergodox_right_led_3_off();
  168. switch (layer) {
  169. // TODO: Make this relevant to the ErgoDox EZ.
  170. case 1:
  171. ergodox_right_led_1_on();
  172. break;
  173. case 2:
  174. ergodox_right_led_2_on();
  175. break;
  176. default:
  177. // none
  178. break;
  179. }
  180. };