diff options
Diffstat (limited to 'keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c')
-rw-r--r-- | keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c | 85 |
1 files changed, 50 insertions, 35 deletions
diff --git a/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c b/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c index c5c8c09636..00c6e59bc7 100644 --- a/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c +++ b/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c @@ -24,51 +24,66 @@ bool process_record_keymap(uint16_t keycode, keyrecord_t *record) { unregister_code(KC_RCTRL); layer_off(L_RCTRL); } - return false; - - default: - return true; + break; } + + return true; +} + +static inline void fn_light() { + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); + rgblight_sethsv_noeeprom(modern_dolch_red.h, modern_dolch_red.s, rgblight_get_val()); +} + +static inline void caps_light() { + rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT); + rgblight_sethsv_noeeprom(modern_dolch_cyan.h, modern_dolch_cyan.s, rgblight_get_val()); } -static bool skip_caps = false; +static inline void restore_light() { + rgblight_config_t saved = { .raw = eeconfig_read_rgblight() }; + rgblight_sethsv_noeeprom(saved.hue, saved.sat, saved.val); + rgblight_mode_noeeprom(saved.mode); +} -static void fn_light(uint32_t state) { +static void check_light_layer(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; + fn_light(); + } else if (IS_HOST_LED_ON(USB_LED_CAPS_LOCK)) { + caps_light(); } else { - rgblight_config_t saved = { .raw = eeconfig_read_rgblight() }; - rgblight_sethsv_noeeprom(saved.hue, saved.sat, saved.val); - rgblight_mode_noeeprom(saved.mode); + restore_light(); } - // 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 - } +static void check_light_led(uint8_t usb_led) { 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()); + caps_light(); + } else if (IS_LAYER_ON(L_FN)) { + fn_light(); } else { - fn_light(layer_state); // Caps is off, check if Fn light should be on + restore_light(); } } +static bool skip_led = false; + 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 + check_light_layer(state); // Fn state changed since last time + skip_led = IS_LAYER_ON_STATE(state, L_FN); + // led_set_keymap will be called automatically after this } return prev_state = state; } void led_set_keymap(uint8_t usb_led) { - caps_light(usb_led); + if (skip_led) { + skip_led = false; + return; // Skip calls triggered by the Fn layer turning on + } + check_light_led(usb_led); } const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { @@ -80,7 +95,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ * │LCtCps│ A │ S │ D │ F │ G │ H │ J │ K │ L │ ; │ ' │ Enter │ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┤ - * │LShiftFn│ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │RShift│FnL│ + * │LShiftFn│ Z │ X │ C │ V │ B │ N │ M │ , │ . │ / │RShift│FnF│ * └─────┬──┴┬──┴──┬┴───┴───┴───┴───┴───┴───┴──┬┴───┴┬───┬─┴───┘ * │LGu│LAlt │ Space │RAlGu│RCt│ * └───┴─────┴───────────────────────────┴─────┴───┘ @@ -90,28 +105,28 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, KC_Q, KC_W, KC_E, KC_R, KC_T, KC_Y, KC_U, KC_I, KC_O, KC_P, KC_LBRC, KC_RBRC, KC_BSPC, LCT_CPS, KC_A, KC_S, KC_D, KC_F, KC_G, KC_H, KC_J, KC_K, KC_L, KC_SCLN, KC_QUOT, KC_ENT, LSFT_FN, KC_Z, KC_X, KC_C, KC_V, KC_B, KC_N, KC_M, KC_COMM, KC_DOT, KC_SLSH, KC_RSFT, FN_FNLK, - XXXXXXX, KC_LGUI, KC_LALT, KC_SPC, RAL_RGU, RCTRL, XXXXXXX + XXXXXXX, KC_LGUI, KC_LALT, KC_SPC, RAL_RGU, RCTRL, XXXXXXX ), /* Function layer * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐ * │ │F1 │F2 │F3 │F4 │F5 │F6 │F7 │F8 │F9 │F10│F11│F12│PSc│Ins│ * ├───┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴───┤ - * │ │Hom│ ↑ │End│PgU│ │ │ │ │M3 │M1 │M↑ │M2 │ Del │ + * │ │Hom│ ↑ │End│PgU│ │ │ │ │M1 │M↑ │М2 │M3 │ Del │ * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ - * │ │ ← │ ↓ │ → │PgD│ │ │ │ │MW↑│M← │M→ │ │ + * │ │ ← │ ↓ │ → │PgD│ │ │ │ │M← │M↓ │M→ │ │ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┤ - * │ │Mut│Vo-│Vo+│Ply│Prv│Nxt│App│MW←│MW→│M↓ │ │ │ + * │ │Mut│Vo-│Vo+│Ply│Prv│Nxt│App│MW↑│M4 │М5 │ │ │ * └─────┬──┴┬──┴──┬┴───┴───┴───┴───┴───┴───┴──┬┴───┴┬───┬─┴───┘ * │ │ │ MW↓ │MAcl2│ │ * └───┴─────┴───────────────────────────┴─────┴───┘ */ [L_FN] = LAYOUT( _______, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_PSCR, KC_INS, - _______, KC_HOME, KC_UP, KC_END, KC_PGUP, _______, _______, _______, _______, KC_BTN3, KC_BTN1, KC_MS_U, KC_BTN2, KC_DEL, - _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, _______, _______, _______, _______, KC_WH_U, KC_MS_L, KC_MS_R, _______, - _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY, KC_MPRV, KC_MNXT, KC_APP, KC_WH_L, KC_WH_R, KC_MS_D, _______, _______, - XXXXXXX, _______, _______, KC_WH_D, KC_ACL2, _______, XXXXXXX + _______, KC_HOME, KC_UP, KC_END, KC_PGUP, _______, _______, _______, _______, KC_BTN1, KC_MS_U, KC_BTN2, KC_BTN3, KC_DEL, + _______, KC_LEFT, KC_DOWN, KC_RGHT, KC_PGDN, _______, _______, _______, _______, KC_MS_L, KC_MS_D, KC_MS_R, _______, + _______, KC_MUTE, KC_VOLD, KC_VOLU, KC_MPLY, KC_MPRV, KC_MNXT, KC_APP, KC_WH_U, KC_BTN4, KC_BTN5, _______, _______, + XXXXXXX, _______, _______, KC_WH_D, KC_ACL2, _______, XXXXXXX ), /* RCtrl layer @@ -122,7 +137,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { * ├─────┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴┬──┴─────┤ * │ │Mv←│Mv↓│Mv→│TNx│ │ │ │ │ │ │ │ │ * ├──────┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴─┬─┴────┬───┤ - * │ │RTg│RV-│RV+│RMd│ │ │ │M4 │M5 │ │ │ │ + * │ │RTg│RV-│RV+│RMd│ │ │ │ │ │ │ │ │ * └─────┬──┴┬──┴──┬┴───┴───┴───┴───┴───┴───┴──┬┴───┴┬───┬─┴───┘ * │DPR│DstNA│ │ │ │ * └───┴─────┴───────────────────────────┴─────┴───┘ @@ -131,7 +146,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, CLEAR, _______, TOP, MV_UP, BOTTOM, TAB_PRV, _______, _______, _______, _______, _______, _______, _______, _______, DEL_NXT, _______, MV_LEFT, MV_DOWN, MV_RGHT, TAB_NXT, _______, _______, _______, _______, _______, _______, _______, _______, - _______, RGB_TOG, RGB_VAD, RGB_VAI, RGB_MOD, _______, _______, _______, KC_BTN4, KC_BTN5, _______, _______, _______, - XXXXXXX, DST_P_R, DST_N_A, _______, _______, _______, XXXXXXX + _______, RGB_TOG, RGB_VAD, RGB_VAI, RGB_MOD, _______, _______, _______, _______, _______, _______, _______, _______, + XXXXXXX, DST_P_R, DST_N_A, _______, _______, _______, XXXXXXX ), }; |