From b7d5a6c50b6a7cd2009d1eab120487b4f2cee670 Mon Sep 17 00:00:00 2001 From: Ryan Date: Sat, 4 May 2024 16:49:19 +1000 Subject: [PATCH] Add new set of keycodes for RGB Matrix (#23463) --- .../keycodes/keycodes_0.0.4_lighting.hjson | 92 +++++++++++++++++++ .../bm68hsrgb/rev2/keymaps/via/keymap.c | 34 +++---- quantum/keycodes.h | 28 ++++++ tests/test_common/keycode_table.cpp | 13 +++ 4 files changed, 150 insertions(+), 17 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.4_lighting.hjson b/data/constants/keycodes/keycodes_0.0.4_lighting.hjson index d7b27230f3..89ec80bd97 100644 --- a/data/constants/keycodes/keycodes_0.0.4_lighting.hjson +++ b/data/constants/keycodes/keycodes_0.0.4_lighting.hjson @@ -62,6 +62,98 @@ "aliases": [ "LM_SPDD" ] + }, + + "0x7840": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_ON", + "aliases": [ + "RM_ON" + ] + }, + "0x7841": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_OFF", + "aliases": [ + "RM_OFF" + ] + }, + "0x7842": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_TOGGLE", + "aliases": [ + "RM_TOGG" + ] + }, + "0x7843": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_MODE_NEXT", + "aliases": [ + "RM_NEXT" + ] + }, + "0x7844": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_MODE_PREVIOUS", + "aliases": [ + "RM_PREV" + ] + }, + "0x7845": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_HUE_UP", + "aliases": [ + "RM_HUEU" + ] + }, + "0x7846": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_HUE_DOWN", + "aliases": [ + "RM_HUED" + ] + }, + "0x7847": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_SATURATION_UP", + "aliases": [ + "RM_SATU" + ] + }, + "0x7848": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_SATURATION_DOWN", + "aliases": [ + "RM_SATD" + ] + }, + "0x7849": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_VALUE_UP", + "aliases": [ + "RM_VALU" + ] + }, + "0x784A": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_VALUE_DOWN", + "aliases": [ + "RM_VALD" + ] + }, + "0x784B": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_SPEED_UP", + "aliases": [ + "RM_SPDU" + ] + }, + "0x784C": { + "group": "rgb_matrix", + "key": "QK_RGB_MATRIX_SPEED_DOWN", + "aliases": [ + "RM_SPDD" + ] } } } diff --git a/keyboards/kprepublic/bm68hsrgb/rev2/keymaps/via/keymap.c b/keyboards/kprepublic/bm68hsrgb/rev2/keymaps/via/keymap.c index 3db3a9a7af..1be0806771 100644 --- a/keyboards/kprepublic/bm68hsrgb/rev2/keymaps/via/keymap.c +++ b/keyboards/kprepublic/bm68hsrgb/rev2/keymaps/via/keymap.c @@ -15,53 +15,53 @@ */ #include QMK_KEYBOARD_H enum my_keycodes { - RM_TOGG = SAFE_RANGE, - RM_MOD, - RM_HUI, - RM_HUD, - RM_SAI, - RM_SAD, - RM_VAI, - RM_VAD + RMT = SAFE_RANGE, + RMS, + RMIH, + RMDH, + RMIS, + RMDS, + RMIV, + RMDV }; bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch (keycode) { - case RM_TOGG: + case RMT: if (record->event.pressed) {rgb_matrix_toggle(); } return false; - case RM_MOD: + case RMS: if (record->event.pressed) {rgb_matrix_step(); } return false; - case RM_HUI: + case RMIH: if (record->event.pressed) {rgb_matrix_increase_hue(); } return false; - case RM_HUD: + case RMDH: if (record->event.pressed) {rgb_matrix_decrease_hue(); } return false; - case RM_SAI: + case RMIS: if (record->event.pressed) {rgb_matrix_increase_sat(); } return false; - case RM_SAD: + case RMDS: if (record->event.pressed) {rgb_matrix_decrease_sat(); } return false; - case RM_VAI: + case RMIV: if (record->event.pressed) {rgb_matrix_increase_val(); } return false; - case RM_VAD: + case RMDV: if (record->event.pressed) {rgb_matrix_decrease_val(); } @@ -82,7 +82,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { [1] = LAYOUT_65_ansi( QK_GESC, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, KC_DEL, QK_BOOT, _______, RGB_TOG, RGB_MOD, RGB_HUI, RGB_HUD, RGB_SAI, RGB_SAD, RGB_VAI, RGB_VAD, RGB_SPI, RGB_SPD, _______, _______, _______, _______, - KC_CAPS, RM_TOGG, RM_MOD, RM_HUI, RM_HUD, RM_SAI, RM_SAD, RM_VAI, RM_VAD, _______, _______, _______, _______, _______, + KC_CAPS, RMT, RMS, RMIH, RMDH, RMIS, RMDS, RMIV, RMDV, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, _______, NK_TOGG, _______, _______, _______, _______, _______, KC_VOLU, _______, _______, _______, _______, _______, _______, _______, _______, _______, KC_VOLD, _______ ), diff --git a/quantum/keycodes.h b/quantum/keycodes.h index da1012cf12..415c7155b3 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -657,6 +657,19 @@ enum qk_keycode_defines { RGB_MODE_GRADIENT = 0x7832, RGB_MODE_RGBTEST = 0x7833, RGB_MODE_TWINKLE = 0x7834, + QK_RGB_MATRIX_ON = 0x7840, + QK_RGB_MATRIX_OFF = 0x7841, + QK_RGB_MATRIX_TOGGLE = 0x7842, + QK_RGB_MATRIX_MODE_NEXT = 0x7843, + QK_RGB_MATRIX_MODE_PREVIOUS = 0x7844, + QK_RGB_MATRIX_HUE_UP = 0x7845, + QK_RGB_MATRIX_HUE_DOWN = 0x7846, + QK_RGB_MATRIX_SATURATION_UP = 0x7847, + QK_RGB_MATRIX_SATURATION_DOWN = 0x7848, + QK_RGB_MATRIX_VALUE_UP = 0x7849, + QK_RGB_MATRIX_VALUE_DOWN = 0x784A, + QK_RGB_MATRIX_SPEED_UP = 0x784B, + QK_RGB_MATRIX_SPEED_DOWN = 0x784C, QK_BOOTLOADER = 0x7C00, QK_REBOOT = 0x7C01, QK_DEBUG_TOGGLE = 0x7C02, @@ -1311,6 +1324,19 @@ enum qk_keycode_defines { RGB_M_G = RGB_MODE_GRADIENT, RGB_M_T = RGB_MODE_RGBTEST, RGB_M_TW = RGB_MODE_TWINKLE, + RM_ON = QK_RGB_MATRIX_ON, + RM_OFF = QK_RGB_MATRIX_OFF, + RM_TOGG = QK_RGB_MATRIX_TOGGLE, + RM_NEXT = QK_RGB_MATRIX_MODE_NEXT, + RM_PREV = QK_RGB_MATRIX_MODE_PREVIOUS, + RM_HUEU = QK_RGB_MATRIX_HUE_UP, + RM_HUED = QK_RGB_MATRIX_HUE_DOWN, + RM_SATU = QK_RGB_MATRIX_SATURATION_UP, + RM_SATD = QK_RGB_MATRIX_SATURATION_DOWN, + RM_VALU = QK_RGB_MATRIX_VALUE_UP, + RM_VALD = QK_RGB_MATRIX_VALUE_DOWN, + RM_SPDU = QK_RGB_MATRIX_SPEED_UP, + RM_SPDD = QK_RGB_MATRIX_SPEED_DOWN, QK_BOOT = QK_BOOTLOADER, QK_RBT = QK_REBOOT, DB_TOGG = QK_DEBUG_TOGGLE, @@ -1436,6 +1462,7 @@ enum qk_keycode_defines { #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_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) #define IS_USER_KEYCODE(code) ((code) >= QK_USER_0 && (code) <= QK_USER_31) @@ -1459,6 +1486,7 @@ enum qk_keycode_defines { #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 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 #define USER_KEYCODE_RANGE QK_USER_0 ... QK_USER_31 diff --git a/tests/test_common/keycode_table.cpp b/tests/test_common/keycode_table.cpp index 06064e77f9..52817804a2 100644 --- a/tests/test_common/keycode_table.cpp +++ b/tests/test_common/keycode_table.cpp @@ -599,6 +599,19 @@ std::map KEYCODE_ID_TABLE = { {RGB_MODE_GRADIENT, "RGB_MODE_GRADIENT"}, {RGB_MODE_RGBTEST, "RGB_MODE_RGBTEST"}, {RGB_MODE_TWINKLE, "RGB_MODE_TWINKLE"}, + {QK_RGB_MATRIX_ON, "QK_RGB_MATRIX_ON"}, + {QK_RGB_MATRIX_OFF, "QK_RGB_MATRIX_OFF"}, + {QK_RGB_MATRIX_TOGGLE, "QK_RGB_MATRIX_TOGGLE"}, + {QK_RGB_MATRIX_MODE_NEXT, "QK_RGB_MATRIX_MODE_NEXT"}, + {QK_RGB_MATRIX_MODE_PREVIOUS, "QK_RGB_MATRIX_MODE_PREVIOUS"}, + {QK_RGB_MATRIX_HUE_UP, "QK_RGB_MATRIX_HUE_UP"}, + {QK_RGB_MATRIX_HUE_DOWN, "QK_RGB_MATRIX_HUE_DOWN"}, + {QK_RGB_MATRIX_SATURATION_UP, "QK_RGB_MATRIX_SATURATION_UP"}, + {QK_RGB_MATRIX_SATURATION_DOWN, "QK_RGB_MATRIX_SATURATION_DOWN"}, + {QK_RGB_MATRIX_VALUE_UP, "QK_RGB_MATRIX_VALUE_UP"}, + {QK_RGB_MATRIX_VALUE_DOWN, "QK_RGB_MATRIX_VALUE_DOWN"}, + {QK_RGB_MATRIX_SPEED_UP, "QK_RGB_MATRIX_SPEED_UP"}, + {QK_RGB_MATRIX_SPEED_DOWN, "QK_RGB_MATRIX_SPEED_DOWN"}, {QK_BOOTLOADER, "QK_BOOTLOADER"}, {QK_REBOOT, "QK_REBOOT"}, {QK_DEBUG_TOGGLE, "QK_DEBUG_TOGGLE"},