keymap.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. /* Copyright 2018 Andreas Lindhé, Christoffer Holmberg
  2. *
  3. * This program is free software: you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License as published by
  5. * the Free Software Foundation, either version 2 of the License, or
  6. * (at your option) any later version.
  7. *
  8. * This program is distributed in the hope that it will be useful,
  9. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. * GNU General Public License for more details.
  12. *
  13. * You should have received a copy of the GNU General Public License
  14. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  15. */
  16. #include QMK_KEYBOARD_H
  17. #include "version.h"
  18. #include "keymap_swedish.h"
  19. #define BASE 0 // default layer
  20. #define SYMB 1 // symbols
  21. #define MDIA 2 // media keys
  22. #define ARRW 3 // arrow + soon mouse
  23. #define SE_LT SE_LESS
  24. #define SE_GT LSFT(SE_LESS)
  25. enum custom_keycodes {
  26. PLACEHOLDER = SAFE_RANGE, // can always be here
  27. EPRM,
  28. VRSN,
  29. RGB_SLD
  30. };
  31. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  32. /* Keymap 0: Basic layer
  33. *
  34. * ,--------------------------------------------------. ,--------------------------------------------------.
  35. * | Esc | ! | " | # | # | % | Ins | | L1 | & | / | ( | ) | = | ? |
  36. * | | 1 | 2 @ | 3 £ | 4 $ | 5 | | | | 6 | 7 { | 8 [ | 9 ] | 0 } | + \ |
  37. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  38. * | Tab | Q | W | E | R | T | L2 | | L2 | Y | U | I | O | P | Å |
  39. * | | | | | | | | | | | | | | | |
  40. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  41. * | L4 | A | S | D | F | G |------| |------| H | J | K | L |Ö / L3| Ä/L2 |
  42. * | | | | | | | | | | | | | | | |
  43. * |--------+------+------+------+------+------| Back | |Forwd |------+------+------+------+------+--------|
  44. * | LShift/| Z | X | C | V | B | | | | N | M | ; | : | _ | RShift/|
  45. * | ( | | | | | | | | | | | , | . | - | ) |
  46. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  47. * | '/ | ` |Alt | Left | Right| | Spc | Bksp | AltGr| * | ~/ |
  48. * | Ctrl | ' | | | | | | | | | Ctrl |
  49. * `----------------------------------' `----------------------------------'
  50. * ,-------------. ,---------------.
  51. * | <>| | End | | Home | ^ |
  52. * ,------|------|------| |------+--------+------.
  53. * | Left | Right| PgDn | | PgUp | Up | Down |
  54. * |------|------|------| |------|--------|------|
  55. * | Ctrl/| Alt/ | | | | Alt/ | Ctrl/|
  56. * | Enter| Esc | Lgui | | Lgui | Esc | Enter|
  57. * `--------------------' `----------------------'
  58. */
  59. // If it accepts an argument (i.e, is a function), it doesn't need KC_
  60. // Otherwise, it needs KC_*
  61. [BASE] = LAYOUT_ergodox_80( // layer 0 : default
  62. // left hand
  63. KC_ESC, KC_1, KC_2, KC_3, KC_4, KC_5, KC_INS,
  64. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
  65. MO(ARRW), KC_A, KC_S, KC_D, KC_F, KC_G,
  66. KC_LSPO, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, KC_WBAK,
  67. CTL_T(SE_APOS), SE_ACUT, KC_LALT, KC_BSPC, KC_SPC,
  68. SE_LESS, KC_END,
  69. KC_LEFT, KC_RIGHT, KC_PGDN,
  70. CTL_T(KC_ENT), ALT_T(KC_ESC), KC_LGUI,
  71. // right hand
  72. TO(ARRW), KC_6, KC_7, KC_8, KC_9, KC_0, SE_PLUS,
  73. TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, SE_AA,
  74. KC_H, KC_J, KC_K, KC_L, LT(MDIA, SE_OSLH), LT(SYMB, SE_AE),
  75. KC_WFWD, KC_N, KC_M, KC_COMM, KC_DOT, SE_MINS, KC_RSPC,
  76. KC_SPC, KC_BSPC, KC_ALGR, SE_ASTR, CTL_T(SE_TILD),
  77. KC_HOME, SE_CIRC,
  78. KC_PGUP, KC_UP, KC_DOWN,
  79. KC_LGUI, ALT_T(KC_ESC), CTL_T(KC_ENT)
  80. ),
  81. /* Keymap: Symbol Layer
  82. *
  83. * ,--------------------------------------------------. ,--------------------------------------------------.
  84. * |Version | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
  85. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  86. * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 |
  87. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  88. * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | |
  89. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  90. * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | - | |
  91. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  92. * | | | | < | > | | | . | 0 | = | |
  93. * `----------------------------------' `----------------------------------'
  94. * ,-------------. ,-------------.
  95. * | | | | | |
  96. * ,------|------|------| |------+------+------.
  97. * | | | | | | | |
  98. * |------|------|------| |------|------|------|
  99. * | | | | | | | |
  100. * `--------------------' `--------------------'
  101. */
  102. // SYMBOLS
  103. [SYMB] = LAYOUT_ergodox_80(
  104. // left hand
  105. VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______,
  106. _______,KC_EXLM,SE_AT, SE_LCBR,SE_RCBR,SE_PIPE,_______,
  107. _______,KC_HASH,SE_DLR, SE_LPRN,SE_RPRN,SE_GRV,
  108. _______,KC_PERC,SE_CIRC,SE_LBRC,SE_RBRC,SE_TILD,_______,
  109. EPRM, _______, _______, SE_LT , SE_GT,
  110. _______,_______,
  111. _______,_______,_______,
  112. _______,_______,_______,
  113. // right hand
  114. _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
  115. _______, KC_UP, KC_7, KC_8, KC_9, SE_ASTR, KC_F12,
  116. KC_DOWN, KC_4, KC_5, KC_6, SE_PLUS, _______,
  117. _______, SE_AMPR, KC_1, KC_2, KC_3, SE_MINS, _______,
  118. _______,KC_DOT, KC_0, SE_EQL, _______,
  119. _______, _______,
  120. _______, _______, _______,
  121. _______, _______, _______
  122. ),
  123. /* Keymap: Media and mouse keys
  124. *
  125. * ,--------------------------------------------------. ,--------------------------------------------------.
  126. * | | | | | | | | | | | | | | | |
  127. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  128. * | | | MsUp | | | | | | | | | | | | |
  129. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  130. * | |MsLeft|MsDown|MsRght| | |------| |------| | | | | | Play |
  131. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  132. * | | | | | | | | | | | | Prev | Next | | |
  133. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  134. * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | |
  135. * `----------------------------------' `----------------------------------'
  136. * ,-------------. ,-------------.
  137. * | | | | | |
  138. * ,------|------|------| |------+------+------.
  139. * | | | | | | | |
  140. * | |------|------| |------|------|------|
  141. * | | | | | | |BrBck |
  142. * `--------------------' `--------------------'
  143. */
  144. // MEDIA AND MOUSE
  145. [MDIA] = LAYOUT_ergodox_80(
  146. _______, _______, _______, _______, _______, _______, _______,
  147. _______, _______, KC_MS_U, _______, _______, _______, _______,
  148. _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______,
  149. _______, _______, _______, _______, _______, _______, _______,
  150. _______, _______, _______, KC_BTN1, KC_BTN2,
  151. _______, _______,
  152. _______, _______, _______,
  153. _______, _______, _______,
  154. // right hand
  155. _______, _______, _______, _______, _______, _______, _______,
  156. _______, _______, _______, _______, _______, _______, _______,
  157. _______, _______, _______, _______, _______, KC_MPLY,
  158. _______, _______, _______, KC_MPRV, KC_MNXT, _______, _______,
  159. KC_VOLU, KC_VOLD, KC_MUTE, _______, _______,
  160. _______, _______,
  161. _______, _______, _______,
  162. _______, _______, KC_WBAK
  163. ),
  164. // Keymap: Ducky Style arrows
  165. [ARRW] = LAYOUT_ergodox_80(
  166. SE_HALF, _______, _______, _______, _______, _______, _______,
  167. _______, _______, KC_UP , _______, _______, _______, _______,
  168. _______, KC_LEFT, KC_DOWN, KC_RIGHT, _______, _______,
  169. _______, _______, _______, _______, _______, _______, _______,
  170. _______, _______, _______, KC_DEL, _______,
  171. _______, _______,
  172. _______, _______, _______,
  173. _______, _______, _______,
  174. // right hand
  175. TO(BASE), _______, _______, _______, _______, _______, _______,
  176. _______, _______, _______, _______, _______, _______, _______,
  177. _______, _______, _______, _______, _______, _______,
  178. _______, _______, _______, _______, _______, _______, _______,
  179. _______, _______, _______, _______, _______,
  180. _______, _______,
  181. _______, _______, _______,
  182. _______, _______, _______
  183. ),
  184. };
  185. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  186. {
  187. // MACRODOWN only works in this function
  188. switch(id) {
  189. case 0:
  190. if (record->event.pressed) {
  191. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  192. }
  193. break;
  194. case 1:
  195. if (record->event.pressed) { // For resetting EEPROM
  196. eeconfig_init();
  197. }
  198. break;
  199. }
  200. return MACRO_NONE;
  201. };
  202. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  203. switch (keycode) {
  204. // dynamically generate these.
  205. case EPRM:
  206. if (record->event.pressed) {
  207. eeconfig_init();
  208. }
  209. return false;
  210. break;
  211. case VRSN:
  212. if (record->event.pressed) {
  213. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  214. }
  215. return false;
  216. break;
  217. case RGB_SLD:
  218. if (record->event.pressed) {
  219. #ifdef RGBLIGHT_ENABLE
  220. rgblight_mode(1);
  221. #endif
  222. }
  223. return false;
  224. break;
  225. }
  226. return true;
  227. }
  228. // Runs just one time when the keyboard initializes.
  229. void matrix_init_user(void) {
  230. };
  231. // Runs constantly in the background, in a loop.
  232. void matrix_scan_user(void) {
  233. uint8_t layer = biton32(layer_state);
  234. ergodox_board_led_off();
  235. ergodox_right_led_1_off();
  236. ergodox_right_led_2_off();
  237. ergodox_right_led_3_off();
  238. switch (layer) {
  239. // Binary: lsb at bottom
  240. case 1:
  241. ergodox_right_led_3_on();
  242. break;
  243. case 2:
  244. ergodox_right_led_2_on();
  245. break;
  246. case 3:
  247. ergodox_board_led_on();
  248. default:
  249. // none
  250. break;
  251. }
  252. };