Skip to content

Commit 4046fad

Browse files
authored
Merge branch 'develop' into ekcoh/profiler
2 parents a3f8272 + 12ee89a commit 4046fad

File tree

13 files changed

+186
-148
lines changed

13 files changed

+186
-148
lines changed

.yamato/config.metadata

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
editors:
2-
- version: 2021.3
2+
- version: 2021.3.45f
33
- version: 2022.3
44
disable_tvos_run: true
55
- version: 6000.0

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 0 additions & 95 deletions
Original file line numberDiff line numberDiff line change
@@ -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
}

Assets/Tests/InputSystem/Plugins/OnScreenTests.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,33 @@ public void Devices_DisablingLastOnScreenControlRemovesCreatedDevice()
365365
Assert.That(InputSystem.devices, Has.None.InstanceOf<Keyboard>());
366366
}
367367

368+
[Test]
369+
[Category("Devices")]
370+
public void Devices_DisablingLastOnScreenControlDoesReportActiveControl()
371+
{
372+
var gameObject = new GameObject();
373+
374+
Assert.That(OnScreenControl.HasAnyActive, Is.False);
375+
376+
var buttonA = gameObject.AddComponent<OnScreenButton>();
377+
378+
Assert.That(OnScreenControl.HasAnyActive, Is.True);
379+
380+
var buttonB = gameObject.AddComponent<OnScreenButton>();
381+
buttonA.controlPath = "/<Keyboard>/a";
382+
buttonB.controlPath = "/<Keyboard>/b";
383+
384+
Assert.That(OnScreenControl.HasAnyActive, Is.True);
385+
386+
buttonA.enabled = false;
387+
388+
Assert.That(OnScreenControl.HasAnyActive, Is.True);
389+
390+
buttonB.enabled = false;
391+
392+
Assert.That(OnScreenControl.HasAnyActive, Is.False);
393+
}
394+
368395
// https://fogbugz.unity3d.com/f/cases/1271942
369396
[UnityTest]
370397
[Category("Devices")]

Assets/Tests/InputSystem/Plugins/PlayerInputTests.cs

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
using Object = UnityEngine.Object;
1818
using Gyroscope = UnityEngine.InputSystem.Gyroscope;
1919
using Is = UnityEngine.TestTools.Constraints.Is;
20+
using UnityEngine.InputSystem.OnScreen;
2021

2122
/// <summary>
2223
/// Tests for <see cref="PlayerInput"/> and <see cref="PlayerInputManager"/>.
@@ -663,6 +664,58 @@ public void PlayerInput_CanAutoSwitchControlSchemesInSinglePlayer()
663664
}));
664665
}
665666

667+
[Test]
668+
[Category("PlayerInput")]
669+
public void PlayerInput_AutoSwitchControlSchemesInSinglePlayerWithOnScreenControl_AutoSwitchToTargetDeviceAndIgnoreMouse()
670+
{
671+
var keyboard = InputSystem.AddDevice<Keyboard>();
672+
var mouse = InputSystem.AddDevice<Mouse>();
673+
674+
var go = new GameObject();
675+
676+
var onScreenButton = go.AddComponent<OnScreenButton>();
677+
onScreenButton.enabled = false;
678+
onScreenButton.controlPath = "<Gamepad>/buttonSouth";
679+
680+
var playerInput = go.AddComponent<PlayerInput>();
681+
playerInput.defaultControlScheme = "Keyboard&Mouse";
682+
playerInput.defaultActionMap = "gameplay";
683+
playerInput.actions = InputActionAsset.FromJson(kActions);
684+
685+
Assert.That(playerInput.devices, Is.EquivalentTo(new InputDevice[] { keyboard, mouse }));
686+
687+
// enable the OnScreenButton, it should switch to Gamepad
688+
onScreenButton.enabled = true;
689+
var gamepad = onScreenButton.control.device;
690+
Assert.That(gamepad, Is.TypeOf<Gamepad>());
691+
Assert.That(playerInput.devices, Is.EquivalentTo(new InputDevice[] { gamepad }));
692+
Assert.That(playerInput.user.controlScheme, Is.Not.Null);
693+
Assert.That(playerInput.user.controlScheme.Value.name, Is.EqualTo("Gamepad"));
694+
695+
// Perform mouse move and click. to try to switch to Keyboard&Mouse scheme
696+
Move(mouse.position, new Vector2(0.123f, 0.234f));
697+
Click(mouse.leftButton);
698+
Move(mouse.position, new Vector2(100f, 100f));
699+
InputSystem.Update();
700+
701+
// The controlScheme shouldn't have changed
702+
Assert.That(playerInput.devices, Is.EquivalentTo(new[] { gamepad }));
703+
Assert.That(playerInput.user.controlScheme, Is.Not.Null);
704+
Assert.That(playerInput.user.controlScheme.Value.name, Is.EqualTo("Gamepad"));
705+
706+
// disabling the OnScreenButton to ensure that it will now switch to Keyboard&Mouse as expected
707+
onScreenButton.enabled = false;
708+
709+
// Perform mouse move and click. to try to switch to Keyboard&Mouse scheme
710+
Move(mouse.position, new Vector2(0.123f, 0.234f));
711+
Click(mouse.leftButton);
712+
Move(mouse.position, new Vector2(100f, 100f));
713+
714+
Assert.That(playerInput.devices, Is.EquivalentTo(new InputDevice[] { keyboard, mouse }));
715+
Assert.That(playerInput.user.controlScheme, Is.Not.Null);
716+
Assert.That(playerInput.user.controlScheme.Value.name, Is.EqualTo("Keyboard&Mouse"));
717+
}
718+
666719
[Test]
667720
[Category("PlayerInput")]
668721
public void PlayerInput_CanAutoSwitchControlSchemesInSinglePlayer_WithSomeDevicesSharedBetweenSchemes()

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2630,6 +2630,11 @@ public void UI_ClickDraggingMouseDoesNotAllocateGCMemory()
26302630
Release(mouse.leftButton);
26312631
scene.eventSystem.InvokeUpdate();
26322632

2633+
#if UNITY_2023_2_OR_NEWER // UnityEngine.InputForUI Module unavailable in earlier releases
2634+
// Process all queued UI events to ensure that next events will not make the events list capacity growing
2635+
UnityEngine.InputForUI.EventProvider.NotifyUpdate();
2636+
#endif
2637+
26332638
var kProfilerRegion = "UI_ClickDraggingDoesNotAllocateGCMemory";
26342639

26352640
// Now for real.

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,17 @@ however, it has to be formatted properly to pass verification tests.
1212

1313
### Fixed
1414
- Fixed an issue causing the Action context menu to not show on right click when right clicking an action in the Input Action Editor [ISXB-1134](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1134).
15+
- Reverted changes from 0ddd534d8 (ISXB-746) which introduced a regression [ISXB-1127](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1127).
1516
- Fixed `ArgumentNullException: Value cannot be null.` during the migration of Project-wide Input Actions from `InputManager.asset` to `InputSystem_Actions.inputactions` asset which lead do the lost of the configuration [ISXB-1105](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1105)
1617
- Fixed pointerId staying the same when simultaneously releasing and then pressing in the same frame on mobile using touch. [ISXB-1006](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-845)
18+
- Fixed ISubmitHandler.OnSubmit event processing when operating in Manual Update mode (ISXB-1141)
19+
- Fixed Rename mode is not entered and name is autocompleted to default when creating a new Action Map on 2022.3. [ISXB-1151](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1151)
20+
- Fixed unexpected control scheme switch when using `OnScreenControl` and pointer based schemes which registed "Cancel" event on every frame.[ISXB-656](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-656)
21+
- Fixed an issue with The "Add Control Scheme..." popup window so that it now persists until any changes are explicitly Saved or Cancelled [case ISXB-1131](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1131)
1722

1823
### Changed
1924
- Added back the InputManager to InputSystem project-wide asset migration code with performance improvement (ISX-2086)
25+
- Changed `OnScreenControl` to automaticaly switch, in Single Player with autoswitch enabled, to the target device control scheme when the first component is enabled to prevent bad interactions when it start.
2026

2127
## [1.11.2] - 2024-10-16
2228

@@ -27,14 +33,12 @@ however, it has to be formatted properly to pass verification tests.
2733
- Fixed "AnalyticsResult" errors on consoles [ISXB-1107]
2834
- Fixed wrong `Display Index` value for touchscreen events.[ISXB-1101](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1101)
2935
- Fixed event handling when using Fixed Update processing where WasPressedThisFrame could appear to true for consecutive frames [ISXB-1006](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1006)
36+
- Removed a redundant warning when using fallback code to parse a HID descriptor. (UUM-71260)
3037

3138
### Added
3239
- Added the display of the device flag `CanRunInBackground` in device debug view.
3340
- Added analytics for programmatic `InputAction` setup via `InputActionSetupExtensions` when exiting play-mode.
3441

35-
### Fixed
36-
- Removed a redundant warning when using fallback code to parse a HID descriptor. (UUM-71260)
37-
3842
### Changed
3943
- Removed the InputManager to InputSystem project-wide asset migration code for performance improvement (ISX-2086)
4044

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

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,6 +1186,16 @@ public unsafe bool IsInProgress()
11861186
return false;
11871187
}
11881188

1189+
private int ExpectedFrame()
1190+
{
1191+
// Used by the Was<XXX>ThisFrame() methods below.
1192+
// When processing events manually the event processing will happen one frame later.
1193+
//
1194+
int frameOffset = InputSystem.settings.updateMode == InputSettings.UpdateMode.ProcessEventsManually ? 1 : 0;
1195+
int expectedFrame = Time.frameCount - frameOffset;
1196+
return expectedFrame;
1197+
}
1198+
11891199
/// <summary>
11901200
/// Returns true if the action's value crossed the press threshold (see <see cref="InputSettings.defaultButtonPressPoint"/>)
11911201
/// at any point in the frame.
@@ -1236,7 +1246,7 @@ public unsafe bool WasPressedThisFrame()
12361246
{
12371247
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
12381248
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1239-
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1249+
return actionStatePtr->pressedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
12401250
}
12411251

12421252
return false;
@@ -1285,7 +1295,7 @@ public unsafe bool WasReleasedThisFrame()
12851295
{
12861296
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
12871297
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1288-
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1298+
return actionStatePtr->releasedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
12891299
}
12901300

12911301
return false;
@@ -1344,7 +1354,7 @@ public unsafe bool WasPerformedThisFrame()
13441354
{
13451355
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
13461356
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1347-
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1357+
return actionStatePtr->lastPerformedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
13481358
}
13491359

13501360
return false;
@@ -1417,7 +1427,7 @@ public unsafe bool WasCompletedThisFrame()
14171427
{
14181428
var actionStatePtr = &state.actionStates[m_ActionIndexInState];
14191429
var currentUpdateStep = InputUpdate.s_UpdateStepCount;
1420-
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == Time.frameCount;
1430+
return actionStatePtr->lastCompletedInUpdate == currentUpdateStep && currentUpdateStep != default && actionStatePtr->frame == ExpectedFrame();
14211431
}
14221432

14231433
return false;

0 commit comments

Comments
 (0)