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.

105 lines
5.5 KiB

  1. /*
  2. Copyright 2016 Daniel Svensson <dsvensson@gmail.com>
  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. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with this program. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. #include QMK_KEYBOARD_H
  15. /* Swedish keys */
  16. #define SE_HALF KC_GRV
  17. #define SE_PLUS KC_MINS
  18. #define SE_ACUT KC_EQL
  19. #define SE_AO KC_LBRC
  20. #define SE_CIRC KC_RBRC
  21. #define SE_QUOT KC_BSLS
  22. #define SE_OE KC_SCLN
  23. #define SE_AE KC_QUOT
  24. #define SE_MINS KC_SLSH
  25. #define SE_LTGT KC_NUBS
  26. #define SE_LCBR RALT(KC_7)
  27. #define SE_LBRC RALT(KC_8)
  28. #define SE_RBRC RALT(KC_9)
  29. #define SE_RCBR RALT(KC_0)
  30. #define SE_PIPE RALT(SE_LTGT)
  31. #define SE_BSLS RALT(SE_PLUS)
  32. #define KM_BLOWRAK 0
  33. #define KM_QWERTY 1
  34. #define KM_MEDIA 2
  35. #define KM_HAXHAX 3
  36. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  37. /* Layer 0: Blowrak ISO layer, a Swedish take on Dvorak */
  38. [KM_BLOWRAK] = LAYOUT( \
  39. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, \
  40. SE_HALF, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, SE_PLUS,SE_ACUT,KC_BSPC, KC_INS, KC_HOME,KC_PGUP, \
  41. KC_TAB, SE_AO, SE_AE, SE_OE, KC_P, KC_Y, KC_F, KC_G, KC_C, KC_R, KC_L, KC_COMM,SE_CIRC,SE_QUOT, KC_DEL, KC_END, KC_PGDN, \
  42. KC_LCTRL,KC_A, KC_O, KC_E, KC_U, KC_I, KC_H, KC_D, KC_T, KC_N, KC_S, SE_MINS, KC_ENT, \
  43. KC_LSFT, SE_LTGT,KC_DOT, KC_Q, KC_J, KC_K, KC_B, KC_X, KC_M, KC_W, KC_V, KC_Z, KC_RSFT, KC_UP, \
  44. MO(KM_MEDIA),KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,KC_MENU,TG(KM_QWERTY), KC_LEFT,KC_DOWN,KC_RGHT),
  45. /* Layer 1: Standard ISO layer */
  46. [KM_QWERTY] = LAYOUT( \
  47. KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR,KC_SLCK,KC_PAUS, \
  48. SE_HALF, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, SE_PLUS,SE_ACUT,KC_BSPC, KC_INS, KC_HOME,KC_PGUP, \
  49. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, SE_AO, SE_CIRC,SE_QUOT, KC_DEL, KC_END, KC_PGDN, \
  50. KC_LCTRL,KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, SE_OE, SE_AE, KC_ENT, \
  51. KC_LSFT, SE_LTGT,KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM,KC_DOT, SE_MINS, KC_RSFT, KC_UP, \
  52. MO(KM_MEDIA),KC_LGUI,KC_LALT, KC_SPC, KC_RALT,KC_RGUI,KC_MENU,TG(KM_QWERTY), KC_LEFT,KC_DOWN,KC_RGHT),
  53. /* Layer 2: Media layer */
  54. [KM_MEDIA] = LAYOUT( \
  55. _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, KC_WAKE,KC_PWR, KC_SLEP, \
  56. _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,KC_VOLU, \
  57. _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, KC_MUTE,_______,KC_VOLD, \
  58. _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, \
  59. _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, KC_MPLY, \
  60. _______,_______,_______, _______, _______,_______,RESET ,_______, KC_MPRV,KC_MSTP,KC_MNXT),
  61. /* Layer 3: Programming layer */
  62. [KM_HAXHAX] = LAYOUT( \
  63. _______, _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \
  64. _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \
  65. _______,SE_LCBR,SE_PIPE,SE_RCBR,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______,_______,_______, \
  66. _______,SE_LBRC,SE_BSLS,SE_RBRC,_______,_______,_______,_______,_______,_______,_______,_______, _______, \
  67. _______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______,_______, _______, _______, \
  68. _______,_______,_______, _______, _______,_______,_______,_______, _______,_______,_______),
  69. };
  70. void matrix_scan_user(void)
  71. {
  72. uint8_t layer = biton32(layer_state);
  73. switch (layer) {
  74. case KM_BLOWRAK:
  75. ph_caps_led_on();
  76. ph_sclk_led_off();
  77. break;
  78. case KM_QWERTY:
  79. ph_sclk_led_on();
  80. ph_caps_led_off();
  81. break;
  82. }
  83. }
  84. /* Mixes in KM_HAXHAX via RALT modifier without shadowing the RALT key combinations. */
  85. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  86. uint8_t modifiers = get_mods();
  87. if (modifiers & MOD_BIT(KC_RALT) && record->event.pressed) {
  88. uint16_t kc = keymap_key_to_keycode(KM_HAXHAX, record->event.key);
  89. if (kc != KC_TRNS) {
  90. register_code(kc);
  91. unregister_code(kc);
  92. return false;
  93. }
  94. }
  95. return true;
  96. }