File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed
Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -179,6 +179,45 @@ public void Events_CanListenForButtonPresses()
179179 InputSystem . Update ( ) ;
180180 }
181181
182+ [ Test ]
183+ [ Category ( "Events" ) ]
184+ public void Events_OnAnyButtonPressed_FiltersOutOtherControls ( )
185+ {
186+ InputSystem . settings . defaultButtonPressPoint = 0.5f ;
187+
188+ var mouse = InputSystem . AddDevice < Mouse > ( ) ;
189+
190+ var callCount = 0 ;
191+
192+ InputSystem . onAnyButtonPress
193+ . Call ( ctrl =>
194+ {
195+ Assert . That ( ctrl , Is . SameAs ( mouse . leftButton ) ) ;
196+ ++ callCount ;
197+ } ) ;
198+
199+ Assert . That ( callCount , Is . Zero ) ;
200+
201+ InputSystem . Update ( ) ;
202+
203+ InputSystem . QueueStateEvent ( mouse , new MouseState ( ) . WithButton ( MouseButton . Left ) ) ;
204+ InputSystem . Update ( ) ;
205+
206+ Assert . That ( callCount , Is . EqualTo ( 1 ) ) ;
207+
208+ var mouseState = new MouseState ( ) ;
209+ mouseState . position . x = 3f ;
210+ InputSystem . QueueStateEvent ( mouse , mouseState . WithButton ( MouseButton . Left ) ) ;
211+ InputSystem . Update ( ) ;
212+
213+ Assert . That ( callCount , Is . EqualTo ( 1 ) ) ;
214+
215+ InputSystem . QueueStateEvent ( mouse , new MouseState ( ) . WithButton ( MouseButton . Left , false ) ) ;
216+ InputSystem . Update ( ) ;
217+
218+ Assert . That ( callCount , Is . EqualTo ( 1 ) ) ;
219+ }
220+
182221 [ Test ]
183222 [ Category ( "Events" ) ]
184223 public void Events_OnAnyButtonPressed_FiltersOutNonStateEvents ( )
You can’t perform that action at this time.
0 commit comments