diff options
Diffstat (limited to 'qmk/keyboards/sofle_choc/keymaps/custom/lighting.c')
| -rw-r--r-- | qmk/keyboards/sofle_choc/keymaps/custom/lighting.c | 53 |
1 files changed, 39 insertions, 14 deletions
diff --git a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c index 827e359..df3b5ec 100644 --- a/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c +++ b/qmk/keyboards/sofle_choc/keymaps/custom/lighting.c @@ -33,6 +33,20 @@ void oneshot_mods_changed_lighting(uint8_t mods) { one_shot_alt_flag = mods & MOD_MASK_ALT; } +uint8_t get_flags(void) { + uint8_t flags = 0; + if (get_mods() & MOD_MASK_CTRL) { + flags |= 0b001; + } + if (one_shot_alt_flag || (get_mods() & MOD_MASK_ALT)) { + flags |= 0b010; + } + if ((get_mods() & MOD_MASK_SHIFT) || host_keyboard_led_state().caps_lock) { + flags |= 0b100; + } + return flags; +} + void housekeeping_task_lighting(void) { // Colors for the mods @@ -47,16 +61,7 @@ void housekeeping_task_lighting(void) { hsv_of_color(HSV_WHITE), // 111 }; - uint8_t flags = 0; - if (get_mods() & MOD_MASK_CTRL) { - flags |= 0b001; - } - if (one_shot_alt_flag || (get_mods() & MOD_MASK_ALT)) { - flags |= 0b010; - } - if ((get_mods() & MOD_MASK_SHIFT) || host_keyboard_led_state().caps_lock) { - flags |= 0b100; - } + uint8_t flags = get_flags(); uint8_t matrix_mode = rgb_matrix_get_mode(); if (matrix_mode != RGB_MATRIX_BREATHING && host_keyboard_led_state().caps_lock) { @@ -82,6 +87,16 @@ void housekeeping_task_lighting(void) { bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { // Activate effects depending of mods + // Check once if we need to activate the LED. This can be cause either a + // layer, or a modifier. If the state is default, exit the function early. + uint8_t flags = get_mods(); + 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)) { + return false; + } + for (uint8_t row = 0; row < MATRIX_ROWS; ++row) { for (uint8_t col = 0; col < MATRIX_COLS; ++col) { uint8_t index = g_led_config.matrix_co[row][col]; @@ -96,19 +111,20 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { set_color(index, 42, 255, 255); } - if (layer == 0) - continue; + //if (layer == 0 && ! flags) + // continue; switch (keycode) { case KC_F1 ... KC_F11: set_color(index, 0, 0, 128); break; case KC_P1 ... KC_P0: + case KC_1 ... KC_0: case KEY_6: set_color(index, 42, 255, 255); break; - case BP_CCED: - case BP_PERC: + case KC_BACKSLASH: + case KC_EQUAL: case KC_PDOT: case KC_KP_SLASH ... KC_KP_PLUS: // Add a bit of red for the punction symbol @@ -124,11 +140,20 @@ bool rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) { break; case KC_HOME: case KC_END: + case KC_TAB: set_color(index, HSV_GREEN); break; + case KC_LSFT: + case KEY_LOK: + set_color(index, HSV_CYAN); + break; case KC_BSPC: + case KC_DELETE: + set_color(index, HSV_PURPLE); + break; case AL_SPC: case AL_ENT: + case TD_ENTR: set_color(index, HSV_BLUE); break; case QK_RGB_MATRIX_VALUE_UP: |
