aboutsummaryrefslogtreecommitdiffstats
path: root/keyboards/mechanicalkeyboards/point65/hotswap/hotswap.c
blob: 1da89f6f2dc71da8212c770c671040ab3a218901 (plain)
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
/* Copyright 2024 Sebastiaan Swinkels @ BeanBoards <sebastiaan.swinkels@googlemail.com>
 *
 * 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 "quantum.h"

 enum point65_layers {
    _QWERTY,
    _FUNCTION
};

bool rgb_matrix_indicators_kb(void) {
    if (!rgb_matrix_indicators_user()){
        return false;
    }
    
    hsv_t hsv = {0, 255, 255};

    // Light up ESC RGB LED when _FUNCTION layer is accessed
    if ((get_highest_layer(layer_state|default_layer_state)) == _FUNCTION){
        hsv.h = 43;
        hsv.s = 105;
        hsv.v = 255;

        if (hsv.v > rgb_matrix_get_val() + RGB_INDICATOR_POS_OFFSET) {
            hsv.v = rgb_matrix_get_val() + RGB_INDICATOR_POS_OFFSET;
        }
        rgb_t rgb = hsv_to_rgb(hsv);

        rgb_matrix_set_color(0, rgb.r, rgb.g, rgb.b);
    }
    // end layer function

    // capslock indicator
    if (host_keyboard_led_state().caps_lock) {
        hsv.h = 43;
        hsv.s = 105;
        hsv.v = 255;

        if (hsv.v > rgb_matrix_get_val() + RGB_INDICATOR_POS_OFFSET) {
                hsv.v = rgb_matrix_get_val() + RGB_INDICATOR_POS_OFFSET;
        }
        rgb_t rgb = hsv_to_rgb(hsv);

        rgb_matrix_set_color(1, rgb.r, rgb.g, rgb.b);
    }
    // end capslock function

    return false;
}