2
0

keymap.c 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273
  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. enum custom_keycodes {
  24. PLACEHOLDER = SAFE_RANGE, // can always be here
  25. EPRM,
  26. VRSN,
  27. RGB_SLD
  28. };
  29. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  30. /* Keymap 0: Basic layer
  31. *
  32. * ,--------------------------------------------------. ,--------------------------------------------------.
  33. * | ½ | ! | " | # | # | % | Ins | | L1 | & | / | ( | ) | = | ? |
  34. * | § | 1 | 2 @ | 3 £ | 4 $ | 5 | | | | 6 | 7 { | 8 [ | 9 ] | 0 } | + \ |
  35. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  36. * | Tab | Q | W | E | R | T | L2 | | L2 | Y | U | I | O | P | Å |
  37. * | | | | | | | | | | | | | | | |
  38. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  39. * | L4 | A | S | D | F | G |------| |------| H | J | K | L |Ö / L3| Ä/L2 |
  40. * | | | | | | | | | | | | | | | |
  41. * |--------+------+------+------+------+------| Back | |Forwd |------+------+------+------+------+--------|
  42. * | LShift/| Z | X | C | V | B | | | | N | M | ; | : | _ | RShift/|
  43. * | ( | | | | | | | | | | | , | . | - | ) |
  44. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  45. * | '/ | ` |Alt | Left | Right| | Spc | Bksp | AltGr| * | ~/ |
  46. * | Ctrl | ' | | | | | | | | | Ctrl |
  47. * `----------------------------------' `----------------------------------'
  48. * ,-------------. ,---------------.
  49. * | <>| | End | | Home | ^ |
  50. * ,------|------|------| |------+--------+------.
  51. * | Left | Right| PgDn | | PgUp | Up | Down |
  52. * |------|------|------| |------|--------|------|
  53. * | Ctrl/| Alt/ | | | | Alt/ | Ctrl/|
  54. * | Enter| Esc | Lgui | | Lgui | Esc | Enter|
  55. * `--------------------' `----------------------'
  56. */
  57. // If it accepts an argument (i.e, is a function), it doesn't need KC_
  58. // Otherwise, it needs KC_*
  59. [BASE] = LAYOUT_ergodox_80( // layer 0 : default
  60. // left hand
  61. NO_HALF, KC_1, KC_2, KC_3, KC_4, KC_5, KC_INS,
  62. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, TG(SYMB),
  63. MO(ARRW), KC_A, KC_S, KC_D, KC_F, KC_G,
  64. KC_LSPO, CTL_T(KC_Z), KC_X, KC_C, KC_V, KC_B, KC_WBAK,
  65. CTL_T(NO_APOS), NO_ACUT, KC_LALT, KC_BSPC, KC_SPC,
  66. NO_LESS, KC_END,
  67. KC_LEFT, KC_RIGHT, KC_PGDN,
  68. CTL_T(KC_ENT), ALT_T(KC_ESC), KC_LGUI,
  69. // right hand
  70. TO(ARRW), KC_6, KC_7, KC_8, KC_9, KC_0, NO_PLUS,
  71. TG(SYMB), KC_Y, KC_U, KC_I, KC_O, KC_P, NO_AA,
  72. KC_H, KC_J, KC_K, KC_L, LT(MDIA, NO_OSLH), LT(SYMB, NO_AE),
  73. KC_WFWD, KC_N, KC_M, KC_COMM, KC_DOT, NO_MINS, KC_RSPC,
  74. KC_SPC, KC_BSPC, KC_ALGR, NO_ASTR, CTL_T(NO_TILD),
  75. KC_HOME, NO_CIRC,
  76. KC_PGUP, KC_UP, KC_DOWN,
  77. KC_LGUI, ALT_T(KC_ESC), CTL_T(KC_ENT)
  78. ),
  79. /* Keymap: Symbol Layer
  80. *
  81. * ,--------------------------------------------------. ,--------------------------------------------------.
  82. * |Version | F1 | F2 | F3 | F4 | F5 | | | | F6 | F7 | F8 | F9 | F10 | F11 |
  83. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  84. * | | ! | @ | { | } | | | | | | Up | 7 | 8 | 9 | * | F12 |
  85. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  86. * | | # | $ | ( | ) | ` |------| |------| Down | 4 | 5 | 6 | + | |
  87. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  88. * | | % | ^ | [ | ] | ~ | | | | & | 1 | 2 | 3 | - | |
  89. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  90. * | | | | | | | | . | 0 | = | |
  91. * `----------------------------------' `----------------------------------'
  92. * ,-------------. ,-------------.
  93. * | | | | | |
  94. * ,------|------|------| |------+------+------.
  95. * | | | | | | | |
  96. * |------|------|------| |------|------|------|
  97. * | | | | | | | |
  98. * `--------------------' `--------------------'
  99. */
  100. // SYMBOLS
  101. [SYMB] = LAYOUT_ergodox_80(
  102. // left hand
  103. VRSN, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, _______,
  104. _______,KC_EXLM,NO_AT, NO_LCBR,NO_RCBR,NO_PIPE,_______,
  105. _______,KC_HASH,NO_DLR, NO_LPRN,NO_RPRN,NO_GRV,
  106. _______,KC_PERC,NO_CIRC,NO_LBRC,NO_RBRC,NO_TILD,_______,
  107. EPRM,_______,_______,_______,_______,
  108. _______,_______,
  109. _______,_______,_______,
  110. _______,_______,_______,
  111. // right hand
  112. _______, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11,
  113. _______, KC_UP, KC_7, KC_8, KC_9, NO_ASTR, KC_F12,
  114. KC_DOWN, KC_4, KC_5, KC_6, NO_PLUS, _______,
  115. _______, NO_AMPR, KC_1, KC_2, KC_3, NO_MINS, _______,
  116. _______,KC_DOT, KC_0, NO_EQL, _______,
  117. _______, _______,
  118. _______, _______, _______,
  119. _______, _______, _______
  120. ),
  121. /* Keymap: Media and mouse keys
  122. *
  123. * ,--------------------------------------------------. ,--------------------------------------------------.
  124. * | | | | | | | | | | | | | | | |
  125. * |--------+------+------+------+------+-------------| |------+------+------+------+------+------+--------|
  126. * | | | MsUp | | | | | | | | | | | | |
  127. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  128. * | |MsLeft|MsDown|MsRght| | |------| |------| | | | | | Play |
  129. * |--------+------+------+------+------+------| | | |------+------+------+------+------+--------|
  130. * | | | | | | | | | | | | Prev | Next | | |
  131. * `--------+------+------+------+------+-------------' `-------------+------+------+------+------+--------'
  132. * | | | | Lclk | Rclk | |VolUp |VolDn | Mute | | |
  133. * `----------------------------------' `----------------------------------'
  134. * ,-------------. ,-------------.
  135. * | | | | | |
  136. * ,------|------|------| |------+------+------.
  137. * | | | | | | | |
  138. * | |------|------| |------|------|------|
  139. * | | | | | | |BrBck |
  140. * `--------------------' `--------------------'
  141. */
  142. // MEDIA AND MOUSE
  143. [MDIA] = LAYOUT_ergodox_80(
  144. _______, _______, _______, _______, _______, _______, _______,
  145. _______, _______, KC_MS_U, _______, _______, _______, _______,
  146. _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, _______,
  147. _______, _______, _______, _______, _______, _______, _______,
  148. _______, _______, _______, KC_BTN1, KC_BTN2,
  149. _______, _______,
  150. _______, _______, _______,
  151. _______, _______, _______,
  152. // right hand
  153. _______, _______, _______, _______, _______, _______, _______,
  154. _______, _______, _______, _______, _______, _______, _______,
  155. _______, _______, _______, _______, _______, KC_MPLY,
  156. _______, _______, _______, KC_MPRV, KC_MNXT, _______, _______,
  157. KC_VOLU, KC_VOLD, KC_MUTE, _______, _______,
  158. _______, _______,
  159. _______, _______, _______,
  160. _______, _______, KC_WBAK
  161. ),
  162. // Keymap: Ducky Style arrows
  163. [ARRW] = LAYOUT_ergodox_80(
  164. _______, _______, _______, _______, _______, _______, _______,
  165. _______, _______, KC_UP , _______, _______, _______, _______,
  166. _______, KC_LEFT, KC_DOWN, KC_RIGHT, _______, _______,
  167. _______, _______, _______, _______, _______, _______, _______,
  168. _______, _______, _______, KC_DEL, _______,
  169. _______, _______,
  170. _______, _______, _______,
  171. _______, _______, _______,
  172. // right hand
  173. TO(BASE), _______, _______, _______, _______, _______, _______,
  174. _______, _______, _______, _______, _______, _______, _______,
  175. _______, _______, _______, _______, _______, _______,
  176. _______, _______, _______, _______, _______, _______, _______,
  177. _______, _______, _______, _______, _______,
  178. _______, _______,
  179. _______, _______, _______,
  180. _______, _______, _______
  181. ),
  182. };
  183. const uint16_t PROGMEM fn_actions[] = {
  184. [1] = ACTION_LAYER_TAP_TOGGLE(SYMB) // FN1 - Momentary Layer 1 (Symbols)
  185. };
  186. const macro_t *action_get_macro(keyrecord_t *record, uint8_t id, uint8_t opt)
  187. {
  188. // MACRODOWN only works in this function
  189. switch(id) {
  190. case 0:
  191. if (record->event.pressed) {
  192. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  193. }
  194. break;
  195. case 1:
  196. if (record->event.pressed) { // For resetting EEPROM
  197. eeconfig_init();
  198. }
  199. break;
  200. }
  201. return MACRO_NONE;
  202. };
  203. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  204. switch (keycode) {
  205. // dynamically generate these.
  206. case EPRM:
  207. if (record->event.pressed) {
  208. eeconfig_init();
  209. }
  210. return false;
  211. break;
  212. case VRSN:
  213. if (record->event.pressed) {
  214. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  215. }
  216. return false;
  217. break;
  218. case RGB_SLD:
  219. if (record->event.pressed) {
  220. #ifdef RGBLIGHT_ENABLE
  221. rgblight_mode(1);
  222. #endif
  223. }
  224. return false;
  225. break;
  226. }
  227. return true;
  228. }
  229. // Runs just one time when the keyboard initializes.
  230. void matrix_init_user(void) {
  231. };
  232. // Runs constantly in the background, in a loop.
  233. void matrix_scan_user(void) {
  234. uint8_t layer = biton32(layer_state);
  235. ergodox_board_led_off();
  236. ergodox_right_led_1_off();
  237. ergodox_right_led_2_off();
  238. ergodox_right_led_3_off();
  239. switch (layer) {
  240. // Binary: lsb at bottom
  241. case 1:
  242. ergodox_right_led_3_on();
  243. break;
  244. case 2:
  245. ergodox_right_led_2_on();
  246. break;
  247. case 3:
  248. ergodox_board_led_on();
  249. default:
  250. // none
  251. break;
  252. }
  253. };