1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
|
/*
Copyright 2021 OwLab
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "spring.h"
enum caps_modes{
CAPS_MODE_UPPER = 0, //UPPER CASE
CAPS_MODE_LOWER //LOWER CASE
};
uint8_t caps_mode_index;
rgblight_config_t pre_rgb;
uint8_t dir_hue, dir_sat;
bool caps_in = false;
uint32_t caps_timer;
void switch_caps_mode(uint8_t mode){
switch(mode){
case CAPS_MODE_UPPER:
dir_hue = 0;
dir_sat = 240;
break;
case CAPS_MODE_LOWER:
dir_hue = 88;
dir_sat = 255;
break;
default:
break;
}
rgblight_sethsv_noeeprom(dir_hue,dir_sat,pre_rgb.val);
}
void init_caps_mode(uint8_t mode){
pre_rgb.mode = rgblight_get_mode();
pre_rgb.hue = rgblight_get_hue();
pre_rgb.sat = rgblight_get_sat();
pre_rgb.val = rgblight_get_val();
caps_in = true;
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
switch_caps_mode(mode);
}
void set_caps_mode(uint8_t mode){
if(caps_in == false){
init_caps_mode(mode);
}else{
switch_caps_mode(mode);
}
caps_timer = timer_read32();
}
void matrix_scan_kb(void) {
if(caps_in){
if(timer_elapsed32(caps_timer) > 3000){
rgblight_sethsv(pre_rgb.hue, pre_rgb.sat, pre_rgb.val);
rgblight_mode(pre_rgb.mode);
caps_in = false;
}
}
matrix_scan_user();
}
bool process_record_kb(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch(keycode) {
case RGB_TOG:
case RGB_MOD:
case RGB_RMOD:
case RGB_HUI:
case RGB_HUD:
case RGB_SAI:
case RGB_SAD:
case RGB_VAI:
case RGB_VAD:
if(caps_in){
return false;
}
break;
case KC_CAPS:
if(IS_LED_ON(host_keyboard_leds(), USB_LED_CAPS_LOCK)){
caps_mode_index = CAPS_MODE_LOWER;
} else{
caps_mode_index = CAPS_MODE_UPPER;
}
set_caps_mode(caps_mode_index);
break;
default:
break;
}
}
return process_record_user(keycode, record);
}
|