Crate xinput_mapper

Crate xinput_mapper 

Source
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_offset is absent, report_offset*8 is used. size_bits supports 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_offset is set, read via bits (size_bits default 4).
MappingYaml
TriggerDef
Triggers
XInputState
Minimal XInput-like state we produce.

Enums§

LoadError
Distinguish IO vs YAML parse errors for file loading.

Functions§

apply_anti_deadzone_i16
Optionally apply anti-deadzone (minimum magnitude). anti in [0..=32767].
apply_deadzone_i16
Apply a centered deadzone on an i16 axis. deadzone in [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. outer in [0..=32767]. If outer>0, map [0..(32767-outer)] -> [0..32767].
apply_radial_deadzone
Radial deadzone for a stick. deadzone in [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. anti and outer in [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_count frames 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 LoadError to 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.