Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Macro keycode name refactoring #18958

Merged
merged 6 commits into from
Nov 5, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
162 changes: 129 additions & 33 deletions data/constants/keycodes/keycodes_0.0.1_macro.hjson
Original file line number Diff line number Diff line change
@@ -3,131 +3,227 @@

"0x7700": {
"group": "macro",
"key": "MACRO_0"
"key": "QK_MACRO_0",
"aliases": [
"MC_0"
]
},
"0x7701": {
"group": "macro",
"key": "MACRO_1"
"key": "QK_MACRO_1",
"aliases": [
"MC_1"
]
},
"0x7702": {
"group": "macro",
"key": "MACRO_2"
"key": "QK_MACRO_2",
"aliases": [
"MC_2"
]
},
"0x7703": {
"group": "macro",
"key": "MACRO_3"
"key": "QK_MACRO_3",
"aliases": [
"MC_3"
]
},
"0x7704": {
"group": "macro",
"key": "MACRO_4"
"key": "QK_MACRO_4",
"aliases": [
"MC_4"
]
},
"0x7705": {
"group": "macro",
"key": "MACRO_5"
"key": "QK_MACRO_5",
"aliases": [
"MC_5"
]
},
"0x7706": {
"group": "macro",
"key": "MACRO_6"
"key": "QK_MACRO_6",
"aliases": [
"MC_6"
]
},
"0x7707": {
"group": "macro",
"key": "MACRO_7"
"key": "QK_MACRO_7",
"aliases": [
"MC_7"
]
},
"0x7708": {
"group": "macro",
"key": "MACRO_8"
"key": "QK_MACRO_8",
"aliases": [
"MC_8"
]
},
"0x7709": {
"group": "macro",
"key": "MACRO_9"
"key": "QK_MACRO_9",
"aliases": [
"MC_9"
]
},
"0x770A": {
"group": "macro",
"key": "MACRO_10"
"key": "QK_MACRO_10",
"aliases": [
"MC_10"
]
},
"0x770B": {
"group": "macro",
"key": "MACRO_11"
"key": "QK_MACRO_11",
"aliases": [
"MC_11"
]
},
"0x770C": {
"group": "macro",
"key": "MACRO_12"
"key": "QK_MACRO_12",
"aliases": [
"MC_12"
]
},
"0x770D": {
"group": "macro",
"key": "MACRO_13"
"key": "QK_MACRO_13",
"aliases": [
"MC_13"
]
},
"0x770E": {
"group": "macro",
"key": "MACRO_14"
"key": "QK_MACRO_14",
"aliases": [
"MC_14"
]
},
"0x770F": {
"group": "macro",
"key": "MACRO_15"
"key": "QK_MACRO_15",
"aliases": [
"MC_15"
]
},
"0x7710": {
"group": "macro",
"key": "MACRO_16"
"key": "QK_MACRO_16",
"aliases": [
"MC_16"
]
},
"0x7711": {
"group": "macro",
"key": "MACRO_17"
"key": "QK_MACRO_17",
"aliases": [
"MC_17"
]
},
"0x7712": {
"group": "macro",
"key": "MACRO_18"
"key": "QK_MACRO_18",
"aliases": [
"MC_18"
]
},
"0x7713": {
"group": "macro",
"key": "MACRO_19"
"key": "QK_MACRO_19",
"aliases": [
"MC_19"
]
},
"0x7714": {
"group": "macro",
"key": "MACRO_20"
"key": "QK_MACRO_20",
"aliases": [
"MC_20"
]
},
"0x7715": {
"group": "macro",
"key": "MACRO_21"
"key": "QK_MACRO_21",
"aliases": [
"MC_21"
]
},
"0x7716": {
"group": "macro",
"key": "MACRO_22"
"key": "QK_MACRO_22",
"aliases": [
"MC_22"
]
},
"0x7717": {
"group": "macro",
"key": "MACRO_23"
"key": "QK_MACRO_23",
"aliases": [
"MC_23"
]
},
"0x7718": {
"group": "macro",
"key": "MACRO_24"
"key": "QK_MACRO_24",
"aliases": [
"MC_24"
]
},
"0x7719": {
"group": "macro",
"key": "MACRO_25"
"key": "QK_MACRO_25",
"aliases": [
"MC_25"
]
},
"0x771A": {
"group": "macro",
"key": "MACRO_26"
"key": "QK_MACRO_26",
"aliases": [
"MC_26"
]
},
"0x771B": {
"group": "macro",
"key": "MACRO_27"
"key": "QK_MACRO_27",
"aliases": [
"MC_27"
]
},
"0x771C": {
"group": "macro",
"key": "MACRO_28"
"key": "QK_MACRO_28",
"aliases": [
"MC_28"
]
},
"0x771D": {
"group": "macro",
"key": "MACRO_29"
"key": "QK_MACRO_29",
"aliases": [
"MC_29"
]
},
"0x771E": {
"group": "macro",
"key": "MACRO_30"
"key": "QK_MACRO_30",
"aliases": [
"MC_30"
]
},
"0x771F": {
"group": "macro",
"key": "MACRO_31"
"key": "QK_MACRO_31",
"aliases": [
"MC_31"
]
}
}
}
}
10 changes: 5 additions & 5 deletions docs/ChangeLog/20211127.md
Original file line number Diff line number Diff line change
@@ -56,27 +56,27 @@ 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"]}
]
],
"layout": "LAYOUT_all",
"layers": [
["MACRO_0", "MACRO_1", "MACRO_2", "MACRO_3"]
["QK_MACRO_0", "QK_MACRO_1", "QK_MACRO_2", "QK_MACRO_3"]
]
}
```
36 changes: 18 additions & 18 deletions docs/configurator_default_keymaps.md
Original file line number Diff line number Diff line change
@@ -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;
}
6 changes: 3 additions & 3 deletions docs/feature_macros.md
Original file line number Diff line number Diff line change
@@ -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.

Loading