Skip to content

Commit

Permalink
BREAKING: Add identifier to conditional_layer (#53)
Browse files Browse the repository at this point in the history
This fixes an issues where multiple tri-state conditions would overwrite
one another
  • Loading branch information
urob committed Aug 8, 2024
1 parent abceadc commit dd06cf4
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 3 additions & 2 deletions docs/core_helpers.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,12 @@ ZMK_COMBO(paste, &kp LC(V), LB1 LB2)

### Synopsis

`ZMK_CONDITIONAL_LAYER(if_layers, then_layers)`
`ZMK_CONDITIONAL_LAYER(name, if_layers, then_layer)`

Set up a `tri-layer` condition, which activates `then_layer` if all layers in `if_layers` are
active.

- `name`: a unique identifier string
- `if_layers`: a list of layers which trigger the `then_layer` if simultaneously active
- `then_layer`: the layer which is activated when the if-condition is met. Due to ZMK's layering
model, it should generally have a higher number than the `if_layers`
Expand All @@ -168,7 +169,7 @@ active.
This triggers "layer 3" if layers "1" and "2" are simultaneously active.

```C++
ZMK_CONDITIONAL_LAYER(1 2, 3)
ZMK_CONDITIONAL_LAYER(its_magic, 1 2, 3)
```
Mind that ZMK's layer numbering starts at 0. One can use layer definitions, as demonstrated in this
Expand Down
4 changes: 3 additions & 1 deletion docs/migration-to-v2.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@
```

4. Change prefix of Danish unicode characters from `dk_` to the ISO language code `da_`
5. (optional) replace `ZMK_BEHAVIOR` with explicit behavior helpers
5. Add identifier string to `ZMK_CONDITIONAL_LAYER`
([new syntax](core_helpers.md#zmk_conditional_layer))
6. (optional) replace `ZMK_BEHAVIOR` with explicit behavior helpers
4 changes: 2 additions & 2 deletions include/zmk-helpers/helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,11 @@

/* ZMK_CONDITIONAL_LAYER */

#define ZMK_CONDITIONAL_LAYER(if_layers, then_layer) \
#define ZMK_CONDITIONAL_LAYER(name, if_layers, then_layer) \
/ { \
conditional_layers { \
compatible = "zmk,conditional-layers"; \
tri_layer { \
tri_layer_ ## name { \
if-layers = <if_layers>; \
then-layer = <then_layer>; \
}; \
Expand Down

0 comments on commit dd06cf4

Please sign in to comment.