From 36d3902504d6aa0d2bdac88c90339c902ade11b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Konstantin=20=C4=90or=C4=91evi=C4=87?= Date: Thu, 25 Jul 2019 21:31:40 +0200 Subject: [PATCH] [User] Update personal userspace and keymaps, add reactive underglow (#6410) * Update MODERN_DOLCH_RED color * Remove unused RAL_LAL tap dance * Disable Space Cadet on all boards * Rework SEND_STRING_CLEAN into CLEAN_MODS, fix DST_P_R/DST_N_A * Disable unnecessary underglow animations * Rearrange feature flags in rules.mk files * Change custom colors from structs to defines * Add some explicit initializers * Add MODERN_DOLCH_CYAN color * Add IS_LAYER_ON_STATE()/IS_LAYER_OFF_STATE() macros * Add led_set_keymap() template function * Change underglow color based on Caps/Fn state * Preserve val when changing underglow colors * Only trigger Fn light for Fn layer * Refactor fn_light() and caps_light() slightly * Add comments to fn_light() and caps_light() --- .../kbdfans/kbd6x/keymaps/konstantin/config.h | 1 - .../kbdfans/kbd6x/keymaps/konstantin/keymap.c | 42 ++++++++++++++- .../kbdfans/kbd6x/keymaps/konstantin/rules.mk | 22 ++++---- .../melody96/keymaps/konstantin/keymap.c | 2 +- .../melody96/keymaps/konstantin/rules.mk | 21 ++++---- keyboards/wasdat/keymaps/konstantin/rules.mk | 18 ++++--- .../whitefox/keymaps/konstantin/rules.mk | 22 ++++---- users/konstantin/config.h | 6 +++ users/konstantin/konstantin.c | 52 ++++++++++++------- users/konstantin/konstantin.h | 22 ++++---- users/konstantin/rgb.c | 7 +-- users/konstantin/rgb.h | 12 +++-- users/konstantin/tap_dance.c | 2 +- users/konstantin/tap_dance.h | 4 +- 14 files changed, 151 insertions(+), 82 deletions(-) diff --git a/keyboards/kbdfans/kbd6x/keymaps/konstantin/config.h b/keyboards/kbdfans/kbd6x/keymaps/konstantin/config.h index 16387fa2f..4b511eb84 100644 --- a/keyboards/kbdfans/kbd6x/keymaps/konstantin/config.h +++ b/keyboards/kbdfans/kbd6x/keymaps/konstantin/config.h @@ -1,4 +1,3 @@ #pragma once #define LAYER_FN -#define SEND_STRING_CLEAN diff --git a/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c b/keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c index b348b0b7b..c5c8c0963 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 * ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐ diff --git a/keyboards/kbdfans/kbd6x/keymaps/konstantin/rules.mk b/keyboards/kbdfans/kbd6x/keymaps/konstantin/rules.mk index f7cf0758b..7262c6db6 100644 --- a/keyboards/kbdfans/kbd6x/keymaps/konstantin/rules.mk +++ b/keyboards/kbdfans/kbd6x/keymaps/konstantin/rules.mk @@ -1,11 +1,11 @@ -BOOTMAGIC_ENABLE = no -COMMAND_ENABLE = yes -CONSOLE_ENABLE = no -EXTRAKEY_ENABLE = yes -MOUSEKEY_ENABLE = yes -NKRO_ENABLE = yes -TAP_DANCE_ENABLE = yes -UNICODEMAP_ENABLE = no - -BACKLIGHT_ENABLE = yes -RGBLIGHT_ENABLE = yes +BACKLIGHT_ENABLE = no +BOOTMAGIC_ENABLE = no +COMMAND_ENABLE = yes +CONSOLE_ENABLE = yes +EXTRAKEY_ENABLE = yes +MOUSEKEY_ENABLE = yes +NKRO_ENABLE = yes +RGBLIGHT_ENABLE = yes +SPACE_CADET_ENABLE = no +TAP_DANCE_ENABLE = yes +UNICODEMAP_ENABLE = no diff --git a/keyboards/melody96/keymaps/konstantin/keymap.c b/keyboards/melody96/keymaps/konstantin/keymap.c index c2b043104..e02ba0f85 100644 --- a/keyboards/melody96/keymaps/konstantin/keymap.c +++ b/keyboards/melody96/keymaps/konstantin/keymap.c @@ -1,7 +1,7 @@ #include QMK_KEYBOARD_H #include "konstantin.h" -static const HSV *colors[] = { &GODSPEED_BLUE, &GODSPEED_YELLOW }; +static const HSV *colors[] = { &godspeed_blue, &godspeed_yellow }; static const size_t cnum = sizeof colors / sizeof *colors; static size_t cidx = 0; diff --git a/keyboards/melody96/keymaps/konstantin/rules.mk b/keyboards/melody96/keymaps/konstantin/rules.mk index 47a859d08..995402cb0 100644 --- a/keyboards/melody96/keymaps/konstantin/rules.mk +++ b/keyboards/melody96/keymaps/konstantin/rules.mk @@ -1,10 +1,11 @@ -BOOTMAGIC_ENABLE = no -COMMAND_ENABLE = yes -CONSOLE_ENABLE = no -EXTRAKEY_ENABLE = yes -MOUSEKEY_ENABLE = yes -NKRO_ENABLE = yes -TAP_DANCE_ENABLE = yes -UNICODEMAP_ENABLE = yes - -BACKLIGHT_ENABLE = no +BACKLIGHT_ENABLE = no +BOOTMAGIC_ENABLE = no +COMMAND_ENABLE = yes +CONSOLE_ENABLE = no +EXTRAKEY_ENABLE = yes +MOUSEKEY_ENABLE = yes +NKRO_ENABLE = yes +RGBLIGHT_ENABLE = yes +SPACE_CADET_ENABLE = no +TAP_DANCE_ENABLE = yes +UNICODEMAP_ENABLE = yes diff --git a/keyboards/wasdat/keymaps/konstantin/rules.mk b/keyboards/wasdat/keymaps/konstantin/rules.mk index 4bb1ee658..041d32114 100644 --- a/keyboards/wasdat/keymaps/konstantin/rules.mk +++ b/keyboards/wasdat/keymaps/konstantin/rules.mk @@ -1,8 +1,10 @@ -BOOTMAGIC_ENABLE = no -COMMAND_ENABLE = yes -CONSOLE_ENABLE = yes -EXTRAKEY_ENABLE = yes -MOUSEKEY_ENABLE = yes -NKRO_ENABLE = yes -TAP_DANCE_ENABLE = yes -UNICODEMAP_ENABLE = yes +BACKLIGHT_ENABLE = no +BOOTMAGIC_ENABLE = no +COMMAND_ENABLE = yes +CONSOLE_ENABLE = yes +EXTRAKEY_ENABLE = yes +MOUSEKEY_ENABLE = yes +NKRO_ENABLE = yes +SPACE_CADET_ENABLE = no +TAP_DANCE_ENABLE = yes +UNICODEMAP_ENABLE = yes diff --git a/keyboards/whitefox/keymaps/konstantin/rules.mk b/keyboards/whitefox/keymaps/konstantin/rules.mk index 625ef346c..bced6e8a7 100644 --- a/keyboards/whitefox/keymaps/konstantin/rules.mk +++ b/keyboards/whitefox/keymaps/konstantin/rules.mk @@ -1,11 +1,11 @@ -BOOTMAGIC_ENABLE = no -COMMAND_ENABLE = yes -CONSOLE_ENABLE = yes -EXTRAKEY_ENABLE = yes -MOUSEKEY_ENABLE = yes -NKRO_ENABLE = yes -TAP_DANCE_ENABLE = yes -UNICODEMAP_ENABLE = yes - -BACKLIGHT_ENABLE = no -VISUALIZER_ENABLE = no +BACKLIGHT_ENABLE = no +BOOTMAGIC_ENABLE = no +COMMAND_ENABLE = yes +CONSOLE_ENABLE = yes +EXTRAKEY_ENABLE = yes +MOUSEKEY_ENABLE = yes +NKRO_ENABLE = yes +SPACE_CADET_ENABLE = no +TAP_DANCE_ENABLE = yes +UNICODEMAP_ENABLE = yes +VISUALIZER_ENABLE = no diff --git a/users/konstantin/config.h b/users/konstantin/config.h index 4edab2baa..d712e79d3 100644 --- a/users/konstantin/config.h +++ b/users/konstantin/config.h @@ -13,6 +13,12 @@ #define NO_ACTION_MACRO #define NO_ACTION_ONESHOT +#undef RGBLIGHT_ANIMATIONS +#define RGBLIGHT_EFFECT_BREATHING +#define RGBLIGHT_EFFECT_RAINBOW_MOOD +#define RGBLIGHT_EFFECT_RAINBOW_SWIRL +#define RGBLIGHT_EFFECT_SNAKE + #define PERMISSIVE_HOLD #define TAPPING_TERM 200 #define TAPPING_TOGGLE 2 diff --git a/users/konstantin/konstantin.c b/users/konstantin/konstantin.c index 9e3caca41..c56c9490f 100644 --- a/users/konstantin/konstantin.c +++ b/users/konstantin/konstantin.c @@ -32,26 +32,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } switch (keycode) { - case CLEAR: - if (record->event.pressed) { - SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); - } - return false; - - case DST_P_R: - (record->event.pressed ? register_code16 : unregister_code16)( - (get_mods() & DST_MOD_MASK) ? DST_REM : DST_PRV - ); - return false; - - case DST_N_A: - (record->event.pressed ? register_code16 : unregister_code16)( - (get_mods() & DST_MOD_MASK) ? DST_ADD : DST_NXT - ); - return false; - + uint16_t kc; #ifdef LAYER_FN - static bool fn_lock; + static bool fn_lock = false; case FN_FNLK: if (record->event.pressed && record->tap.count == TAPPING_TOGGLE) { @@ -77,6 +60,28 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { } return true; + case CLEAR: + if (record->event.pressed) { + CLEAN_MODS( + SEND_STRING(SS_LCTRL("a") SS_TAP(X_DELETE)); + ) + } + return false; + + case DST_P_R: + kc = (get_mods() & DST_MOD_MASK) ? DST_REM : DST_PRV; + CLEAN_MODS( + (record->event.pressed ? register_code16 : unregister_code16)(kc); + ) + return false; + + case DST_N_A: + kc = (get_mods() & DST_MOD_MASK) ? DST_ADD : DST_NXT; + CLEAN_MODS( + (record->event.pressed ? register_code16 : unregister_code16)(kc); + ) + return false; + default: return true; } @@ -91,7 +96,7 @@ uint32_t layer_state_set_user(uint32_t state) { state = layer_state_set_keymap(state); #ifdef LAYER_NUMPAD - bool numpad = state & 1UL<