keymap.c 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /* Copyright 2022 ML
  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 <string.h>
  18. #include <math.h>
  19. #include <lib/lib8tion/lib8tion.h>
  20. // Each layer gets a name for readability, which is then used in the keymap matrix below.
  21. // The underscores don't mean anything - you can have a layer called STUFF or any other name.
  22. // Layer names don't all need to be of the same length, obviously, and you can also skip them
  23. // entirely and just use numbers.
  24. enum layer_names {
  25. _BASE,
  26. _FN,
  27. };
  28. const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
  29. /*
  30. ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐┌───┐
  31. │Esc││F1 │F2 │F3 │F4 ││F5 │F6 │F7 │F8 ││F9 │F10│F11│F12││Pse││Del│
  32. └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘└───┘
  33. ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐┌───┐
  34. │ ` │ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Bckspc││Del│
  35. ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┤├───┤
  36. │ Tab │ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ │ ] │ \ ││PgU│
  37. ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤├───┤
  38. │ Caps │ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; │ ' │ Enter ││PgD│
  39. ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘└───┘
  40. │ LShift │ z │ x │ c │ v │ b │ n │ m │ , │ . │ / │ RSft │┌───┐
  41. ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─────┘│ ↑ │
  42. │LCrl│GUI │LAlt│ Space │RAlt│ Fn │ ┌───┼───┼───┐
  43. └────┴────┴────┴────────────────────────┴────┴────┘ │ ← │ ↓ │ → │
  44. └───┴───┴───┘
  45. ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐┌───┐
  46. │ ││ │ │ │ ││ │ │ │ ││ │ │ │ ││ ││ │
  47. └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘└───┘
  48. ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐┌───┐
  49. │ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ ~ │ ││ │
  50. ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤├───┤
  51. │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | ││ │
  52. ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤├───┤
  53. │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ " │ ││ │
  54. ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘└───┘
  55. │ LShift │ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? │ RSft │┌───┐
  56. ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─────┘│ │
  57. │ │ │ │ │ │ │ ┌───┼───┼───┐
  58. └────┴────┴────┴────────────────────────┴────┴────┘ │ │ │ │
  59. └───┴───┴───┘
  60. */
  61. /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
  62. [_BASE] = LAYOUT(
  63. 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,
  64. 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_HOME,
  65. 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_PGUP,
  66. 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_PGDN,
  67. 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,
  68. KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_LEFT, KC_DOWN, KC_RIGHT
  69. ),
  70. /*
  71. ┌───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┬───┬───┬───┐┌───┐┌───┐
  72. │Rst││ │ │ │ ││ │ │ │ ││ │ │ │ ││ ││Tog│
  73. └───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┴───┴───┴───┘└───┘└───┘
  74. ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐┌───┐
  75. │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ││Hui│
  76. ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤├───┤
  77. │ │ │ │ │ │ │ │ │ │ │ │ │ │ ││Hud│
  78. ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤├───┤
  79. │ │ │ │ │ │ │ │ │ │ │ │ │ ││ │
  80. ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┘└───┘
  81. │ │ │ │ │ │ │ │ │ │ │ │ │┌───┐
  82. ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─────┘│Vai│
  83. │ │ │ │ │ │ │ ┌───┼───┼───┐
  84. └────┴────┴────┴────────────────────────┴────┴────┘ │Spd│Vad│Spi│
  85. └───┴───┴───┘
  86. */
  87. /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */
  88. [_FN] = LAYOUT(
  89. QK_BOOT, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_TOGG,
  90. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_HUEU,
  91. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_HUED,
  92. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______,
  93. _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_VALU,
  94. _______, _______, _______, _______, _______, _______, RM_SPDD, RM_VALD, RM_SPDU
  95. ),
  96. };
  97. #ifdef ENCODER_MAP_ENABLE
  98. const uint16_t PROGMEM encoder_map[][NUM_ENCODERS][NUM_DIRECTIONS] = {
  99. [0] = { ENCODER_CCW_CW(KC_VOLD, KC_VOLU) },
  100. [1] = { ENCODER_CCW_CW(RM_PREV, RM_NEXT) },
  101. };
  102. #endif
  103. bool rgb_matrix_indicators_user(void) {
  104. rgb_matrix_set_color(2, 0, 0, 0);
  105. hsv_t hsv = rgb_matrix_config.hsv;
  106. uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1));
  107. hsv.h = time;
  108. rgb_t rgb = hsv_to_rgb(hsv);
  109. if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) {
  110. if (host_keyboard_led_state().caps_lock) {
  111. rgb_matrix_set_color(2, rgb.r, rgb.g, rgb.b);
  112. }
  113. } else {
  114. if (host_keyboard_led_state().caps_lock) {
  115. rgb_matrix_set_color(2, rgb.r, rgb.g, rgb.b);
  116. } else {
  117. rgb_matrix_set_color(2, 0, 0, 0);
  118. }
  119. }
  120. return false;
  121. }