logo

qmk_firmware

custom branch of QMK firmware git clone https://anongit.hacktivis.me/git/qmk_firmware.git

keymap.c (12897B)


  1. /* Copyright 2022 Feker
  2. * Copyright 2022 HorrorTroll <https://github.com/HorrorTroll>
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. */
  17. #include QMK_KEYBOARD_H
  18. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  19. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  20. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  21. // entirely and just use numbers.
  22. enum layer_names {
  23. _BASE,
  24. _FN,
  25. };
  26. // enum layer_keycodes { };
  27. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  28. /*
  29. ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐ ┌───┐
  30. │Esc││F1 │F2 │F3 │F4 ││F5 │F6 │F7 │F8 ││F9 │F10│F11│F12││Del│ │Mut│
  31. └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘ └───┘
  32. ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┐
  33. │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Bckspc│ │Ins│
  34. ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┤
  35. │ Tab │ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ │ ] │ \ │ │End│
  36. ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ ├───┤
  37. │ Caps │ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; │ ' │ Enter │ │PgU│
  38. ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘ ├───┤
  39. │ LShift │ z │ x │ c │ v │ b │ n │ m │ , │ . │ / │ RSft │┌───┐│PgD│
  40. ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┘│ ↑ │└───┘
  41. │LCrl│GUI │LAlt│ Space │RAt│Fn │Rcl│┌───┼───┼───┐
  42. └────┴────┴────┴────────────────────────┴───┴───┴───┘│ ← │ ↓ │ → │
  43. └───┴───┴───┘
  44. ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐ ┌───┐
  45. │ ││ │ │ │ ││ │ │ │ ││ │ │ │ ││ │ │ │
  46. └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘ └───┘
  47. ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┐
  48. │ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ │ │
  49. ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┤
  50. │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | │ │ │
  51. ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ ├───┤
  52. │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ " │ │ │ │
  53. ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘ ├───┤
  54. │ LShift │ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? │ RSft │┌───┐│ │
  55. ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┘│ │└───┘
  56. │ │ │ │ │ │ │ │┌───┼───┼───┐
  57. └────┴────┴────┴────────────────────────┴───┴───┴───┘│ │ │ │
  58. └───┴───┴───┘
  59. */
  60. /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
  61. [_BASE] = LAYOUT(
  62. 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_DEL, KC_MUTE,
  63. KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_MINS, KC_EQL, KC_BSPC, KC_INS,
  64. KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSLS, KC_END,
  65. KC_CAPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, KC_PGUP,
  66. KC_LSFT, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, KC_UP, KC_PGDN,
  67. KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT
  68. ),
  69. /*
  70. ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐ ┌───┐
  71. │Rst││Mcm│Hom│Cal│Sel││Prv│Nxt│Ply│Stp││Mut│VoD│VoU│Mai││ │ │Tog│
  72. └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘ └───┘
  73. ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ ┌───┐
  74. │NKO│ │ │ │ │ │ │ │ │ │ │Spd│Spi│ │ │Mod│
  75. ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤ ├───┤
  76. │ │ │ │ │ │ │ │ │ │ │Prt│ │ │ │ │Hui│
  77. ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ ├───┤
  78. │ │ │Scr│ │ │ │ │ │ │ │ │ │ │ │Sai│
  79. ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘ ├───┤
  80. │ │ │ │ │ │ │Num│ │ │ │ │ │┌───┐│Sad│
  81. ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─────┘│Vai│└───┘
  82. │ │GTog│ │ │ │ │ ┌───┼───┼───┐
  83. └────┴────┴────┴────────────────────────┴────┴────┘ │ │Vad│ │
  84. └───┴───┴───┘
  85. */
  86. /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */
  87. [_FN] = LAYOUT(
  88. QK_BOOT, KC_MYCM, KC_WHOM, KC_CALC, KC_SLCT, KC_MPRV, KC_MNXT, KC_MPLY, KC_MSTP, KC_MUTE, KC_VOLD, KC_VOLU, KC_MAIL, _______, RM_TOGG,
  89. NK_TOGG, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_SPDD, RM_SPDU, _______, RM_NEXT,
  90. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_PSCR, _______, _______, _______, RM_HUEU,
  91. _______, _______, KC_SCRL, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_SATU,
  92. _______, _______, _______, _______, _______, _______, KC_NUM, _______, _______, _______, _______, _______, RM_VALU, RM_SATD,
  93. _______, GU_TOGG, _______, _______, _______, _______, _______, _______, RM_VALD, _______
  94. ),
  95. };
  96. bool process_record_user(uint16_t keycode, keyrecord_t *record) {
  97. switch (keycode) {
  98. case QK_RGB_MATRIX_TOGGLE:
  99. if (record->event.pressed) {
  100. switch (rgb_matrix_get_flags()) {
  101. case LED_FLAG_ALL: {
  102. rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR);
  103. rgb_matrix_set_color_all(0, 0, 0);
  104. }
  105. break;
  106. case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): {
  107. rgb_matrix_set_flags(LED_FLAG_UNDERGLOW);
  108. rgb_matrix_set_color_all(0, 0, 0);
  109. }
  110. break;
  111. case (LED_FLAG_UNDERGLOW): {
  112. rgb_matrix_set_flags(LED_FLAG_NONE);
  113. rgb_matrix_set_color_all(0, 0, 0);
  114. }
  115. break;
  116. default: {
  117. rgb_matrix_set_flags(LED_FLAG_ALL);
  118. rgb_matrix_enable_noeeprom();
  119. }
  120. break;
  121. }
  122. }
  123. return false;
  124. }
  125. return true;
  126. }
  127. bool rgb_matrix_indicators_user(void) {
  128. rgb_matrix_set_color(46, 0, 0, 0);
  129. rgb_matrix_set_color(104, 0, 0, 0);
  130. uint8_t red = host_keyboard_led_state().caps_lock ? 255 : 0;
  131. uint8_t blue = host_keyboard_led_state().scroll_lock ? 255 : 0;
  132. uint8_t green = keymap_config.no_gui ? 255 : 0;
  133. if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) {
  134. if (host_keyboard_led_state().num_lock) {
  135. rgb_matrix_set_color(46, 255, 0, 0);
  136. }
  137. rgb_matrix_set_color(104, red, green, blue);
  138. } else {
  139. if (host_keyboard_led_state().num_lock) {
  140. rgb_matrix_set_color(46, 255, 0, 0);
  141. } else {
  142. rgb_matrix_set_color(46, 0, 0, 0);
  143. }
  144. rgb_matrix_set_color(104, red, green, blue);
  145. }
  146. return false;
  147. }
  148. #ifdef ENCODER_MAP_ENABLE
  149. const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
  150. [_BASE] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
  151. [_FN] = { ENCODER_CCW_CW(KC_TRNS, KC_TRNS) },
  152. };
  153. #endif