Expand description
Functional helpers to convert a DInput->XInput YAML mapping into an XInput-like state.
- Pure functions; no hidden global state
- YAML schema matches the one produced by
dinput_mapper, with backward-compatible extensions - Comments are in English by request
Modules§
- XButtons
- XInput button bit flags (matches Windows XINPUT header values)
Structs§
- Axes
- Axis
- Generic axis descriptor with optional bit-level addressing.
Backward compatible: if
bit_offsetis absent,report_offset*8 is used.size_bitssupports 4/8/10/12/16 (others fall back via generic reader). - Buttons
- Device
- Dpad
- D-Pad (HAT) descriptor.
Backward compatible byte model + NEW bit/nibble addressing.
Priority: if
bit_offsetis set, read via bits (size_bitsdefault 4). - Mapping
Yaml - Trigger
Def - Triggers
- XInput
State - Minimal XInput-like state we produce.
Enums§
- Load
Error - Distinguish IO vs YAML parse errors for file loading.
Functions§
- apply_
anti_ deadzone_ i16 - Optionally apply anti-deadzone (minimum magnitude).
antiin [0..=32767]. - apply_
deadzone_ i16 - Apply a centered deadzone on an i16 axis.
deadzonein [0..=32767]. Values within [-deadzone..deadzone] -> 0. Outside, linearly re-scale to full range to preserve reach. - apply_
outer_ deadzone_ i16 - Apply an outer deadzone (a.k.a. saturation zone) to compress near extremes.
outerin [0..=32767]. If outer>0, map [0..(32767-outer)] -> [0..32767]. - apply_
radial_ deadzone - Radial deadzone for a stick.
deadzonein [0..=32767]. - apply_
response_ curve_ i16 - Apply a symmetric gamma-like response curve on an i16 axis.
gamma> 0 (typical range 0.5..3.0). gamma>1: softer center, stronger end; gamma<1: more sensitive center. - apply_
u8_ zones - Map u8 [0..255] through an anti-deadzone (minimum) and optional linear outer-deadzone.
antiandouterin [0..=255]. - autorepeat_
fire - Autorepeat helper (legacy): when a bit is held, fires at (first_delay_ms then repeat_rate_ms). Uses modulo and can miss if jittery polls.
- autorepeat_
fire_ window - Autorepeat helper (jitter-tolerant): fire if the time since last fire crosses the next repeat boundary within a small window.
- button_
edges - Compute edge masks between previous and current buttons.
- debounce_
bit - Debounce mask: require a stable
hold_countframes before accepting changes. - map_
report_ to_ xinput - Convert a raw HID input report to an XInput-like state using the mapping. This is a pure function: output depends only on (mapping, report).
- merge_
masks - Merge a list of masks (e.g., macro/extra layers) into one via OR.
- parse_
mapping_ yaml_ file - Parse YAML file content into MappingYaml.
Returns
LoadErrorto separate IO and YAML failures. - parse_
mapping_ yaml_ str - Parse YAML string into MappingYaml.
- postprocess_
stick - Compose helpers for a typical stick pipeline (backward-compatible).
- postprocess_
stick_ ex - Extended pipeline with outer-deadzone and response curve (new API).
- remap_
buttons - Build a new mask by applying a remap table (source->dest). Missing sources are ignored.
remap: list of (src_mask_bit, dst_mask_bit). - set_bit
- Set/clear/toggle helpers
- square_
to_ circle - Convert square stick into circular region while preserving direction.
- toggle_
bit - trigger_
hysteresis - Trigger with hysteresis: returns new state given last state and two thresholds.
- trigger_
pressed - Trigger thresholding: turn trigger value [0..255] into boolean press.