keymap.c (10320B)
1 /* Copyright 2022 HorrorTroll <https://github.com/HorrorTroll> 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 17 #include <string.h> 18 #include <math.h> 19 20 #include <lib/lib8tion/lib8tion.h> 21 22 #include QMK_KEYBOARD_H 23 24 // Each layer gets a name for readability, which is then used in the keymap matrix below. 25 // The underscores don't mean anything - you can have a layer called STUFF or any other name. 26 // Layer names don't all need to be of the same length, obviously, and you can also skip them 27 // entirely and just use numbers. 28 29 enum layer_names { 30 _BASE, 31 _FN, 32 }; 33 34 // enum layer_keycodes { }; 35 36 const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { 37 38 /* 39 ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ 40 │Esc│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Bakspc│ ` │ 41 ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ 42 │ Tab │ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ │ ] │ \ │Del│ 43 ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ 44 │ Caps │ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; │ ' │ Enter │PgU│ 45 ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ 46 │ LShift │ z │ x │ c │ v │ b │ n │ m │ , │ . │ / │ RSft │ ↑ │PgD│ 47 ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┼───┤ 48 │LCrl│GUI │LAlt│ Space │RAt│Fn │RCl│ ← │ ↓ │ → │ 49 └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┴───┘ 50 ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ 51 │ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ ~ │ 52 ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ 53 │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | │ │ 54 ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ 55 │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ " │ │ │ 56 ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ 57 │ LShift │ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? │ RSft │ │ │ 58 ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┼───┤ 59 │ │ │ │ │ │ │ │ │ │ │ 60 └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┴───┘ 61 */ 62 /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ 63 [_BASE] = LAYOUT_65_ansi( 64 KC_ESC, 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_GRV, 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_DEL, 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_PGUP, 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, KC_PGDN, 68 KC_LCTL, KC_LGUI, KC_LALT, KC_SPC, KC_RALT, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RGHT 69 ), 70 71 /* 72 ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ 73 │ │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│ │Rst│ 74 ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ 75 │ │ │ ↑ │ │ │ │ │ │Ins│ │PSc│ │ │ Hui │Mod│ 76 ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ 77 │ │ ← │ ↓ │ → │ │ │ │ │ │Tog│ │ │ │Hom│ 78 ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ 79 │ │ │ │Cal│ │ │ │Mut│VoD│VoU│ │ │Vai│End│ 80 ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴──┬┴──┬┴──┬───┼───┼───┤ 81 │ │ │ │ │ │ │App│Spd│Vad│Spi│ 82 └────┴────┴────┴────────────────────────┴───┴───┴───┴───┴───┴───┘ 83 */ 84 /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 */ 85 [_FN] = LAYOUT_65_ansi( 86 _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, QK_BOOT, 87 _______, _______, KC_UP, _______, _______, _______, _______, _______, KC_INS, _______, KC_PSCR, _______, _______, RM_HUEU, RM_NEXT, 88 _______, KC_LEFT, KC_DOWN, KC_RGHT, _______, _______, _______, _______, _______, RM_TOGG, _______, _______, _______, KC_HOME, 89 _______, _______, _______, KC_CALC, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RM_VALU, KC_END, 90 _______, _______, _______, _______, _______, _______, KC_APP, RM_SPDD, RM_VALD, RM_SPDU 91 ), 92 }; 93 94 bool process_record_user(uint16_t keycode, keyrecord_t *record) { 95 switch (keycode) { 96 case QK_RGB_MATRIX_TOGGLE: 97 if (record->event.pressed) { 98 switch (rgb_matrix_get_flags()) { 99 case LED_FLAG_ALL: { 100 rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); 101 rgb_matrix_set_color_all(0, 0, 0); 102 } 103 break; 104 case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): { 105 rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); 106 rgb_matrix_set_color_all(0, 0, 0); 107 } 108 break; 109 case (LED_FLAG_UNDERGLOW): { 110 rgb_matrix_set_flags(LED_FLAG_NONE); 111 rgb_matrix_set_color_all(0, 0, 0); 112 } 113 break; 114 default: { 115 rgb_matrix_set_flags(LED_FLAG_ALL); 116 rgb_matrix_enable_noeeprom(); 117 } 118 break; 119 } 120 } 121 return false; 122 } 123 return true; 124 } 125 126 bool rgb_matrix_indicators_user(void) { 127 hsv_t hsv = rgb_matrix_config.hsv; 128 uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1)); 129 hsv.h = time; 130 rgb_t rgb = hsv_to_rgb(hsv); 131 132 if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) { 133 if (host_keyboard_led_state().caps_lock) { 134 rgb_matrix_set_color(30, rgb.r, rgb.g, rgb.b); 135 } 136 } else { 137 if (host_keyboard_led_state().caps_lock) { 138 rgb_matrix_set_color(30, rgb.r, rgb.g, rgb.b); 139 } else { 140 rgb_matrix_set_color(30, 0, 0, 0); 141 } 142 } 143 return false; 144 }