summaryrefslogtreecommitdiff
path: root/users/drashna/rgb
diff options
context:
space:
mode:
Diffstat (limited to 'users/drashna/rgb')
-rw-r--r--users/drashna/rgb/rgb_matrix_stuff.c60
-rw-r--r--users/drashna/rgb/rgb_stuff.c92
2 files changed, 88 insertions, 64 deletions
diff --git a/users/drashna/rgb/rgb_matrix_stuff.c b/users/drashna/rgb/rgb_matrix_stuff.c
index 36a7502733..2c23c29784 100644
--- a/users/drashna/rgb/rgb_matrix_stuff.c
+++ b/users/drashna/rgb/rgb_matrix_stuff.c
@@ -15,7 +15,7 @@ void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode
}
switch (mode) {
- case 1: // breathing
+ case 1: // breathing
{
uint16_t time = scale16by8(g_rgb_timer, speed / 8);
hsv.v = scale8(abs8(sin8(time) - 128) * 2, hsv.v);
@@ -27,7 +27,7 @@ void rgb_matrix_layer_helper(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode
}
break;
}
- default: // Solid Color
+ default: // Solid Color
{
RGB rgb = hsv_to_rgb(hsv);
for (uint8_t i = 0; i < DRIVER_LED_TOTAL; i++) {
@@ -59,6 +59,8 @@ void keyboard_post_init_rgb_matrix(void) {
#endif
if (userspace_config.rgb_layer_change) {
rgb_matrix_set_flags(LED_FLAG_UNDERGLOW | LED_FLAG_KEYLIGHT | LED_FLAG_INDICATOR);
+ } else {
+ rgb_matrix_set_flags(LED_FLAG_ALL);
}
}
@@ -70,7 +72,7 @@ bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
}
#endif
switch (keycode) {
- case RGB_IDL: // This allows me to use underglow as layer indication, or as normal
+ case RGB_IDL: // This allows me to use underglow as layer indication, or as normal
#if defined(RGB_MATRIX_ENABLE) && defined(RGB_MATRIX_FRAMEBUFFER_EFFECTS)
if (record->event.pressed) {
userspace_config.rgb_matrix_idle_anim ^= 1;
@@ -86,9 +88,13 @@ bool process_record_user_rgb_matrix(uint16_t keycode, keyrecord_t *record) {
return true;
}
-__attribute__((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) { return true; }
-void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
- if (!rgb_matrix_indicators_advanced_keymap(led_min, led_max)) { return; }
+__attribute__((weak)) bool rgb_matrix_indicators_advanced_keymap(uint8_t led_min, uint8_t led_max) {
+ return true;
+}
+void rgb_matrix_indicators_advanced_user(uint8_t led_min, uint8_t led_max) {
+ if (!rgb_matrix_indicators_advanced_keymap(led_min, led_max)) {
+ return;
+ }
#if defined(RGBLIGHT_ENABLE)
if (!userspace_config.rgb_layer_change)
@@ -96,19 +102,7 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min,
if (userspace_config.rgb_layer_change)
#endif
{
- switch (get_highest_layer(layer_state | default_layer_state)) {
- case _DEFAULT_LAYER_1:
- rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
- break;
- case _DEFAULT_LAYER_2:
- rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
- break;
- case _DEFAULT_LAYER_3:
- rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
- break;
- case _DEFAULT_LAYER_4:
- rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
- break;
+ switch (get_highest_layer(layer_state & ~((layer_state_t)1 << _MOUSE))) {
case _GAMEPAD:
rgb_matrix_layer_helper(HSV_ORANGE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
@@ -124,9 +118,33 @@ void rgb_matrix_indicators_advanced_user(uint8_t led_min,
case _ADJUST:
rgb_matrix_layer_helper(HSV_RED, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
break;
+ default:
+ if (layer_state_is(_MOUSE)) {
+ rgb_matrix_layer_helper(HSV_PURPLE, 1, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ } else {
+ switch (get_highest_layer(default_layer_state)) {
+ case _DEFAULT_LAYER_1:
+ rgb_matrix_layer_helper(DEFAULT_LAYER_1_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ break;
+ case _DEFAULT_LAYER_2:
+ rgb_matrix_layer_helper(DEFAULT_LAYER_2_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ break;
+ case _DEFAULT_LAYER_3:
+ rgb_matrix_layer_helper(DEFAULT_LAYER_3_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ break;
+ case _DEFAULT_LAYER_4:
+ rgb_matrix_layer_helper(DEFAULT_LAYER_4_HSV, 0, rgb_matrix_config.speed, LED_FLAG_MODIFIER, led_min, led_max);
+ break;
+ }
+ }
+ break;
}
}
}
-__attribute__((weak)) bool rgb_matrix_indicators_keymap(void) { return true; }
-void rgb_matrix_indicators_user(void) { rgb_matrix_indicators_keymap(); }
+__attribute__((weak)) bool rgb_matrix_indicators_keymap(void) {
+ return true;
+}
+void rgb_matrix_indicators_user(void) {
+ rgb_matrix_indicators_keymap();
+}
diff --git a/users/drashna/rgb/rgb_stuff.c b/users/drashna/rgb/rgb_stuff.c
index 7d2cf0c73d..c283e58d26 100644
--- a/users/drashna/rgb/rgb_stuff.c
+++ b/users/drashna/rgb/rgb_stuff.c
@@ -1,28 +1,30 @@
// Copyright 2020 Christopher Courtney, aka Drashna Jael're (@drashna) <drashna@live.com>
// SPDX-License-Identifier: GPL-2.0-or-later
-#ifdef RGBLIGHT_ENABLE
-
-# include "drashna.h"
-# include "rgb_stuff.h"
-# include "eeprom.h"
+#include "drashna.h"
+#include "rgb_stuff.h"
+#include "eeprom.h"
bool has_initialized;
-void rgblight_sethsv_default_helper(uint8_t index) { rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index); }
+void rgblight_sethsv_default_helper(uint8_t index) {
+ rgblight_sethsv_at(rgblight_get_hue(), rgblight_get_sat(), rgblight_get_val(), index);
+}
void rgblight_set_hsv_and_mode(uint8_t hue, uint8_t sat, uint8_t val, uint8_t mode) {
rgblight_sethsv_noeeprom(hue, sat, val);
// wait_us(175); // Add a slight delay between color and mode to ensure it's processed correctly
rgblight_mode_noeeprom(mode);
}
-bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) { return true; }
+bool process_record_user_rgb_light(uint16_t keycode, keyrecord_t *record) {
+ return true;
+}
-# if defined(RGBLIGHT_STARTUP_ANIMATION)
-static bool is_enabled;
-static bool is_rgblight_startup;
-static HSV old_hsv;
-static uint8_t old_mode;
+#if defined(RGBLIGHT_STARTUP_ANIMATION)
+static bool is_enabled;
+static bool is_rgblight_startup;
+static HSV old_hsv;
+static uint8_t old_mode;
deferred_token rgb_startup_token;
uint32_t rgb_startup_animation(uint32_t triger_time, void *cb_arg) {
@@ -44,10 +46,10 @@ uint32_t rgb_startup_animation(uint32_t triger_time, void *cb_arg) {
}
return is_rgblight_startup ? 10 : 0;
}
-# endif
+#endif
void keyboard_post_init_rgb_light(void) {
-# if defined(RGBLIGHT_STARTUP_ANIMATION)
+#if defined(RGBLIGHT_STARTUP_ANIMATION)
is_enabled = rgblight_is_enabled();
if (userspace_config.rgb_layer_change) {
layer_state_set_rgb_light(layer_state);
@@ -56,27 +58,17 @@ void keyboard_post_init_rgb_light(void) {
old_mode = rgblight_get_mode();
rgblight_mode_noeeprom(RGBLIGHT_MODE_STATIC_LIGHT);
is_rgblight_startup = true;
- rgb_startup_token = defer_exec(300, rgb_startup_animation, NULL);
-# endif
+ rgb_startup_token = defer_exec(300, rgb_startup_animation, NULL);
+#endif
if (userspace_config.rgb_layer_change) {
layer_state_set_rgb_light(layer_state);
}
-
}
layer_state_t layer_state_set_rgb_light(layer_state_t state) {
-# ifdef RGBLIGHT_ENABLE
+#ifdef RGBLIGHT_ENABLE
if (userspace_config.rgb_layer_change) {
- switch (get_highest_layer(state | default_layer_state)) {
- case _MOUSE: // mouse
- if (!layer_state_cmp(state, _GAMEPAD) && !layer_state_cmp(state, _DIABLO)) {
-# if defined(RGBLIGHT_EFFECT_TWINKLE)
- rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_TWINKLE + 5);
-# else
- rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3);
-# endif
- }
- break;
+ switch (get_highest_layer(state & ~((layer_state_t)1 << _MOUSE))) {
case _MEDIA:
rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_KNIGHT + 1);
break;
@@ -84,6 +76,7 @@ layer_state_t layer_state_set_rgb_light(layer_state_t state) {
rgblight_set_hsv_and_mode(HSV_ORANGE, RGBLIGHT_MODE_SNAKE + 2);
break;
case _DIABLO:
+ case _DIABLOII:
rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_BREATHING + 3);
break;
case _RAISE:
@@ -95,23 +88,36 @@ layer_state_t layer_state_set_rgb_light(layer_state_t state) {
case _ADJUST:
rgblight_set_hsv_and_mode(HSV_RED, RGBLIGHT_MODE_KNIGHT + 2);
break;
- case _DEFAULT_LAYER_1:
- rgblight_set_hsv_and_mode(DEFAULT_LAYER_1_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
- break;
- case _DEFAULT_LAYER_2:
- rgblight_set_hsv_and_mode(DEFAULT_LAYER_2_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
- break;
- case _DEFAULT_LAYER_3:
- rgblight_set_hsv_and_mode(DEFAULT_LAYER_3_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
- break;
- case _DEFAULT_LAYER_4:
- rgblight_set_hsv_and_mode(DEFAULT_LAYER_4_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
- break;
+ default:
+ if (layer_state_cmp(state, _MOUSE)) {
+# if defined(RGBLIGHT_EFFECT_TWINKLE)
+ rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_TWINKLE + 5);
+# else
+ rgblight_set_hsv_and_mode(HSV_CHARTREUSE, RGBLIGHT_MODE_BREATHING + 3);
+# endif
+ } else {
+ default_layer_state_set_rgb_light(default_layer_state);
+ }
}
+#endif // RGBLIGHT_ENABLE
}
-# endif // RGBLIGHT_ENABLE
-
return state;
}
-#endif
+layer_state_t default_layer_state_set_rgb_light(layer_state_t state) {
+ switch (get_highest_layer(state)) {
+ case _DEFAULT_LAYER_1:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_1_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
+ break;
+ case _DEFAULT_LAYER_2:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_2_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
+ break;
+ case _DEFAULT_LAYER_3:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_3_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
+ break;
+ case _DEFAULT_LAYER_4:
+ rgblight_set_hsv_and_mode(DEFAULT_LAYER_4_HSV, RGBLIGHT_MODE_STATIC_LIGHT);
+ break;
+ }
+ return state;
+}