keymap.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347
  1. #include QMK_KEYBOARD_H
  2. extern keymap_config_t keymap_config;
  3. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  4. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  5. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  6. // entirely and just use numbers.
  7. #define _QWERTY 0
  8. #define _COLEMAK 1
  9. #define _DVORAK 2
  10. #define _LOWER 3
  11. #define _RAISE 4
  12. #define _ADJUST 16
  13. enum custom_keycodes {
  14. QWERTY = SAFE_RANGE,
  15. COLEMAK,
  16. DVORAK,
  17. LOWER,
  18. RAISE,
  19. ADJUST,
  20. };
  21. // Fillers to make layering more clear
  22. #define _______ KC_TRNS
  23. #define XXXXXXX KC_NO
  24. #if HELIX_ROWS == 5
  25. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  26. /* Qwerty
  27. * ,-----------------------------------------------------------------------------------.
  28. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  29. * |------+------+------+------+------+------+------+------+------+------+------+------|
  30. * | Tab | Q | W | E | R | T | Y | U | I | O | P | Del |
  31. * |------+------+------+------+------+-------------+------+------+------+------+------|
  32. * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
  33. * |------+------+------+------+------+------|------+------+------+------+------+------|
  34. * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
  35. * |------+------+------+------+------+------+------+------+------+------+------+------|
  36. * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
  37. * `-----------------------------------------------------------------------------------'
  38. */
  39. [_QWERTY] = LAYOUT( \
  40. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  41. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \
  42. KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  43. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  44. ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  45. ),
  46. /* Colemak
  47. * ,-----------------------------------------------------------------------------------.
  48. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  49. * |------+------+------+------+------+------+------+------+------+------+------+------|
  50. * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Del |
  51. * |------+------+------+------+------+-------------+------+------+------+------+------|
  52. * | Esc | A | R | S | T | D | H | N | E | I | O | " |
  53. * |------+------+------+------+------+------|------+------+------+------+------+------|
  54. * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
  55. * |------+------+------+------+------+------+------+------+------+------+------+------|
  56. * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
  57. * `-----------------------------------------------------------------------------------'
  58. */
  59. [_COLEMAK] = LAYOUT( \
  60. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  61. KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_DEL, \
  62. KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
  63. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  64. ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  65. ),
  66. /* Dvorak
  67. * ,-----------------------------------------------------------------------------------.
  68. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  69. * |------+------+------+------+------+------+------+------+------+------+------+------|
  70. * | Tab | " | , | . | P | Y | F | G | C | R | L | Del |
  71. * |------+------+------+------+------+-------------+------+------+------+------+------|
  72. * | Esc | A | O | E | U | I | D | H | T | N | S | / |
  73. * |------+------+------+------+------+------|------+------+------+------+------+------|
  74. * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
  75. * |------+------+------+------+------+------+------+------+------+------+------+------|
  76. * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
  77. * `-----------------------------------------------------------------------------------'
  78. */
  79. [_DVORAK] = LAYOUT( \
  80. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  81. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_DEL, \
  82. KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
  83. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
  84. ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  85. ),
  86. /* Lower
  87. * ,-----------------------------------------------------------------------------------.
  88. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
  89. * |------+------+------+------+------+-------------+------+------+------+------+------|
  90. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Del |
  91. * |------+------+------+------+------+-------------+------+------+------+------+------|
  92. * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
  93. * |------+------+------+------+------+------|------+------+------+------+------+------|
  94. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
  95. * |------+------+------+------+------+------+------+------+------+------+------+------|
  96. * | | | | | | | | Next | Vol- | Vol+ | Play |
  97. * `-----------------------------------------------------------------------------------'
  98. */
  99. [_LOWER] = LAYOUT( \
  100. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
  101. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_DEL, \
  102. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
  103. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
  104. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  105. ),
  106. /* Raise
  107. * ,-----------------------------------------------------------------------------------.
  108. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  109. * |------+------+------+------+------+-------------+------+------+------+------+------|
  110. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Del |
  111. * |------+------+------+------+------+-------------+------+------+------+------+------|
  112. * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
  113. * |------+------+------+------+------+------|------+------+------+------+------+------|
  114. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
  115. * |------+------+------+------+------+------+------+------+------+------+------+------|
  116. * | | | | | | | | Next | Vol- | Vol+ | Play |
  117. * `-----------------------------------------------------------------------------------'
  118. */
  119. [_RAISE] = LAYOUT( \
  120. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  121. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_DEL, \
  122. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  123. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
  124. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  125. ),
  126. /* Adjust (Lower + Raise)
  127. * ,-----------------------------------------------------------------------------------.
  128. * | F1 | F2 | F3 | F4 | F5 | F6 | F7 | F8 | F9 | F10 | F11 | F12 |
  129. * |------+------+------+------+------+------+------+------+------+------+------+------|
  130. * | | Reset| | | | | | | | | | Del |
  131. * |------+------+------+------+------+-------------+------+------+------+------+------|
  132. * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
  133. * |------+------+------+------+------+------|------+------+------+------+------+------|
  134. * | | | | | | | | | | | | |
  135. * |------+------+------+------+------+------+------+------+------+------+------+------|
  136. * | | | | | | | | | | | |
  137. * `-----------------------------------------------------------------------------------'
  138. */
  139. [_ADJUST] = LAYOUT( \
  140. KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, \
  141. _______, RESET, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
  142. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
  143. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  144. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  145. )
  146. };
  147. #elif HELIX_ROWS == 4
  148. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  149. /* Qwerty
  150. * ,-----------------------------------------------------------------------------------.
  151. * | Tab | Q | W | E | R | T | Y | U | I | O | P | Bksp |
  152. * |------+------+------+------+------+-------------+------+------+------+------+------|
  153. * | Esc | A | S | D | F | G | H | J | K | L | ; | " |
  154. * |------+------+------+------+------+------|------+------+------+------+------+------|
  155. * | Shift| Z | X | C | V | B | N | M | , | . | / |Enter |
  156. * |------+------+------+------+------+------+------+------+------+------+------+------|
  157. * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
  158. * `-----------------------------------------------------------------------------------'
  159. */
  160. [_QWERTY] = LAYOUT( \
  161. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_DEL, \
  162. KC_ESC, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, \
  163. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  164. ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  165. ),
  166. /* Colemak
  167. * ,-----------------------------------------------------------------------------------.
  168. * | Tab | Q | W | F | P | G | J | L | U | Y | ; | Bksp |
  169. * |------+------+------+------+------+-------------+------+------+------+------+------|
  170. * | Esc | A | R | S | T | D | H | N | E | I | O | " |
  171. * |------+------+------+------+------+------|------+------+------+------+------+------|
  172. * | Shift| Z | X | C | V | B | K | M | , | . | / |Enter |
  173. * |------+------+------+------+------+------+------+------+------+------+------+------|
  174. * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
  175. * `-----------------------------------------------------------------------------------'
  176. */
  177. [_COLEMAK] = LAYOUT( \
  178. KC_TAB, KC_Q, KC_W, KC_F, KC_P, KC_G, KC_J, KC_L, KC_U, KC_Y, KC_SCLN, KC_BSPC, \
  179. KC_ESC, KC_A, KC_R, KC_S, KC_T, KC_D, KC_H, KC_N, KC_E, KC_I, KC_O, KC_QUOT, \
  180. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_K, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_ENT , \
  181. ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  182. ),
  183. /* Dvorak
  184. * ,-----------------------------------------------------------------------------------.
  185. * | Tab | " | , | . | P | Y | F | G | C | R | L | Bksp |
  186. * |------+------+------+------+------+-------------+------+------+------+------+------|
  187. * | Esc | A | O | E | U | I | D | H | T | N | S | / |
  188. * |------+------+------+------+------+------|------+------+------+------+------+------|
  189. * | Shift| ; | Q | J | K | X | B | M | W | V | Z |Enter |
  190. * |------+------+------+------+------+------+------+------+------+------+------+------|
  191. * |Adjust| Ctrl | Alt | GUI |Lower |Space |Space |Raise | Left | Down | Up |Right |
  192. * `-----------------------------------------------------------------------------------'
  193. */
  194. [_DVORAK] = LAYOUT( \
  195. KC_TAB, KC_QUOT, KC_COMM, KC_DOT, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_BSPC, \
  196. KC_ESC, KC_A, KC_O, KC_E, KC_U, KC_I, KC_D, KC_H, KC_T, KC_N, KC_S, KC_SLSH, \
  197. KC_LSFT, KC_SCLN, KC_Q, KC_J, KC_K, KC_X, KC_B, KC_M, KC_W, KC_V, KC_Z, KC_ENT , \
  198. ADJUST, KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT \
  199. ),
  200. /* Lower
  201. * ,-----------------------------------------------------------------------------------.
  202. * | ~ | ! | @ | # | $ | % | ^ | & | * | ( | ) | Bksp |
  203. * |------+------+------+------+------+-------------+------+------+------+------+------|
  204. * | Del | F1 | F2 | F3 | F4 | F5 | F6 | _ | + | | \ | | |
  205. * |------+------+------+------+------+------|------+------+------+------+------+------|
  206. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO ~ |ISO | | | |Enter |
  207. * |------+------+------+------+------+------+------+------+------+------+------+------|
  208. * | | | | | | | | Next | Vol- | Vol+ | Play |
  209. * `-----------------------------------------------------------------------------------'
  210. */
  211. [_LOWER] = LAYOUT( \
  212. KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, \
  213. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, \
  214. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12,S(KC_NUHS),S(KC_NUBS),_______, _______, _______, \
  215. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  216. ),
  217. /* Raise
  218. * ,-----------------------------------------------------------------------------------.
  219. * | ` | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 0 | Bksp |
  220. * |------+------+------+------+------+-------------+------+------+------+------+------|
  221. * | Del | F1 | F2 | F3 | F4 | F5 | F6 | - | = | [ | ] | \ |
  222. * |------+------+------+------+------+------|------+------+------+------+------+------|
  223. * | | F7 | F8 | F9 | F10 | F11 | F12 |ISO # |ISO / | | |Enter |
  224. * |------+------+------+------+------+------+------+------+------+------+------+------|
  225. * | | | | | | | | Next | Vol- | Vol+ | Play |
  226. * `-----------------------------------------------------------------------------------'
  227. */
  228. [_RAISE] = LAYOUT( \
  229. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, \
  230. KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_MINS, KC_EQL, KC_LBRC, KC_RBRC, KC_BSLS, \
  231. _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_NUHS, KC_NUBS, _______, _______, _______, \
  232. _______, _______, _______, _______, _______, _______, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY \
  233. ),
  234. /* Adjust (Lower + Raise)
  235. * ,-----------------------------------------------------------------------------------.
  236. * | | Reset| | | | | | | | | | Del |
  237. * |------+------+------+------+------+-------------+------+------+------+------+------|
  238. * | | | |Aud on|Audoff|AGnorm|AGswap|Qwerty|Colemk|Dvorak| | |
  239. * |------+------+------+------+------+------|------+------+------+------+------+------|
  240. * | | | | | | | | | | | | |
  241. * |------+------+------+------+------+------+------+------+------+------+------+------|
  242. * | | | | | | | | | | | |
  243. * `-----------------------------------------------------------------------------------'
  244. */
  245. [_ADJUST] = LAYOUT( \
  246. _______, RESET, _______, M_SAMPLE, _______, _______, _______, _______, _______, _______, _______, KC_DEL, \
  247. _______, _______, _______, AU_ON, AU_OFF, AG_NORM, AG_SWAP, QWERTY, COLEMAK, DVORAK, _______, _______, \
  248. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, \
  249. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______ \
  250. )
  251. };
  252. #else
  253. #error "undefined keymaps"
  254. #endif
  255. #ifdef AUDIO_ENABLE
  256. float tone_qwerty[][2] = SONG(QWERTY_SOUND);
  257. float tone_dvorak[][2] = SONG(DVORAK_SOUND);
  258. float tone_colemak[][2] = SONG(COLEMAK_SOUND);
  259. #endif
  260. void persistent_default_layer_set(uint16_t default_layer) {
  261. eeconfig_update_default_layer(default_layer);
  262. default_layer_set(default_layer);
  263. }
  264. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  265. switch (keycode) {
  266. case QWERTY:
  267. if (record->event.pressed) {
  268. #ifdef AUDIO_ENABLE
  269. PLAY_SONG(tone_qwerty);
  270. #endif
  271. persistent_default_layer_set(1UL<<_QWERTY);
  272. }
  273. return false;
  274. break;
  275. case COLEMAK:
  276. if (record->event.pressed) {
  277. #ifdef AUDIO_ENABLE
  278. PLAY_SONG(tone_colemak);
  279. #endif
  280. persistent_default_layer_set(1UL<<_COLEMAK);
  281. }
  282. return false;
  283. break;
  284. case DVORAK:
  285. if (record->event.pressed) {
  286. #ifdef AUDIO_ENABLE
  287. PLAY_SONG(tone_dvorak);
  288. #endif
  289. persistent_default_layer_set(1UL<<_DVORAK);
  290. }
  291. return false;
  292. break;
  293. case LOWER:
  294. if (record->event.pressed) {
  295. layer_on(_LOWER);
  296. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  297. } else {
  298. layer_off(_LOWER);
  299. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  300. }
  301. return false;
  302. break;
  303. case RAISE:
  304. if (record->event.pressed) {
  305. layer_on(_RAISE);
  306. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  307. } else {
  308. layer_off(_RAISE);
  309. update_tri_layer(_LOWER, _RAISE, _ADJUST);
  310. }
  311. return false;
  312. break;
  313. case ADJUST:
  314. if (record->event.pressed) {
  315. layer_on(_ADJUST);
  316. } else {
  317. layer_off(_ADJUST);
  318. }
  319. return false;
  320. break;
  321. }
  322. return true;
  323. }