Skip to content

Commit b594670

Browse files
authored
FIX: Actions stuck in Performed after multiple simultaneous key presses (case 1295535, #1257).
1 parent 7520669 commit b594670

File tree

3 files changed

+37
-0
lines changed

3 files changed

+37
-0
lines changed

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7391,6 +7391,32 @@ public void Actions_OnActionWithMultipleBindings_IfGroupIsAmbiguous_OverridesAll
73917391
Assert.That(action.bindings[1].overridePath, Is.EqualTo("/gamepad/buttonSouth"));
73927392
}
73937393

7394+
[Test]
7395+
[Category("Actions")]
7396+
public void Actions_OnActionWithMultipleBindings_CanTransitionFromOneActuatedControlToAnother()
7397+
{
7398+
var keyboard = InputSystem.AddDevice<Keyboard>();
7399+
var wasCanceled = false;
7400+
var action = new InputAction("test", InputActionType.Button);
7401+
action.canceled += _ => wasCanceled = true;
7402+
action.AddBinding("<Keyboard>/s");
7403+
action.AddBinding("<Keyboard>/a");
7404+
action.Enable();
7405+
7406+
Press(keyboard.sKey);
7407+
Assert.That(action.phase, Is.EqualTo(InputActionPhase.Performed));
7408+
7409+
Press(keyboard.aKey);
7410+
Assert.That(action.phase, Is.EqualTo(InputActionPhase.Performed));
7411+
7412+
Release(keyboard.sKey);
7413+
Assert.That(action.phase, Is.EqualTo(InputActionPhase.Performed));
7414+
7415+
Release(keyboard.aKey);
7416+
Assert.That(action.phase, Is.EqualTo(InputActionPhase.Waiting));
7417+
Assert.That(wasCanceled, Is.True);
7418+
}
7419+
73947420
[Test]
73957421
[Category("Actions")]
73967422
public void Actions_CanRestoreDefaultsAfterOverridingBinding()

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@ however, it has to be formatted properly to pass verification tests.
2424
* In our own measurements, `InputUser.OnEvent` is >9 times faster than before and `RebindingOperation.OnEvent` is ~2.5 times faster.
2525
- Fixed PS4 controller not recognized on Mac when connected over Bluetooth ([case 1286449](https://issuetracker.unity3d.com/issues/input-system-dualshock-4-zct1e-dualshock-2-v1-devices-are-not-fully-recognised-over-bluetooth)).
2626
- Fixed restart prompt after package installation not appearing on Unity 2020.2+ ([case 1292513](https://issuetracker.unity3d.com/issues/input-system-after-package-install-the-update-slash-switch-and-restart-prompt-does-not-appear)).
27+
- Fixed action with multiple bindings getting stuck in `Performed` state when two or more controls are pressed at the same time ([case 1295535](https://issuetracker.unity3d.com/issues/input-system-not-registering-multiple-inputs)).
28+
* Regression introduced in 1.1-preview.2.
2729

2830
### Added
2931

Packages/com.unity.inputsystem/InputSystem/Actions/InputActionState.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1451,6 +1451,15 @@ private void ProcessDefaultInteraction(ref TriggerState trigger, int actionIndex
14511451
var threshold = pressPoint * ButtonControl.s_GlobalDefaultButtonReleaseThreshold;
14521452
if (actuation <= threshold)
14531453
ChangePhaseOfAction(InputActionPhase.Canceled, ref trigger);
1454+
else
1455+
{
1456+
// ShouldIgnoreControlStateChange may have switched one from control to another,
1457+
// so make sure we update the trigger state here regardless of whether we changed
1458+
// phase or not.
1459+
actionState->controlIndex = trigger.controlIndex;
1460+
actionState->bindingIndex = trigger.bindingIndex;
1461+
actionState->magnitude = actuation;
1462+
}
14541463
}
14551464
else if (actionState->isPassThrough)
14561465
{

0 commit comments

Comments
 (0)