xinput-mapper

Crates.ioxinput-mapper
lib.rsxinput-mapper
version0.1.2
created_at2025-10-10 13:39:58.92272+00
updated_at2025-10-10 17:23:02.957958+00
descriptionFunctional helpers to convert DInput YAML mapping into an XInput-like state.
homepage
repositoryhttps://github.com/tetthys/xinput-mapper
max_upload_size
id1876947
size42,238
(tetthys)

documentation

README

xinput-mapper

Functional helpers to convert DirectInput / HID reports → XInput-like states
Pure Rust, no global state, reusable across tools and engines.


✨ Features

  • ✅ Parse mapping YAML generated by dinput_mapper
  • ✅ Convert raw HID reports into XInputState
  • ✅ Pure functional API (no globals, testable)
  • ✅ Deadzone, remap, and shaping utilities (utils module)
  • ✅ Compatible with ViGEm, custom input bridges, or emulators

📦 Installation

cargo add xinput-mapper

Or add manually to Cargo.toml:

[dependencies]
xinput-mapper = "0.1"

🧩 Example

use xinput_mapper::{
    parse_mapping_yaml_file,
    map_report_to_xinput,
    XButtons,
    utils::postprocess_stick,
};

fn main() -> Result<(), Box<dyn std::error::Error>> {
    // Load YAML mapping (produced by dinput_mapper)
    let mapping = parse_mapping_yaml_file(std::path::Path::new("mapping.yaml"))?;

    // Example: simulate 64-byte HID report
    let report = vec![0u8; 64];
    let mut xs = map_report_to_xinput(&mapping, &report);

    // Optional postprocessing
    let (lx, ly) = postprocess_stick(xs.thumb_lx, xs.thumb_ly, true, 4000, 1200);
    xs.thumb_lx = lx;
    xs.thumb_ly = ly;

    println!("Mapped: {:?}", xs);
    Ok(())
}

🧠 Public API

Function Description
parse_mapping_yaml_file(path) Load YAML mapping file
map_report_to_xinput(mapping, report) Convert HID report → XInput-like state
XButtons::* Standard XInput button bitflags
utils::* Stick shaping, deadzone, button helpers

For full documentation, see lib.md.


🧾 License

Licensed under either of:

  • MIT License — see LICENSE-MIT
  • Apache License 2.0 — see LICENSE-APACHE

Author: [tetthys] Repository: https://github.com/tetthys/xinput-mapper

Commit count: 0

cargo fmt