diff options
Diffstat (limited to 'users/greatwizard/underglow.c')
-rw-r--r-- | users/greatwizard/underglow.c | 109 |
1 files changed, 109 insertions, 0 deletions
diff --git a/users/greatwizard/underglow.c b/users/greatwizard/underglow.c new file mode 100644 index 000000000..db31290ac --- /dev/null +++ b/users/greatwizard/underglow.c | |||
@@ -0,0 +1,109 @@ | |||
1 | /* Copyright 2020 Guillaume Gérard | ||
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 | #include "underglow.h" | ||
17 | |||
18 | void keyboard_post_init_rgb(void) { | ||
19 | user_config_t user_config; | ||
20 | user_config.raw = eeconfig_read_user(); | ||
21 | if (!user_config.rgb_layer_change) { | ||
22 | return; | ||
23 | } | ||
24 | rgblight_enable_noeeprom(); | ||
25 | rgblight_sethsv_noeeprom_orange(); | ||
26 | rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); | ||
27 | } | ||
28 | |||
29 | bool process_record_rgb(uint16_t keycode, keyrecord_t *record) { | ||
30 | switch (keycode) { | ||
31 | case RGB_LAYER: | ||
32 | if (record->event.pressed) { | ||
33 | user_config_t user_config; | ||
34 | user_config.raw = eeconfig_read_user(); | ||
35 | user_config.rgb_layer_change ^= 1; | ||
36 | eeconfig_update_user(user_config.raw); | ||
37 | if (user_config.rgb_layer_change) { | ||
38 | layer_state_set(layer_state); | ||
39 | } | ||
40 | } | ||
41 | return false; | ||
42 | case RGB_MODE_FORWARD ... RGB_MODE_RGBTEST: | ||
43 | if (record->event.pressed) { | ||
44 | user_config_t user_config; | ||
45 | user_config.raw = eeconfig_read_user(); | ||
46 | if (user_config.rgb_layer_change) { | ||
47 | user_config.rgb_layer_change = false; | ||
48 | eeconfig_update_user(user_config.raw); | ||
49 | } | ||
50 | } | ||
51 | return true; | ||
52 | } | ||
53 | return true; | ||
54 | } | ||
55 | |||
56 | layer_state_t layer_state_set_rgb(layer_state_t state) { | ||
57 | user_config_t user_config; | ||
58 | user_config.raw = eeconfig_read_user(); | ||
59 | if (!user_config.rgb_layer_change) { | ||
60 | return state; | ||
61 | } | ||
62 | switch (get_highest_layer(state)) { | ||
63 | case _QWERTY: | ||
64 | #ifdef LAYERS_PROGRAMMER | ||
65 | case _PROGRAMMER_SHIFTED: | ||
66 | #endif | ||
67 | rgblight_sethsv_noeeprom_orange(); | ||
68 | break; | ||
69 | #ifdef LAYERS_ORTHO | ||
70 | case _LOWER: | ||
71 | rgblight_sethsv_noeeprom_red(); | ||
72 | break; | ||
73 | case _RAISE: | ||
74 | rgblight_sethsv_noeeprom_blue(); | ||
75 | break; | ||
76 | case _ADJUST: | ||
77 | rgblight_sethsv_noeeprom_purple(); | ||
78 | break; | ||
79 | #endif | ||
80 | #ifdef LAYER_FN | ||
81 | case _FN: | ||
82 | rgblight_sethsv_noeeprom_chartreuse(); | ||
83 | break; | ||
84 | #endif | ||
85 | #ifdef LAYER_GIT | ||
86 | case _GIT: | ||
87 | rgblight_sethsv_noeeprom_teal(); | ||
88 | break; | ||
89 | #endif | ||
90 | default: | ||
91 | rgblight_sethsv_noeeprom_white(); | ||
92 | break; | ||
93 | } | ||
94 | return state; | ||
95 | } | ||
96 | |||
97 | bool led_update_rgb(led_t led_state) { | ||
98 | user_config_t user_config; | ||
99 | user_config.raw = eeconfig_read_user(); | ||
100 | if (!user_config.rgb_layer_change) { | ||
101 | return true; | ||
102 | } | ||
103 | if (led_state.caps_lock) { | ||
104 | rgblight_mode_noeeprom(RGBLIGHT_MODE_BREATHING + 3); | ||
105 | } else { | ||
106 | rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); | ||
107 | } | ||
108 | return true; | ||
109 | } | ||