input_map

Macro input_map 

Source
macro_rules! input_map {
    () => { ... };
    ( $( $t: tt )* ) => { ... };
}
Expand description

Outputs an input with the inputed binds.

The input is structured by a list of (Action, bind, bind, ..). An action is pressed if any of its binds are pressed.

Binds are described as either [InputCode, InputCode, ..] or InputCode. A bind is pressed if all its InputCodes are pressed.

use winit_input_map::*;
use Action::*;
#[derive(PartialEq, Eq, Clone, Copy, Hash, Debug)]
enum Action {
    Select, Undo, Redo, Confirm
}
let input = { use base_input_codes::*; input_map!(
    (Select, MouseButton::Left, ShiftLeft, ShiftRight),
    (Action::Undo,  [KeyZ, ControlLeft], [KeyZ, ControlRight]),
    (Redo,  [KeyR, ControlLeft], [KeyR, ControlRight]),
    (Confirm, MouseButton::Left, Enter)
) };