@@ -87,7 +87,16 @@ macro_rules! entry {
8787 entry!{ action=$action, message=InputMapperMessage :: KeyUp ( Key :: $key) $( , modifiers=[ $( $m) ,* ] ) ?}
8888 } } ;
8989 { action=$action: expr, message=$message: expr $( , modifiers=[ $( $m: ident) ,* $( , ) ?] ) ?} => { {
90- MappingEntry { trigger: $message, modifiers: modifiers!( $( $( $m) ,* ) ?) , action: $action. into( ) }
90+ & [ MappingEntry { trigger: $message, modifiers: modifiers!( $( $( $m) ,* ) ?) , action: $action. into( ) } ]
91+ } } ;
92+ { action=$action: expr, triggers=[ $( $m: ident) ,* $( , ) ?] } => { {
93+ & [
94+ MappingEntry { trigger: InputMapperMessage :: PointerMove , action: $action. into( ) , modifiers: modifiers!( ) } ,
95+ $(
96+ MappingEntry { trigger: InputMapperMessage :: KeyDown ( Key :: $m) , action: $action. into( ) , modifiers: modifiers!( ) } ,
97+ MappingEntry { trigger: InputMapperMessage :: KeyUp ( Key :: $m) , action: $action. into( ) , modifiers: modifiers!( ) } ,
98+ ) *
99+ ]
91100 } } ;
92101}
93102macro_rules! mapping {
@@ -98,15 +107,17 @@ macro_rules! mapping {
98107 let mut pointer_move: KeyMappingEntries = Default :: default ( ) ;
99108 let mut mouse_scroll: KeyMappingEntries = Default :: default ( ) ;
100109 $(
101- let arr = match $entry. trigger {
102- InputMapperMessage :: KeyDown ( key) => & mut key_down[ key as usize ] ,
103- InputMapperMessage :: KeyUp ( key) => & mut key_up[ key as usize ] ,
104- InputMapperMessage :: PointerMove => & mut pointer_move,
105- InputMapperMessage :: MouseScroll => & mut mouse_scroll,
106- } ;
107- arr. push( $entry) ;
108- ) *
109- ( key_up, key_down, pointer_move, mouse_scroll)
110+ for entry in $entry {
111+ let arr = match entry. trigger {
112+ InputMapperMessage :: KeyDown ( key) => & mut key_down[ key as usize ] ,
113+ InputMapperMessage :: KeyUp ( key) => & mut key_up[ key as usize ] ,
114+ InputMapperMessage :: PointerMove => & mut pointer_move,
115+ InputMapperMessage :: MouseScroll => & mut mouse_scroll,
116+ } ;
117+ arr. push( entry. clone( ) ) ;
118+ }
119+ ) *
120+ ( key_up, key_down, pointer_move, mouse_scroll)
110121 } } ;
111122}
112123
@@ -131,43 +142,25 @@ impl Default for Mapping {
131142 entry! { action=RectangleMessage :: DragStop , key_up=Lmb } ,
132143 entry! { action=RectangleMessage :: Abort , key_down=Rmb } ,
133144 entry! { action=RectangleMessage :: Abort , key_down=KeyEscape } ,
134- entry! { action=RectangleMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , message=InputMapperMessage :: PointerMove } ,
135- entry! { action=RectangleMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_down=KeyAlt } ,
136- entry! { action=RectangleMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_up=KeyAlt } ,
137- entry! { action=RectangleMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_down=KeyShift } ,
138- entry! { action=RectangleMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_up=KeyShift } ,
145+ entry! { action=RectangleMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , triggers=[ KeyAlt , KeyShift ] } ,
139146 // Ellipse
140147 entry! { action=EllipseMessage :: DragStart , key_down=Lmb } ,
141148 entry! { action=EllipseMessage :: DragStop , key_up=Lmb } ,
142149 entry! { action=EllipseMessage :: Abort , key_down=Rmb } ,
143150 entry! { action=EllipseMessage :: Abort , key_down=KeyEscape } ,
144- entry! { action=EllipseMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , message=InputMapperMessage :: PointerMove } ,
145- entry! { action=EllipseMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_down=KeyAlt } ,
146- entry! { action=EllipseMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_up=KeyAlt } ,
147- entry! { action=EllipseMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_down=KeyShift } ,
148- entry! { action=EllipseMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_up=KeyShift } ,
151+ entry! { action=EllipseMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , triggers=[ KeyAlt , KeyShift ] } ,
149152 // Shape
150153 entry! { action=ShapeMessage :: DragStart , key_down=Lmb } ,
151154 entry! { action=ShapeMessage :: DragStop , key_up=Lmb } ,
152155 entry! { action=ShapeMessage :: Abort , key_down=Rmb } ,
153156 entry! { action=ShapeMessage :: Abort , key_down=KeyEscape } ,
154- entry! { action=ShapeMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , message=InputMapperMessage :: PointerMove } ,
155- entry! { action=ShapeMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_down=KeyAlt } ,
156- entry! { action=ShapeMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_up=KeyAlt } ,
157- entry! { action=ShapeMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_down=KeyShift } ,
158- entry! { action=ShapeMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , key_up=KeyShift } ,
157+ entry! { action=ShapeMessage :: Resize { center: KeyAlt , lock_ratio: KeyShift } , triggers=[ KeyAlt , KeyShift ] } ,
159158 // Line
160- entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , message=InputMapperMessage :: PointerMove } ,
161- entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , key_down=KeyAlt } ,
162- entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , key_up=KeyAlt } ,
163- entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , key_down=KeyShift } ,
164- entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , key_up=KeyShift } ,
165- entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , key_down=KeyControl } ,
166- entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , key_up=KeyControl } ,
167159 entry! { action=LineMessage :: DragStart , key_down=Lmb } ,
168160 entry! { action=LineMessage :: DragStop , key_up=Lmb } ,
169161 entry! { action=LineMessage :: Abort , key_down=Rmb } ,
170162 entry! { action=LineMessage :: Abort , key_down=KeyEscape } ,
163+ entry! { action=LineMessage :: Redraw { center: KeyAlt , lock_angle: KeyControl , snap_angle: KeyShift } , triggers=[ KeyAlt , KeyShift , KeyControl ] } ,
171164 // Pen
172165 entry! { action=PenMessage :: PointerMove , message=InputMapperMessage :: PointerMove } ,
173166 entry! { action=PenMessage :: DragStart , key_down=Lmb } ,
0 commit comments