You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
13 KiB

  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. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  186. switch (keycode) {
  187. // dynamically generate these.
  188. case EPRM:
  189. if (record->event.pressed) {
  190. eeconfig_init();
  191. }
  192. return false;
  193. break;
  194. case VRSN:
  195. if (record->event.pressed) {
  196. SEND_STRING (QMK_KEYBOARD "/" QMK_KEYMAP " @ " QMK_VERSION);
  197. }
  198. return false;
  199. break;
  200. case RGB_SLD:
  201. if (record->event.pressed) {
  202. #ifdef RGBLIGHT_ENABLE
  203. rgblight_mode(1);
  204. #endif
  205. }
  206. return false;
  207. break;
  208. }
  209. return true;
  210. }
  211. // Runs just one time when the keyboard initializes.
  212. void matrix_init_user(void) {
  213. };
  214. // Runs constantly in the background, in a loop.
  215. void matrix_scan_user(void) {
  216. uint8_t layer = biton32(layer_state);
  217. ergodox_board_led_off();
  218. ergodox_right_led_1_off();
  219. ergodox_right_led_2_off();
  220. ergodox_right_led_3_off();
  221. switch (layer) {
  222. // Binary: lsb at bottom
  223. case 1:
  224. ergodox_right_led_3_on();
  225. break;
  226. case 2:
  227. ergodox_right_led_2_on();
  228. break;
  229. case 3:
  230. ergodox_board_led_on();
  231. default:
  232. // none
  233. break;
  234. }
  235. };