diff --git a/builddefs/common_features.mk b/builddefs/common_features.mk index 2eb7056b6f6..f5b01de015d 100644 --- a/builddefs/common_features.mk +++ b/builddefs/common_features.mk @@ -456,6 +456,10 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes) COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners POST_CONFIG_H += $(QUANTUM_DIR)/rgb_matrix/post_config.h + + # TODO: Remove this + SRC += $(QUANTUM_DIR)/process_keycode/process_underglow.c + SRC += $(QUANTUM_DIR)/process_keycode/process_rgb_matrix.c SRC += $(QUANTUM_DIR)/color.c SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c diff --git a/docs/features/rgblight.md b/docs/features/rgblight.md index 2afc2eb7d09..4322fe796e7 100644 --- a/docs/features/rgblight.md +++ b/docs/features/rgblight.md @@ -59,6 +59,10 @@ Changing the **Value** sets the overall brightness.
## Keycodes +::: warning +These keycodes also simultaneously control [RGB Matrix](rgb_matrix), if enabled. This behaviour is in the process of being deprecated, so during this time it is recommended to additionally include the dedicated RGB Matrix keycodes to your keymap, and add `#define RGB_MATRIX_DISABLE_SHARED_KEYCODES` to `config.h`. +::: + |Key |Aliases |Description | |------------------------------|----------|---------------------------------------------------------------------| |`QK_UNDERGLOW_TOGGLE` |`UG_TOGG` |Toggle RGB lighting on or off | diff --git a/keyboards/inett_studio/sqx/hotswap/config.h b/keyboards/inett_studio/sqx/hotswap/config.h index 4172a72379f..22d2e739cbb 100644 --- a/keyboards/inett_studio/sqx/hotswap/config.h +++ b/keyboards/inett_studio/sqx/hotswap/config.h @@ -20,3 +20,5 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/inett_studio/sqx/universal/config.h b/keyboards/inett_studio/sqx/universal/config.h index 4172a72379f..22d2e739cbb 100644 --- a/keyboards/inett_studio/sqx/universal/config.h +++ b/keyboards/inett_studio/sqx/universal/config.h @@ -20,3 +20,5 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/kprepublic/bm60hsrgb_ec/rev2/config.h b/keyboards/kprepublic/bm60hsrgb_ec/rev2/config.h index b58434efece..ddb8a2525ff 100644 --- a/keyboards/kprepublic/bm60hsrgb_ec/rev2/config.h +++ b/keyboards/kprepublic/bm60hsrgb_ec/rev2/config.h @@ -16,3 +16,5 @@ #pragma once #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/kprepublic/bm68hsrgb/rev2/config.h b/keyboards/kprepublic/bm68hsrgb/rev2/config.h index f35697b992e..026cbdcdca0 100644 --- a/keyboards/kprepublic/bm68hsrgb/rev2/config.h +++ b/keyboards/kprepublic/bm68hsrgb/rev2/config.h @@ -17,3 +17,5 @@ #pragma once #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/mechlovin/adelais/rgb_led/rev2/config.h b/keyboards/mechlovin/adelais/rgb_led/rev2/config.h index 82b582bfe12..fea263d7fbe 100644 --- a/keyboards/mechlovin/adelais/rgb_led/rev2/config.h +++ b/keyboards/mechlovin/adelais/rgb_led/rev2/config.h @@ -2,3 +2,5 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/mechlovin/hannah60rgb/rev2/config.h b/keyboards/mechlovin/hannah60rgb/rev2/config.h index 82b582bfe12..fea263d7fbe 100644 --- a/keyboards/mechlovin/hannah60rgb/rev2/config.h +++ b/keyboards/mechlovin/hannah60rgb/rev2/config.h @@ -2,3 +2,5 @@ #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/owlab/voice65/hotswap/config.h b/keyboards/owlab/voice65/hotswap/config.h index be6b66e58a8..97bde08548e 100644 --- a/keyboards/owlab/voice65/hotswap/config.h +++ b/keyboards/owlab/voice65/hotswap/config.h @@ -18,3 +18,5 @@ along with this program. If not, see . #pragma once #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/owlab/voice65/soldered/config.h b/keyboards/owlab/voice65/soldered/config.h index be6b66e58a8..97bde08548e 100644 --- a/keyboards/owlab/voice65/soldered/config.h +++ b/keyboards/owlab/voice65/soldered/config.h @@ -18,3 +18,5 @@ along with this program. If not, see . #pragma once #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/qwertykeys/qk100/ansi/config.h b/keyboards/qwertykeys/qk100/ansi/config.h index b78d15782ba..ceba1c798dd 100644 --- a/keyboards/qwertykeys/qk100/ansi/config.h +++ b/keyboards/qwertykeys/qk100/ansi/config.h @@ -30,3 +30,5 @@ along with this program. If not, see . #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2 #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/work_louder/loop/config.h b/keyboards/work_louder/loop/config.h index b883b0ff578..5b031c6fc10 100644 --- a/keyboards/work_louder/loop/config.h +++ b/keyboards/work_louder/loop/config.h @@ -18,3 +18,5 @@ along with this program. If not, see . #pragma once #define RGBLIGHT_DI_PIN E6 + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/work_louder/micro/config.h b/keyboards/work_louder/micro/config.h index b9f2d8d87dc..6748a5f5951 100644 --- a/keyboards/work_louder/micro/config.h +++ b/keyboards/work_louder/micro/config.h @@ -9,3 +9,5 @@ #define WORK_LOUDER_LED_PIN_1 B6 #define WORK_LOUDER_LED_PIN_2 B7 #define WORK_LOUDER_LED_PIN_3 B5 + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/work_louder/nano/config.h b/keyboards/work_louder/nano/config.h index 2372f371b99..492931c559c 100644 --- a/keyboards/work_louder/nano/config.h +++ b/keyboards/work_louder/nano/config.h @@ -18,3 +18,5 @@ along with this program. If not, see . #pragma once #define RGBLIGHT_DI_PIN C7 + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/work_louder/numpad/config.h b/keyboards/work_louder/numpad/config.h index cfc27d36124..809c498dbbb 100644 --- a/keyboards/work_louder/numpad/config.h +++ b/keyboards/work_louder/numpad/config.h @@ -5,3 +5,5 @@ #define RGBLIGHT_DI_PIN D2 #define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9 + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/keyboards/work_louder/work_board/config.h b/keyboards/work_louder/work_board/config.h index 6688711bbbc..efd4c529cd8 100644 --- a/keyboards/work_louder/work_board/config.h +++ b/keyboards/work_louder/work_board/config.h @@ -20,3 +20,5 @@ along with this program. If not, see . #define RGBLIGHT_DI_PIN D2 #define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9 + +#define RGB_MATRIX_DISABLE_SHARED_KEYCODES diff --git a/quantum/process_keycode/process_underglow.c b/quantum/process_keycode/process_underglow.c index 779672ac076..6104cd02c6c 100644 --- a/quantum/process_keycode/process_underglow.c +++ b/quantum/process_keycode/process_underglow.c @@ -2,87 +2,200 @@ // SPDX-License-Identifier: GPL-2.0-or-later #include "process_underglow.h" -#include "rgblight.h" +#if defined(RGBLIGHT_ENABLE) +# include "rgblight.h" +#endif #include "action_util.h" #include "keycodes.h" #include "modifiers.h" +// TODO: Remove this +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) +# include "rgb_matrix.h" +#endif + bool process_underglow(uint16_t keycode, keyrecord_t *record) { if (record->event.pressed) { uint8_t shifted = get_mods() & MOD_MASK_SHIFT; switch (keycode) { case QK_UNDERGLOW_TOGGLE: +#if defined(RGBLIGHT_ENABLE) rgblight_toggle(); +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + rgb_matrix_toggle(); +#endif return false; case QK_UNDERGLOW_MODE_NEXT: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_step_reverse(); } else { rgblight_step(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_step_reverse(); + } else { + rgb_matrix_step(); + } +#endif return false; case QK_UNDERGLOW_MODE_PREVIOUS: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_step(); } else { rgblight_step_reverse(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_step(); + } else { + rgb_matrix_step_reverse(); + } +#endif return false; case QK_UNDERGLOW_HUE_UP: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_decrease_hue(); } else { rgblight_increase_hue(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_decrease_hue(); + } else { + rgb_matrix_increase_hue(); + } +#endif return false; case QK_UNDERGLOW_HUE_DOWN: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_increase_hue(); } else { rgblight_decrease_hue(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_increase_hue(); + } else { + rgb_matrix_decrease_hue(); + } +#endif return false; case QK_UNDERGLOW_SATURATION_UP: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_decrease_sat(); } else { rgblight_increase_sat(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_decrease_sat(); + } else { + rgb_matrix_increase_sat(); + } +#endif return false; case QK_UNDERGLOW_SATURATION_DOWN: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_increase_sat(); } else { rgblight_decrease_sat(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_increase_sat(); + } else { + rgb_matrix_decrease_sat(); + } +#endif return false; case QK_UNDERGLOW_VALUE_UP: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_decrease_val(); } else { rgblight_increase_val(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_decrease_val(); + } else { + rgb_matrix_increase_val(); + } +#endif return false; case QK_UNDERGLOW_VALUE_DOWN: +#if defined(RGBLIGHT_ENABLE) if (shifted) { - rgblight_increase_hue(); + rgblight_increase_val(); } else { - rgblight_decrease_hue(); + rgblight_decrease_val(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_increase_val(); + } else { + rgb_matrix_decrease_val(); + } +#endif return false; case QK_UNDERGLOW_SPEED_UP: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_decrease_speed(); } else { rgblight_increase_speed(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_decrease_speed(); + } else { + rgb_matrix_increase_speed(); + } +#endif return false; case QK_UNDERGLOW_SPEED_DOWN: +#if defined(RGBLIGHT_ENABLE) if (shifted) { rgblight_increase_speed(); } else { rgblight_decrease_speed(); } +#endif + +#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) + if (shifted) { + rgb_matrix_increase_speed(); + } else { + rgb_matrix_decrease_speed(); + } +#endif return false; } } diff --git a/quantum/quantum.c b/quantum/quantum.c index 8bfe04e1798..874df1593a2 100644 --- a/quantum/quantum.c +++ b/quantum/quantum.c @@ -60,7 +60,7 @@ # include "process_rgb_matrix.h" #endif -#if defined(RGBLIGHT_ENABLE) +#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) # include "process_underglow.h" #endif @@ -382,7 +382,7 @@ bool process_record_quantum(keyrecord_t *record) { #ifdef GRAVE_ESC_ENABLE process_grave_esc(keycode, record) && #endif -#if defined(RGBLIGHT_ENABLE) +#if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE) process_underglow(keycode, record) && #endif #if defined(RGB_MATRIX_ENABLE)