diff options
Diffstat (limited to 'keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c')
-rw-r--r-- | keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c | 42 |
1 files changed, 41 insertions, 1 deletions
diff --git a/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c b/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c index b348b0b7bf..c5c8c09636 100644 --- a/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c +++ b/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c @@ -10,7 +10,7 @@ enum layers_keymap { }; void eeconfig_init_keymap(void) { - rgblight_sethsv(MODERN_DOLCH_RED.h, MODERN_DOLCH_RED.s, MODERN_DOLCH_RED.v); + rgblight_sethsv(MODERN_DOLCH_RED); rgblight_mode(RGBLIGHT_MODE_RAINBOW_SWIRL); } @@ -31,6 +31,46 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { } } +static bool skip_caps = false; + +static void fn_light(uint32_t state) { + if (IS_LAYER_ON_STATE(state, L_FN)) { + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); + rgblight_sethsv_noeeprom(modern_dolch_red.h, modern_dolch_red.s, rgblight_get_val()); + skip_caps = true; + } else { + rgblight_config_t saved = { .raw = eeconfig_read_rgblight() }; + rgblight_sethsv_noeeprom(saved.hue, saved.sat, saved.val); + rgblight_mode_noeeprom(saved.mode); + } + // caps_light will be called automatically after this +} + +static void caps_light(uint8_t usb_led) { + if (skip_caps) { + skip_caps = false; + return; // Skip calls triggered by the Fn layer turning on + } + if (IS_LED_ON(usb_led, USB_LED_CAPS_LOCK)) { + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); + rgblight_sethsv_noeeprom(modern_dolch_cyan.h, modern_dolch_cyan.s, rgblight_get_val()); + } else { + fn_light(layer_state); // Caps is off, check if Fn light should be on + } +} + +uint32_t layer_state_set_keymap(uint32_t state) { + static uint32_t prev_state = L_BASE; + if (IS_LAYER_ON_STATE(state, L_FN) != IS_LAYER_ON_STATE(prev_state, L_FN)) { + fn_light(state); // Fn state changed since last time + } + return prev_state = state; +} + +void led_set_keymap(uint8_t usb_led) { + caps_light(usb_led); +} + const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { /* Base layer * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐ |