diff options
Diffstat (limited to 'keyboards/mwstudio/mw65_rgb/keymaps/thearesia/keymap.c')
-rw-r--r-- | keyboards/mwstudio/mw65_rgb/keymaps/thearesia/keymap.c | 201 |
1 files changed, 201 insertions, 0 deletions
diff --git a/keyboards/mwstudio/mw65_rgb/keymaps/thearesia/keymap.c b/keyboards/mwstudio/mw65_rgb/keymaps/thearesia/keymap.c new file mode 100644 index 000000000..70279c334 --- /dev/null +++ b/keyboards/mwstudio/mw65_rgb/keymaps/thearesia/keymap.c | |||
@@ -0,0 +1,201 @@ | |||
1 | /* Copyright 2021 Thearesia | ||
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 = 0, | ||
31 | _FN = 1 | ||
32 | }; | ||
33 | |||
34 | // enum layer_keycodes { }; | ||
35 | |||
36 | enum user_rgb_mode { | ||
37 | RGB_MODE_ALL, | ||
38 | RGB_MODE_KEYLIGHT, | ||
39 | RGB_MODE_UNDERGLOW, | ||
40 | RGB_MODE_NONE, | ||
41 | }; | ||
42 | |||
43 | typedef union { | ||
44 | uint32_t raw; | ||
45 | struct { | ||
46 | uint8_t rgb_mode :8; | ||
47 | }; | ||
48 | } user_config_t; | ||
49 | |||
50 | user_config_t user_config; | ||
51 | |||
52 | const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { | ||
53 | |||
54 | /* | ||
55 | VolD ◯ VolU | ||
56 | ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ | ||
57 | │Esc│ 1 │ 2 │ 3 │ 4 │ 5 │ 6 │ 7 │ 8 │ 9 │ 0 │ - │ = │ Bckspc│Hom│ | ||
58 | ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ | ||
59 | │ Tab │ q │ w │ e │ r │ t │ y │ u │ i │ o │ p │ [ │ ] │ \ │End│ | ||
60 | ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ | ||
61 | │ Caps │ a │ s │ d │ f │ g │ h │ j │ k │ l │ ; │ ' │ Enter │PgU│ | ||
62 | ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ | ||
63 | │ LShift │ z │ x │ c │ v │ b │ n │ m │ , │ . │ / │ RSft │ ↑ │PgD│ | ||
64 | ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─┬───┼───┼───┤ | ||
65 | │LCrl│GUI │LAlt│ Space │RAlt│ Fn │ │ ← │ ↓ │ → │ | ||
66 | └────┴────┴────┴────────────────────────┴────┴────┘ └───┴───┴───┘ | ||
67 | ◯ | ||
68 | ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┬───┐ | ||
69 | │ ~ │ ! │ @ │ # │ $ │ % │ ^ │ & │ * │ ( │ ) │ _ │ + │ │ │ | ||
70 | ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┤ | ||
71 | │ │ Q │ W │ E │ R │ T │ Y │ U │ I │ O │ P │ { │ } │ | │ │ | ||
72 | ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ | ||
73 | │ Caps │ A │ S │ D │ F │ G │ H │ J │ K │ L │ : │ " │ │ │ | ||
74 | ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ | ||
75 | │ LShift │ Z │ X │ C │ V │ B │ N │ M │ < │ > │ ? │ RSht │ │ │ | ||
76 | ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─┬───┼───┼───┤ | ||
77 | │ │ │ │ │ │ │ │ │ │ │ | ||
78 | └────┴────┴────┴────────────────────────┴────┴────┘ └───┴───┴───┘ | ||
79 | */ | ||
80 | /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ | ||
81 | [_BASE] = LAYOUT( | ||
82 | 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_VOLD, KC_HOME, KC_VOLU, | ||
83 | 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, | ||
84 | 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, | ||
85 | 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, | ||
86 | KC_LCTL, KC_LGUI, KC_LALT, KC_SPACE, MO(_FN), KC_RCTL, KC_LEFT, KC_DOWN, KC_RIGHT | ||
87 | ), | ||
88 | |||
89 | /* | ||
90 | ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───────┐ /────\ | ||
91 | │ ` │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│ Home │ │ │ | ||
92 | ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─────┼───┐ │ │ | ||
93 | │Reset│ │ │ │ │ │ │ │ │Hud│Hui│ │ │Pause│Ins│ \────/ | ||
94 | ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┼───┤ | ||
95 | │ │ │ │ │ │ │ │ │ │Sad│Sai│ │ PrtSc │Del│ | ||
96 | ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┼───┤ | ||
97 | │ │ │ │ │ │ │ │ │Spd│Spi│ │ │Vai│Tog│ | ||
98 | ├────┬───┴┬──┴─┬─┴───┴───┴───┴───┴───┴──┬┴───┼───┴┬─┬───┼───┼───┤ | ||
99 | │ │ │ │ │ │ Fn │ │Rod│Vad│Mod│ | ||
100 | └────┴────┴────┴────────────────────────┴────┴────┘ └───┴───┴───┘ | ||
101 | */ | ||
102 | /* Row: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 */ | ||
103 | [_FN] = LAYOUT( | ||
104 | KC_GRV, 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_HOME, _______, _______, _______, | ||
105 | RESET, _______, _______, _______, _______, _______, _______, _______, RGB_HUD, RGB_HUI, _______, _______, _______, KC_PAUSE, KC_INS, | ||
106 | _______, _______, _______, _______, _______, _______, _______, _______, RGB_SAD, RGB_SAI, _______, _______, KC_PSCR, KC_DEL, | ||
107 | _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, _______, _______, RGB_VAI, RGB_TOG, | ||
108 | _______, _______, _______, _______, _______, _______, RGB_RMOD, RGB_VAD, RGB_MOD | ||
109 | ), | ||
110 | }; | ||
111 | |||
112 | void keyboard_post_init_kb(void) { | ||
113 | user_config.raw = eeconfig_read_user(); | ||
114 | switch (user_config.rgb_mode) { | ||
115 | case RGB_MODE_ALL: | ||
116 | rgb_matrix_set_flags(LED_FLAG_ALL); | ||
117 | rgb_matrix_enable_noeeprom(); | ||
118 | break; | ||
119 | case RGB_MODE_KEYLIGHT: | ||
120 | rgb_matrix_set_flags(LED_FLAG_KEYLIGHT); | ||
121 | rgb_matrix_set_color_all(0, 0, 0); | ||
122 | break; | ||
123 | case RGB_MODE_UNDERGLOW: | ||
124 | rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); | ||
125 | rgb_matrix_set_color_all(0, 0, 0); | ||
126 | break; | ||
127 | case RGB_MODE_NONE: | ||
128 | rgb_matrix_set_flags(LED_FLAG_NONE); | ||
129 | rgb_matrix_set_color_all(0, 0, 0); | ||
130 | break; | ||
131 | } | ||
132 | } | ||
133 | |||
134 | bool process_record_user(uint16_t keycode, keyrecord_t *record) { | ||
135 | switch (keycode) { | ||
136 | case RGB_TOG: | ||
137 | if (record->event.pressed) { | ||
138 | switch (rgb_matrix_get_flags()) { | ||
139 | case LED_FLAG_ALL: { | ||
140 | rgb_matrix_set_flags(LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR); | ||
141 | rgb_matrix_set_color_all(0, 0, 0); | ||
142 | user_config.rgb_mode = RGB_MODE_KEYLIGHT; | ||
143 | } | ||
144 | break; | ||
145 | case (LED_FLAG_KEYLIGHT | LED_FLAG_MODIFIER | LED_FLAG_INDICATOR): { | ||
146 | rgb_matrix_set_flags(LED_FLAG_UNDERGLOW); | ||
147 | rgb_matrix_set_color_all(0, 0, 0); | ||
148 | user_config.rgb_mode = RGB_MODE_UNDERGLOW; | ||
149 | } | ||
150 | break; | ||
151 | case (LED_FLAG_UNDERGLOW): { | ||
152 | rgb_matrix_set_flags(LED_FLAG_NONE); | ||
153 | rgb_matrix_set_color_all(0, 0, 0); | ||
154 | user_config.rgb_mode = RGB_MODE_NONE; | ||
155 | } | ||
156 | break; | ||
157 | default: { | ||
158 | rgb_matrix_set_flags(LED_FLAG_ALL); | ||
159 | rgb_matrix_enable_noeeprom(); | ||
160 | user_config.rgb_mode = RGB_MODE_ALL; | ||
161 | } | ||
162 | break; | ||
163 | } | ||
164 | eeconfig_update_user(user_config.raw); | ||
165 | } | ||
166 | return false; | ||
167 | } | ||
168 | return true; | ||
169 | } | ||
170 | |||
171 | #ifdef ENCODER_ENABLE | ||
172 | bool encoder_update_user(uint8_t index, bool clockwise) { | ||
173 | if (index == 0) { | ||
174 | if (clockwise) { | ||
175 | tap_code(dynamic_keymap_get_keycode(biton32(layer_state), 4, 3)); | ||
176 | } else { | ||
177 | tap_code(dynamic_keymap_get_keycode(biton32(layer_state), 4, 4)); | ||
178 | } | ||
179 | } | ||
180 | return true; | ||
181 | } | ||
182 | #endif | ||
183 | |||
184 | void rgb_matrix_indicators_user(void) { | ||
185 | HSV hsv = rgb_matrix_config.hsv; | ||
186 | uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1)); | ||
187 | hsv.h = time; | ||
188 | RGB rgb = hsv_to_rgb(hsv); | ||
189 | |||
190 | if ((rgb_matrix_get_flags() & LED_FLAG_KEYLIGHT)) { | ||
191 | if (host_keyboard_led_state().caps_lock) { | ||
192 | rgb_matrix_set_color(52, rgb.r, rgb.g, rgb.b); | ||
193 | } | ||
194 | } else { | ||
195 | if (host_keyboard_led_state().caps_lock) { | ||
196 | rgb_matrix_set_color(52, rgb.r, rgb.g, rgb.b); | ||
197 | } else { | ||
198 | rgb_matrix_set_color(52, 0, 0, 0); | ||
199 | } | ||
200 | } | ||
201 | } | ||