@@ -1224,8 +1224,8 @@ public void EventHandledPolicy_ShouldReflectUserSetting()
12241224 Assert . That ( InputSystem . s_Manager . inputEventHandledPolicy , Is . EqualTo ( InputEventHandledPolicy . SuppressStateUpdates ) ) ;
12251225
12261226 // Assert policy can be changed
1227- InputSystem . s_Manager . inputEventHandledPolicy = InputEventHandledPolicy . SuppressActionUpdates ;
1228- Assert . That ( InputSystem . s_Manager . inputEventHandledPolicy , Is . EqualTo ( InputEventHandledPolicy . SuppressActionUpdates ) ) ;
1227+ InputSystem . s_Manager . inputEventHandledPolicy = InputEventHandledPolicy . SuppressActionEventNotifications ;
1228+ Assert . That ( InputSystem . s_Manager . inputEventHandledPolicy , Is . EqualTo ( InputEventHandledPolicy . SuppressActionEventNotifications ) ) ;
12291229
12301230 // Assert policy can be changed back
12311231 InputSystem . s_Manager . inputEventHandledPolicy = InputEventHandledPolicy . SuppressStateUpdates ;
@@ -1245,27 +1245,37 @@ class SuppressedActionEventData
12451245 public int CanceledCount ;
12461246 }
12471247
1248- // Note that each element in the expected value arrays correspond to accumulated count per test step.
1248+ // Note that each element in the expected value arrays correspond to accumulated count per test step, in summary:
1249+ // Step 0: Initialize state
1250+ // Step 1: Press gamepad north and stick (Event marked handled)
1251+ // Step 2: Periodic state update/reading without changes (north and stick still actuated)
1252+ // Step 3: Release button north and stick while no longer being suppressed.
1253+ // Step 4: Press gamepad north and stick.
1254+
1255+ // Press event is detected in step 2 (false positive) with default interaction
12491256 [ TestCase ( InputEventHandledPolicy . SuppressStateUpdates , // policy
12501257 null , // interactions
12511258 new int [ ] { 0 , 0 , 1 , 1 , 2 } , // started
12521259 new int [ ] { 0 , 0 , 1 , 1 , 2 } , // performed
12531260 new int [ ] { 0 , 0 , 0 , 1 , 1 } ) ] // cancelled
1254- [ TestCase ( InputEventHandledPolicy . SuppressActionUpdates ,
1261+ // Press event is not detected in step 1/2 with default interaction
1262+ [ TestCase ( InputEventHandledPolicy . SuppressActionEventNotifications ,
12551263 null ,
12561264 new int [ ] { 0 , 0 , 0 , 0 , 1 } ,
12571265 new int [ ] { 0 , 0 , 0 , 0 , 1 } ,
1258- new int [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
1266+ new int [ ] { 0 , 0 , 0 , 1 , 1 } ) ]
1267+ // Press event is detected in step 2 (false positive) with explicit press interaction
12591268 [ TestCase ( InputEventHandledPolicy . SuppressStateUpdates ,
12601269 "press" ,
12611270 new int [ ] { 0 , 0 , 1 , 1 , 2 } ,
12621271 new int [ ] { 0 , 0 , 1 , 1 , 2 } ,
12631272 new int [ ] { 0 , 0 , 0 , 1 , 1 } ) ]
1264- [ TestCase ( InputEventHandledPolicy . SuppressActionUpdates ,
1273+ // Press event is not detected in step 1/2 (false positive) with explicit press interaction
1274+ [ TestCase ( InputEventHandledPolicy . SuppressActionEventNotifications ,
12651275 "press" ,
12661276 new int [ ] { 0 , 0 , 0 , 0 , 1 } ,
12671277 new int [ ] { 0 , 0 , 0 , 0 , 1 } ,
1268- new int [ ] { 0 , 0 , 0 , 0 , 0 } ) ]
1278+ new int [ ] { 0 , 0 , 0 , 1 , 1 } ) ]
12691279 [ Category ( "Events" ) ]
12701280 [ Description ( "ISXB-1524, ISXB-1396 Events suppressed has side-effects on actions" ) ]
12711281 public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransition (
@@ -1274,6 +1284,7 @@ public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransit
12741284 {
12751285 // Update setting to match desired scenario
12761286 InputSystem . s_Manager . inputEventHandledPolicy = policy ;
1287+ var seesControlChangesUnderSuppression = policy == InputEventHandledPolicy . SuppressActionEventNotifications ;
12771288
12781289 // Use a boxed boolean to allow lambda to capture reference.
12791290 var data = new SuppressedActionEventData ( ) ;
@@ -1296,7 +1307,7 @@ public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransit
12961307 action . performed += _ => ++ data . PerformedCount ;
12971308 action . canceled += _ => ++ data . CanceledCount ;
12981309
1299- // Ensure state is updated/initialized
1310+ // Step 0: Ensure state is updated/initialized
13001311 InputSystem . QueueStateEvent ( device , new GamepadState ( ) { leftStick = new Vector2 ( 0.01f , 0.0f ) } ) ;
13011312 InputSystem . Update ( ) ;
13021313 Assert . That ( data . StartedCount , Is . EqualTo ( expectedStarted [ 0 ] ) ) ;
@@ -1307,9 +1318,12 @@ public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransit
13071318 Assert . That ( action . WasPressedThisFrame , Is . EqualTo ( performedThisFrame ) ) ;
13081319 var releasedThisFrame = expectedCancelled [ 0 ] != 0 ;
13091320 Assert . That ( action . WasReleasedThisFrame , Is . EqualTo ( releasedThisFrame ) ) ;
1310- // TODO Assert.That(Gamepad.current.buttonNorth.wasPressedThisFrame, Is.False); <-- TODO Needs separate handling, just suppress?
1321+ Assert . That ( action . IsPressed , Is . False ) ; // Note: This is not an event and hence not suppressed
1322+
1323+ Assert . That ( Gamepad . current . buttonNorth . wasPressedThisFrame , Is . False ) ;
1324+ Assert . That ( Gamepad . current . buttonNorth . wasReleasedThisFrame , Is . False ) ;
13111325
1312- // Press button north and left stick with event suppression active
1326+ // Step 1: Press button north and left stick with event suppression active
13131327 data . MarkNextEventHandled = true ;
13141328 InputSystem . QueueStateEvent ( device , new GamepadState ( ) { leftStick = new Vector2 ( 1.00f , 0.01f ) }
13151329 . WithButton ( GamepadButton . North ) ) ;
@@ -1322,9 +1336,12 @@ public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransit
13221336 Assert . That ( action . WasPressedThisFrame , Is . EqualTo ( performedThisFrame ) ) ;
13231337 releasedThisFrame = expectedCancelled [ 1 ] - expectedCancelled [ 0 ] > 0 ;
13241338 Assert . That ( action . WasReleasedThisFrame , Is . EqualTo ( releasedThisFrame ) ) ;
1325- // TODO Assert.That(Gamepad.current.buttonNorth.wasPressedThisFrame , Is.EqualTo(expectedPerformed[1] - expectedPerformed[0] > 0));
1339+ Assert . That ( action . IsPressed , Is . EqualTo ( seesControlChangesUnderSuppression ) ) ; // Note: This is not an event and hence not suppressed
13261340
1327- // Simulate a periodic reading (e.g. driven by noise or irrelevant control), this will trigger performed count.
1341+ Assert . That ( Gamepad . current . buttonNorth . wasPressedThisFrame , Is . EqualTo ( seesControlChangesUnderSuppression ) ) ;
1342+ Assert . That ( Gamepad . current . buttonNorth . wasReleasedThisFrame , Is . False ) ;
1343+
1344+ // Step 2: Simulate a periodic reading (e.g. driven by noise or irrelevant control), this will trigger performed count.
13281345 // Note that for SuppressStateUpdates (default), this would trigger a state change since North button
13291346 // transitions from 0 to 1 which is considered a press.
13301347 data . MarkNextEventHandled = false ;
@@ -1339,9 +1356,12 @@ public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransit
13391356 Assert . That ( action . WasPressedThisFrame , Is . EqualTo ( performedThisFrame ) ) ;
13401357 releasedThisFrame = expectedCancelled [ 2 ] - expectedCancelled [ 1 ] > 0 ;
13411358 Assert . That ( action . WasReleasedThisFrame , Is . EqualTo ( releasedThisFrame ) ) ;
1342- // TODO Assert.That(Gamepad.current.buttonNorth.wasPressedThisFrame, Is.EqualTo(expectedPerformed[2] - expectedPerformed[1] > 0));
1359+ Assert . That ( action . IsPressed , Is . True ) ; // Note: This is not an event and hence not suppressed
1360+
1361+ Assert . That ( Gamepad . current . buttonNorth . wasPressedThisFrame , Is . EqualTo ( ! seesControlChangesUnderSuppression ) ) ;
1362+ Assert . That ( Gamepad . current . buttonNorth . wasReleasedThisFrame , Is . False ) ;
13431363
1344- // Release button north and stick while no longer being suppressed. This may result in a release if
1364+ // Step 3: Release button north and stick while no longer being suppressed. This may result in a release if
13451365 // previous event was completely ignored without updating interaction state.
13461366 InputSystem . QueueStateEvent ( device , new GamepadState ( ) { leftStick = new Vector2 ( 0.00f , 0.01f ) } ) ;
13471367 InputSystem . Update ( ) ;
@@ -1353,9 +1373,12 @@ public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransit
13531373 Assert . That ( action . WasPressedThisFrame , Is . EqualTo ( performedThisFrame ) ) ;
13541374 releasedThisFrame = expectedCancelled [ 3 ] - expectedCancelled [ 2 ] > 0 ;
13551375 Assert . That ( action . WasReleasedThisFrame , Is . EqualTo ( releasedThisFrame ) ) ;
1356- // TODO Assert.That(Gamepad.current.buttonNorth.wasPressedThisFrame , Is.EqualTo(expectedPerformed[3] - expectedPerformed[2] > 0));
1376+ Assert . That ( action . IsPressed , Is . False ) ; // Note: This is not an event and hence not suppressed
13571377
1358- // Press button north and stick again while not being suppressed.
1378+ Assert . That ( Gamepad . current . buttonNorth . wasPressedThisFrame , Is . False ) ;
1379+ Assert . That ( Gamepad . current . buttonNorth . wasReleasedThisFrame , Is . True ) ;
1380+
1381+ // Step 4: Press button north and stick again while not being suppressed.
13591382 InputSystem . QueueStateEvent ( device , new GamepadState ( ) { leftStick = new Vector2 ( 0.99f , 0.00f ) }
13601383 . WithButton ( GamepadButton . North ) ) ;
13611384 InputSystem . Update ( ) ;
@@ -1367,6 +1390,10 @@ public void Events_ShouldRespectHandledPolicyUponUpdateAndSuppressedPressTransit
13671390 Assert . That ( action . WasPressedThisFrame , Is . EqualTo ( performedThisFrame ) ) ;
13681391 releasedThisFrame = expectedCancelled [ 4 ] - expectedCancelled [ 3 ] > 0 ;
13691392 Assert . That ( action . WasReleasedThisFrame , Is . EqualTo ( releasedThisFrame ) ) ;
1393+ Assert . That ( action . IsPressed , Is . True ) ; // Note: This is not an event and hence not suppressed
1394+
1395+ Assert . That ( Gamepad . current . buttonNorth . wasPressedThisFrame , Is . True ) ;
1396+ Assert . That ( Gamepad . current . buttonNorth . wasReleasedThisFrame , Is . False ) ;
13701397 }
13711398
13721399 [ StructLayout ( LayoutKind . Explicit , Size = 2 ) ]
0 commit comments