rev1.c (3014B)
1 /* Copyright 2023 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 "quantum.h" 18 19 #ifdef RGB_MATRIX_ENABLE 20 bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 21 switch (keycode) { 22 case QK_RGB_MATRIX_TOGGLE: 23 if (record->event.pressed) { 24 switch (rgb_matrix_get_flags()) { 25 case LED_FLAG_ALL: { 26 rgb_matrix_set_flags(LED_FLAG_NONE); 27 rgb_matrix_set_color_all(0, 0, 0); 28 } 29 break; 30 default: { 31 rgb_matrix_set_flags(LED_FLAG_ALL); 32 rgb_matrix_enable_noeeprom(); 33 } 34 break; 35 } 36 } 37 return false; 38 case QK_RGB_MATRIX_MODE_NEXT: 39 if (record->event.pressed) { 40 switch (rgb_matrix_get_mode()) { 41 case RGB_MATRIX_SOLID_MULTISPLASH: 42 rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR); 43 return false; 44 default: 45 rgb_matrix_step(); 46 return false; 47 } 48 } 49 return false; 50 case QK_RGB_MATRIX_MODE_PREVIOUS: 51 if (record->event.pressed) { 52 switch (rgb_matrix_get_mode()) { 53 case RGB_MATRIX_SOLID_COLOR: 54 rgb_matrix_mode(RGB_MATRIX_SOLID_MULTISPLASH); 55 return false; 56 default: 57 rgb_matrix_step_reverse(); 58 return false; 59 } 60 } 61 return false; 62 } 63 64 return process_record_user(keycode, record); 65 } 66 67 bool rgb_matrix_indicators_kb(void) { 68 if (!rgb_matrix_indicators_user()) { 69 return false; 70 } 71 72 if (host_keyboard_led_state().caps_lock) { 73 rgb_matrix_set_color(30, 0, 75, 75); 74 } else if (!(rgb_matrix_get_flags() & LED_FLAG_INDICATOR)) { 75 rgb_matrix_set_color(30, RGB_OFF); 76 } 77 return true; 78 } 79 80 void keyboard_post_init_kb(void) { 81 if (!(rgb_matrix_get_flags() & LED_FLAG_ALL)) { 82 rgb_matrix_set_color_all(0, 0, 0); 83 } else { 84 rgb_matrix_mode_noeeprom(RGB_MATRIX_CUSTOM_STARTUP_SWIRL_ANIM); 85 } 86 87 keyboard_post_init_user(); 88 } 89 #endif