Transformer Input Processor
Overview
The transformer input processor is used to perform various transforms on the value of an input event that has a code matching the codes set on the transformer. Events with other codes will be ignored.
Available Transforms
The following transforms are available, by including
the dt-bindings/zmk/input_transform.h header
provided by ZMK near the top of your keymap/overlay:
#include <dt-bindings/zmk/input_transform.h>
INPUT_TRANSFORM_XY_SWAP- When encountering a value with matching type, swap the type of the event to the other axis, e.g. change an event of typeINPUT_REL_Xto typeINPUT_REL_Y.INPUT_TRANSFORM_X_INVERT- Invert the values of any events that match the configuredx-codesof the processor, by multiplying by negative one.INPUT_TRANSFORM_Y_INVERT- Invert the values of any events that match the configuredy-codesof the processor, by multiplying by negative one.
Usage
When used, a transformer takes one parameter, a combination of flags indicating which transforms to apply:
&zip_xy_transform (INPUT_TRANSFORM_X_INVERT | INPUT_TRANSFORM_Y_INVERT)
Pre-Defined Instances
Three pre-defined instance of the scaler input processor are available:
| Reference | Description |
|---|---|
&zip_xy_transform | Applies the given transforms to X/Y movement events |
&zip_scroll_transform | Applies the given transforms to wheel/horizontal wheel events |
User Defined Instances
Users can define new instances of the transform input processor if they want to target different codes.
Example
#include <zephyr/dt-bindings/input/input-event-codes.h>
/ {
input_processors {
my_rotation_event_transform: my_rotation_event_transform {
compatible = "zmk,input-processor-transform";
#input-processor-cells = <1>;
type = <INPUT_EV_REL>;
x-codes = <INPUT_REL_RX>;
y-codes = <INPUT_REL_RY>;
};
};
}
Compatible
The transform input processor uses a compatible property of "zmk,input-processor-transform".
Standard Properties
#input-processor-cells- required to be constant value of<1>.
User Properties
type- The type of events to transform. Usually, this isINPUT_EV_RELfor relative events.x-codes- The specific X codes within the given type to transform, e.g. relative event codesy-codes- The specific Y codes within the given type to transform, e.g. relative event codes