2019-07-08 06:27:30 -07:00
|
|
|
#include "mattly.h"
|
|
|
|
|
|
|
|
__attribute__ ((weak))
|
|
|
|
layer_state_t layer_state_set_keymap (layer_state_t state) {
|
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2020-07-21 17:08:56 -07:00
|
|
|
static uint16_t current_state = 0;
|
|
|
|
|
2019-07-08 06:27:30 -07:00
|
|
|
void set_lights_default(void) {
|
|
|
|
#ifdef RGBLIGHT_ENABLE
|
2023-02-05 18:36:09 -08:00
|
|
|
if (host_keyboard_led_state().caps_lock) {
|
2019-07-08 06:27:30 -07:00
|
|
|
rgblight_sethsv_noeeprom(HSV_CAPS);
|
|
|
|
} else {
|
2020-07-21 17:08:56 -07:00
|
|
|
if (current_state == _BASE_MAC) {
|
|
|
|
rgblight_sethsv_noeeprom(HSV_MAC);
|
|
|
|
} else if (current_state == _OVER_WIN) {
|
|
|
|
rgblight_sethsv_noeeprom(HSV_WIN);
|
|
|
|
}
|
2019-07-08 06:27:30 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void layer_state_set_rgb(layer_state_t state) {
|
|
|
|
#ifdef RGBLIGHT_ENABLE
|
2020-07-21 17:08:56 -07:00
|
|
|
switch (get_highest_layer(state)) {
|
2019-07-08 06:27:30 -07:00
|
|
|
case _SYMBOL:
|
|
|
|
rgblight_sethsv_noeeprom(HSV_SYMBOL);
|
|
|
|
break;
|
|
|
|
case _NAVNUM:
|
2020-07-21 17:08:56 -07:00
|
|
|
case _NAVNUM_WIN:
|
2019-07-08 06:27:30 -07:00
|
|
|
rgblight_sethsv_noeeprom(HSV_NAVNUM);
|
|
|
|
break;
|
2023-07-05 23:03:45 -07:00
|
|
|
case _GAME:
|
|
|
|
rgblight_sethsv_noeeprom(HSV_GAME);
|
|
|
|
break;
|
2019-07-08 06:27:30 -07:00
|
|
|
case _FUNCT:
|
2020-07-21 17:08:56 -07:00
|
|
|
case _FUNCT_WIN:
|
2019-07-08 06:27:30 -07:00
|
|
|
rgblight_sethsv_noeeprom(HSV_FUNCT);
|
|
|
|
break;
|
2020-07-21 17:08:56 -07:00
|
|
|
default:
|
|
|
|
set_lights_default();
|
2019-07-08 06:27:30 -07:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
layer_state_t layer_state_set_user (layer_state_t state) {
|
|
|
|
state = update_tri_layer_state(state, _SYMBOL, _NAVNUM, _FUNCT);
|
2020-07-21 17:08:56 -07:00
|
|
|
state = update_tri_layer_state(state, _OVER_WIN, _NAVNUM, _NAVNUM_WIN);
|
|
|
|
state = update_tri_layer_state(state, _OVER_WIN, _FUNCT, _FUNCT_WIN);
|
|
|
|
current_state = get_highest_layer(state);
|
2019-07-08 06:27:30 -07:00
|
|
|
layer_state_set_rgb(state);
|
|
|
|
return layer_state_set_keymap (state);
|
|
|
|
}
|
|
|
|
|
|
|
|
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
|
|
|
|
switch (keycode) {
|
|
|
|
case KC_CAPS:
|
|
|
|
#ifdef RGBLIGHT_ENABLE
|
|
|
|
set_lights_default();
|
|
|
|
#endif
|
|
|
|
return true;
|
2022-11-15 08:52:01 -08:00
|
|
|
case QK_BOOT:
|
2020-07-21 17:08:56 -07:00
|
|
|
#ifdef RGBLIGHT_ENABLE
|
|
|
|
rgblight_sethsv_noeeprom(HSV_RESET);
|
|
|
|
#endif
|
2019-07-08 06:27:30 -07:00
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void keyboard_post_init_user(void) {
|
|
|
|
#ifdef RGBLIGHT_ENABLE
|
|
|
|
rgblight_enable_noeeprom();
|
|
|
|
set_lights_default();
|
|
|
|
#endif
|
|
|
|
}
|