diff options
| author | Sébastien Dailly <sebastien@dailly.me> | 2026-11-27 09:21:15 +0100 |
|---|---|---|
| committer | Sébastien Dailly <sebastien@dailly.me> | 2026-11-27 09:21:15 +0100 |
| commit | 93ed6753590d1b996beb95b35980cb613f4447e5 (patch) | |
| tree | 2f2d5bb2241c77353606868f1a874a9fdc3526ef /qmk/keyboards/sofle_choc/keymaps/custom/lighting.c | |
| parent | 60b834c340cc6d5508eec31c2368bf5cf01e72a0 (diff) | |
Removed old code
Diffstat (limited to 'qmk/keyboards/sofle_choc/keymaps/custom/lighting.c')
| -rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/lighting.c | 44 |
1 files changed, 30 insertions, 14 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c index f4a58d7..df729cc 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c @@ -27,26 +27,33 @@ void lighting_init(void) { static uint8_t last_flags; -static bool one_shot_alt_flag = 0; - -void oneshot_mods_changed_lighting(uint8_t mods) { - one_shot_alt_flag = mods & MOD_MASK_ALT; -} - -uint8_t get_flags(void) { +static uint8_t one_shot_flags = 0; + +// Build a bit set depending of the active mods. +// The bit set is intended to match colors (see below) +// +// There is a special case for the caps_lock state, because the function can +// be called either from the active mods on the keyboard, or from the active +// oneshot mods and I do not want to report the capslock in the evaluation of +// the oneshot flags. +uint8_t get_flags(uint8_t mods, bool with_caps) { uint8_t flags = 0; - if (get_mods() & MOD_MASK_CTRL) { + if (mods & MOD_MASK_CTRL) { flags |= 0b001; } - if (one_shot_alt_flag || (get_mods() & MOD_MASK_ALT)) { + if (mods & MOD_MASK_ALT) { flags |= 0b010; } - if ((get_mods() & MOD_MASK_SHIFT) || host_keyboard_led_state().caps_lock) { + if ((mods & MOD_MASK_SHIFT) || (with_caps && host_keyboard_led_state().caps_lock)) { flags |= 0b100; } return flags; } +void oneshot_mods_changed_lighting(uint8_t mods) { + one_shot_flags = get_flags(mods, false); +} + void housekeeping_task_lighting(void) { // Colors for the mods @@ -61,10 +68,11 @@ void housekeeping_task_lighting(void) { hsv_of_color(HSV_WHITE), // 111 }; - uint8_t flags = get_flags(); + uint8_t flags = get_flags(get_mods(), true) | one_shot_flags; uint8_t matrix_mode = rgb_matrix_get_mode(); - if (matrix_mode != RGB_MATRIX_BREATHING && host_keyboard_led_state().caps_lock) { + if (matrix_mode != RGB_MATRIX_BREATHING && \ + (host_keyboard_led_state().caps_lock || one_shot_flags)) { rgb_matrix_mode_noeeprom(RGB_MATRIX_BREATHING); } @@ -93,7 +101,11 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { uint8_t current_layer = get_highest_layer(layer_state); // The value `layer_state` is global - if (! (flags || current_layer || is_star || one_shot_alt_flag)) { + if (! (flags + || current_layer + || is_star + || one_shot_flags + || host_keyboard_led_state().caps_lock)) { return false; } @@ -140,6 +152,7 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { case KC_HOME: case KC_END: case KC_TAB: + case KEY_INS: set_color(index, HSV_GREEN); break; case KC_LSFT: @@ -159,7 +172,10 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { case QK_RGB_MATRIX_VALUE_DOWN: set_color(index, HSV_SPRINGGREEN); break; - + case OS_LCTL: + case OS_RCTL: + set_color(index, 55, 255, 255); + break; } } } |
