From 58db04154276abe9ac9f8b74caf3c47ee942619c Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 21:44:37 +1100 Subject: [PATCH 1/6] Macro naming. --- .../keycodes/keycodes_0.0.1_macro.hjson | 66 +++++++++--------- .../pytest/macro/keymaps/default/keymap.json | 2 +- .../moonlander/keymaps/jjerrell/keymap.c | 12 ++-- .../work_board/keymaps/via/keymap.c | 8 +-- lib/python/qmk/keymap.py | 2 +- quantum/keycodes.h | 67 +++++++++---------- 6 files changed, 78 insertions(+), 79 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.1_macro.hjson b/data/constants/keycodes/keycodes_0.0.1_macro.hjson index 70b9ecf15431..f2cb34bdb0f0 100644 --- a/data/constants/keycodes/keycodes_0.0.1_macro.hjson +++ b/data/constants/keycodes/keycodes_0.0.1_macro.hjson @@ -3,131 +3,131 @@ "0x7700": { "group": "macro", - "key": "MACRO_0" + "key": "QK_MACRO_0" }, "0x7701": { "group": "macro", - "key": "MACRO_1" + "key": "QK_MACRO_1" }, "0x7702": { "group": "macro", - "key": "MACRO_2" + "key": "QK_MACRO_2" }, "0x7703": { "group": "macro", - "key": "MACRO_3" + "key": "QK_MACRO_3" }, "0x7704": { "group": "macro", - "key": "MACRO_4" + "key": "QK_MACRO_4" }, "0x7705": { "group": "macro", - "key": "MACRO_5" + "key": "QK_MACRO_5" }, "0x7706": { "group": "macro", - "key": "MACRO_6" + "key": "QK_MACRO_6" }, "0x7707": { "group": "macro", - "key": "MACRO_7" + "key": "QK_MACRO_7" }, "0x7708": { "group": "macro", - "key": "MACRO_8" + "key": "QK_MACRO_8" }, "0x7709": { "group": "macro", - "key": "MACRO_9" + "key": "QK_MACRO_9" }, "0x770A": { "group": "macro", - "key": "MACRO_10" + "key": "QK_MACRO_10" }, "0x770B": { "group": "macro", - "key": "MACRO_11" + "key": "QK_MACRO_11" }, "0x770C": { "group": "macro", - "key": "MACRO_12" + "key": "QK_MACRO_12" }, "0x770D": { "group": "macro", - "key": "MACRO_13" + "key": "QK_MACRO_13" }, "0x770E": { "group": "macro", - "key": "MACRO_14" + "key": "QK_MACRO_14" }, "0x770F": { "group": "macro", - "key": "MACRO_15" + "key": "QK_MACRO_15" }, "0x7710": { "group": "macro", - "key": "MACRO_16" + "key": "QK_MACRO_16" }, "0x7711": { "group": "macro", - "key": "MACRO_17" + "key": "QK_MACRO_17" }, "0x7712": { "group": "macro", - "key": "MACRO_18" + "key": "QK_MACRO_18" }, "0x7713": { "group": "macro", - "key": "MACRO_19" + "key": "QK_MACRO_19" }, "0x7714": { "group": "macro", - "key": "MACRO_20" + "key": "QK_MACRO_20" }, "0x7715": { "group": "macro", - "key": "MACRO_21" + "key": "QK_MACRO_21" }, "0x7716": { "group": "macro", - "key": "MACRO_22" + "key": "QK_MACRO_22" }, "0x7717": { "group": "macro", - "key": "MACRO_23" + "key": "QK_MACRO_23" }, "0x7718": { "group": "macro", - "key": "MACRO_24" + "key": "QK_MACRO_24" }, "0x7719": { "group": "macro", - "key": "MACRO_25" + "key": "QK_MACRO_25" }, "0x771A": { "group": "macro", - "key": "MACRO_26" + "key": "QK_MACRO_26" }, "0x771B": { "group": "macro", - "key": "MACRO_27" + "key": "QK_MACRO_27" }, "0x771C": { "group": "macro", - "key": "MACRO_28" + "key": "QK_MACRO_28" }, "0x771D": { "group": "macro", - "key": "MACRO_29" + "key": "QK_MACRO_29" }, "0x771E": { "group": "macro", - "key": "MACRO_30" + "key": "QK_MACRO_30" }, "0x771F": { "group": "macro", - "key": "MACRO_31" + "key": "QK_MACRO_31" } } -} \ No newline at end of file +} diff --git a/keyboards/handwired/pytest/macro/keymaps/default/keymap.json b/keyboards/handwired/pytest/macro/keymaps/default/keymap.json index f319d862d833..23c371aa3434 100644 --- a/keyboards/handwired/pytest/macro/keymaps/default/keymap.json +++ b/keyboards/handwired/pytest/macro/keymaps/default/keymap.json @@ -2,7 +2,7 @@ "keyboard": "handwired/pytest/basic", "keymap": "default_json", "layout": "LAYOUT_ortho_1x1", - "layers": [["MACRO_0"]], + "layers": [["QK_MACRO_0"]], "macros": [ [ "Hello, World!", diff --git a/keyboards/moonlander/keymaps/jjerrell/keymap.c b/keyboards/moonlander/keymaps/jjerrell/keymap.c index ee6226177f69..1ae24a8b2fae 100644 --- a/keyboards/moonlander/keymaps/jjerrell/keymap.c +++ b/keyboards/moonlander/keymaps/jjerrell/keymap.c @@ -1,18 +1,18 @@ /** * Copyright (C) 2021 Jerrell, Jacob <@jjerrell> - * + * * This file is part of qmk_firmware. - * + * * qmk_firmware is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * qmk_firmware is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with qmk_firmware. If not, see . */ @@ -66,7 +66,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, __________________QWERTY_L1__________________, KC_SLSH, KC_LALT, __________________QWERTY_L2__________________, KC_BSLS, KC_LSFT, __________________QWERTY_L3__________________, - KC_LGUI, MACRO_1, MACRO_2, MACRO_3, MACRO_4, QK_LOCK, + KC_LGUI, QK_MACRO_1, QK_MACRO_2, QK_MACRO_3, QK_MACRO_4, QK_LOCK, KC_SPC, KC_BTN2, MO(_LOWER) ), [_GAME_LOWER] = LAYOUT_moonlander_gamepad( @@ -74,7 +74,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, __________________QWERTY_L1__________________, KC_SLSH, KC_LALT, __________________QWERTY_L2__________________, KC_BSLS, KC_LSFT, __________________QWERTY_L3__________________, - KC_LGUI, MACRO_5, MACRO_6, MACRO_7, MACRO_8, QK_LOCK, + KC_LGUI, QK_MACRO_5, QK_MACRO_6, QK_MACRO_7, QK_MACRO_8, QK_LOCK, KC_SPC, KC_BTN2, MO(_LOWER) ) }; diff --git a/keyboards/work_louder/work_board/keymaps/via/keymap.c b/keyboards/work_louder/work_board/keymaps/via/keymap.c index d39c5f405db2..4216faf92ab4 100644 --- a/keyboards/work_louder/work_board/keymaps/via/keymap.c +++ b/keyboards/work_louder/work_board/keymaps/via/keymap.c @@ -39,10 +39,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { MO(3), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT ), [_LOWER] = LAYOUT( - KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, _______, - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, - _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS),S(KC_NUBS),KC_HOME, KC_END, _______, - _______, _______, _______, MACRO_1, _______, MACRO_0, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, _______, + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, + _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS),S(KC_NUBS),KC_HOME, KC_END, _______, + _______, _______, _______, QK_MACRO_1, _______, QK_MACRO_0, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY ), [_RAISE] = LAYOUT( KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, _______, diff --git a/lib/python/qmk/keymap.py b/lib/python/qmk/keymap.py index fc1421962f90..315af35b73e0 100644 --- a/lib/python/qmk/keymap.py +++ b/lib/python/qmk/keymap.py @@ -266,7 +266,7 @@ def generate_c(keymap_json): new_macro = "".join(macro) new_macro = new_macro.replace('""', '') - macro_txt.append(f' case MACRO_{i}:') + macro_txt.append(f' case QK_MACRO_{i}:') macro_txt.append(f' SEND_STRING({new_macro});') macro_txt.append(' return false;') diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 6772bb6a4a31..225cba90931b 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -582,38 +582,38 @@ enum qk_keycode_defines { QK_STENO_GEMINI = 0x74F1, QK_STENO_COMB = 0x74F2, QK_STENO_COMB_MAX = 0x74FC, - MACRO_0 = 0x7700, - MACRO_1 = 0x7701, - MACRO_2 = 0x7702, - MACRO_3 = 0x7703, - MACRO_4 = 0x7704, - MACRO_5 = 0x7705, - MACRO_6 = 0x7706, - MACRO_7 = 0x7707, - MACRO_8 = 0x7708, - MACRO_9 = 0x7709, - MACRO_10 = 0x770A, - MACRO_11 = 0x770B, - MACRO_12 = 0x770C, - MACRO_13 = 0x770D, - MACRO_14 = 0x770E, - MACRO_15 = 0x770F, - MACRO_16 = 0x7710, - MACRO_17 = 0x7711, - MACRO_18 = 0x7712, - MACRO_19 = 0x7713, - MACRO_20 = 0x7714, - MACRO_21 = 0x7715, - MACRO_22 = 0x7716, - MACRO_23 = 0x7717, - MACRO_24 = 0x7718, - MACRO_25 = 0x7719, - MACRO_26 = 0x771A, - MACRO_27 = 0x771B, - MACRO_28 = 0x771C, - MACRO_29 = 0x771D, - MACRO_30 = 0x771E, - MACRO_31 = 0x771F, + QK_MACRO_0 = 0x7700, + QK_MACRO_1 = 0x7701, + QK_MACRO_2 = 0x7702, + QK_MACRO_3 = 0x7703, + QK_MACRO_4 = 0x7704, + QK_MACRO_5 = 0x7705, + QK_MACRO_6 = 0x7706, + QK_MACRO_7 = 0x7707, + QK_MACRO_8 = 0x7708, + QK_MACRO_9 = 0x7709, + QK_MACRO_10 = 0x770A, + QK_MACRO_11 = 0x770B, + QK_MACRO_12 = 0x770C, + QK_MACRO_13 = 0x770D, + QK_MACRO_14 = 0x770E, + QK_MACRO_15 = 0x770F, + QK_MACRO_16 = 0x7710, + QK_MACRO_17 = 0x7711, + QK_MACRO_18 = 0x7712, + QK_MACRO_19 = 0x7713, + QK_MACRO_20 = 0x7714, + QK_MACRO_21 = 0x7715, + QK_MACRO_22 = 0x7716, + QK_MACRO_23 = 0x7717, + QK_MACRO_24 = 0x7718, + QK_MACRO_25 = 0x7719, + QK_MACRO_26 = 0x771A, + QK_MACRO_27 = 0x771B, + QK_MACRO_28 = 0x771C, + QK_MACRO_29 = 0x771D, + QK_MACRO_30 = 0x771E, + QK_MACRO_31 = 0x771F, BL_ON = 0x7800, BL_OFF = 0x7801, BL_DEC = 0x7802, @@ -1108,8 +1108,7 @@ enum qk_keycode_defines { #define IS_PROGRAMMABLE_BUTTON_KEYCODE(code) ((code) >= QK_PROGRAMMABLE_BUTTON_1 && (code) <= QK_PROGRAMMABLE_BUTTON_32) #define IS_AUDIO_KEYCODE(code) ((code) >= AU_ON && (code) <= MUV_DE) #define IS_STENO_KEYCODE(code) ((code) >= QK_STENO_BOLT && (code) <= QK_STENO_COMB_MAX) -#define IS_MACRO_KEYCODE(code) ((code) >= MACRO_0 && (code) <= MACRO_31) +#define IS_MACRO_KEYCODE(code) ((code) >= QK_MACRO_0 && (code) <= QK_MACRO_31) #define IS_BACKLIGHT_KEYCODE(code) ((code) >= BL_ON && (code) <= BL_BRTG) #define IS_RGB_KEYCODE(code) ((code) >= RGB_TOG && (code) <= RGB_MODE_TWINKLE) #define IS_QUANTUM_KEYCODE(code) ((code) >= QK_BOOTLOADER && (code) <= QK_AUTOCORRECT_TOGGLE) - From 144b73f7f95333d735f8439b23e04cc17b94b733 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 21:52:39 +1100 Subject: [PATCH 2/6] Elsewhere. --- docs/ChangeLog/20211127.md | 10 +++++----- docs/feature_macros.md | 6 +++--- lib/python/qmk/tests/test_cli_commands.py | 4 ++-- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/docs/ChangeLog/20211127.md b/docs/ChangeLog/20211127.md index d954bb9f6190..0780ab6a44c6 100644 --- a/docs/ChangeLog/20211127.md +++ b/docs/ChangeLog/20211127.md @@ -56,19 +56,19 @@ You can now define up to 32 macros in your `keymap.json` file, as used by [QMK C "keyboard": "handwired/my_macropad", "keymap": "my_keymap", "macros": [ - [ // first listed is MACRO_0... + [ // first listed is QK_MACRO_0... {"action":"down", "keycodes": ["LSFT"]}, "hello world1", {"action": "up","keycodes": ["LSFT"]} ], - [ // ...then MACRO_1... + [ // ...then QK_MACRO_1... {"action":"tap", "keycodes": ["LCTL", "LALT", "DEL"]} ], - [ // ...then MACRO_2... + [ // ...then QK_MACRO_2... "ding!", {"action":"beep"} ], - [ // ...and MACRO_3. + [ // ...and QK_MACRO_3. {"action":"tap", "keycodes": ["F1"]}, {"action":"delay", "duration": "1000"}, {"action":"tap", "keycodes": ["PGDN"]} @@ -76,7 +76,7 @@ You can now define up to 32 macros in your `keymap.json` file, as used by [QMK C ], "layout": "LAYOUT_all", "layers": [ - ["MACRO_0", "MACRO_1", "MACRO_2", "MACRO_3"] + ["QK_MACRO_0", "QK_MACRO_1", "QK_MACRO_2", "QK_MACRO_3"] ] } ``` diff --git a/docs/feature_macros.md b/docs/feature_macros.md index 63b7223db9a0..08310555fb77 100644 --- a/docs/feature_macros.md +++ b/docs/feature_macros.md @@ -33,7 +33,7 @@ You can define up to 32 macros in a `keymap.json` file, as used by [Configurator ], "layout": "LAYOUT_all", "layers": [ - ["MACRO_0", "MACRO_1", "MACRO_2", "MACRO_3"] + ["QK_MACRO_0", "QK_MACRO_1", "QK_MACRO_2", "QK_MACRO_3"] ] } ``` @@ -52,7 +52,7 @@ If you type in a language other than English, or use a non-QWERTY layout like Co ], "layout": "LAYOUT_all", "layers": [ - ["MACRO_0"] + ["QK_MACRO_0"] ] } ``` @@ -199,7 +199,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { #### Advanced Macros -In addition to the `process_record_user()` function, is the `post_process_record_user()` function. This runs after `process_record` and can be used to do things after a keystroke has been sent. This is useful if you want to have a key pressed before and released after a normal key, for instance. +In addition to the `process_record_user()` function, is the `post_process_record_user()` function. This runs after `process_record` and can be used to do things after a keystroke has been sent. This is useful if you want to have a key pressed before and released after a normal key, for instance. In this example, we modify most normal keypresses so that `F22` is pressed before the keystroke is normally sent, and release it __only after__ it's been released. diff --git a/lib/python/qmk/tests/test_cli_commands.py b/lib/python/qmk/tests/test_cli_commands.py index 9bfc5a0a799f..e598b281a6a5 100644 --- a/lib/python/qmk/tests/test_cli_commands.py +++ b/lib/python/qmk/tests/test_cli_commands.py @@ -150,8 +150,8 @@ def test_json2c(): def test_json2c_macros(): result = check_subcommand("json2c", 'keyboards/handwired/pytest/macro/keymaps/default/keymap.json') check_returncode(result) - assert 'LAYOUT_ortho_1x1(MACRO_0)' in result.stdout - assert 'case MACRO_0:' in result.stdout + assert 'LAYOUT_ortho_1x1(QK_MACRO_0)' in result.stdout + assert 'case QK_MACRO_0:' in result.stdout assert 'SEND_STRING("Hello, World!"SS_TAP(X_ENTER));' in result.stdout From 7e7c5e54e0ab3e4df8054ec230337eec51eb68b1 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 22:11:22 +1100 Subject: [PATCH 3/6] Rollback as per userspace. --- keyboards/moonlander/keymaps/jjerrell/keymap.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/keyboards/moonlander/keymaps/jjerrell/keymap.c b/keyboards/moonlander/keymaps/jjerrell/keymap.c index 1ae24a8b2fae..ee6226177f69 100644 --- a/keyboards/moonlander/keymaps/jjerrell/keymap.c +++ b/keyboards/moonlander/keymaps/jjerrell/keymap.c @@ -1,18 +1,18 @@ /** * Copyright (C) 2021 Jerrell, Jacob <@jjerrell> - * + * * This file is part of qmk_firmware. - * + * * qmk_firmware is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. - * + * * qmk_firmware is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - * + * * You should have received a copy of the GNU General Public License * along with qmk_firmware. If not, see . */ @@ -66,7 +66,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, __________________QWERTY_L1__________________, KC_SLSH, KC_LALT, __________________QWERTY_L2__________________, KC_BSLS, KC_LSFT, __________________QWERTY_L3__________________, - KC_LGUI, QK_MACRO_1, QK_MACRO_2, QK_MACRO_3, QK_MACRO_4, QK_LOCK, + KC_LGUI, MACRO_1, MACRO_2, MACRO_3, MACRO_4, QK_LOCK, KC_SPC, KC_BTN2, MO(_LOWER) ), [_GAME_LOWER] = LAYOUT_moonlander_gamepad( @@ -74,7 +74,7 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { KC_TAB, __________________QWERTY_L1__________________, KC_SLSH, KC_LALT, __________________QWERTY_L2__________________, KC_BSLS, KC_LSFT, __________________QWERTY_L3__________________, - KC_LGUI, QK_MACRO_5, QK_MACRO_6, QK_MACRO_7, QK_MACRO_8, QK_LOCK, + KC_LGUI, MACRO_5, MACRO_6, MACRO_7, MACRO_8, QK_LOCK, KC_SPC, KC_BTN2, MO(_LOWER) ) }; From 0a42d4906697111eba6c83163c94e1649b98ae60 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 22:14:22 +1100 Subject: [PATCH 4/6] Change docs to make distinction between macros and custom keycodes. --- docs/configurator_default_keymaps.md | 36 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/configurator_default_keymaps.md b/docs/configurator_default_keymaps.md index 3fea15166af6..d08ec2953967 100644 --- a/docs/configurator_default_keymaps.md +++ b/docs/configurator_default_keymaps.md @@ -122,26 +122,26 @@ There is a way to support custom keycodes: if the logic for a custom keycode is ```c enum custom_keycodes { - MACRO_1 = SAFE_RANGE, - MACRO_2, - MACRO_3 + CUSTOM_1 = SAFE_RANGE, + CUSTOM_2, + CUSTOM_3 }; ... bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch(keycode) { - case MACRO_1: + case CUSTOM_1: if (record->event.pressed) { - SEND_STRING("This is macro #1."); + SEND_STRING("This is custom keycode #1."); } return false; - case MACRO_2: + case CUSTOM_2: if (record->event.pressed) { - SEND_STRING("This is macro #2."); + SEND_STRING("This is custom keycode #2."); } return false; - case MACRO_3: + case CUSTOM_3: if (record->event.pressed) { - SEND_STRING("This is macro #3."); + SEND_STRING("This is custom keycode #3."); } return false; } @@ -153,9 +153,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { ```c enum keyboard_keycodes { - MACRO_1 = SAFE_RANGE, - MACRO_2, - MACRO_3, + CUSTOM_1 = SAFE_RANGE, + CUSTOM_2, + CUSTOM_3, NEW_SAFE_RANGE // Important! }; ``` @@ -165,19 +165,19 @@ enum keyboard_keycodes { ```c bool process_record_kb(uint16_t keycode, keyrecord_t *record) { switch(keycode) { - case MACRO_1: + case CUSTOM_1: if (record->event.pressed) { - SEND_STRING("This is macro #1."); + SEND_STRING("This is custom keycode #1."); } return false; - case MACRO_2: + case CUSTOM_2: if (record->event.pressed) { - SEND_STRING("This is macro #2."); + SEND_STRING("This is custom keycode #2."); } return false; - case MACRO_3: + case CUSTOM_3: if (record->event.pressed) { - SEND_STRING("This is macro #3."); + SEND_STRING("This is custom keycode #3."); } return false; } From 52ba88d6eb422dc0e8f44365dbc79166219e1842 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 22:16:42 +1100 Subject: [PATCH 5/6] Change docs to make distinction between macros and custom keycodes. --- docs/zh-cn/configurator_default_keymaps.md | 36 +++++++++++----------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/docs/zh-cn/configurator_default_keymaps.md b/docs/zh-cn/configurator_default_keymaps.md index 82e4ca818dbd..c446a457145c 100644 --- a/docs/zh-cn/configurator_default_keymaps.md +++ b/docs/zh-cn/configurator_default_keymaps.md @@ -127,26 +127,26 @@ enum layer_names { ```c enum custom_keycodes { - MACRO_1 = SAFE_RANGE, - MACRO_2, - MACRO_3 + CUSTOM_1 = SAFE_RANGE, + CUSTOM_2, + CUSTOM_3 }; ... bool process_record_user(uint16_t keycode, keyrecord_t *record) { switch(keycode) { - case MACRO_1: + case CUSTOM_1: if (record->event.pressed) { - SEND_STRING("This is macro #1."); + SEND_STRING("This is custom keycode #1."); } return false; - case MACRO_2: + case CUSTOM_2: if (record->event.pressed) { - SEND_STRING("This is macro #2."); + SEND_STRING("This is custom keycode #2."); } return false; - case MACRO_3: + case CUSTOM_3: if (record->event.pressed) { - SEND_STRING("This is macro #3."); + SEND_STRING("This is custom keycode #3."); } return false; } @@ -158,9 +158,9 @@ bool process_record_user(uint16_t keycode, keyrecord_t *record) { ```c enum keyboard_keycodes { - MACRO_1 = SAFE_RANGE, - MACRO_2, - MACRO_3, + CUSTOM_1 = SAFE_RANGE, + CUSTOM_2, + CUSTOM_3, NEW_SAFE_RANGE // 重要! }; ``` @@ -170,19 +170,19 @@ enum keyboard_keycodes { ```c bool process_record_kb(uint16_t keycode, keyrecord_t *record) { switch(keycode) { - case MACRO_1: + case CUSTOM_1: if (record->event.pressed) { - SEND_STRING("This is macro #1."); + SEND_STRING("This is custom keycode #1."); } return false; - case MACRO_2: + case CUSTOM_2: if (record->event.pressed) { - SEND_STRING("This is macro #2."); + SEND_STRING("This is custom keycode #2."); } return false; - case MACRO_3: + case CUSTOM_3: if (record->event.pressed) { - SEND_STRING("This is macro #3."); + SEND_STRING("This is custom keycode #3."); } return false; } From c7297e3e6e7162f42ee430be91c2a07e78b15f05 Mon Sep 17 00:00:00 2001 From: Nick Brassel Date: Sat, 5 Nov 2022 22:26:10 +1100 Subject: [PATCH 6/6] Short names. --- .../keycodes/keycodes_0.0.1_macro.hjson | 160 ++++++++++++++---- .../work_board/keymaps/via/keymap.c | 8 +- quantum/keycodes.h | 32 ++++ 3 files changed, 164 insertions(+), 36 deletions(-) diff --git a/data/constants/keycodes/keycodes_0.0.1_macro.hjson b/data/constants/keycodes/keycodes_0.0.1_macro.hjson index f2cb34bdb0f0..409853fed9eb 100644 --- a/data/constants/keycodes/keycodes_0.0.1_macro.hjson +++ b/data/constants/keycodes/keycodes_0.0.1_macro.hjson @@ -3,131 +3,227 @@ "0x7700": { "group": "macro", - "key": "QK_MACRO_0" + "key": "QK_MACRO_0", + "aliases": [ + "MC_0" + ] }, "0x7701": { "group": "macro", - "key": "QK_MACRO_1" + "key": "QK_MACRO_1", + "aliases": [ + "MC_1" + ] }, "0x7702": { "group": "macro", - "key": "QK_MACRO_2" + "key": "QK_MACRO_2", + "aliases": [ + "MC_2" + ] }, "0x7703": { "group": "macro", - "key": "QK_MACRO_3" + "key": "QK_MACRO_3", + "aliases": [ + "MC_3" + ] }, "0x7704": { "group": "macro", - "key": "QK_MACRO_4" + "key": "QK_MACRO_4", + "aliases": [ + "MC_4" + ] }, "0x7705": { "group": "macro", - "key": "QK_MACRO_5" + "key": "QK_MACRO_5", + "aliases": [ + "MC_5" + ] }, "0x7706": { "group": "macro", - "key": "QK_MACRO_6" + "key": "QK_MACRO_6", + "aliases": [ + "MC_6" + ] }, "0x7707": { "group": "macro", - "key": "QK_MACRO_7" + "key": "QK_MACRO_7", + "aliases": [ + "MC_7" + ] }, "0x7708": { "group": "macro", - "key": "QK_MACRO_8" + "key": "QK_MACRO_8", + "aliases": [ + "MC_8" + ] }, "0x7709": { "group": "macro", - "key": "QK_MACRO_9" + "key": "QK_MACRO_9", + "aliases": [ + "MC_9" + ] }, "0x770A": { "group": "macro", - "key": "QK_MACRO_10" + "key": "QK_MACRO_10", + "aliases": [ + "MC_10" + ] }, "0x770B": { "group": "macro", - "key": "QK_MACRO_11" + "key": "QK_MACRO_11", + "aliases": [ + "MC_11" + ] }, "0x770C": { "group": "macro", - "key": "QK_MACRO_12" + "key": "QK_MACRO_12", + "aliases": [ + "MC_12" + ] }, "0x770D": { "group": "macro", - "key": "QK_MACRO_13" + "key": "QK_MACRO_13", + "aliases": [ + "MC_13" + ] }, "0x770E": { "group": "macro", - "key": "QK_MACRO_14" + "key": "QK_MACRO_14", + "aliases": [ + "MC_14" + ] }, "0x770F": { "group": "macro", - "key": "QK_MACRO_15" + "key": "QK_MACRO_15", + "aliases": [ + "MC_15" + ] }, "0x7710": { "group": "macro", - "key": "QK_MACRO_16" + "key": "QK_MACRO_16", + "aliases": [ + "MC_16" + ] }, "0x7711": { "group": "macro", - "key": "QK_MACRO_17" + "key": "QK_MACRO_17", + "aliases": [ + "MC_17" + ] }, "0x7712": { "group": "macro", - "key": "QK_MACRO_18" + "key": "QK_MACRO_18", + "aliases": [ + "MC_18" + ] }, "0x7713": { "group": "macro", - "key": "QK_MACRO_19" + "key": "QK_MACRO_19", + "aliases": [ + "MC_19" + ] }, "0x7714": { "group": "macro", - "key": "QK_MACRO_20" + "key": "QK_MACRO_20", + "aliases": [ + "MC_20" + ] }, "0x7715": { "group": "macro", - "key": "QK_MACRO_21" + "key": "QK_MACRO_21", + "aliases": [ + "MC_21" + ] }, "0x7716": { "group": "macro", - "key": "QK_MACRO_22" + "key": "QK_MACRO_22", + "aliases": [ + "MC_22" + ] }, "0x7717": { "group": "macro", - "key": "QK_MACRO_23" + "key": "QK_MACRO_23", + "aliases": [ + "MC_23" + ] }, "0x7718": { "group": "macro", - "key": "QK_MACRO_24" + "key": "QK_MACRO_24", + "aliases": [ + "MC_24" + ] }, "0x7719": { "group": "macro", - "key": "QK_MACRO_25" + "key": "QK_MACRO_25", + "aliases": [ + "MC_25" + ] }, "0x771A": { "group": "macro", - "key": "QK_MACRO_26" + "key": "QK_MACRO_26", + "aliases": [ + "MC_26" + ] }, "0x771B": { "group": "macro", - "key": "QK_MACRO_27" + "key": "QK_MACRO_27", + "aliases": [ + "MC_27" + ] }, "0x771C": { "group": "macro", - "key": "QK_MACRO_28" + "key": "QK_MACRO_28", + "aliases": [ + "MC_28" + ] }, "0x771D": { "group": "macro", - "key": "QK_MACRO_29" + "key": "QK_MACRO_29", + "aliases": [ + "MC_29" + ] }, "0x771E": { "group": "macro", - "key": "QK_MACRO_30" + "key": "QK_MACRO_30", + "aliases": [ + "MC_30" + ] }, "0x771F": { "group": "macro", - "key": "QK_MACRO_31" + "key": "QK_MACRO_31", + "aliases": [ + "MC_31" + ] } } } diff --git a/keyboards/work_louder/work_board/keymaps/via/keymap.c b/keyboards/work_louder/work_board/keymaps/via/keymap.c index 4216faf92ab4..0ffdd8b494de 100644 --- a/keyboards/work_louder/work_board/keymaps/via/keymap.c +++ b/keyboards/work_louder/work_board/keymaps/via/keymap.c @@ -39,10 +39,10 @@ const uint16_t PROGMEM keymaps[][MATRIX_ROWS][MATRIX_COLS] = { MO(3), KC_LCTL, KC_LALT, KC_LGUI, LOWER, KC_SPC, KC_SPC, RAISE, KC_LEFT, KC_DOWN, KC_UP, KC_RGHT ), [_LOWER] = LAYOUT( - KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, _______, - KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, - _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS),S(KC_NUBS),KC_HOME, KC_END, _______, - _______, _______, _______, QK_MACRO_1, _______, QK_MACRO_0, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY + KC_TILD, KC_EXLM, KC_AT, KC_HASH, KC_DLR, KC_PERC, KC_CIRC, KC_AMPR, KC_ASTR, KC_LPRN, KC_RPRN, KC_BSPC, _______, + KC_DEL, KC_F1, KC_F2, KC_F3, KC_F4, KC_F5, KC_F6, KC_UNDS, KC_PLUS, KC_LCBR, KC_RCBR, KC_PIPE, + _______, KC_F7, KC_F8, KC_F9, KC_F10, KC_F11, KC_F12, S(KC_NUHS),S(KC_NUBS),KC_HOME, KC_END, _______, + _______, _______, _______, MC_1, _______, MC_0, _______, _______, KC_MNXT, KC_VOLD, KC_VOLU, KC_MPLY ), [_RAISE] = LAYOUT( KC_GRV, KC_1, KC_2, KC_3, KC_4, KC_5, KC_6, KC_7, KC_8, KC_9, KC_0, KC_BSPC, _______, diff --git a/quantum/keycodes.h b/quantum/keycodes.h index 225cba90931b..e3c9321d16df 100644 --- a/quantum/keycodes.h +++ b/quantum/keycodes.h @@ -1000,6 +1000,38 @@ enum qk_keycode_defines { CK_UP = CLICKY_UP, CK_DOWN = CLICKY_DOWN, CK_RST = CLICKY_RESET, + MC_0 = QK_MACRO_0, + MC_1 = QK_MACRO_1, + MC_2 = QK_MACRO_2, + MC_3 = QK_MACRO_3, + MC_4 = QK_MACRO_4, + MC_5 = QK_MACRO_5, + MC_6 = QK_MACRO_6, + MC_7 = QK_MACRO_7, + MC_8 = QK_MACRO_8, + MC_9 = QK_MACRO_9, + MC_10 = QK_MACRO_10, + MC_11 = QK_MACRO_11, + MC_12 = QK_MACRO_12, + MC_13 = QK_MACRO_13, + MC_14 = QK_MACRO_14, + MC_15 = QK_MACRO_15, + MC_16 = QK_MACRO_16, + MC_17 = QK_MACRO_17, + MC_18 = QK_MACRO_18, + MC_19 = QK_MACRO_19, + MC_20 = QK_MACRO_20, + MC_21 = QK_MACRO_21, + MC_22 = QK_MACRO_22, + MC_23 = QK_MACRO_23, + MC_24 = QK_MACRO_24, + MC_25 = QK_MACRO_25, + MC_26 = QK_MACRO_26, + MC_27 = QK_MACRO_27, + MC_28 = QK_MACRO_28, + MC_29 = QK_MACRO_29, + MC_30 = QK_MACRO_30, + MC_31 = QK_MACRO_31, RGB_MOD = RGB_MODE_FORWARD, RGB_RMOD = RGB_MODE_REVERSE, RGB_M_P = RGB_MODE_PLAIN,