Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Separate RGBLight/RGB Matrix keycode handling #23679

Merged
merged 10 commits into from
Oct 12, 2024
  •  
  •  
  •  
8 changes: 2 additions & 6 deletions builddefs/common_features.mk
Original file line number Diff line number Diff line change
Expand Up @@ -311,11 +311,11 @@ ifeq ($(strip $(RGBLIGHT_ENABLE)), yes)
POST_CONFIG_H += $(QUANTUM_DIR)/rgblight/rgblight_post_config.h
OPT_DEFS += -DRGBLIGHT_ENABLE
OPT_DEFS += -DRGBLIGHT_$(strip $(shell echo $(RGBLIGHT_DRIVER) | tr '[:lower:]' '[:upper:]'))
SRC += $(QUANTUM_DIR)/process_keycode/process_underglow.c
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgblight/rgblight.c
SRC += $(QUANTUM_DIR)/rgblight/rgblight_drivers.c
CIE1931_CURVE := yes
RGB_KEYCODES_ENABLE := yes
endif

ifeq ($(strip $(RGBLIGHT_DRIVER)), ws2812)
Expand Down Expand Up @@ -461,12 +461,12 @@ 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
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb_matrix.c
SRC += $(QUANTUM_DIR)/color.c
SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix.c
SRC += $(QUANTUM_DIR)/rgb_matrix/rgb_matrix_drivers.c
LIB8TION_ENABLE := yes
CIE1931_CURVE := yes
RGB_KEYCODES_ENABLE := yes

ifeq ($(strip $(RGB_MATRIX_DRIVER)), aw20216s)
SPI_DRIVER_REQUIRED = yes
Expand Down Expand Up @@ -569,10 +569,6 @@ ifeq ($(strip $(RGB_MATRIX_ENABLE)), yes)
endif
endif

ifeq ($(strip $(RGB_KEYCODES_ENABLE)), yes)
SRC += $(QUANTUM_DIR)/process_keycode/process_rgb.c
endif

VARIABLE_TRACE ?= no
ifneq ($(strip $(VARIABLE_TRACE)),no)
SRC += $(QUANTUM_DIR)/variable_trace.c
Expand Down
46 changes: 16 additions & 30 deletions docs/feature_rgb_matrix.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,34 +575,21 @@ As mentioned earlier, the center of the keyboard by default is expected to be `{

## Keycodes :id=keycodes

All RGB keycodes are currently shared with the RGBLIGHT system:

|Key |Aliases |Description |
|-------------------|----------|--------------------------------------------------------------------------------------|
|`RGB_TOG` | |Toggle RGB lighting on or off |
|`RGB_MODE_FORWARD` |`RGB_MOD` |Cycle through modes, reverse direction when Shift is held |
|`RGB_MODE_REVERSE` |`RGB_RMOD`|Cycle through modes in reverse, forward direction when Shift is held |
|`RGB_HUI` | |Increase hue, decrease hue when Shift is held |
|`RGB_HUD` | |Decrease hue, increase hue when Shift is held |
|`RGB_SAI` | |Increase saturation, decrease saturation when Shift is held |
|`RGB_SAD` | |Decrease saturation, increase saturation when Shift is held |
|`RGB_VAI` | |Increase value (brightness), decrease value when Shift is held |
|`RGB_VAD` | |Decrease value (brightness), increase value when Shift is held |
|`RGB_SPI` | |Increase effect speed (does not support eeprom yet), decrease speed when Shift is held|
|`RGB_SPD` | |Decrease effect speed (does not support eeprom yet), increase speed when Shift is held|
|`RGB_MODE_PLAIN` |`RGB_M_P` |Static (no animation) mode |
|`RGB_MODE_BREATHE` |`RGB_M_B` |Breathing animation mode |
|`RGB_MODE_RAINBOW` |`RGB_M_R` |Full gradient scrolling left to right (uses the `RGB_MATRIX_CYCLE_LEFT_RIGHT` mode) |
|`RGB_MODE_SWIRL` |`RGB_M_SW`|Full gradient spinning pinwheel around center of keyboard (uses `RGB_MATRIX_CYCLE_PINWHEEL` mode) |

* `RGB_MODE_*` keycodes will generally work, but not all of the modes are currently mapped to the correct effects for the RGB Matrix system.

`RGB_MODE_PLAIN`, `RGB_MODE_BREATHE`, `RGB_MODE_RAINBOW`, and `RGB_MODE_SWIRL` are the only ones that are mapped properly. The rest don't have a direct equivalent, and are not mapped.

?> `RGB_*` keycodes cannot be used with functions like `tap_code16(RGB_HUD)` as they're not USB HID keycodes. If you wish to replicate similar behaviour in custom code within your firmware (e.g. inside `encoder_update_user()` or `process_record_user()`), the equivalent [RGB functions](#functions) should be used instead.


!> By default, if you have both the [RGB Light](feature_rgblight.md) and the RGB Matrix feature enabled, these keycodes will work for both features, at the same time. You can disable the keycode functionality by defining the `*_DISABLE_KEYCODES` option for the specific feature.
|Key |Aliases |Description |
|-------------------------------|---------|-----------------------------------|
|`QK_RGB_MATRIX_ON` |`RM_ON` |Turn on RGB Matrix |
|`QK_RGB_MATRIX_OFF` |`RM_OFF` |Turn off RGB Matrix |
|`QK_RGB_MATRIX_TOGGLE` |`RM_TOGG`|Toggle RGB Matrix on or off |
|`QK_RGB_MATRIX_MODE_NEXT` |`RM_NEXT`|Cycle through animations |
|`QK_RGB_MATRIX_MODE_PREVIOUS` |`RM_PREV`|Cycle through animations in reverse|
|`QK_RGB_MATRIX_HUE_UP` |`RM_HUEU`|Cycle through hue |
|`QK_RGB_MATRIX_HUE_DOWN` |`RM_HUED`|Cycle through hue in reverse |
|`QK_RGB_MATRIX_SATURATION_UP` |`RM_SATU`|Increase the saturation |
|`QK_RGB_MATRIX_SATURATION_DOWN`|`RM_SATD`|Decrease the saturation |
|`QK_RGB_MATRIX_VALUE_UP` |`RM_VALU`|Increase the brightness level |
|`QK_RGB_MATRIX_VALUE_DOWN` |`RM_VALD`|Decrease the brightness level |
|`QK_RGB_MATRIX_SPEED_UP` |`RM_SPDU`|Increase the animation speed |
|`QK_RGB_MATRIX_SPEED_DOWN` |`RM_SPDD`|Decrease the animation speed |

## RGB Matrix Effects :id=rgb-matrix-effects

Expand Down Expand Up @@ -775,7 +762,7 @@ Solid reactive effects will pulse RGB light on key presses with user configurabl
#define RGB_MATRIX_SOLID_REACTIVE_GRADIENT_MODE
```

Gradient mode will loop through the color wheel hues over time and its duration can be controlled with the effect speed keycodes (`RGB_SPI`/`RGB_SPD`).
Gradient mode will loop through the color wheel hues over time and its duration can be controlled with the effect speed keycodes (`RM_SPDU`/`RM_SPDD`).

## Custom RGB Matrix Effects :id=custom-rgb-matrix-effects

Expand Down Expand Up @@ -880,7 +867,6 @@ These are defined in [`color.h`](https://github.com/qmk/qmk_firmware/blob/master
#define RGB_MATRIX_DEFAULT_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
#define RGB_MATRIX_DEFAULT_SPD 127 // Sets the default animation speed, if none has been set
#define RGB_MATRIX_DEFAULT_FLAGS LED_FLAG_ALL // Sets the default LED flags, if none has been set
#define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
#define RGB_MATRIX_SPLIT { X, Y } // (Optional) For split keyboards, the number of LEDs connected on each half. X = left, Y = Right.
// If reactive effects are enabled, you also will want to enable SPLIT_TRANSPORT_MIRROR
#define RGB_TRIGGER_ON_KEYDOWN // Triggers RGB keypress events on key down. This makes RGB control feel more responsive. This may cause RGB to not function properly on some boards
Expand Down
4 changes: 0 additions & 4 deletions docs/feature_rgblight.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,9 +81,6 @@ Changing the **Value** sets the overall brightness.<br>

?> `RGB_*` keycodes cannot be used with functions like `tap_code16(RGB_HUI)` as they're not USB HID keycodes. If you wish to replicate similar behaviour in custom code within your firmware (e.g. inside `encoder_update_user()` or `process_record_user()`), the equivalent [RGB functions](#functions) should be used instead.


!> By default, if you have both the RGB Light and the [RGB Matrix](feature_rgb_matrix.md) feature enabled, these keycodes will work for both features, at the same time. You can disable the keycode functionality by defining the `*_DISABLE_KEYCODES` option for the specific feature.

## Configuration

Your RGB lighting can be configured by placing these `#define`s in your `config.h`:
Expand All @@ -96,7 +93,6 @@ Your RGB lighting can be configured by placing these `#define`s in your `config.
|`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level |
|`RGBLIGHT_SLEEP` |*Not defined* |If defined, the RGB lighting will be switched off when the host goes to sleep |
|`RGBLIGHT_SPLIT` |*Not defined* |If defined, synchronization functionality for split keyboards is added |
|`RGBLIGHT_DISABLE_KEYCODES`|*Not defined* |If defined, disables the ability to control RGB Light from the keycodes. You must use code functions to control the feature|
|`RGBLIGHT_DEFAULT_MODE` |`RGBLIGHT_MODE_STATIC_LIGHT`|The default mode to use upon clearing the EEPROM |
|`RGBLIGHT_DEFAULT_HUE` |`0` (red) |The default hue to use upon clearing the EEPROM |
|`RGBLIGHT_DEFAULT_SAT` |`UINT8_MAX` (255) |The default saturation to use upon clearing the EEPROM |
Expand Down
36 changes: 19 additions & 17 deletions docs/keycodes.md
Original file line number Diff line number Diff line change
Expand Up @@ -722,23 +722,25 @@ See also: [RGB Lighting](feature_rgblight.md)
|`RGB_MODE_GRADIENT`|`RGB_M_G` |Static gradient animation mode |
|`RGB_MODE_RGBTEST` |`RGB_M_T` |Red,Green,Blue test animation mode |

## RGB Matrix Lighting :id=rgb-matrix-lighting

See also: [RGB Matrix Lighting](feature_rgb_matrix.md)

|Key |Aliases |Description |
|-------------------|----------|--------------------------------------------------------------------------------------|
|`RGB_TOG` | |Toggle RGB lighting on or off |
|`RGB_MODE_FORWARD` |`RGB_MOD` |Cycle through modes, reverse direction when Shift is held |
|`RGB_MODE_REVERSE` |`RGB_RMOD`|Cycle through modes in reverse, forward direction when Shift is held |
|`RGB_HUI` | |Increase hue, decrease hue when Shift is held |
|`RGB_HUD` | |Decrease hue, increase hue when Shift is held |
|`RGB_SAI` | |Increase saturation, decrease saturation when Shift is held |
|`RGB_SAD` | |Decrease saturation, increase saturation when Shift is held |
|`RGB_VAI` | |Increase value (brightness), decrease value when Shift is held |
|`RGB_VAD` | |Decrease value (brightness), increase value when Shift is held |
|`RGB_SPI` | |Increase effect speed (does not support eeprom yet), decrease speed when Shift is held|
|`RGB_SPD` | |Decrease effect speed (does not support eeprom yet), increase speed when Shift is held|
## RGB Matrix :id=rgb-matrix

See also: [RGB Matrix](feature_rgb_matrix.md)

|Key |Aliases |Description |
|-------------------------------|---------|-----------------------------------|
|`QK_RGB_MATRIX_ON` |`RM_ON` |Turn on RGB Matrix |
|`QK_RGB_MATRIX_OFF` |`RM_OFF` |Turn off RGB Matrix |
|`QK_RGB_MATRIX_TOGGLE` |`RM_TOGG`|Toggle RGB Matrix on or off |
|`QK_RGB_MATRIX_MODE_NEXT` |`RM_NEXT`|Cycle through animations |
|`QK_RGB_MATRIX_MODE_PREVIOUS` |`RM_PREV`|Cycle through animations in reverse|
|`QK_RGB_MATRIX_HUE_UP` |`RM_HUEU`|Cycle through hue |
|`QK_RGB_MATRIX_HUE_DOWN` |`RM_HUED`|Cycle through hue in reverse |
|`QK_RGB_MATRIX_SATURATION_UP` |`RM_SATU`|Increase the saturation |
|`QK_RGB_MATRIX_SATURATION_DOWN`|`RM_SATD`|Decrease the saturation |
|`QK_RGB_MATRIX_VALUE_UP` |`RM_VALU`|Increase the brightness level |
|`QK_RGB_MATRIX_VALUE_DOWN` |`RM_VALD`|Decrease the brightness level |
|`QK_RGB_MATRIX_SPEED_UP` |`RM_SPDU`|Increase the animation speed |
|`QK_RGB_MATRIX_SPEED_DOWN` |`RM_SPDD`|Decrease the animation speed |

## US ANSI Shifted Symbols :id=us-ansi-shifted-symbols

Expand Down
4 changes: 2 additions & 2 deletions keyboards/1k/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@

const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
[0] = LAYOUT_ortho_1x1(
RGB_HUI
UG_HUEU
)
};
bool process_record_user(uint16_t keycode, keyrecord_t *record) {
if (record->event.pressed) {
switch (keycode) {
case RGB_HUI:
case QK_UNDERGLOW_HUE_UP:
rgblite_increase_hue();
break;
}
Expand Down
8 changes: 4 additions & 4 deletions keyboards/25keys/zinc/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
*/
[_ADJUST] = LAYOUT_ortho_4x12(
_______, QK_BOOT, RGBRST, _______, _______, _______, _______, QWERTY, COLEMAK, DVORAK, _______, KC_INS,
_______, RGB_TOG, RGB_HUI, RGB_SAI, RGB_VAI, AG_NORM, AG_SWAP, KC_MINS, KC_EQL, KC_PSCR, KC_SCRL, KC_PAUS,
RGB_RMOD,RGB_MOD, RGB_HUD, RGB_SAD, RGB_VAD, _______, _______, _______, _______, _______, KC_PGUP, _______,
_______, UG_TOGG, UG_HUEU, UG_SATU, UG_VALU, AG_NORM, AG_SWAP, KC_MINS, KC_EQL, KC_PSCR, KC_SCRL, KC_PAUS,
UG_PREV, UG_NEXT, UG_HUED, UG_SATD, UG_VALD, _______, _______, _______, _______, _______, KC_PGUP, _______,
_______, _______, _______, EISU, EISU, EISU, KANA, KANA, KANA, KC_HOME, KC_PGDN, KC_END
)
};
Expand Down Expand Up @@ -246,7 +246,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
break;

//led operations - RGB mode change now updates the RGB_current_mode to allow the right RGB mode to be set after reactive keys are released
case RGB_RMOD:
case QK_UNDERGLOW_MODE_PREVIOUS:
#if defined(RGBLIGHT_ENABLE)
if (record->event.pressed) {
rgblight_mode_noeeprom(RGB_current_config.mode);
Expand All @@ -257,7 +257,7 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) {
#endif
break;

case RGB_MOD:
case QK_UNDERGLOW_MODE_NEXT:
#if defined(RGBLIGHT_ENABLE)
if (record->event.pressed) {
rgblight_mode_noeeprom(RGB_current_config.mode);
Expand Down
2 changes: 1 addition & 1 deletion keyboards/akko/5087/5087.c
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ bool process_record_kb(uint16_t keycode, keyrecord_t* record) {
eeconfig_update_keymap(keymap_config.raw);
}
return false;
case RGB_TOG:
case QK_RGB_MATRIX_TOGGLE:
if (record->event.pressed) {
switch (rgb_matrix_get_flags()) {
case LED_FLAG_ALL: {
Expand Down
20 changes: 10 additions & 10 deletions keyboards/akko/5087/keymaps/default/keymap.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,11 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {

[WIN_FN] = LAYOUT_tkl_ansi( /* FN */
_______, KC_MYCM, KC_MAIL, KC_WSCH, KC_WHOM, KC_MSEL, KC_MPLY, KC_MPRV, KC_MNXT, _______,_______, _______, _______, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, _______, _______, _______,
_______, _______,TG(WIN_W),_______, _______, _______, _______, _______, _______, DF(MAC_B),_______,_______, _______, RGB_MOD, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, _______, _______, RGB_HUI,
_______, _______, _______, KC_CALC, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_VAI,
_______, GU_TOGG, _______, _______, _______, _______, _______, _______, RGB_SAD, RGB_VAD, RGB_SAI),
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_SPDD, RM_SPDU, _______, _______, _______, _______,
_______, _______,TG(WIN_W),_______, _______, _______, _______, _______, _______, DF(MAC_B),_______,_______, _______, RM_NEXT, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, RM_TOGG, _______, _______, RM_HUEU,
_______, _______, _______, KC_CALC, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RM_VALU,
_______, GU_TOGG, _______, _______, _______, _______, _______, _______, RM_SATD, RM_VALD, RM_SATU),

[MAC_B] = LAYOUT_tkl_ansi( /* Base */
KC_ESC, KC_BRID, KC_BRIU, KC_MCTL, KC_LPAD, KC_F5, KC_F6, KC_MPRV, KC_MPLY, KC_MNXT, KC_MUTE, KC_VOLD, KC_VOLU, KC_PSCR, KC_SCRL, KC_PAUS,
Expand All @@ -70,10 +70,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = {
_______, _______, _______, _______, _______, _______, MO(MAC_FN), _______, KC_A, KC_S, KC_D),
[MAC_FN] = LAYOUT_tkl_ansi( /* FN */
KC_ESC, KC_F1, KC_F2, KC_F3, KC_F4, _______, _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_SPD, RGB_SPI, _______, _______, _______, _______,
_______, _______,TG(MAC_W),_______, _______, _______, _______, _______, _______, DF(WIN_B),_______,_______, _______, RGB_MOD, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, RGB_TOG, _______, _______, RGB_HUI,
_______, _______, _______, KC_CALC, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RGB_VAI,
_______, _______, _______, _______, _______, _______, _______, _______, RGB_SAD, RGB_VAD, RGB_SAI)
_______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, RM_SPDD, RM_SPDU, _______, _______, _______, _______,
_______, _______,TG(MAC_W),_______, _______, _______, _______, _______, _______, DF(WIN_B),_______,_______, _______, RM_NEXT, _______, _______, _______,
_______, _______, _______, _______, _______, _______, _______, _______, _______, RM_TOGG, _______, _______, RM_HUEU,
_______, _______, _______, KC_CALC, _______, _______, _______, KC_MUTE, KC_VOLD, KC_VOLU, _______, _______, RM_VALU,
_______, _______, _______, _______, _______, _______, _______, _______, RM_SATD, RM_VALD, RM_SATU)
};
// clang-format on
Loading
Loading