From 98642ca02878741531105bd879c0d61110198b62 Mon Sep 17 00:00:00 2001 From: Drashna Jaelre Date: Mon, 22 Jun 2020 01:38:58 -0700 Subject: Improve keycode handling for RGB (#7677) Co-authored-by: drashna Co-authored-by: noroadsleft <18669334+noroadsleft@users.noreply.github.com> --- quantum/process_keycode/process_rgb.c | 85 +++++++++++++++++++++++++++++++---- 1 file changed, 77 insertions(+), 8 deletions(-) (limited to 'quantum') diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c index 21164b8f9f..a1e46e0348 100644 --- a/quantum/process_keycode/process_rgb.c +++ b/quantum/process_keycode/process_rgb.c @@ -59,78 +59,147 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { uint8_t shifted = get_mods() & MOD_MASK_SHIFT; switch (keycode) { case RGB_TOG: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) rgblight_toggle(); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_toggle(); +#endif return false; case RGB_MODE_FORWARD: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_step, rgblight_step_reverse); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_step, rgb_matrix_step_reverse); +#endif return false; case RGB_MODE_REVERSE: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_step_reverse, rgblight_step); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_step_reverse, rgb_matrix_step); +#endif return false; case RGB_HUI: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_hue, rgblight_decrease_hue); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_increase_hue, rgb_matrix_decrease_hue); +#endif return false; case RGB_HUD: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_hue, rgblight_increase_hue); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_decrease_hue, rgb_matrix_increase_hue); +#endif return false; case RGB_SAI: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_sat, rgblight_decrease_sat); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_increase_sat, rgb_matrix_decrease_sat); +#endif return false; case RGB_SAD: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_sat, rgblight_increase_sat); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_decrease_sat, rgb_matrix_increase_sat); +#endif return false; case RGB_VAI: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_val, rgblight_decrease_val); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_increase_val, rgb_matrix_decrease_val); +#endif return false; case RGB_VAD: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_val, rgblight_increase_val); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_decrease_val, rgb_matrix_increase_val); +#endif return false; case RGB_SPI: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_speed, rgblight_decrease_speed); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_increase_speed, rgb_matrix_decrease_speed); +#endif return false; case RGB_SPD: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_speed, rgblight_increase_speed); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + handleKeycodeRGB(shifted, rgb_matrix_decrease_speed, rgb_matrix_increase_speed); +#endif return false; case RGB_MODE_PLAIN: +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) + rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR); +#endif return false; case RGB_MODE_BREATHE: -#ifdef RGBLIGHT_EFFECT_BREATHING +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_BREATHING) handleKeycodeRGBMode(RGBLIGHT_MODE_BREATHING, RGBLIGHT_MODE_BREATHING_end); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_BREATHING) + rgb_matrix_mode(RGB_MATRIX_BREATHING); #endif return false; case RGB_MODE_RAINBOW: -#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_MOOD) handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT) + rgb_matrix_mode(RGB_MATRIX_CYCLE_LEFT_RIGHT); #endif return false; case RGB_MODE_SWIRL: -#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_SWIRL) handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end); +#endif +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_PINWHEEL) + rgb_matrix_mode(RGB_MATRIX_CYCLE_PINWHEEL); #endif return false; case RGB_MODE_SNAKE: -#ifdef RGBLIGHT_EFFECT_SNAKE +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_SNAKE) handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end); #endif return false; case RGB_MODE_KNIGHT: -#ifdef RGBLIGHT_EFFECT_KNIGHT +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_KNIGHT) handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end); #endif return false; case RGB_MODE_XMAS: -#ifdef RGBLIGHT_EFFECT_CHRISTMAS +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_CHRISTMAS) rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); #endif return false; case RGB_MODE_GRADIENT: -#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_STATIC_GRADIENT) handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end); #endif return false; case RGB_MODE_RGBTEST: -#ifdef RGBLIGHT_EFFECT_RGB_TEST +#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RGB_TEST) rgblight_mode(RGBLIGHT_MODE_RGB_TEST); #endif return false; -- cgit v1.2.3