Basic hat support. (#20)

Reviewed-on: #20
Co-authored-by: Anna Rose Wiggins <annabunches@gmail.com>
Co-committed-by: Anna Rose Wiggins <annabunches@gmail.com>
This commit is contained in:
Anna Rose Wiggins 2025-09-15 17:55:55 +00:00 committed by Anna Rose Wiggins
parent 62befa045a
commit 5e005478f1
12 changed files with 151 additions and 13 deletions

View file

@ -70,6 +70,17 @@ rules:
device: main
axis: RZ
# Hat mapping. Hats are technically an axis, but only output -1, 0, or 1, so we don't normalize
# them to an output range, we just pass them through mostly unmodified
- type: hat
input:
device: flightstick
inverted: true # hats do support inversion. As with other rule types, this only has an effect on *inputs*.
hat: hat0x # a typical joystick hat actually has 2 hat axes: x and y
output:
device: main
hat: hat0x
# Straightforward button mapping
- type: button
input:
@ -111,8 +122,9 @@ rules:
input:
device: flightstick
axis: ABS_RY # This axis commonly represents thumbsticks
deadzone_start: 0
deadzone_end: 30000
deadzones:
- start: 0
end: 30000
output:
device: main
button: BTN_BASE4
@ -129,8 +141,9 @@ rules:
input:
device: flightstick
axis: ABS_Z
deadzone_start: 0
deadzone_end: 500
deadzones:
- start: 0
end: 500
output:
device: mouse
button: REL_WHEEL

View file

@ -48,6 +48,7 @@ All `rules` must have a `type` parameter. Valid values for this parameter are:
* `axis-combined` - a mapping that combines 2 input axes into a single output axis.
* `axis-to-button` - causes an axis input to produce a button output. This can be repeated with variable speed proportional to the axis' input value
* `axis-to-relaxis` - like axis-to-button, but produces a "relative axis" output value. This is useful for simulating mouse scrollwheel and movement events.
* `hat` - a special type of axis with ternary output. Each joystick hat will typically be 2 hat axes named `ABS_HAT0X` / `ABS_HAT0Y`, where the `0` is an index between 0 - 3. So for a typical hat you would define 2 `hat` rules.
Configuration options for each rule type vary. See [examples/ruletypes.yml](examples/ruletypes.yml) for an example of each type with all options specified.