pub fn control_map_parser(
input: &str,
) -> IResult<&str, Vec<Line>, VerboseError<&str>>
Expand description
parse controlmap.txt
ยงExamples
use pretty_assertions::assert_eq;
use controlmap_parser::parser::{control_map_parser, EventLine, Line, KeyID};
let input = r#"
// Main Gameplay
Forward 0x11 0xff 0xff 1 1 0 0x801
Back 0x1f 0xff 0xff 1 1 0 0x801
// Menu Mode
Accept !0,Activate 0xff 0x2000 0 0 0 0x8
"#;
let actual = control_map_parser(input);
let expected = Ok((
"",
vec![
Line::BlankLine,
Line::Comment(" Main Gameplay".into()),
Line::EventLine(EventLine {
event_name: "Forward".into(),
keyboard_id: KeyID::One("0x11".into()),
mouse_id: KeyID::One("0xff".into()),
gamepad_id: KeyID::One("0xff".into()),
remap_key: true,
remap_mouse: true,
remap_gamepad: false,
event_binary_flag: Some("0x801".into()),
}),
Line::EventLine(EventLine {
event_name: "Back".into(),
keyboard_id: KeyID::One("0x1f".into()),
mouse_id: KeyID::One("0xff".into()),
gamepad_id: KeyID::One("0xff".into()),
remap_key: true,
remap_mouse: true,
remap_gamepad: false,
event_binary_flag: Some("0x801".into()),
}),
Line::Comment(" Menu Mode".into()),
Line::EventLine(EventLine {
event_name: "Accept".into(),
keyboard_id: KeyID::Alias("Activate".into()),
mouse_id: KeyID::One("0xff".into()),
gamepad_id: KeyID::One("0x2000".into()),
remap_key: false,
remap_mouse: false,
remap_gamepad: false,
event_binary_flag: Some("0x8".into()),
}),
],
));
assert_eq!(actual, expected);