Backward compatibility for new RGB keycode handling (#24490)

Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com>
This commit is contained in:
Ryan 2024-11-20 09:53:33 +11:00 committed by GitHub
parent e66fce38b2
commit 9c86583981
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
18 changed files with 154 additions and 5 deletions

View File

@ -456,6 +456,10 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations
COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners COMMON_VPATH += $(QUANTUM_DIR)/rgb_matrix/animations/runners
POST_CONFIG_H += $(QUANTUM_DIR)/rgb_matrix/post_config.h 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)/process_keycode/process_rgb_matrix.c
SRC += $(QUANTUM_DIR)/color.c SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c

View File

@ -59,6 +59,10 @@ Changing the **Value** sets the overall brightness.<br>
## Keycodes ## 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 | |Key |Aliases |Description |
|------------------------------|----------|---------------------------------------------------------------------| |------------------------------|----------|---------------------------------------------------------------------|
|`QK_UNDERGLOW_TOGGLE` |`UG_TOGG` |Toggle RGB lighting on or off | |`QK_UNDERGLOW_TOGGLE` |`UG_TOGG` |Toggle RGB lighting on or off |

View File

@ -20,3 +20,5 @@
#define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -20,3 +20,5 @@
#define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_VCC
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -16,3 +16,5 @@
#pragma once #pragma once
#define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND #define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -17,3 +17,5 @@
#pragma once #pragma once
#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -2,3 +2,5 @@
#define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -2,3 +2,5 @@
#define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND #define IS31FL3731_I2C_ADDRESS_1 IS31FL3731_I2C_ADDRESS_GND
#define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA #define IS31FL3731_I2C_ADDRESS_2 IS31FL3731_I2C_ADDRESS_SDA
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -30,3 +30,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2 #define I2C1_DUTY_CYCLE FAST_DUTY_CYCLE_2
#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND #define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
#define RGBLIGHT_DI_PIN E6 #define RGBLIGHT_DI_PIN E6
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -9,3 +9,5 @@
#define WORK_LOUDER_LED_PIN_1 B6 #define WORK_LOUDER_LED_PIN_1 B6
#define WORK_LOUDER_LED_PIN_2 B7 #define WORK_LOUDER_LED_PIN_2 B7
#define WORK_LOUDER_LED_PIN_3 B5 #define WORK_LOUDER_LED_PIN_3 B5
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once #pragma once
#define RGBLIGHT_DI_PIN C7 #define RGBLIGHT_DI_PIN C7
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -5,3 +5,5 @@
#define RGBLIGHT_DI_PIN D2 #define RGBLIGHT_DI_PIN D2
#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9 #define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -20,3 +20,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_DI_PIN D2 #define RGBLIGHT_DI_PIN D2
#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9 #define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9
#define RGB_MATRIX_DISABLE_SHARED_KEYCODES

View File

@ -2,87 +2,200 @@
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
#include "process_underglow.h" #include "process_underglow.h"
#include "rgblight.h" #if defined(RGBLIGHT_ENABLE)
# include "rgblight.h"
#endif
#include "action_util.h" #include "action_util.h"
#include "keycodes.h" #include "keycodes.h"
#include "modifiers.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) { bool process_underglow(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) { if (record->event.pressed) {
uint8_t shifted = get_mods() & MOD_MASK_SHIFT; uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
switch (keycode) { switch (keycode) {
case QK_UNDERGLOW_TOGGLE: case QK_UNDERGLOW_TOGGLE:
#if defined(RGBLIGHT_ENABLE)
rgblight_toggle(); rgblight_toggle();
#endif
#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES)
rgb_matrix_toggle();
#endif
return false; return false;
case QK_UNDERGLOW_MODE_NEXT: case QK_UNDERGLOW_MODE_NEXT:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_step_reverse(); rgblight_step_reverse();
} else { } else {
rgblight_step(); 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; return false;
case QK_UNDERGLOW_MODE_PREVIOUS: case QK_UNDERGLOW_MODE_PREVIOUS:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_step(); rgblight_step();
} else { } else {
rgblight_step_reverse(); 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; return false;
case QK_UNDERGLOW_HUE_UP: case QK_UNDERGLOW_HUE_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_decrease_hue(); rgblight_decrease_hue();
} else { } else {
rgblight_increase_hue(); 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; return false;
case QK_UNDERGLOW_HUE_DOWN: case QK_UNDERGLOW_HUE_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_increase_hue(); rgblight_increase_hue();
} else { } else {
rgblight_decrease_hue(); 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; return false;
case QK_UNDERGLOW_SATURATION_UP: case QK_UNDERGLOW_SATURATION_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_decrease_sat(); rgblight_decrease_sat();
} else { } else {
rgblight_increase_sat(); 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; return false;
case QK_UNDERGLOW_SATURATION_DOWN: case QK_UNDERGLOW_SATURATION_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_increase_sat(); rgblight_increase_sat();
} else { } else {
rgblight_decrease_sat(); 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; return false;
case QK_UNDERGLOW_VALUE_UP: case QK_UNDERGLOW_VALUE_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_decrease_val(); rgblight_decrease_val();
} else { } else {
rgblight_increase_val(); 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; return false;
case QK_UNDERGLOW_VALUE_DOWN: case QK_UNDERGLOW_VALUE_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_increase_hue(); rgblight_increase_val();
} else { } 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; return false;
case QK_UNDERGLOW_SPEED_UP: case QK_UNDERGLOW_SPEED_UP:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_decrease_speed(); rgblight_decrease_speed();
} else { } else {
rgblight_increase_speed(); 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; return false;
case QK_UNDERGLOW_SPEED_DOWN: case QK_UNDERGLOW_SPEED_DOWN:
#if defined(RGBLIGHT_ENABLE)
if (shifted) { if (shifted) {
rgblight_increase_speed(); rgblight_increase_speed();
} else { } else {
rgblight_decrease_speed(); 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; return false;
} }
} }

View File

@ -60,7 +60,7 @@
# include "process_rgb_matrix.h" # include "process_rgb_matrix.h"
#endif #endif
#if defined(RGBLIGHT_ENABLE) #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
# include "process_underglow.h" # include "process_underglow.h"
#endif #endif
@ -382,7 +382,7 @@ bool process_record_quantum(keyrecord_t *record) {
#ifdef GRAVE_ESC_ENABLE #ifdef GRAVE_ESC_ENABLE
process_grave_esc(keycode, record) && process_grave_esc(keycode, record) &&
#endif #endif
#if defined(RGBLIGHT_ENABLE) #if defined(RGBLIGHT_ENABLE) || defined(RGB_MATRIX_ENABLE)
process_underglow(keycode, record) && process_underglow(keycode, record) &&
#endif #endif
#if defined(RGB_MATRIX_ENABLE) #if defined(RGB_MATRIX_ENABLE)