From 224ff1d262402a48d1d04912be10d22074d78ced Mon Sep 17 00:00:00 2001 From: Ryan Date: Tue, 7 May 2024 18:36:50 +1000 Subject: [PATCH] Normalise RGBLight (underglow) keycodes (#23656) --- .../keycodes/keycodes_0.0.4_lighting.hjson | 80 +++++++++++++++++++ quantum/keycodes.h | 41 ++++++---- quantum/process_keycode/process_rgb.c | 22 ++--- quantum/quantum_keycodes_legacy.h | 13 +++ tests/test_common/keycode_table.cpp | 22 ++--- 5 files changed, 141 insertions(+), 37 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.4_lighting.hjson b/data/constants/keycodes/keycodes_0.0.4_lighting.hjson index 89ec80bd975..b341c664bd8 100644 --- a/data/constants/keycodes/keycodes_0.0.4_lighting.hjson +++ b/data/constants/keycodes/keycodes_0.0.4_lighting.hjson @@ -64,6 +64,86 @@ ] }, + "0x7820": { + "group": "underglow", + "key": "QK_UNDERGLOW_TOGGLE", + "aliases": [ + "UG_TOGG" + ] + }, + "0x7821": { + "group": "underglow", + "key": "QK_UNDERGLOW_MODE_NEXT", + "aliases": [ + "!reset!", + "UG_NEXT" + ] + }, + "0x7822": { + "group": "underglow", + "key": "QK_UNDERGLOW_MODE_PREVIOUS", + "aliases": [ + "!reset!", + "UG_PREV" + ] + }, + "0x7823": { + "group": "underglow", + "key": "QK_UNDERGLOW_HUE_UP", + "aliases": [ + "UG_HUEU" + ] + }, + "0x7824": { + "group": "underglow", + "key": "QK_UNDERGLOW_HUE_DOWN", + "aliases": [ + "UG_HUED" + ] + }, + "0x7825": { + "group": "underglow", + "key": "QK_UNDERGLOW_SATURATION_UP", + "aliases": [ + "UG_SATU" + ] + }, + "0x7826": { + "group": "underglow", + "key": "QK_UNDERGLOW_SATURATION_DOWN", + "aliases": [ + "UG_SATD" + ] + }, + "0x7827": { + "group": "underglow", + "key": "QK_UNDERGLOW_VALUE_UP", + "aliases": [ + "UG_VALU" + ] + }, + "0x7828": { + "group": "underglow", + "key": "QK_UNDERGLOW_VALUE_DOWN", + "aliases": [ + "UG_VALD" + ] + }, + "0x7829": { + "group": "underglow", + "key": "QK_UNDERGLOW_SPEED_UP", + "aliases": [ + "UG_SPDU" + ] + }, + "0x782A": { + "group": "underglow", + "key": "QK_UNDERGLOW_SPEED_DOWN", + "aliases": [ + "UG_SPDD" + ] + }, + "0x7840": { "group": "rgb_matrix", "key": "QK_RGB_MATRIX_ON", diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 415c7155b3a..c92028ab439 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -636,17 +636,17 @@ enum qk_keycode_defines { QK_LED_MATRIX_BRIGHTNESS_DOWN = 0x7816, QK_LED_MATRIX_SPEED_UP = 0x7817, QK_LED_MATRIX_SPEED_DOWN = 0x7818, - RGB_TOG = 0x7820, - RGB_MODE_FORWARD = 0x7821, - RGB_MODE_REVERSE = 0x7822, - RGB_HUI = 0x7823, - RGB_HUD = 0x7824, - RGB_SAI = 0x7825, - RGB_SAD = 0x7826, - RGB_VAI = 0x7827, - RGB_VAD = 0x7828, - RGB_SPI = 0x7829, - RGB_SPD = 0x782A, + QK_UNDERGLOW_TOGGLE = 0x7820, + QK_UNDERGLOW_MODE_NEXT = 0x7821, + QK_UNDERGLOW_MODE_PREVIOUS = 0x7822, + QK_UNDERGLOW_HUE_UP = 0x7823, + QK_UNDERGLOW_HUE_DOWN = 0x7824, + QK_UNDERGLOW_SATURATION_UP = 0x7825, + QK_UNDERGLOW_SATURATION_DOWN = 0x7826, + QK_UNDERGLOW_VALUE_UP = 0x7827, + QK_UNDERGLOW_VALUE_DOWN = 0x7828, + QK_UNDERGLOW_SPEED_UP = 0x7829, + QK_UNDERGLOW_SPEED_DOWN = 0x782A, RGB_MODE_PLAIN = 0x782B, RGB_MODE_BREATHE = 0x782C, RGB_MODE_RAINBOW = 0x782D, @@ -1312,8 +1312,17 @@ enum qk_keycode_defines { LM_BRID = QK_LED_MATRIX_BRIGHTNESS_DOWN, LM_SPDU = QK_LED_MATRIX_SPEED_UP, LM_SPDD = QK_LED_MATRIX_SPEED_DOWN, - RGB_MOD = RGB_MODE_FORWARD, - RGB_RMOD = RGB_MODE_REVERSE, + UG_TOGG = QK_UNDERGLOW_TOGGLE, + UG_NEXT = QK_UNDERGLOW_MODE_NEXT, + UG_PREV = QK_UNDERGLOW_MODE_PREVIOUS, + UG_HUEU = QK_UNDERGLOW_HUE_UP, + UG_HUED = QK_UNDERGLOW_HUE_DOWN, + UG_SATU = QK_UNDERGLOW_SATURATION_UP, + UG_SATD = QK_UNDERGLOW_SATURATION_DOWN, + UG_VALU = QK_UNDERGLOW_VALUE_UP, + UG_VALD = QK_UNDERGLOW_VALUE_DOWN, + UG_SPDU = QK_UNDERGLOW_SPEED_UP, + UG_SPDD = QK_UNDERGLOW_SPEED_DOWN, RGB_M_P = RGB_MODE_PLAIN, RGB_M_B = RGB_MODE_BREATHE, RGB_M_R = RGB_MODE_RAINBOW, @@ -1461,7 +1470,8 @@ enum qk_keycode_defines { #define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31) #define IS_BACKLIGHT_KEYCODE(code) ((code) >= QK_BACKLIGHT_ON && (code) <= QK_BACKLIGHT_TOGGLE_BREATHING) #define IS_LED_MATRIX_KEYCODE(code) ((code) >= QK_LED_MATRIX_ON && (code) <= QK_LED_MATRIX_SPEED_DOWN) -#define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE) +#define IS_UNDERGLOW_KEYCODE(code) ((code) >= QK_UNDERGLOW_TOGGLE && (code) <= QK_UNDERGLOW_SPEED_DOWN) +#define IS_RGB_KEYCODE(code) ((code) >= RGB_MODE_PLAIN && (code) <= RGB_MODE_TWINKLE) #define IS_RGB_MATRIX_KEYCODE(code) ((code) >= QK_RGB_MATRIX_ON && (code) <= QK_RGB_MATRIX_SPEED_DOWN) #define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_ALT_REPEAT_KEY) #define IS_KB_KEYCODE(code) ((code) >= QK_KB_0 && (code) <= QK_KB_31) @@ -1485,7 +1495,8 @@ enum qk_keycode_defines { #define MACRO_KEYCODE_RANGE QK_MACRO_0 ... QK_MACRO_31 #define BACKLIGHT_KEYCODE_RANGE QK_BACKLIGHT_ON ... QK_BACKLIGHT_TOGGLE_BREATHING #define LED_MATRIX_KEYCODE_RANGE QK_LED_MATRIX_ON ... QK_LED_MATRIX_SPEED_DOWN -#define RGB_KEYCODE_RANGE RGB_TOG ... RGB_MODE_TWINKLE +#define UNDERGLOW_KEYCODE_RANGE QK_UNDERGLOW_TOGGLE ... QK_UNDERGLOW_SPEED_DOWN +#define RGB_KEYCODE_RANGE RGB_MODE_PLAIN ... RGB_MODE_TWINKLE #define RGB_MATRIX_KEYCODE_RANGE QK_RGB_MATRIX_ON ... QK_RGB_MATRIX_SPEED_DOWN #define QUANTUM_KEYCODE_RANGE QK_BOOTLOADER ... QK_ALT_REPEAT_KEY #define KB_KEYCODE_RANGE QK_KB_0 ... QK_KB_31 diff --git a/quantum/process_keycode/process_rgb.c b/quantum/process_keycode/process_rgb.c index 4e63bf3ca84..b113d1c1e7f 100644 --- a/quantum/process_keycode/process_rgb.c +++ b/quantum/process_keycode/process_rgb.c @@ -69,7 +69,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { uint8_t shifted = get_mods() & MOD_MASK_SHIFT; #endif switch (keycode) { - case RGB_TOG: + case QK_UNDERGLOW_TOGGLE: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) rgblight_toggle(); #endif @@ -77,7 +77,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { rgb_matrix_toggle(); #endif return false; - case RGB_MODE_FORWARD: + case QK_UNDERGLOW_MODE_NEXT: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_step, rgblight_step_reverse); #endif @@ -85,7 +85,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_step, rgb_matrix_step_reverse); #endif return false; - case RGB_MODE_REVERSE: + case QK_UNDERGLOW_MODE_PREVIOUS: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_step_reverse, rgblight_step); #endif @@ -93,7 +93,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_step_reverse, rgb_matrix_step); #endif return false; - case RGB_HUI: + case QK_UNDERGLOW_HUE_UP: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_hue, rgblight_decrease_hue); #endif @@ -101,7 +101,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_increase_hue, rgb_matrix_decrease_hue); #endif return false; - case RGB_HUD: + case QK_UNDERGLOW_HUE_DOWN: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_hue, rgblight_increase_hue); #endif @@ -109,7 +109,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_decrease_hue, rgb_matrix_increase_hue); #endif return false; - case RGB_SAI: + case QK_UNDERGLOW_SATURATION_UP: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_sat, rgblight_decrease_sat); #endif @@ -117,7 +117,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_increase_sat, rgb_matrix_decrease_sat); #endif return false; - case RGB_SAD: + case QK_UNDERGLOW_SATURATION_DOWN: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_sat, rgblight_increase_sat); #endif @@ -125,7 +125,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_decrease_sat, rgb_matrix_increase_sat); #endif return false; - case RGB_VAI: + case QK_UNDERGLOW_VALUE_UP: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_val, rgblight_decrease_val); #endif @@ -133,7 +133,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_increase_val, rgb_matrix_decrease_val); #endif return false; - case RGB_VAD: + case QK_UNDERGLOW_VALUE_DOWN: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_val, rgblight_increase_val); #endif @@ -141,7 +141,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_decrease_val, rgb_matrix_increase_val); #endif return false; - case RGB_SPI: + case QK_UNDERGLOW_SPEED_UP: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_increase_speed, rgblight_decrease_speed); #endif @@ -149,7 +149,7 @@ bool process_rgb(const uint16_t keycode, const keyrecord_t *record) { handleKeycodeRGB(shifted, rgb_matrix_increase_speed, rgb_matrix_decrease_speed); #endif return false; - case RGB_SPD: + case QK_UNDERGLOW_SPEED_DOWN: #if defined(RGBLIGHT_ENABLE) && !defined(RGBLIGHT_DISABLE_KEYCODES) handleKeycodeRGB(shifted, rgblight_decrease_speed, rgblight_increase_speed); #endif diff --git a/quantum/quantum_keycodes_legacy.h b/quantum/quantum_keycodes_legacy.h index 51ec77bae0f..6ea5e13f3a9 100644 --- a/quantum/quantum_keycodes_legacy.h +++ b/quantum/quantum_keycodes_legacy.h @@ -3,3 +3,16 @@ // clang-format off // Deprecated Quantum keycodes +#define RGB_TOG QK_UNDERGLOW_TOGGLE +#define RGB_MOD QK_UNDERGLOW_MODE_NEXT +#define RGB_MODE_FORWARD QK_UNDERGLOW_MODE_NEXT +#define RGB_RMOD QK_UNDERGLOW_MODE_PREVIOUS +#define RGB_MODE_REVERSE QK_UNDERGLOW_MODE_PREVIOUS +#define RGB_HUI QK_UNDERGLOW_HUE_UP +#define RGB_HUD QK_UNDERGLOW_HUE_DOWN +#define RGB_SAI QK_UNDERGLOW_SATURATION_UP +#define RGB_SAD QK_UNDERGLOW_SATURATION_DOWN +#define RGB_VAI QK_UNDERGLOW_VALUE_UP +#define RGB_VAD QK_UNDERGLOW_VALUE_DOWN +#define RGB_SPI QK_UNDERGLOW_SPEED_UP +#define RGB_SPD QK_UNDERGLOW_SPEED_DOWN diff --git a/tests/test_common/keycode_table.cpp b/tests/test_common/keycode_table.cpp index 52817804a25..18dd5360277 100644 --- a/tests/test_common/keycode_table.cpp +++ b/tests/test_common/keycode_table.cpp @@ -578,17 +578,17 @@ std::map KEYCODE_ID_TABLE = { {QK_LED_MATRIX_BRIGHTNESS_DOWN, "QK_LED_MATRIX_BRIGHTNESS_DOWN"}, {QK_LED_MATRIX_SPEED_UP, "QK_LED_MATRIX_SPEED_UP"}, {QK_LED_MATRIX_SPEED_DOWN, "QK_LED_MATRIX_SPEED_DOWN"}, - {RGB_TOG, "RGB_TOG"}, - {RGB_MODE_FORWARD, "RGB_MODE_FORWARD"}, - {RGB_MODE_REVERSE, "RGB_MODE_REVERSE"}, - {RGB_HUI, "RGB_HUI"}, - {RGB_HUD, "RGB_HUD"}, - {RGB_SAI, "RGB_SAI"}, - {RGB_SAD, "RGB_SAD"}, - {RGB_VAI, "RGB_VAI"}, - {RGB_VAD, "RGB_VAD"}, - {RGB_SPI, "RGB_SPI"}, - {RGB_SPD, "RGB_SPD"}, + {QK_UNDERGLOW_TOGGLE, "QK_UNDERGLOW_TOGGLE"}, + {QK_UNDERGLOW_MODE_NEXT, "QK_UNDERGLOW_MODE_NEXT"}, + {QK_UNDERGLOW_MODE_PREVIOUS, "QK_UNDERGLOW_MODE_PREVIOUS"}, + {QK_UNDERGLOW_HUE_UP, "QK_UNDERGLOW_HUE_UP"}, + {QK_UNDERGLOW_HUE_DOWN, "QK_UNDERGLOW_HUE_DOWN"}, + {QK_UNDERGLOW_SATURATION_UP, "QK_UNDERGLOW_SATURATION_UP"}, + {QK_UNDERGLOW_SATURATION_DOWN, "QK_UNDERGLOW_SATURATION_DOWN"}, + {QK_UNDERGLOW_VALUE_UP, "QK_UNDERGLOW_VALUE_UP"}, + {QK_UNDERGLOW_VALUE_DOWN, "QK_UNDERGLOW_VALUE_DOWN"}, + {QK_UNDERGLOW_SPEED_UP, "QK_UNDERGLOW_SPEED_UP"}, + {QK_UNDERGLOW_SPEED_DOWN, "QK_UNDERGLOW_SPEED_DOWN"}, {RGB_MODE_PLAIN, "RGB_MODE_PLAIN"}, {RGB_MODE_BREATHE, "RGB_MODE_BREATHE"}, {RGB_MODE_RAINBOW, "RGB_MODE_RAINBOW"},