Merge branch 'behaviors/macros-take-two' of https://github.com/petejohanson/zmk into petejohanson_behaviors/macros-take-two

This commit is contained in:
Jamie Ding 2022-03-22 03:43:46 +00:00
commit 38e47f478a

View file

@ -134,3 +134,49 @@ bindings
, <&kp L &kp O &kp N &kp G>
;
```
## Common Patterns
### Layer Activation + More
Macros make it easy to combine a [layer behavior](/docs/behaviors/layers), e.g. `&mo` with another behavior at the same time.
Common examples are enabling one or more modifiers when the layer is active, or changing the RBG underglow color.
To achieve this, a combination of a 0ms wait time and splitting the press and release between a `&macro_pause_for_release` is used:
#### Layer + Modifier
```
wait-ms = <0>;
bindings
= <&macro_press &mo 1 &kp LSHFT>
, <&macro_pause_for_release>
, <&macro_release &mo 1 &kp LSHFT>;
```
#### Layer + Underglow Color
To trigged a different underglow when the macro is pressed, and when it is released, we use the macro "press" activation mode whenever triggering the `&rgb_ug` behavior:
```
wait-ms = <0>;
bindings
= <&macro_press &mo 1 &rgb_ug RGB_COLOR_HSB(128,100,100)>
, <&macro_pause_for_release>
, <&macro_release &mo 1 &macro_press &rgb_ug RGB_COLOR_HSB(300,100,50)>;
```
## Keycode Sequences
The other common use case for macros is to sending sequences of keycodes to the connected host. Here, a wait and tap time of at least 30ms is recommended to
avoid having HID notifications grouped at the BLE protocol level and then processed out of order:
```
wait-ms = <40>;
tap-ms = <40>;
bindings
= <&kp Z &kp M &kp K>
, <&kp SPACE>
, <&kp R &kp O &kp C &kp K &kp S>
;
```