diff options
| author | Ryan <fauxpark@gmail.com> | 2024-11-20 09:53:33 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-11-20 09:53:33 +1100 |
| commit | 9c865839819bf9ec3ed573354a53bcbe905080f7 (patch) | |
| tree | 9b9b94bf3ec84ad3dcdac28949046180c55243d8 /quantum/process_keycode | |
| parent | e66fce38b232646111e6811a03133e557d897cba (diff) | |
Backward compatibility for new RGB keycode handling (#24490)
Co-authored-by: Dasky <32983009+daskygit@users.noreply.github.com>
Diffstat (limited to 'quantum/process_keycode')
| -rw-r--r-- | quantum/process_keycode/process_underglow.c | 119 |
1 files changed, 116 insertions, 3 deletions
diff --git a/quantum/process_keycode/process_underglow.c b/quantum/process_keycode/process_underglow.c index 779672ac07..6104cd02c6 100644 --- a/quantum/process_keycode/process_underglow.c +++ b/quantum/process_keycode/process_underglow.c | |||
| @@ -2,87 +2,200 @@ | |||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | 2 | // SPDX-License-Identifier: GPL-2.0-or-later |
| 3 | 3 | ||
| 4 | #include "process_underglow.h" | 4 | #include "process_underglow.h" |
| 5 | #include "rgblight.h" | 5 | #if defined(RGBLIGHT_ENABLE) |
| 6 | # include "rgblight.h" | ||
| 7 | #endif | ||
| 6 | #include "action_util.h" | 8 | #include "action_util.h" |
| 7 | #include "keycodes.h" | 9 | #include "keycodes.h" |
| 8 | #include "modifiers.h" | 10 | #include "modifiers.h" |
| 9 | 11 | ||
| 12 | // TODO: Remove this | ||
| 13 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 14 | # include "rgb_matrix.h" | ||
| 15 | #endif | ||
| 16 | |||
| 10 | bool process_underglow(uint16_t keycode, keyrecord_t *record) { | 17 | bool process_underglow(uint16_t keycode, keyrecord_t *record) { |
| 11 | if (record->event.pressed) { | 18 | if (record->event.pressed) { |
| 12 | uint8_t shifted = get_mods() & MOD_MASK_SHIFT; | 19 | uint8_t shifted = get_mods() & MOD_MASK_SHIFT; |
| 13 | switch (keycode) { | 20 | switch (keycode) { |
| 14 | case QK_UNDERGLOW_TOGGLE: | 21 | case QK_UNDERGLOW_TOGGLE: |
| 22 | #if defined(RGBLIGHT_ENABLE) | ||
| 15 | rgblight_toggle(); | 23 | rgblight_toggle(); |
| 24 | #endif | ||
| 25 | |||
| 26 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 27 | rgb_matrix_toggle(); | ||
| 28 | #endif | ||
| 16 | return false; | 29 | return false; |
| 17 | case QK_UNDERGLOW_MODE_NEXT: | 30 | case QK_UNDERGLOW_MODE_NEXT: |
| 31 | #if defined(RGBLIGHT_ENABLE) | ||
| 18 | if (shifted) { | 32 | if (shifted) { |
| 19 | rgblight_step_reverse(); | 33 | rgblight_step_reverse(); |
| 20 | } else { | 34 | } else { |
| 21 | rgblight_step(); | 35 | rgblight_step(); |
| 22 | } | 36 | } |
| 37 | #endif | ||
| 38 | |||
| 39 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 40 | if (shifted) { | ||
| 41 | rgb_matrix_step_reverse(); | ||
| 42 | } else { | ||
| 43 | rgb_matrix_step(); | ||
| 44 | } | ||
| 45 | #endif | ||
| 23 | return false; | 46 | return false; |
| 24 | case QK_UNDERGLOW_MODE_PREVIOUS: | 47 | case QK_UNDERGLOW_MODE_PREVIOUS: |
| 48 | #if defined(RGBLIGHT_ENABLE) | ||
| 25 | if (shifted) { | 49 | if (shifted) { |
| 26 | rgblight_step(); | 50 | rgblight_step(); |
| 27 | } else { | 51 | } else { |
| 28 | rgblight_step_reverse(); | 52 | rgblight_step_reverse(); |
| 29 | } | 53 | } |
| 54 | #endif | ||
| 55 | |||
| 56 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 57 | if (shifted) { | ||
| 58 | rgb_matrix_step(); | ||
| 59 | } else { | ||
| 60 | rgb_matrix_step_reverse(); | ||
| 61 | } | ||
| 62 | #endif | ||
| 30 | return false; | 63 | return false; |
| 31 | case QK_UNDERGLOW_HUE_UP: | 64 | case QK_UNDERGLOW_HUE_UP: |
| 65 | #if defined(RGBLIGHT_ENABLE) | ||
| 32 | if (shifted) { | 66 | if (shifted) { |
| 33 | rgblight_decrease_hue(); | 67 | rgblight_decrease_hue(); |
| 34 | } else { | 68 | } else { |
| 35 | rgblight_increase_hue(); | 69 | rgblight_increase_hue(); |
| 36 | } | 70 | } |
| 71 | #endif | ||
| 72 | |||
| 73 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 74 | if (shifted) { | ||
| 75 | rgb_matrix_decrease_hue(); | ||
| 76 | } else { | ||
| 77 | rgb_matrix_increase_hue(); | ||
| 78 | } | ||
| 79 | #endif | ||
| 37 | return false; | 80 | return false; |
| 38 | case QK_UNDERGLOW_HUE_DOWN: | 81 | case QK_UNDERGLOW_HUE_DOWN: |
| 82 | #if defined(RGBLIGHT_ENABLE) | ||
| 39 | if (shifted) { | 83 | if (shifted) { |
| 40 | rgblight_increase_hue(); | 84 | rgblight_increase_hue(); |
| 41 | } else { | 85 | } else { |
| 42 | rgblight_decrease_hue(); | 86 | rgblight_decrease_hue(); |
| 43 | } | 87 | } |
| 88 | #endif | ||
| 89 | |||
| 90 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 91 | if (shifted) { | ||
| 92 | rgb_matrix_increase_hue(); | ||
| 93 | } else { | ||
| 94 | rgb_matrix_decrease_hue(); | ||
| 95 | } | ||
| 96 | #endif | ||
| 44 | return false; | 97 | return false; |
| 45 | case QK_UNDERGLOW_SATURATION_UP: | 98 | case QK_UNDERGLOW_SATURATION_UP: |
| 99 | #if defined(RGBLIGHT_ENABLE) | ||
| 46 | if (shifted) { | 100 | if (shifted) { |
| 47 | rgblight_decrease_sat(); | 101 | rgblight_decrease_sat(); |
| 48 | } else { | 102 | } else { |
| 49 | rgblight_increase_sat(); | 103 | rgblight_increase_sat(); |
| 50 | } | 104 | } |
| 105 | #endif | ||
| 106 | |||
| 107 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 108 | if (shifted) { | ||
| 109 | rgb_matrix_decrease_sat(); | ||
| 110 | } else { | ||
| 111 | rgb_matrix_increase_sat(); | ||
| 112 | } | ||
| 113 | #endif | ||
| 51 | return false; | 114 | return false; |
| 52 | case QK_UNDERGLOW_SATURATION_DOWN: | 115 | case QK_UNDERGLOW_SATURATION_DOWN: |
| 116 | #if defined(RGBLIGHT_ENABLE) | ||
| 53 | if (shifted) { | 117 | if (shifted) { |
| 54 | rgblight_increase_sat(); | 118 | rgblight_increase_sat(); |
| 55 | } else { | 119 | } else { |
| 56 | rgblight_decrease_sat(); | 120 | rgblight_decrease_sat(); |
| 57 | } | 121 | } |
| 122 | #endif | ||
| 123 | |||
| 124 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 125 | if (shifted) { | ||
| 126 | rgb_matrix_increase_sat(); | ||
| 127 | } else { | ||
| 128 | rgb_matrix_decrease_sat(); | ||
| 129 | } | ||
| 130 | #endif | ||
| 58 | return false; | 131 | return false; |
| 59 | case QK_UNDERGLOW_VALUE_UP: | 132 | case QK_UNDERGLOW_VALUE_UP: |
| 133 | #if defined(RGBLIGHT_ENABLE) | ||
| 60 | if (shifted) { | 134 | if (shifted) { |
| 61 | rgblight_decrease_val(); | 135 | rgblight_decrease_val(); |
| 62 | } else { | 136 | } else { |
| 63 | rgblight_increase_val(); | 137 | rgblight_increase_val(); |
| 64 | } | 138 | } |
| 139 | #endif | ||
| 140 | |||
| 141 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 142 | if (shifted) { | ||
| 143 | rgb_matrix_decrease_val(); | ||
| 144 | } else { | ||
| 145 | rgb_matrix_increase_val(); | ||
| 146 | } | ||
| 147 | #endif | ||
| 65 | return false; | 148 | return false; |
| 66 | case QK_UNDERGLOW_VALUE_DOWN: | 149 | case QK_UNDERGLOW_VALUE_DOWN: |
| 150 | #if defined(RGBLIGHT_ENABLE) | ||
| 67 | if (shifted) { | 151 | if (shifted) { |
| 68 | rgblight_increase_hue(); | 152 | rgblight_increase_val(); |
| 69 | } else { | 153 | } else { |
| 70 | rgblight_decrease_hue(); | 154 | rgblight_decrease_val(); |
| 71 | } | 155 | } |
| 156 | #endif | ||
| 157 | |||
| 158 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 159 | if (shifted) { | ||
| 160 | rgb_matrix_increase_val(); | ||
| 161 | } else { | ||
| 162 | rgb_matrix_decrease_val(); | ||
| 163 | } | ||
| 164 | #endif | ||
| 72 | return false; | 165 | return false; |
| 73 | case QK_UNDERGLOW_SPEED_UP: | 166 | case QK_UNDERGLOW_SPEED_UP: |
| 167 | #if defined(RGBLIGHT_ENABLE) | ||
| 74 | if (shifted) { | 168 | if (shifted) { |
| 75 | rgblight_decrease_speed(); | 169 | rgblight_decrease_speed(); |
| 76 | } else { | 170 | } else { |
| 77 | rgblight_increase_speed(); | 171 | rgblight_increase_speed(); |
| 78 | } | 172 | } |
| 173 | #endif | ||
| 174 | |||
| 175 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 176 | if (shifted) { | ||
| 177 | rgb_matrix_decrease_speed(); | ||
| 178 | } else { | ||
| 179 | rgb_matrix_increase_speed(); | ||
| 180 | } | ||
| 181 | #endif | ||
| 79 | return false; | 182 | return false; |
| 80 | case QK_UNDERGLOW_SPEED_DOWN: | 183 | case QK_UNDERGLOW_SPEED_DOWN: |
| 184 | #if defined(RGBLIGHT_ENABLE) | ||
| 81 | if (shifted) { | 185 | if (shifted) { |
| 82 | rgblight_increase_speed(); | 186 | rgblight_increase_speed(); |
| 83 | } else { | 187 | } else { |
| 84 | rgblight_decrease_speed(); | 188 | rgblight_decrease_speed(); |
| 85 | } | 189 | } |
| 190 | #endif | ||
| 191 | |||
| 192 | #if defined(RGB_MATRIX_ENABLE) && !defined(RGB_MATRIX_DISABLE_SHARED_KEYCODES) | ||
| 193 | if (shifted) { | ||
| 194 | rgb_matrix_increase_speed(); | ||
| 195 | } else { | ||
| 196 | rgb_matrix_decrease_speed(); | ||
| 197 | } | ||
| 198 | #endif | ||
| 86 | return false; | 199 | return false; |
| 87 | } | 200 | } |
| 88 | } | 201 | } |
