winit_input_map

Macro input_map

source
macro_rules! input_map {
    () => { ... };
    ( $( ( $x:expr, $( $k:expr ),* ) ),* ) => { ... };
}
Expand description

creates new input map with binds and actions. anything that impliments into<Input> can be used as bind

#[derive(ToUsize)]
enum Action {
    Jump,
    Left,
    Right,
    Interact
}
use Action::*;
use winit_input_map::*;
use winit::{keyboard::KeyCode, event::MouseButton}
let mut input = input_map!(
    (Jump, KeyCode::Space),
    (Left, KeyCode::KeyA, KeyCode::LeftArrow),
    (Right, KeyCode::KeyD, KeyCode::RightArrow),
    (Interact, MouseButton::Left)
);