Macro input_map

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

Creates new input map with inputed input codes bound to the acompaning action. Anything that impliments into<InputCode> can be bound to an action

use Action::*;
use winit_input_map::*;
use winit::{keyboard::KeyCode, event::MouseButton};
#[derive(Hash, PartialEq, Eq, Clone, Copy)]
enum Action {
    Jump,
    Left,
    Right,
    Interact
}
let mut input = input_map!(
    (Jump,     KeyCode::Space                    ),
    (Left,     KeyCode::KeyA, KeyCode::ArrowLeft ),
    (Right,    KeyCode::KeyD, KeyCode::ArrowRight),
    (Interact, MouseButton::Left                 )
);