Skip to content

Commit

Permalink
Backward compatibility for new RGB keycode handling (#24490)
Browse files Browse the repository at this point in the history
Co-authored-by: Dasky <[email protected]>
  • Loading branch information
fauxpark and daskygit authored Nov 19, 2024
1 parent e66fce3 commit 9c86583
Show file tree
Hide file tree
Showing 18 changed files with 154 additions and 5 deletions.
4 changes: 4 additions & 0 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions docs/features/rgblight.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ Changing the **Value** sets the overall brightness.<br>

## 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 |
Expand Down
2 changes: 2 additions & 0 deletions keyboards/inett_studio/sqx/hotswap/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions keyboards/inett_studio/sqx/universal/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions keyboards/kprepublic/bm60hsrgb_ec/rev2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@
#pragma once

#define IS31FL3733_I2C_ADDRESS_1 IS31FL3733_I2C_ADDRESS_GND_GND

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/kprepublic/bm68hsrgb/rev2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,5 @@
#pragma once

#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/mechlovin/adelais/rgb_led/rev2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions keyboards/mechlovin/hannah60rgb/rev2/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions keyboards/owlab/voice65/hotswap/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/owlab/voice65/soldered/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#define IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/qwertykeys/qk100/ansi/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 IS31FL3741_I2C_ADDRESS_1 IS31FL3741_I2C_ADDRESS_GND

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/work_louder/loop/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#define RGBLIGHT_DI_PIN E6

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/work_louder/micro/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions keyboards/work_louder/nano/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#pragma once

#define RGBLIGHT_DI_PIN C7

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/work_louder/numpad/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,5 @@

#define RGBLIGHT_DI_PIN D2
#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
2 changes: 2 additions & 0 deletions keyboards/work_louder/work_board/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,5 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define RGBLIGHT_DI_PIN D2

#define RGBLIGHT_DEFAULT_MODE RGBLIGHT_MODE_STATIC_GRADIENT + 9

#define RGB_MATRIX_DISABLE_SHARED_KEYCODES
119 changes: 116 additions & 3 deletions quantum/process_keycode/process_underglow.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down
4 changes: 2 additions & 2 deletions quantum/quantum.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 9c86583

Please sign in to comment.