summaryrefslogtreecommitdiff
path: root/keyboards/kbdfans
diff options
context:
space:
mode:
authorKonstantin Đorđević <konstantin.djordjevic@tradecore.com>2019-07-25 21:31:40 +0200
committerDrashna Jaelre <drashna@live.com>2019-07-25 12:31:40 -0700
commit36d3902504d6aa0d2bdac88c90339c902ade11b3 (patch)
treeb4a36c6b3cb5d54f44680df60c1845e8cb917197 /keyboards/kbdfans
parentf204ed67f210b1dde20333727c79c47a5b70518a (diff)
[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()
Diffstat (limited to 'keyboards/kbdfans')
-rw-r--r--keyboards/kbdfans/kbd6x/keymaps/konstantin/config.h1
-rw-r--r--keyboards/kbdfans/kbd6x/keymaps/konstantin/keymap.c42
-rw-r--r--keyboards/kbdfans/kbd6x/keymaps/konstantin/rules.mk22
3 files changed, 52 insertions, 13 deletions
diff --git a/keyboards/kbdfans/kbd6x/keymaps/konstantin/config.h b/keyboards/kbdfans/kbd6x/keymaps/konstantin/config.h
index 16387fa2f6..4b511eb848 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 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
* ┌───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┬───┐
diff --git a/keyboards/kbdfans/kbd6x/keymaps/konstantin/rules.mk b/keyboards/kbdfans/kbd6x/keymaps/konstantin/rules.mk
index f7cf0758b7..7262c6db66 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