aboutsummaryrefslogtreecommitdiff
path: root/docs/feature_dynamic_macros.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/feature_dynamic_macros.md')
-rw-r--r--docs/feature_dynamic_macros.md75
1 files changed, 39 insertions, 36 deletions
diff --git a/docs/feature_dynamic_macros.md b/docs/feature_dynamic_macros.md
index 0d11a2864..b86df6c60 100644
--- a/docs/feature_dynamic_macros.md
+++ b/docs/feature_dynamic_macros.md
@@ -4,51 +4,45 @@ QMK supports temporary macros created on the fly. We call these Dynamic Macros.
4 4
5You can store one or two macros and they may have a combined total of 128 keypresses. You can increase this size at the cost of RAM. 5You can store one or two macros and they may have a combined total of 128 keypresses. You can increase this size at the cost of RAM.
6 6
7To enable them, first add a new element to the end of your `keycodes` enum — `DYNAMIC_MACRO_RANGE`: 7To enable them, first include `DYNAMIC_MACRO_ENABLE = yes` in your `rules.mk`. Then, add the following keys to your keymap:
8 8
9```c 9|Key |Alias |Description |
10enum keycodes { 10|------------------|----------|---------------------------------------------------|
11 QWERTY = SAFE_RANGE, 11|`DYN_REC_START1` |`DM_REC1` |Start recording Macro 1 |
12 COLEMAK, 12|`DYN_REC_START2` |`DM_REC2` |Start recording Macro 2 |
13 DVORAK, 13|`DYN_MACRO_PLAY1` |`DM_PLY1` |Replay Macro 1 |
14 PLOVER, 14|`DYN_MACRO_PLAY2` |`DM_PLY2` |Replay Macro 2 |
15 LOWER, 15|`DYN_REC_STOP` |`DM_RSTP` |Finish the macro that is currently being recorded. |
16 RAISE,
17 BACKLIT,
18 EXT_PLV,
19 DYNAMIC_MACRO_RANGE,
20};
21```
22 16
23Your `keycodes` enum may have a slightly different name. You must add `DYNAMIC_MACRO_RANGE` as the last element because `dynamic_macros.h` will add some more keycodes after it. 17That should be everything necessary.
24 18
25Below it, include the `dynamic_macro.h` header: 19To start recording the macro, press either `DYN_REC_START1` or `DYN_REC_START2`.
26 20
27```c 21To finish the recording, press the `DYN_REC_STOP` layer button.
28 #include "dynamic_macro.h"`
29```
30 22
31Add the following keys to your keymap: 23To replay the macro, press either `DYN_MACRO_PLAY1` or `DYN_MACRO_PLAY2`.
32 24
33* `DYN_REC_START1` — start recording the macro 1, 25It is possible to replay a macro as part of a macro. It's ok to replay macro 2 while recording macro 1 and vice versa but never create recursive macros i.e. macro 1 that replays macro 1. If you do so and the keyboard will get unresponsive, unplug the keyboard and plug it again. You can disable this completly by defining `DYNAMIC_MACRO_NO_NESTING` in your `config.h` file.
34* `DYN_REC_START2` — start recording the macro 2,
35* `DYN_MACRO_PLAY1` — replay the macro 1,
36* `DYN_MACRO_PLAY2` — replay the macro 2,
37* `DYN_REC_STOP` — finish the macro that is currently being recorded.
38 26
39Add the following code to the very beginning of your `process_record_user()` function: 27?> For the details about the internals of the dynamic macros, please read the comments in the `process_dynamic_macro.h` and `process_dynamic_macro.c` files.
40 28
41```c 29## Customization
42 if (!process_record_dynamic_macro(keycode, record)) {
43 return false;
44 }
45```
46 30
47That should be everything necessary. To start recording the macro, press either `DYN_REC_START1` or `DYN_REC_START2`. To finish the recording, press the `DYN_REC_STOP` layer button. To replay the macro, press either `DYN_MACRO_PLAY1` or `DYN_MACRO_PLAY2`. 31There are a number of options added that should allow some additional degree of customization
48 32
49Note that it's possible to replay a macro as part of a macro. It's ok to replay macro 2 while recording macro 1 and vice versa but never create recursive macros i.e. macro 1 that replays macro 1. If you do so and the keyboard will get unresponsive, unplug the keyboard and plug it again. 33|Define |Default |Description |
34|----------------------------|----------------|-----------------------------------------------------------------------------------------------------------------|
35|`DYNAMIC_MACRO_SIZE` |128 |Sets the amount of memory that Dynamic Macros can use. This is a limited resource, dependent on the controller. |
36|`DYNAMIC_MACRO_USER_CALL` |*Not defined* |Defining this falls back to using the user `keymap.c` file to trigger the macro behavior. |
37|`DYNAMIC_MACRO_NO_NESTING` |*Not Defined* |Defining this disables the ability to call a macro from another macro (nested macros). |
50 38
51For users of the earlier versions of dynamic macros: It is still possible to finish the macro recording using just the layer modifier used to access the dynamic macro keys, without a dedicated `DYN_REC_STOP` key. If you want this behavior back, use the following snippet instead of the one above: 39
40If the LEDs start blinking during the recording with each keypress, it means there is no more space for the macro in the macro buffer. To fit the macro in, either make the other macro shorter (they share the same buffer) or increase the buffer size by adding the `DYNAMIC_MACRO_SIZE` define in your `config.h` (default value: 128; please read the comments for it in the header).
41
42
43### DYNAMIC_MACRO_USER_CALL
44
45For users of the earlier versions of dynamic macros: It is still possible to finish the macro recording using just the layer modifier used to access the dynamic macro keys, without a dedicated `DYN_REC_STOP` key. If you want this behavior back, add `#define DYNAMIC_MACRO_USER_CALL` to your `config.h` and insert the following snippet at the beginning of your `process_record_user()` function:
52 46
53```c 47```c
54 uint16_t macro_kc = (keycode == MO(_DYN) ? DYN_REC_STOP : keycode); 48 uint16_t macro_kc = (keycode == MO(_DYN) ? DYN_REC_STOP : keycode);
@@ -58,6 +52,15 @@ For users of the earlier versions of dynamic macros: It is still possible to fin
58 } 52 }
59``` 53```
60 54
61If the LEDs start blinking during the recording with each keypress, it means there is no more space for the macro in the macro buffer. To fit the macro in, either make the other macro shorter (they share the same buffer) or increase the buffer size by setting the `DYNAMIC_MACRO_SIZE` preprocessor macro (default value: 128; please read the comments for it in the header). 55### User Hooks
56
57There are a number of hooks that you can use to add custom functionality and feedback options to Dynamic Macro feature. This allows for some additional degree of customization.
58
59Note, that direction indicates which macro it is, with `1` being Macro 1, `-1` being Macro 2, and 0 being no macro.
60
61* `dynamic_macro_record_start_user(void)` - Triggered when you start recording a macro.
62* `dynamic_macro_play_user(int8_t direction)` - Triggered when you play back a macro.
63* `dynamic_macro_record_key_user(int8_t direction, keyrecord_t *record)` - Triggered on each keypress while recording a macro.
64* `dynamic_macro_record_end_user(int8_t direction)` - Triggered when the macro recording is stopped.
62 65
63For the details about the internals of the dynamic macros, please read the comments in the `dynamic_macro.h` header. 66Additionally, you can call `dynamic_macro_led_blink()` to flash the backlights if that feature is enabled.