macro_rules! buttons {
(@inner $chain:tt , $($tail:tt)*) => { ... };
(@inner $chain:tt !$button:tt $($tail:tt)*) => { ... };
(@inner $chain:tt $button:tt $($tail:tt)*) => { ... };
(@inner $chain:tt) => { ... };
($($args:tt)*) => { ... };
}Expand description
Passing multiple buttons as an argument for functions.
This macro produces a value of type [ButtonArg].
ยงSyntax
This macro receives variant names of Button separated by commas,
buttons!(A, B, Esc, F12);Or number letarals corresponding to numeric keys.
buttons!(0, 1, 2);Variables can be used by enclosing them in square brackets.
let a = Button::A;
buttons!([a], B, C);The prefix ! means that this key is released.
let b = Button::B;
buttons!(!A, ![b], !0);Nested buttons!(..) will be flattened.
let arg = buttons!(A, B, C);
assert_eq!(
buttons!([arg], D, E),
buttons!(A, B, C, D, E),
);The prefix ! of nested buttons!(..) will affect each button.
let arg = buttons!(A, B, C);
assert_eq!(
buttons!(![arg], D, E),
buttons!(!A, !B, !C, D, E),
);