@@ -12405,99 +12405,4 @@ public void Actions_ActionMapDisabledDuringOnAfterSerialization()
1240512405 Assert.That(map.enabled, Is.True);
1240612406 Assert.That(map.FindAction("MyAction", true).enabled, Is.True);
1240712407 }
12408-
12409- // ResetDevice wasn't properly clearly Composite key state, i.e. BindingState.pressTime
12410- // https://jira.unity3d.com/browse/ISXB-746
12411- [Test]
12412- [TestCase(false)]
12413- [TestCase(true)]
12414- [Category("Actions")]
12415- public void Actions_CompositeBindingResetWhenResetDeviceCalledWhileExecutingAction(bool useTwoModifierComposite)
12416- {
12417- var keyboard = InputSystem.AddDevice<Keyboard>();
12418- bool actionPerformed;
12419-
12420- // Enables "Modifier must be pressed first" behavior on all Composite Bindings
12421- InputSystem.settings.shortcutKeysConsumeInput = true;
12422-
12423- const string modifier1 = "<Keyboard>/shift";
12424- const string modifier2 = "<Keyboard>/ctrl";
12425- const string key = "<Keyboard>/F1";
12426-
12427- var map = new InputActionMap();
12428- var resetAction = map.AddAction("resetAction");
12429-
12430- if (!useTwoModifierComposite)
12431- {
12432- resetAction.AddCompositeBinding("OneModifier")
12433- .With("Modifier", modifier1)
12434- .With("Binding", key);
12435- }
12436- else
12437- {
12438- resetAction.AddCompositeBinding("TwoModifiers")
12439- .With("Modifier1", modifier1)
12440- .With("Modifier2", modifier2)
12441- .With("Binding", key);
12442- }
12443-
12444- resetAction.performed += (InputAction.CallbackContext ctx) =>
12445- {
12446- // Disable the Keyboard while action is being performed.
12447- // This simulates an "OnFocusLost" event occurring while processing the Action, e.g. when switching primary displays or moving the main window
12448- actionPerformed = true;
12449- InputSystem.s_Manager.EnableOrDisableDevice(keyboard.device, false, InputManager.DeviceDisableScope.TemporaryWhilePlayerIsInBackground);
12450- };
12451-
12452- map.Enable();
12453-
12454- actionPerformed = false;
12455- Press(keyboard.leftShiftKey);
12456- Press(keyboard.leftCtrlKey);
12457- Press(keyboard.f1Key);
12458-
12459- Assert.IsTrue(actionPerformed);
12460-
12461- // Re enable the Keyboard (before keys are released) and execute Action again
12462- InputSystem.s_Manager.EnableOrDisableDevice(keyboard.device, true, InputManager.DeviceDisableScope.TemporaryWhilePlayerIsInBackground);
12463-
12464- actionPerformed = false;
12465- Release(keyboard.leftShiftKey);
12466- Release(keyboard.leftCtrlKey);
12467- Release(keyboard.f1Key);
12468-
12469- Press(keyboard.leftCtrlKey);
12470- Press(keyboard.leftShiftKey);
12471- Press(keyboard.f1Key);
12472-
12473- Assert.IsTrue(actionPerformed);
12474-
12475- actionPerformed = false;
12476- Release(keyboard.leftCtrlKey);
12477- Release(keyboard.leftShiftKey);
12478- Release(keyboard.f1Key);
12479-
12480- // Re enable the Keyboard (after keys are released) and execute Action one more time
12481- InputSystem.s_Manager.EnableOrDisableDevice(keyboard.device, true, InputManager.DeviceDisableScope.TemporaryWhilePlayerIsInBackground);
12482-
12483- Press(keyboard.leftCtrlKey);
12484- Press(keyboard.leftShiftKey);
12485- Press(keyboard.f1Key);
12486-
12487- Assert.IsTrue(actionPerformed);
12488-
12489- actionPerformed = false;
12490- Press(keyboard.leftShiftKey);
12491- Press(keyboard.leftCtrlKey);
12492- Press(keyboard.f1Key);
12493-
12494- // Re enable the Keyboard (before keys are released) and verify Action isn't triggered when Key pressed first
12495- InputSystem.s_Manager.EnableOrDisableDevice(keyboard.device, true, InputManager.DeviceDisableScope.TemporaryWhilePlayerIsInBackground);
12496-
12497- Press(keyboard.f1Key);
12498- Press(keyboard.leftCtrlKey);
12499- Press(keyboard.leftShiftKey);
12500-
12501- Assert.IsFalse(actionPerformed);
12502- }
1250312408}
0 commit comments