diff options
| author | Drashna Jaelre <drashna@live.com> | 2020-08-22 07:44:42 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-08-22 07:44:42 -0700 |
| commit | 220b1c9db40d95271dcdd8d8050e46a2a3143c65 (patch) | |
| tree | f98a2177f5ec0009df4400cfd5b100a3ff816297 /keyboards/moonlander/moonlander.c | |
| parent | 346bfb2a052f4e05cc91e55e1317c8529c405ac6 (diff) | |
| download | qmk_firmware-220b1c9db40d95271dcdd8d8050e46a2a3143c65.tar.gz qmk_firmware-220b1c9db40d95271dcdd8d8050e46a2a3143c65.zip | |
[Keyboard] Add ZSA Moonlander (#9853)
Diffstat (limited to 'keyboards/moonlander/moonlander.c')
| -rw-r--r-- | keyboards/moonlander/moonlander.c | 466 |
1 files changed, 466 insertions, 0 deletions
diff --git a/keyboards/moonlander/moonlander.c b/keyboards/moonlander/moonlander.c new file mode 100644 index 000000000..403e6aef8 --- /dev/null +++ b/keyboards/moonlander/moonlander.c | |||
| @@ -0,0 +1,466 @@ | |||
| 1 | /* Copyright 2020 ZSA Technology Labs, Inc <@zsa> | ||
| 2 | * Copyright 2020 Jack Humbert <jack.humb@gmail.com> | ||
| 3 | * Copyright 2020 Drashna Jael're <drashna@live.com> | ||
| 4 | * | ||
| 5 | * This program is free software: you can redistribute it and/or modify | ||
| 6 | * it under the terms of the GNU General Public License as published by | ||
| 7 | * the Free Software Foundation, either version 2 of the License, or | ||
| 8 | * (at your option) any later version. | ||
| 9 | * | ||
| 10 | * This program is distributed in the hope that it will be useful, | ||
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
| 13 | * GNU General Public License for more details. | ||
| 14 | * | ||
| 15 | * You should have received a copy of the GNU General Public License | ||
| 16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
| 17 | */ | ||
| 18 | |||
| 19 | |||
| 20 | |||
| 21 | #include "moonlander.h" | ||
| 22 | #ifdef WEBUSB_ENABLE | ||
| 23 | # include "webusb.h" | ||
| 24 | #endif | ||
| 25 | |||
| 26 | keyboard_config_t keyboard_config; | ||
| 27 | |||
| 28 | bool mcp23018_leds[3] = {0, 0, 0}; | ||
| 29 | bool is_launching = false; | ||
| 30 | |||
| 31 | #ifdef DYNAMIC_MACRO_ENABLE | ||
| 32 | static bool is_dynamic_recording = false; | ||
| 33 | |||
| 34 | void dynamic_macro_record_start_user(void) { is_dynamic_recording = true; } | ||
| 35 | |||
| 36 | void dynamic_macro_record_end_user(int8_t direction) { | ||
| 37 | is_dynamic_recording = false; | ||
| 38 | ML_LED_3(false); | ||
| 39 | } | ||
| 40 | #endif | ||
| 41 | |||
| 42 | void moonlander_led_task(void) { | ||
| 43 | if (is_launching) { | ||
| 44 | ML_LED_1(false); | ||
| 45 | ML_LED_2(false); | ||
| 46 | ML_LED_3(false); | ||
| 47 | ML_LED_4(false); | ||
| 48 | ML_LED_5(false); | ||
| 49 | ML_LED_6(false); | ||
| 50 | |||
| 51 | ML_LED_1(true); | ||
| 52 | wait_ms(250); | ||
| 53 | ML_LED_2(true); | ||
| 54 | wait_ms(250); | ||
| 55 | ML_LED_3(true); | ||
| 56 | wait_ms(250); | ||
| 57 | ML_LED_4(true); | ||
| 58 | wait_ms(250); | ||
| 59 | ML_LED_5(true); | ||
| 60 | wait_ms(250); | ||
| 61 | ML_LED_6(true); | ||
| 62 | wait_ms(250); | ||
| 63 | ML_LED_1(false); | ||
| 64 | wait_ms(250); | ||
| 65 | ML_LED_2(false); | ||
| 66 | wait_ms(250); | ||
| 67 | ML_LED_3(false); | ||
| 68 | wait_ms(250); | ||
| 69 | ML_LED_4(false); | ||
| 70 | wait_ms(250); | ||
| 71 | ML_LED_5(false); | ||
| 72 | wait_ms(250); | ||
| 73 | ML_LED_6(false); | ||
| 74 | wait_ms(250); | ||
| 75 | is_launching = false; | ||
| 76 | layer_state_set_kb(layer_state); | ||
| 77 | } | ||
| 78 | #ifdef DYNAMIC_MACRO_ENABLE | ||
| 79 | else if (is_dynamic_recording) { | ||
| 80 | ML_LED_3(true); | ||
| 81 | wait_ms(100); | ||
| 82 | ML_LED_3(false); | ||
| 83 | wait_ms(155); | ||
| 84 | } | ||
| 85 | #endif | ||
| 86 | #ifdef WEBUSB_ENABLE | ||
| 87 | else if (webusb_state.pairing == true) { | ||
| 88 | static uint8_t led_mask; | ||
| 89 | |||
| 90 | ML_LED_1(false); | ||
| 91 | ML_LED_2(false); | ||
| 92 | ML_LED_3(false); | ||
| 93 | ML_LED_4(false); | ||
| 94 | ML_LED_5(false); | ||
| 95 | ML_LED_6(false); | ||
| 96 | |||
| 97 | if (!led_mask) { | ||
| 98 | led_mask = 1; | ||
| 99 | } else { | ||
| 100 | led_mask++; | ||
| 101 | if (led_mask > 12) led_mask = 1; | ||
| 102 | } | ||
| 103 | switch (led_mask) { | ||
| 104 | case 1: | ||
| 105 | case 12: | ||
| 106 | ML_LED_1(true); | ||
| 107 | break; | ||
| 108 | case 2: | ||
| 109 | case 11: | ||
| 110 | ML_LED_2(true); | ||
| 111 | break; | ||
| 112 | case 3: | ||
| 113 | case 10: | ||
| 114 | ML_LED_3(true); | ||
| 115 | break; | ||
| 116 | case 4: | ||
| 117 | case 9: | ||
| 118 | ML_LED_4(true); | ||
| 119 | break; | ||
| 120 | case 5: | ||
| 121 | case 8: | ||
| 122 | ML_LED_5(true); | ||
| 123 | break; | ||
| 124 | case 6: | ||
| 125 | case 7: | ||
| 126 | ML_LED_6(true); | ||
| 127 | break; | ||
| 128 | } | ||
| 129 | wait_ms(150); | ||
| 130 | } | ||
| 131 | #endif | ||
| 132 | } | ||
| 133 | |||
| 134 | static THD_WORKING_AREA(waLEDThread, 128); | ||
| 135 | static THD_FUNCTION(LEDThread, arg) { | ||
| 136 | (void)arg; | ||
| 137 | chRegSetThreadName("LEDThread"); | ||
| 138 | while (true) { | ||
| 139 | moonlander_led_task(); | ||
| 140 | } | ||
| 141 | } | ||
| 142 | |||
| 143 | void keyboard_pre_init_kb(void) { | ||
| 144 | setPinOutput(B5); | ||
| 145 | setPinOutput(B4); | ||
| 146 | setPinOutput(B3); | ||
| 147 | |||
| 148 | writePinLow(B5); | ||
| 149 | writePinLow(B4); | ||
| 150 | writePinLow(B3); | ||
| 151 | |||
| 152 | chThdCreateStatic(waLEDThread, sizeof(waLEDThread), NORMALPRIO - 16, LEDThread, NULL); | ||
| 153 | |||
| 154 | /* the array is initialized to 0, no need to re-set it here */ | ||
| 155 | // mcp23018_leds[0] = 0; // blue | ||
| 156 | // mcp23018_leds[1] = 0; // green | ||
| 157 | // mcp23018_leds[2] = 0; // red | ||
| 158 | |||
| 159 | keyboard_pre_init_user(); | ||
| 160 | } | ||
| 161 | |||
| 162 | #ifdef ORYX_CONFIGURATOR | ||
| 163 | layer_state_t layer_state_set_kb(layer_state_t state) { | ||
| 164 | state = layer_state_set_user(state); | ||
| 165 | if (is_launching) return state; | ||
| 166 | |||
| 167 | ML_LED_1(false); | ||
| 168 | ML_LED_2(false); | ||
| 169 | ML_LED_3(false); | ||
| 170 | ML_LED_4(false); | ||
| 171 | ML_LED_5(false); | ||
| 172 | ML_LED_6(false); | ||
| 173 | |||
| 174 | uint8_t layer = get_highest_layer(state); | ||
| 175 | switch (layer) { | ||
| 176 | case 1: | ||
| 177 | ML_LED_1(1); | ||
| 178 | ML_LED_4(1); | ||
| 179 | break; | ||
| 180 | case 2: | ||
| 181 | ML_LED_2(1); | ||
| 182 | ML_LED_5(1); | ||
| 183 | break; | ||
| 184 | case 3: | ||
| 185 | ML_LED_3(1); | ||
| 186 | break; | ||
| 187 | case 4: | ||
| 188 | ML_LED_4(1); | ||
| 189 | break; | ||
| 190 | case 5: | ||
| 191 | ML_LED_5(1); | ||
| 192 | break; | ||
| 193 | case 6: | ||
| 194 | ML_LED_6(1); | ||
| 195 | break; | ||
| 196 | default: | ||
| 197 | break; | ||
| 198 | } | ||
| 199 | |||
| 200 | return state; | ||
| 201 | } | ||
| 202 | #endif | ||
| 203 | |||
| 204 | #ifdef RGB_MATRIX_ENABLE | ||
| 205 | // clang-format off | ||
| 206 | const is31_led g_is31_leds[DRIVER_LED_TOTAL] = { | ||
| 207 | /* Refer to IS31 manual for these locations | ||
| 208 | * driver | ||
| 209 | * | R location | ||
| 210 | * | | G location | ||
| 211 | * | | | B location | ||
| 212 | * | | | | */ | ||
| 213 | {0, C3_2, C1_1, C4_2}, // 1 | ||
| 214 | {0, C2_2, C1_2, C4_3}, | ||
| 215 | {0, C2_3, C1_3, C3_3}, | ||
| 216 | {0, C2_4, C1_4, C3_4}, | ||
| 217 | {0, C2_5, C1_5, C3_5}, | ||
| 218 | {0, C2_6, C1_6, C3_6}, | ||
| 219 | {0, C2_7, C1_7, C3_7}, | ||
| 220 | {0, C2_8, C1_8, C3_8}, | ||
| 221 | {0, C3_1, C2_1, C4_1}, | ||
| 222 | |||
| 223 | {0, C7_8, C6_8, C8_8}, // 10 | ||
| 224 | {0, C7_7, C6_7, C9_8}, | ||
| 225 | {0, C8_7, C6_6, C9_7}, | ||
| 226 | {0, C8_6, C7_6, C9_6}, | ||
| 227 | {0, C8_5, C7_5, C9_5}, | ||
| 228 | {0, C8_4, C7_4, C9_4}, | ||
| 229 | {0, C8_3, C7_3, C9_3}, | ||
| 230 | {0, C8_2, C7_2, C9_2}, | ||
| 231 | {0, C8_1, C7_1, C9_1}, | ||
| 232 | |||
| 233 | {0, C3_10, C1_9, C4_10}, // 19 | ||
| 234 | {0, C2_10, C1_10, C4_11}, | ||
| 235 | {0, C2_11, C1_11, C3_11}, | ||
| 236 | {0, C2_12, C1_12, C3_12}, | ||
| 237 | {0, C2_13, C1_13, C3_13}, | ||
| 238 | {0, C2_14, C1_14, C3_14}, | ||
| 239 | {0, C2_15, C1_15, C3_15}, | ||
| 240 | {0, C2_16, C1_16, C3_16}, | ||
| 241 | {0, C3_9, C2_9, C4_9}, | ||
| 242 | |||
| 243 | {0, C7_16, C6_16, C8_16}, // 28 | ||
| 244 | {0, C7_15, C6_15, C9_16}, | ||
| 245 | {0, C8_15, C6_14, C9_15}, | ||
| 246 | {0, C8_10, C7_10, C9_10}, | ||
| 247 | {0, C8_9, C7_9, C9_9}, | ||
| 248 | {0, C8_11, C7_11, C9_11}, | ||
| 249 | {0, C8_12, C7_12, C9_12}, | ||
| 250 | {0, C8_13, C7_13, C9_13}, | ||
| 251 | {0, C8_14, C7_14, C9_14}, | ||
| 252 | |||
| 253 | {1, C3_2, C1_1, C4_2}, // 1 | ||
| 254 | {1, C2_2, C1_2, C4_3}, | ||
| 255 | {1, C2_3, C1_3, C3_3}, | ||
| 256 | {1, C2_4, C1_4, C3_4}, | ||
| 257 | {1, C2_5, C1_5, C3_5}, | ||
| 258 | {1, C2_6, C1_6, C3_6}, | ||
| 259 | {1, C2_7, C1_7, C3_7}, | ||
| 260 | {1, C2_8, C1_8, C3_8}, | ||
| 261 | {1, C3_1, C2_1, C4_1}, | ||
| 262 | |||
| 263 | {1, C7_8, C6_8, C8_8}, // 10 | ||
| 264 | {1, C7_7, C6_7, C9_8}, | ||
| 265 | {1, C8_7, C6_6, C9_7}, | ||
| 266 | {1, C8_6, C7_6, C9_6}, | ||
| 267 | {1, C8_5, C7_5, C9_5}, | ||
| 268 | {1, C8_4, C7_4, C9_4}, | ||
| 269 | {1, C8_3, C7_3, C9_3}, | ||
| 270 | {1, C8_2, C7_2, C9_2}, | ||
| 271 | {1, C8_1, C7_1, C9_1}, | ||
| 272 | |||
| 273 | {1, C3_10, C1_9, C4_10}, // 19 | ||
| 274 | {1, C2_10, C1_10, C4_11}, | ||
| 275 | {1, C2_11, C1_11, C3_11}, | ||
| 276 | {1, C2_12, C1_12, C3_12}, | ||
| 277 | {1, C2_13, C1_13, C3_13}, | ||
| 278 | {1, C2_14, C1_14, C3_14}, | ||
| 279 | {1, C2_15, C1_15, C3_15}, | ||
| 280 | {1, C2_16, C1_16, C3_16}, | ||
| 281 | {1, C3_9, C2_9, C4_9}, | ||
| 282 | |||
| 283 | {1, C7_16, C6_16, C8_16}, // 28 | ||
| 284 | {1, C7_15, C6_15, C9_16}, | ||
| 285 | {1, C8_15, C6_14, C9_15}, | ||
| 286 | {1, C8_10, C7_10, C9_10}, | ||
| 287 | {1, C8_9, C7_9, C9_9}, | ||
| 288 | {1, C8_11, C7_11, C9_11}, | ||
| 289 | {1, C8_12, C7_12, C9_12}, | ||
| 290 | {1, C8_13, C7_13, C9_13}, | ||
| 291 | {1, C8_14, C7_14, C9_14}, | ||
| 292 | |||
| 293 | }; | ||
| 294 | |||
| 295 | led_config_t g_led_config = { { | ||
| 296 | { 0, 5, 10, 15, 20, 25, 29 }, | ||
| 297 | { 1, 6, 11, 16, 21, 26, 30 }, | ||
| 298 | { 2, 7, 12, 17, 22, 27, 31 }, | ||
| 299 | { 3, 8, 13, 18, 23, 28, NO_LED }, | ||
| 300 | { 4, 9, 14, 19, 24, NO_LED, NO_LED }, | ||
| 301 | { 32, 33, 34, 35, NO_LED, NO_LED, NO_LED }, | ||
| 302 | { 65, 61, 56, 51, 46, 41, 36 }, | ||
| 303 | { 66, 62, 57, 52, 47, 42, 37 }, | ||
| 304 | { 67, 63, 58, 53, 48, 43, 38 }, | ||
| 305 | { NO_LED, 64, 59, 54, 49, 44, 39 }, | ||
| 306 | { NO_LED, NO_LED, 60, 55, 50, 45, 40 }, | ||
| 307 | { NO_LED, NO_LED, NO_LED, 71, 70, 69, 68 }, | ||
| 308 | }, { | ||
| 309 | { 0, 0 }, { 0, 12 }, { 0, 25 }, { 0, 38 }, { 0, 51 }, | ||
| 310 | { 17, 0 }, { 17, 12 }, { 17, 25 }, { 17, 38 }, { 17, 51 }, | ||
| 311 | { 34, 0 }, { 34, 12 }, { 34, 25 }, { 34, 38 }, { 34, 51 }, | ||
| 312 | { 51, 0 }, { 51, 12 }, { 51, 25 }, { 51, 38 }, { 51, 51 }, | ||
| 313 | { 68, 0 }, { 68, 12 }, { 68, 25 }, { 68, 38 }, { 68, 51 }, | ||
| 314 | { 86, 0 }, { 86, 12 }, { 86, 25 }, { 86, 38 }, | ||
| 315 | { 105, 0 }, { 105, 12 }, { 105, 25 }, | ||
| 316 | { 90, 55 }, { 105, 68 }, { 116, 86 }, { 116, 59 }, | ||
| 317 | |||
| 318 | { 250, 0 }, { 250, 12 }, { 250, 25 }, { 250, 38 }, { 250, 51 }, | ||
| 319 | { 233, 0 }, { 233, 12 }, { 233, 25 }, { 233, 38 }, { 233, 51 }, | ||
| 320 | { 216, 0 }, { 216, 12 }, { 216, 25 }, { 216, 38 }, { 216, 51 }, | ||
| 321 | { 198, 0 }, { 198, 12 }, { 198, 25 }, { 198, 38 }, { 198, 51 }, | ||
| 322 | { 181, 0 }, { 181, 12 }, { 181, 25 }, { 181, 38 }, { 181, 51 }, | ||
| 323 | { 163, 0 }, { 163, 12 }, { 163, 25 }, { 163, 38 }, | ||
| 324 | { 146, 0 }, { 146, 12 }, { 146, 25 }, | ||
| 325 | { 161, 55 }, { 161, 68 }, { 146, 86 }, { 131, 59 } | ||
| 326 | |||
| 327 | }, { | ||
| 328 | 1, 1, 1, 1, 1, 4, | ||
| 329 | 4, 4, 4, 1, 4, 4, | ||
| 330 | 4, 4, 1, 4, 4, 4, | ||
| 331 | 4, 1, 4, 4, 4, 4, | ||
| 332 | 1, 4, 4, 4, 4, 4, | ||
| 333 | 4, 4, 1, 1, 1, 1, | ||
| 334 | 1, 1, 1, 1, 1, 4, | ||
| 335 | 4, 4, 4, 1, 4, 4, | ||
| 336 | 4, 4, 1, 4, 4, 4, | ||
| 337 | 4, 1, 4, 4, 4, 4, | ||
| 338 | 1, 4, 4, 4, 4, 4, | ||
| 339 | 4, 4, 1, 1, 1, 1 | ||
| 340 | } }; | ||
| 341 | // clang-format on | ||
| 342 | |||
| 343 | void suspend_power_down_kb(void) { | ||
| 344 | rgb_matrix_set_suspend_state(true); | ||
| 345 | suspend_power_down_user(); | ||
| 346 | } | ||
| 347 | |||
| 348 | void suspend_wakeup_init_kb(void) { | ||
| 349 | rgb_matrix_set_suspend_state(false); | ||
| 350 | suspend_wakeup_init_user(); | ||
| 351 | } | ||
| 352 | #endif | ||
| 353 | |||
| 354 | #ifdef AUDIO_ENABLE | ||
| 355 | bool music_mask_kb(uint16_t keycode) { | ||
| 356 | switch (keycode) { | ||
| 357 | case QK_LAYER_TAP ... QK_ONE_SHOT_LAYER_MAX: | ||
| 358 | case QK_LAYER_TAP_TOGGLE ... QK_LAYER_MOD_MAX: | ||
| 359 | case QK_MOD_TAP ... QK_MOD_TAP_MAX: | ||
| 360 | case AU_ON ... MUV_DE: | ||
| 361 | case RESET: | ||
| 362 | case EEP_RST: | ||
| 363 | return false; | ||
| 364 | default: | ||
| 365 | return music_mask_user(keycode); | ||
| 366 | } | ||
| 367 | } | ||
| 368 | #endif | ||
| 369 | |||
| 370 | #ifdef SWAP_HANDS_ENABLE | ||
| 371 | // swap-hands action needs a matrix to define the swap | ||
| 372 | // clang-format off | ||
| 373 | const keypos_t hand_swap_config[MATRIX_ROWS][MATRIX_COLS] = { | ||
| 374 | /* Left hand, matrix positions */ | ||
| 375 | {{6,6}, {5,6}, {4,6}, {3,6}, {2,6}, {1,6},{0,6}}, | ||
| 376 | {{6,7}, {5,7}, {4,7}, {3,7}, {2,7}, {1,7},{0,7}}, | ||
| 377 | {{6,8}, {5,8}, {4,8}, {3,8}, {2,8}, {1,8},{0,8}}, | ||
| 378 | {{6,9}, {5,9}, {4,9}, {3,9}, {2,9}, {1,9},{0,9}}, | ||
| 379 | {{6,10},{5,10},{4,10},{3,10},{2,10},{1,10},{0,10}}, | ||
| 380 | {{6,11},{5,11},{4,11},{3,11},{2,11},{1,11},{0,11}}, | ||
| 381 | /* Right hand, matrix positions */ | ||
| 382 | {{6,0}, {5,0}, {4,0}, {3,0}, {2,0}, {1,0},{0,0}}, | ||
| 383 | {{6,1}, {5,1}, {4,1}, {3,1}, {2,1}, {1,1},{0,1}}, | ||
| 384 | {{6,2}, {5,2}, {4,2}, {3,2}, {2,2}, {1,2},{0,2}}, | ||
| 385 | {{6,3}, {5,3}, {4,3}, {3,3}, {2,3}, {1,3},{0,3}}, | ||
| 386 | {{6,4}, {5,4}, {4,4}, {3,4}, {2,4}, {1,4},{0,4}}, | ||
| 387 | {{6,5}, {5,5}, {4,5}, {3,5}, {2,5}, {1,5},{0,5}}, | ||
| 388 | }; | ||
| 389 | // clang-format on | ||
| 390 | |||
| 391 | void keyboard_post_init_kb(void) { | ||
| 392 | rgb_matrix_enable_noeeprom(); | ||
| 393 | keyboard_post_init_user(); | ||
| 394 | } | ||
| 395 | #endif | ||
| 396 | |||
| 397 | #if defined(AUDIO_ENABLE) && defined(MUSIC_MAP) | ||
| 398 | // clang-format off | ||
| 399 | const uint8_t music_map[MATRIX_ROWS][MATRIX_COLS] = LAYOUT_moonlander( | ||
| 400 | 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, | ||
| 401 | 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, | ||
| 402 | 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, | ||
| 403 | 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, | ||
| 404 | 8, 9, 10, 11, 12, 3, 4, 13, 14, 15, 16, 17, | ||
| 405 | 0, 1, 2, 5, 6, 7 | ||
| 406 | ); | ||
| 407 | // clang-format on | ||
| 408 | #endif | ||
| 409 | |||
| 410 | #ifdef ORYX_CONFIGURATOR | ||
| 411 | bool process_record_kb(uint16_t keycode, keyrecord_t *record) { | ||
| 412 | switch (keycode) { | ||
| 413 | #ifdef WEBUSB_ENABLE | ||
| 414 | case WEBUSB_PAIR: | ||
| 415 | if (!record->event.pressed && !webusb_state.pairing) layer_state_set_kb(layer_state); | ||
| 416 | break; | ||
| 417 | #endif | ||
| 418 | #ifdef RGB_MATRIX_ENABLE | ||
| 419 | case TOGGLE_LAYER_COLOR: | ||
| 420 | if (record->event.pressed) { | ||
| 421 | keyboard_config.disable_layer_led ^= 1; | ||
| 422 | if (keyboard_config.disable_layer_led) rgb_matrix_set_color_all(0, 0, 0); | ||
| 423 | eeconfig_update_kb(keyboard_config.raw); | ||
| 424 | } | ||
| 425 | break; | ||
| 426 | case RGB_TOG: | ||
| 427 | if (record->event.pressed) { | ||
| 428 | switch (rgb_matrix_get_flags()) { | ||
| 429 | case LED_FLAG_ALL: { | ||
| 430 | rgb_matrix_set_flags(LED_FLAG_NONE); | ||
| 431 | keyboard_config.rgb_matrix_enable = false; | ||
| 432 | rgb_matrix_set_color_all(0, 0, 0); | ||
| 433 | } break; | ||
| 434 | default: { | ||
| 435 | rgb_matrix_set_flags(LED_FLAG_ALL); | ||
| 436 | keyboard_config.rgb_matrix_enable = true; | ||
| 437 | } break; | ||
| 438 | } | ||
| 439 | eeconfig_update_kb(keyboard_config.raw); | ||
| 440 | } | ||
| 441 | return false; | ||
| 442 | #endif | ||
| 443 | } | ||
| 444 | return process_record_user(keycode, record); | ||
| 445 | } | ||
| 446 | |||
| 447 | #endif | ||
| 448 | |||
| 449 | void matrix_init_kb(void) { | ||
| 450 | keyboard_config.raw = eeconfig_read_kb(); | ||
| 451 | |||
| 452 | #ifdef RGB_MATRIX_ENABLE | ||
| 453 | if (keyboard_config.rgb_matrix_enable) { | ||
| 454 | rgb_matrix_set_flags(LED_FLAG_ALL); | ||
| 455 | } else { | ||
| 456 | rgb_matrix_set_flags(LED_FLAG_NONE); | ||
| 457 | } | ||
| 458 | #endif | ||
| 459 | } | ||
| 460 | |||
| 461 | void eeconfig_init_kb(void) { // EEPROM is getting reset! | ||
| 462 | keyboard_config.raw = 0; | ||
| 463 | keyboard_config.rgb_matrix_enable = true; | ||
| 464 | eeconfig_update_kb(keyboard_config.raw); | ||
| 465 | eeconfig_init_user(); | ||
| 466 | } | ||
