keymap.c 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. /* Copyright 2022 durken (https://github.com/durken1/)
  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 "keymap_swedish.h"
  18. enum layers {
  19. BASE,
  20. MBO,
  21. SYM,
  22. NUM,
  23. FN
  24. };
  25. enum combos {
  26. WF_ARNG,
  27. EI_ADIA,
  28. UK_ODIA
  29. };
  30. #if defined PS2_MOUSE_ENABLE
  31. #include "ps2_mouse.h"
  32. #endif
  33. #if defined AUTO_BUTTONS && defined PS2_MOUSE_ENABLE
  34. static uint16_t auto_buttons_timer;
  35. extern int tp_buttons; // mousekey button state set in action.c and used in ps2_mouse.c
  36. void ps2_mouse_moved_user(report_mouse_t *mouse_report) {
  37. if (auto_buttons_timer) {
  38. auto_buttons_timer = timer_read();
  39. } else {
  40. if (!tp_buttons) {
  41. layer_on(MBO);
  42. auto_buttons_timer = timer_read();
  43. }
  44. }
  45. }
  46. void matrix_scan_user(void) {
  47. if (auto_buttons_timer && (timer_elapsed(auto_buttons_timer) > AUTO_BUTTONS_TIMEOUT)) {
  48. if (!tp_buttons) {
  49. layer_off(MBO);
  50. auto_buttons_timer = 0;
  51. }
  52. }
  53. }
  54. #endif // defined AUTO_BUTTONS && defined PS2_MOUSE_ENABLE
  55. // Left-hand home row mods
  56. #define GUI_A LGUI_T(KC_A)
  57. #define ALT_R LALT_T(KC_R)
  58. #define SFT_S LSFT_T(KC_S)
  59. #define CTRL_T LCTL_T(KC_T)
  60. // Right-hand home row mods
  61. #define CTL_N RCTL_T(KC_N)
  62. #define SFT_E RSFT_T(KC_E)
  63. #define ALT_I LALT_T(KC_I)
  64. #define GUI_O LGUI_T(KC_O)
  65. #define NUM_SPC LT(NUM, KC_SPC)
  66. #define FN_ENT LT(FN, KC_ENT)
  67. #define SYM_BSP LT(SYM, KC_BSPC)
  68. const uint16_t PROGMEM arng_combo[] = {ALT_R, SFT_S, COMBO_END};
  69. const uint16_t PROGMEM adia_combo[] = {SFT_E, ALT_I, COMBO_END};
  70. const uint16_t PROGMEM odia_combo[] = {SE_U, SE_K, COMBO_END};
  71. combo_t key_combos[COMBO_COUNT] = {
  72. [WF_ARNG] = COMBO(arng_combo, SE_ARNG),
  73. [EI_ADIA] = COMBO(adia_combo, SE_ADIA),
  74. [UK_ODIA] = COMBO(odia_combo, SE_ODIA)
  75. };
  76. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  77. [BASE] = LAYOUT_split_3x5_3(
  78. // BASE
  79. //,--------------------------------------------, ,--------------------------------------------.
  80. SE_Q, SE_W, SE_F, SE_P, SE_B, SE_Y, SE_L, SE_U, SE_K, SE_QUOT,
  81. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  82. GUI_A, ALT_R, SFT_S, CTRL_T, SE_G, SE_M, CTL_N, SFT_E, ALT_I, GUI_O,
  83. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  84. SE_Z, SE_X, SE_C, SE_D, SE_V, SE_J, SE_H, SE_COMM, SE_DOT, SE_MINS,
  85. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  86. KC_ESC, NUM_SPC, KC_TAB, FN_ENT, SYM_BSP, KC_DEL
  87. //`--------------------------' '--------------------------'
  88. ),
  89. [MBO] = LAYOUT_split_3x5_3(
  90. // Mouse
  91. //,--------------------------------------------, ,--------------------------------------------.
  92. _______, _______, _______, _______, _______, KC_BTN1, KC_BTN2, _______, _______, _______,
  93. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  94. _______, _______, _______, _______, _______, KC_BTN3, _______, _______, _______, _______,
  95. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  96. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  97. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  98. _______, _______, _______, _______, KC_BSPC, _______
  99. //`--------------------------' '--------------------------'
  100. ),
  101. [SYM] = LAYOUT_split_3x5_3(
  102. // Symbols
  103. //,--------------------------------------------, ,--------------------------------------------.
  104. SE_SECT, SE_ACUT, SE_SLSH, SE_TILD, _______, _______, SE_PIPE, SE_BSLS, SE_DIAE, SE_CIRC,
  105. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  106. SE_EXLM, SE_DLR, SE_LPRN, SE_LBRC, _______, _______, SE_RBRC, SE_RPRN, SE_HASH, SE_QUES,
  107. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  108. _______, SE_PERC, SE_LCBR, SE_LABK, _______, _______, SE_RABK, SE_RCBR, SE_AMPR, _______,
  109. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  110. SE_AT, SE_EQL, SE_DQUO, _______, _______, _______
  111. //`--------------------------' '--------------------------'
  112. ),
  113. [NUM] = LAYOUT_split_3x5_3(
  114. // Numbers
  115. //,--------------------------------------------, ,--------------------------------------------.
  116. _______, KC_MPRV, KC_MPLY, KC_MNXT, _______, _______, SE_7, SE_8, SE_9, SE_QUOT,
  117. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  118. SE_PLUS, SE_MINS, SE_ASTR, SE_SLSH, SE_CIRC, _______, SE_4, SE_5, SE_6, _______,
  119. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  120. _______, _______, KC_VOLD, KC_VOLU, _______, KC_SPC, SE_1, SE_2, SE_3, _______,
  121. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  122. _______, _______, _______, SE_COMM, SE_0, SE_DOT
  123. //`--------------------------' '--------------------------'
  124. ),
  125. [FN] = LAYOUT_split_3x5_3(
  126. // FN
  127. //,--------------------------------------------, ,--------------------------------------------.
  128. _______, _______, _______, _______, _______, _______, KC_F7, KC_F8, KC_F9, KC_F10,
  129. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  130. KC_LEFT, KC_DOWN, KC_UP, KC_RGHT, _______, _______, KC_F4, KC_F5, KC_F6, KC_F11,
  131. //|--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------|
  132. _______, _______, _______, _______, _______, _______, KC_F1, KC_F2, KC_F3, KC_F12,
  133. //|--------+--------+--------+--------+--------+--------| |--------+--------+--------+--------+--------+--------|
  134. KC_PSCR, KC_CAPS, _______, _______, _______, _______
  135. //`--------------------------' '--------------------------'
  136. )
  137. };