feat(behaviors): Add reusable sensor behaviors.

* Add new sensor behaviors that either take full bindings
  add definition, or accept parameters when bound in the
  keymap.
* Remove existing hard-coded key press sensor behavior
  and instead leverage new generic sensor behaviors to
  achieve the same functionality.

Co-authored-by: nick@conway.dev
This commit is contained in:
Nick Conway
2022-05-23 16:33:08 -04:00
committed by Pete Johanson
parent 9a73650041
commit 3db163aa2c
17 changed files with 301 additions and 107 deletions

View File

@@ -23,17 +23,17 @@ Keyboards and macropads with encoder support will typically take the two EC11 pi
### Rotation
Rotation is handled separately as a type of sensor. The behavior for this is set in `sensor-bindings`, which is defined in each keymap layer in the following format:
Rotation is handled separately as a type of sensor. The behavior for this is set in `sensor-bindings`. See [Sensor Rotation](../behaviors/sensor-rotate.md) for customizing this behavior.
```
sensor-bindings = <BINDING CW_KEY CCW_KEY>;
sensor-bindings = <BINDING [CW_KEY] [CCW_KEY]>;
```
- `BINDING`, for now, has only one behavior available; `&inc_dec_kp` for key presses (see [Key Press](../behaviors/key-press.md) for details on available keycodes).
- `BINDING` is either a user-defined behavior, or `&inc_dec_kp` for key presses (see [Key Press](../behaviors/key-press.md) for details on available keycodes).
- `CW_KEY` is the keycode activated by a clockwise turn.
- `CCW_KEY` is the keycode activated by a counter-clockwise turn.
Additional encoders can be configured by adding more `BINDING CW_KEY CCW_KEY` sets immediately after the first.
Additional encoders can be configured by adding more bindings immediately after the first.
As an example, a complete `sensor-bindings` for a Kyria with two encoders could look like: