pila87.c (2115B)
1 /* Copyright 2023 Phage Studio 2 * Copyright 2023 HorrorTroll <https://github.com/HorrorTroll> 3 * 4 * This program is free software: you can redistribute it and/or modify 5 * it under the terms of the GNU General Public License as published by 6 * the Free Software Foundation, either version 2 of the License, or 7 * (at your option) any later version. 8 * 9 * This program is distributed in the hope that it will be useful, 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 * GNU General Public License for more details. 13 * 14 * You should have received a copy of the GNU General Public License 15 * along with this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include "quantum.h" 19 20 #ifdef RGB_MATRIX_ENABLE 21 22 #include <string.h> 23 #include <math.h> 24 #include <lib/lib8tion/lib8tion.h> 25 26 bool process_record_kb(uint16_t keycode, keyrecord_t *record) { 27 switch (keycode) { 28 case QK_RGB_MATRIX_TOGGLE: 29 if (record->event.pressed) { 30 switch (rgb_matrix_get_flags()) { 31 case LED_FLAG_ALL: { 32 rgb_matrix_set_flags(LED_FLAG_NONE); 33 rgb_matrix_set_color_all(0, 0, 0); 34 } 35 break; 36 default: { 37 rgb_matrix_set_flags(LED_FLAG_ALL); 38 rgb_matrix_enable_noeeprom(); 39 } 40 break; 41 } 42 } 43 return false; 44 } 45 return process_record_user(keycode, record); 46 } 47 48 bool rgb_matrix_indicators_kb(void) { 49 if (!rgb_matrix_indicators_user()) { 50 return false; 51 } 52 53 hsv_t hsv = rgb_matrix_config.hsv; 54 uint8_t time = scale16by8(g_rgb_timer, qadd8(32, 1)); 55 hsv.h = time; 56 rgb_t rgb = hsv_to_rgb(hsv); 57 58 if (host_keyboard_led_state().caps_lock) { 59 rgb_matrix_set_color(40, rgb.r, rgb.g, rgb.b); 60 } else if (!(rgb_matrix_get_flags() & LED_FLAG_INDICATOR)) { 61 rgb_matrix_set_color(40, 0, 0, 0); 62 } 63 return true; 64 } 65 #endif