aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDrashna Jaelre <drashna@live.com>2020-06-22 01:38:58 -0700
committerGitHub <noreply@github.com>2020-06-22 09:38:58 +0100
commit98642ca02878741531105bd879c0d61110198b62 (patch)
treebefd24e847255379c60f9c77df53072245fa6b7b
parent82dc8faaf30a6b77ec715852c3841fde087b6b07 (diff)
downloadqmk_firmware-98642ca02878741531105bd879c0d61110198b62.tar.gz
qmk_firmware-98642ca02878741531105bd879c0d61110198b62.zip
Improve keycode handling for RGB (#7677)
Co-authored-by: drashna <drashna@live.com> Co-authored-by: noroadsleft <18669334+noroadsleft@users.noreply.github.com>
-rw-r--r--docs/feature_rgb_matrix.md11
-rw-r--r--docs/feature_rgblight.md4
-rw-r--r--quantum/process_keycode/process_rgb.c85
3 files changed, 91 insertions, 9 deletions
diff --git a/docs/feature_rgb_matrix.md b/docs/feature_rgb_matrix.md
index a4f434cbd..9604bdcc8 100644
--- a/docs/feature_rgb_matrix.md
+++ b/docs/feature_rgb_matrix.md
@@ -186,8 +186,16 @@ All RGB keycodes are currently shared with the RGBLIGHT system:
186|`RGB_VAD` | |Decrease value (brightness), increase value when Shift is held | 186|`RGB_VAD` | |Decrease value (brightness), increase value when Shift is held |
187|`RGB_SPI` | |Increase effect speed (does not support eeprom yet), decrease speed when Shift is held| 187|`RGB_SPI` | |Increase effect speed (does not support eeprom yet), decrease speed when Shift is held|
188|`RGB_SPD` | |Decrease effect speed (does not support eeprom yet), increase speed when Shift is held| 188|`RGB_SPD` | |Decrease effect speed (does not support eeprom yet), increase speed when Shift is held|
189|`RGB_MODE_PLAIN` |`RGB_M_P `|Static (no animation) mode |
190|`RGB_MODE_BREATHE` |`RGB_M_B` |Breathing animation mode |
191|`RGB_MODE_RAINBOW` |`RGB_M_R` |Full gradient scrolling left to right (uses the `RGB_MATRIX_CYCLE_LEFT_RIGHT` mode) |
192|`RGB_MODE_SWIRL` |`RGB_M_SW`|Full gradient spinning pinwheel around center of keyboard (uses `RGB_MATRIX_CYCLE_PINWHEEL` mode) |
189 193
190* `RGB_MODE_*` keycodes will generally work, but are not currently mapped to the correct effects for the RGB Matrix system 194* `RGB_MODE_*` keycodes will generally work, but not all of the modes are currently mapped to the correct effects for the RGB Matrix system.
195
196`RGB_MODE_PLAIN`, `RGB_MODE_BREATHE`, `RGB_MODE_RAINBOW`, and `RGB_MATRIX_SWIRL` are the only ones that are mapped properly. The rest don't have a direct equivalent, and are not mapped.
197
198!> 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.
191 199
192## RGB Matrix Effects :id=rgb-matrix-effects 200## RGB Matrix Effects :id=rgb-matrix-effects
193 201
@@ -385,6 +393,7 @@ These are defined in [`rgblight_list.h`](https://github.com/qmk/qmk_firmware/blo
385#define RGB_MATRIX_STARTUP_SAT 255 // Sets the default saturation value, if none has been set 393#define RGB_MATRIX_STARTUP_SAT 255 // Sets the default saturation value, if none has been set
386#define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set 394#define RGB_MATRIX_STARTUP_VAL RGB_MATRIX_MAXIMUM_BRIGHTNESS // Sets the default brightness value, if none has been set
387#define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set 395#define RGB_MATRIX_STARTUP_SPD 127 // Sets the default animation speed, if none has been set
396#define RGB_MATRIX_DISABLE_KEYCODES // disables control of rgb matrix by keycodes (must use code functions to control the feature)
388``` 397```
389 398
390## EEPROM storage :id=eeprom-storage 399## EEPROM storage :id=eeprom-storage
diff --git a/docs/feature_rgblight.md b/docs/feature_rgblight.md
index 5921e9941..a81b50e82 100644
--- a/docs/feature_rgblight.md
+++ b/docs/feature_rgblight.md
@@ -64,6 +64,9 @@ Changing the **Value** sets the overall brightness.<br>
64|`RGB_MODE_GRADIENT`|`RGB_M_G` |Static gradient animation mode | 64|`RGB_MODE_GRADIENT`|`RGB_M_G` |Static gradient animation mode |
65|`RGB_MODE_RGBTEST` |`RGB_M_T` |Red, Green, Blue test animation mode | 65|`RGB_MODE_RGBTEST` |`RGB_M_T` |Red, Green, Blue test animation mode |
66 66
67!> 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.
68
69
67## Configuration 70## Configuration
68 71
69Your RGB lighting can be configured by placing these `#define`s in your `config.h`: 72Your RGB lighting can be configured by placing these `#define`s in your `config.h`:
@@ -76,6 +79,7 @@ Your RGB lighting can be configured by placing these `#define`s in your `config.
76|`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level | 79|`RGBLIGHT_LIMIT_VAL` |`255` |The maximum brightness level |
77|`RGBLIGHT_SLEEP` |*Not defined*|If defined, the RGB lighting will be switched off when the host goes to sleep| 80|`RGBLIGHT_SLEEP` |*Not defined*|If defined, the RGB lighting will be switched off when the host goes to sleep|
78|`RGBLIGHT_SPLIT` |*Not defined*|If defined, synchronization functionality for split keyboards is added| 81|`RGBLIGHT_SPLIT` |*Not defined*|If defined, synchronization functionality for split keyboards is added|
82|`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|
79 83
80## Effects and Animations 84## Effects and Animations
81 85
diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c
index 21164b8f9..a1e46e034 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) {
59 uint8_t shifted = get_mods() & MOD_MASK_SHIFT; 59 uint8_t shifted = get_mods() & MOD_MASK_SHIFT;
60 switch (keycode) { 60 switch (keycode) {
61 case RGB_TOG: 61 case RGB_TOG:
62#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
62 rgblight_toggle(); 63 rgblight_toggle();
64#endif
65#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
66 rgb_matrix_toggle();
67#endif
63 return false; 68 return false;
64 case RGB_MODE_FORWARD: 69 case RGB_MODE_FORWARD:
70#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
65 handleKeycodeRGB(shifted, rgblight_step, rgblight_step_reverse); 71 handleKeycodeRGB(shifted, rgblight_step, rgblight_step_reverse);
72#endif
73#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
74 handleKeycodeRGB(shifted, rgb_matrix_step, rgb_matrix_step_reverse);
75#endif
66 return false; 76 return false;
67 case RGB_MODE_REVERSE: 77 case RGB_MODE_REVERSE:
78#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
68 handleKeycodeRGB(shifted, rgblight_step_reverse, rgblight_step); 79 handleKeycodeRGB(shifted, rgblight_step_reverse, rgblight_step);
80#endif
81#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
82 handleKeycodeRGB(shifted, rgb_matrix_step_reverse, rgb_matrix_step);
83#endif
69 return false; 84 return false;
70 case RGB_HUI: 85 case RGB_HUI:
86#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
71 handleKeycodeRGB(shifted, rgblight_increase_hue, rgblight_decrease_hue); 87 handleKeycodeRGB(shifted, rgblight_increase_hue, rgblight_decrease_hue);
88#endif
89#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
90 handleKeycodeRGB(shifted, rgb_matrix_increase_hue, rgb_matrix_decrease_hue);
91#endif
72 return false; 92 return false;
73 case RGB_HUD: 93 case RGB_HUD:
94#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
74 handleKeycodeRGB(shifted, rgblight_decrease_hue, rgblight_increase_hue); 95 handleKeycodeRGB(shifted, rgblight_decrease_hue, rgblight_increase_hue);
96#endif
97#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
98 handleKeycodeRGB(shifted, rgb_matrix_decrease_hue, rgb_matrix_increase_hue);
99#endif
75 return false; 100 return false;
76 case RGB_SAI: 101 case RGB_SAI:
102#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
77 handleKeycodeRGB(shifted, rgblight_increase_sat, rgblight_decrease_sat); 103 handleKeycodeRGB(shifted, rgblight_increase_sat, rgblight_decrease_sat);
104#endif
105#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
106 handleKeycodeRGB(shifted, rgb_matrix_increase_sat, rgb_matrix_decrease_sat);
107#endif
78 return false; 108 return false;
79 case RGB_SAD: 109 case RGB_SAD:
110#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
80 handleKeycodeRGB(shifted, rgblight_decrease_sat, rgblight_increase_sat); 111 handleKeycodeRGB(shifted, rgblight_decrease_sat, rgblight_increase_sat);
112#endif
113#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
114 handleKeycodeRGB(shifted, rgb_matrix_decrease_sat, rgb_matrix_increase_sat);
115#endif
81 return false; 116 return false;
82 case RGB_VAI: 117 case RGB_VAI:
118#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
83 handleKeycodeRGB(shifted, rgblight_increase_val, rgblight_decrease_val); 119 handleKeycodeRGB(shifted, rgblight_increase_val, rgblight_decrease_val);
120#endif
121#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
122 handleKeycodeRGB(shifted, rgb_matrix_increase_val, rgb_matrix_decrease_val);
123#endif
84 return false; 124 return false;
85 case RGB_VAD: 125 case RGB_VAD:
126#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
86 handleKeycodeRGB(shifted, rgblight_decrease_val, rgblight_increase_val); 127 handleKeycodeRGB(shifted, rgblight_decrease_val, rgblight_increase_val);
128#endif
129#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
130 handleKeycodeRGB(shifted, rgb_matrix_decrease_val, rgb_matrix_increase_val);
131#endif
87 return false; 132 return false;
88 case RGB_SPI: 133 case RGB_SPI:
134#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
89 handleKeycodeRGB(shifted, rgblight_increase_speed, rgblight_decrease_speed); 135 handleKeycodeRGB(shifted, rgblight_increase_speed, rgblight_decrease_speed);
136#endif
137#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
138 handleKeycodeRGB(shifted, rgb_matrix_increase_speed, rgb_matrix_decrease_speed);
139#endif
90 return false; 140 return false;
91 case RGB_SPD: 141 case RGB_SPD:
142#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
92 handleKeycodeRGB(shifted, rgblight_decrease_speed, rgblight_increase_speed); 143 handleKeycodeRGB(shifted, rgblight_decrease_speed, rgblight_increase_speed);
144#endif
145#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
146 handleKeycodeRGB(shifted, rgb_matrix_decrease_speed, rgb_matrix_increase_speed);
147#endif
93 return false; 148 return false;
94 case RGB_MODE_PLAIN: 149 case RGB_MODE_PLAIN:
150#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES)
95 rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT); 151 rgblight_mode(RGBLIGHT_MODE_STATIC_LIGHT);
152#endif
153#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES)
154 rgb_matrix_mode(RGB_MATRIX_SOLID_COLOR);
155#endif
96 return false; 156 return false;
97 case RGB_MODE_BREATHE: 157 case RGB_MODE_BREATHE:
98#ifdef RGBLIGHT_EFFECT_BREATHING 158#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined(RGBLIGHT_EFFECT_BREATHING)
99 handleKeycodeRGBMode(RGBLIGHT_MODE_BREATHING, RGBLIGHT_MODE_BREATHING_end); 159 handleKeycodeRGBMode(RGBLIGHT_MODE_BREATHING, RGBLIGHT_MODE_BREATHING_end);
100#endif 160#endif
161#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_BREATHING)
162 rgb_matrix_mode(RGB_MATRIX_BREATHING);
163#endif
101 return false; 164 return false;
102 case RGB_MODE_RAINBOW: 165 case RGB_MODE_RAINBOW:
103#ifdef RGBLIGHT_EFFECT_RAINBOW_MOOD 166#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_MOOD)
104 handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end); 167 handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_MOOD, RGBLIGHT_MODE_RAINBOW_MOOD_end);
105#endif 168#endif
169#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_LEFT_RIGHT)
170 rgb_matrix_mode(RGB_MATRIX_CYCLE_LEFT_RIGHT);
171#endif
106 return false; 172 return false;
107 case RGB_MODE_SWIRL: 173 case RGB_MODE_SWIRL:
108#ifdef RGBLIGHT_EFFECT_RAINBOW_SWIRL 174#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RAINBOW_SWIRL)
109 handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end); 175 handleKeycodeRGBMode(RGBLIGHT_MODE_RAINBOW_SWIRL, RGBLIGHT_MODE_RAINBOW_SWIRL_end);
110#endif 176#endif
177#if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_KEYCODES) && !defined(DISABLE_RGB_MATRIX_CYCLE_PINWHEEL)
178 rgb_matrix_mode(RGB_MATRIX_CYCLE_PINWHEEL);
179#endif
111 return false; 180 return false;
112 case RGB_MODE_SNAKE: 181 case RGB_MODE_SNAKE:
113#ifdef RGBLIGHT_EFFECT_SNAKE 182#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_SNAKE)
114 handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end); 183 handleKeycodeRGBMode(RGBLIGHT_MODE_SNAKE, RGBLIGHT_MODE_SNAKE_end);
115#endif 184#endif
116 return false; 185 return false;
117 case RGB_MODE_KNIGHT: 186 case RGB_MODE_KNIGHT:
118#ifdef RGBLIGHT_EFFECT_KNIGHT 187#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_KNIGHT)
119 handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end); 188 handleKeycodeRGBMode(RGBLIGHT_MODE_KNIGHT, RGBLIGHT_MODE_KNIGHT_end);
120#endif 189#endif
121 return false; 190 return false;
122 case RGB_MODE_XMAS: 191 case RGB_MODE_XMAS:
123#ifdef RGBLIGHT_EFFECT_CHRISTMAS 192#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_CHRISTMAS)
124 rgblight_mode(RGBLIGHT_MODE_CHRISTMAS); 193 rgblight_mode(RGBLIGHT_MODE_CHRISTMAS);
125#endif 194#endif
126 return false; 195 return false;
127 case RGB_MODE_GRADIENT: 196 case RGB_MODE_GRADIENT:
128#ifdef RGBLIGHT_EFFECT_STATIC_GRADIENT 197#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_STATIC_GRADIENT)
129 handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end); 198 handleKeycodeRGBMode(RGBLIGHT_MODE_STATIC_GRADIENT, RGBLIGHT_MODE_STATIC_GRADIENT_end);
130#endif 199#endif
131 return false; 200 return false;
132 case RGB_MODE_RGBTEST: 201 case RGB_MODE_RGBTEST:
133#ifdef RGBLIGHT_EFFECT_RGB_TEST 202#if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) && defined( RGBLIGHT_EFFECT_RGB_TEST)
134 rgblight_mode(RGBLIGHT_MODE_RGB_TEST); 203 rgblight_mode(RGBLIGHT_MODE_RGB_TEST);
135#endif 204#endif
136 return false; 205 return false;