binds

Macro binds 

Source
macro_rules! binds {
    ( $( ( $x: expr, $( $tail: tt )* ) ),* ) => { ... };
}
Expand description

Outputs binds in the expected format for add_binds, set_binds and InputMap::new though in the latter case input_map! should be used to skip the middle man.

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 mut input = input_map!((Select, base_input_codes::ShiftLeft));

let binds = { use base_input_codes::*; binds!(
    (Select, MouseButton::Left, ShiftRight),
    (Action::Undo,  [KeyZ, ControlLeft], [KeyZ, ControlRight], KeyCode::Undo),
    (Redo,  [KeyR, ControlLeft], [KeyR, ControlRight]),
    (Confirm, MouseButton::Left, Enter)
) };

input.add_binds(&binds);