| Crates.io | xinput-mapper |
| lib.rs | xinput-mapper |
| version | 0.1.2 |
| created_at | 2025-10-10 13:39:58.92272+00 |
| updated_at | 2025-10-10 17:23:02.957958+00 |
| description | Functional helpers to convert DInput YAML mapping into an XInput-like state. |
| homepage | |
| repository | https://github.com/tetthys/xinput-mapper |
| max_upload_size | |
| id | 1876947 |
| size | 42,238 |
Functional helpers to convert DirectInput / HID reports → XInput-like states
Pure Rust, no global state, reusable across tools and engines.
dinput_mapperXInputStateutils module)cargo add xinput-mapper
Or add manually to Cargo.toml:
[dependencies]
xinput-mapper = "0.1"
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(())
}
| 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.
Licensed under either of:
LICENSE-MITLICENSE-APACHEAuthor: [tetthys] Repository: https://github.com/tetthys/xinput-mapper