diff options
| author | Ryan <fauxpark@gmail.com> | 2024-06-13 21:59:46 +1000 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-06-13 21:59:46 +1000 |
| commit | c4a74be7f02ec64033638e93a49924df20fb2e57 (patch) | |
| tree | 316591afc43709e873dea3f6733454f1f37d1194 /quantum/process_keycode/process_rgb_matrix.c | |
| parent | dafbb92f4ea851a498bec2edd35cede469ee9504 (diff) | |
Add process_keycode handlers for new RGB Matrix and Underglow keycodes (#23896)
Diffstat (limited to 'quantum/process_keycode/process_rgb_matrix.c')
| -rw-r--r-- | quantum/process_keycode/process_rgb_matrix.c | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/quantum/process_keycode/process_rgb_matrix.c b/quantum/process_keycode/process_rgb_matrix.c new file mode 100644 index 0000000000..fd2aa1a0c7 --- /dev/null +++ b/quantum/process_keycode/process_rgb_matrix.c | |||
| @@ -0,0 +1,101 @@ | |||
| 1 | // Copyright 2024 QMK | ||
| 2 | // SPDX-License-Identifier: GPL-2.0-or-later | ||
| 3 | |||
| 4 | #include "process_rgb_matrix.h" | ||
| 5 | #include "rgb_matrix.h" | ||
| 6 | #include "action_util.h" | ||
| 7 | #include "keycodes.h" | ||
| 8 | #include "modifiers.h" | ||
| 9 | |||
| 10 | bool process_rgb_matrix(uint16_t keycode, keyrecord_t *record) { | ||
| 11 | #ifdef RGB_TRIGGER_ON_KEYDOWN | ||
| 12 | if (record->event.pressed) { | ||
| 13 | #else | ||
| 14 | if (!record->event.pressed) { | ||
| 15 | #endif | ||
| 16 | bool shifted = get_mods() & MOD_MASK_SHIFT; | ||
| 17 | switch (keycode) { | ||
| 18 | case QK_RGB_MATRIX_ON: | ||
| 19 | rgb_matrix_enable(); | ||
| 20 | return false; | ||
| 21 | case QK_RGB_MATRIX_OFF: | ||
| 22 | rgb_matrix_disable(); | ||
| 23 | return false; | ||
| 24 | case QK_RGB_MATRIX_TOGGLE: | ||
| 25 | rgb_matrix_toggle(); | ||
| 26 | return false; | ||
| 27 | case QK_RGB_MATRIX_MODE_NEXT: | ||
| 28 | if (shifted) { | ||
| 29 | rgb_matrix_step_reverse(); | ||
| 30 | } else { | ||
| 31 | rgb_matrix_step(); | ||
| 32 | } | ||
| 33 | return false; | ||
| 34 | case QK_RGB_MATRIX_MODE_PREVIOUS: | ||
| 35 | if (shifted) { | ||
| 36 | rgb_matrix_step(); | ||
| 37 | } else { | ||
| 38 | rgb_matrix_step_reverse(); | ||
| 39 | } | ||
| 40 | return false; | ||
| 41 | case QK_RGB_MATRIX_HUE_UP: | ||
| 42 | if (shifted) { | ||
| 43 | rgb_matrix_decrease_hue(); | ||
| 44 | } else { | ||
| 45 | rgb_matrix_increase_hue(); | ||
| 46 | } | ||
| 47 | return false; | ||
| 48 | case QK_RGB_MATRIX_HUE_DOWN: | ||
| 49 | if (shifted) { | ||
| 50 | rgb_matrix_increase_hue(); | ||
| 51 | } else { | ||
| 52 | rgb_matrix_decrease_hue(); | ||
| 53 | } | ||
| 54 | return false; | ||
| 55 | case QK_RGB_MATRIX_SATURATION_UP: | ||
| 56 | if (shifted) { | ||
| 57 | rgb_matrix_decrease_sat(); | ||
| 58 | } else { | ||
| 59 | rgb_matrix_increase_sat(); | ||
| 60 | } | ||
| 61 | return false; | ||
| 62 | case QK_RGB_MATRIX_SATURATION_DOWN: | ||
| 63 | if (shifted) { | ||
| 64 | rgb_matrix_increase_sat(); | ||
| 65 | } else { | ||
| 66 | rgb_matrix_decrease_sat(); | ||
| 67 | } | ||
| 68 | return false; | ||
| 69 | case QK_RGB_MATRIX_VALUE_UP: | ||
| 70 | if (shifted) { | ||
| 71 | rgb_matrix_decrease_val(); | ||
| 72 | } else { | ||
| 73 | rgb_matrix_increase_val(); | ||
| 74 | } | ||
| 75 | return false; | ||
| 76 | case QK_RGB_MATRIX_VALUE_DOWN: | ||
| 77 | if (shifted) { | ||
| 78 | rgb_matrix_increase_val(); | ||
| 79 | } else { | ||
| 80 | rgb_matrix_decrease_val(); | ||
| 81 | } | ||
| 82 | return false; | ||
| 83 | case QK_RGB_MATRIX_SPEED_UP: | ||
| 84 | if (shifted) { | ||
| 85 | rgb_matrix_decrease_speed(); | ||
| 86 | } else { | ||
| 87 | rgb_matrix_increase_speed(); | ||
| 88 | } | ||
| 89 | return false; | ||
| 90 | case QK_RGB_MATRIX_SPEED_DOWN: | ||
| 91 | if (shifted) { | ||
| 92 | rgb_matrix_increase_speed(); | ||
| 93 | } else { | ||
| 94 | rgb_matrix_decrease_speed(); | ||
| 95 | } | ||
| 96 | return false; | ||
| 97 | } | ||
| 98 | } | ||
| 99 | |||
| 100 | return true; | ||
| 101 | } | ||
