xinput-mapper 0.1.2

Functional helpers to convert DInput YAML mapping into an XInput-like state.
Documentation
# 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


```bash
cargo add xinput-mapper
````

Or add manually to `Cargo.toml`:

```toml
[dependencies]
xinput-mapper = "0.1"
```

---

## 🧩 Example


```rust
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`](./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](https://github.com/tetthys/xinput-mapper)

```