@@ -669,6 +669,78 @@ public void Actions_CanPerformTapInteraction()
669669 Assert . That ( action . phase , Is . EqualTo ( InputActionPhase . Waiting ) ) ;
670670 }
671671
672+ [ Test ]
673+ [ Category ( "Actions" ) ]
674+ public void Actions_CanPerformTapInteractionWithAnalogControls ( )
675+ {
676+ ResetTime ( ) ;
677+
678+ var gamepad = InputSystem . AddDevice < Gamepad > ( ) ;
679+
680+ var action = new InputAction ( binding : "<Gamepad>/leftTrigger" , type : InputActionType . Button ,
681+ interactions : "tap(duration=0.2)" ) ;
682+
683+ // This is the default value, which makes the release point to be 0.75 * 0.5 = 0.375.
684+ InputSystem . settings . defaultButtonPressPoint = 0.5f ;
685+
686+ action . Enable ( ) ;
687+
688+ currentTime = 0f ;
689+
690+ using ( var trace = new InputActionTrace ( ) )
691+ {
692+ trace . SubscribeTo ( action ) ;
693+
694+ currentTime = 0.1f ;
695+ Set ( gamepad . leftTrigger , 0.3f ) ;
696+ currentTime = 0.2f ;
697+ Set ( gamepad . leftTrigger , 0.54f ) ;
698+
699+ Assert . That ( trace ,
700+ Started < TapInteraction > ( action , value : 0.54f , time : 0.2f ) ) ;
701+ trace . Clear ( ) ;
702+
703+ // Assert that a timeout will ocurr and a canceled event will be triggered.
704+ currentTime = 0.5f ;
705+ Set ( gamepad . leftTrigger , 0.9f ) ;
706+ Assert . That ( trace ,
707+ Canceled < TapInteraction > ( action ) ) ;
708+ trace . Clear ( ) ;
709+
710+ // Maintain a value above the press point for a while to assess that a start event is not triggered.
711+ // This was the case where the tap interaction was previously re-starting.
712+ currentTime = 1.2f ;
713+ Set ( gamepad . leftTrigger , 0.52f ) ;
714+
715+ Assert . That ( trace , Is . Empty ) ;
716+
717+ // Go below the release point so check that no cancel event is triggered, since it didn't start.
718+ // This was the case where the tap interaction was previously re-starting and then would cancel after
719+ // timeout.
720+ currentTime = 1.5f ;
721+ Set ( gamepad . leftTrigger , 0.2f ) ;
722+
723+ Assert . That ( trace , Is . Empty ) ;
724+
725+ // Go above the press point again and check that a start event is triggered.
726+ currentTime = 2.0f ;
727+ Set ( gamepad . leftTrigger , 0.6f ) ;
728+
729+ Assert . That ( trace ,
730+ Started < TapInteraction > ( action ) ) ;
731+ trace . Clear ( ) ;
732+
733+ currentTime = 2.10f ;
734+ Set ( gamepad . leftTrigger , 0.4f ) ;
735+
736+ // Check that the tap is performed.
737+ currentTime = 2.15f ;
738+ Set ( gamepad . leftTrigger , 0.2f ) ;
739+ Assert . That ( trace ,
740+ Performed < TapInteraction > ( action ) ) ;
741+ }
742+ }
743+
672744 [ Test ]
673745 [ Category ( "Actions" ) ]
674746 public void Actions_CanPerformDoubleTapInteraction ( )
0 commit comments