File tree Expand file tree Collapse file tree
Packages/com.unity.inputsystem/InputSystem/Controls Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1114,9 +1114,13 @@ public static unsafe InputControl GetFirstButtonPressOrNull(this InputEventPtr e
11141114
11151115 foreach ( var control in eventPtr . EnumerateControls ( Enumerate . IgnoreControlsInDefaultState , magnitudeThreshold : magnitude ) )
11161116 {
1117- // Continue if the control did change in the event or did not have a previous state to compare to.
1117+ // Skip if the value didn't change. For IInputStateCallbackReceiver devices (e.g. Touchscreen),
1118+ // the event may not carry full device state, so fall back to checking the control was at
1119+ // default (not pressed) before this event.
11181120 var stateInEvent = control . GetStatePtrFromStateEvent ( eventPtr ) ;
1119- if ( stateInEvent == null || ! control . CompareValue ( control . currentStatePtr , stateInEvent ) )
1121+ var currentState = control . currentStatePtr ;
1122+ if ( stateInEvent != null ? ! control . CompareValue ( currentState , stateInEvent )
1123+ : control . CompareValue ( currentState , control . defaultStatePtr ) )
11201124 continue ;
11211125 if ( buttonControlsOnly && ! control . isButton )
11221126 continue ;
You can’t perform that action at this time.
0 commit comments