keymap.c 14 KB

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