Skip to content

Commit 2e840e2

Browse files
committed
Merge branch 'isx-2322-polling-frequency' of github.com:Unity-Technologies/InputSystem into isx-2322-polling-frequency
2 parents 2473d86 + 7e18947 commit 2e840e2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+613
-169
lines changed
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#if UNITY_EDITOR && UNITY_INPUT_SYSTEM_PROJECT_WIDE_ACTIONS && UNITY_6000_0_OR_NEWER
2+
3+
using System;
4+
using NUnit.Framework;
5+
using System.Collections;
6+
using System.Linq;
7+
using UnityEditor;
8+
using UnityEngine;
9+
using UnityEngine.InputSystem;
10+
using UnityEngine.InputSystem.Editor;
11+
using UnityEngine.TestTools;
12+
using UnityEngine.UIElements;
13+
14+
internal enum SomeEnum
15+
{
16+
OptionA = 10,
17+
OptionB = 20
18+
}
19+
20+
#if UNITY_EDITOR
21+
[InitializeOnLoad]
22+
#endif
23+
internal class CustomProcessor : InputProcessor<float>
24+
{
25+
public SomeEnum SomeEnum;
26+
27+
#if UNITY_EDITOR
28+
static CustomProcessor()
29+
{
30+
Initialize();
31+
}
32+
33+
#endif
34+
35+
[RuntimeInitializeOnLoadMethod(RuntimeInitializeLoadType.BeforeSceneLoad)]
36+
private static void Initialize()
37+
{
38+
InputSystem.RegisterProcessor<CustomProcessor>();
39+
}
40+
41+
public override float Process(float value, InputControl control)
42+
{
43+
return value;
44+
}
45+
}
46+
47+
internal class CustomProcessorEnumTest : UIToolkitBaseTestWindow<InputActionsEditorWindow>
48+
{
49+
InputActionAsset m_Asset;
50+
51+
public override void OneTimeSetUp()
52+
{
53+
base.OneTimeSetUp();
54+
m_Asset = AssetDatabaseUtils.CreateAsset<InputActionAsset>();
55+
56+
var actionMap = m_Asset.AddActionMap("Action Map");
57+
58+
actionMap.AddAction("Action", InputActionType.Value, processors: "Custom(SomeEnum=10)");
59+
}
60+
61+
public override void OneTimeTearDown()
62+
{
63+
AssetDatabaseUtils.Restore();
64+
base.OneTimeTearDown();
65+
}
66+
67+
public override IEnumerator UnitySetup()
68+
{
69+
m_Window = InputActionsEditorWindow.OpenEditor(m_Asset);
70+
yield return null;
71+
}
72+
73+
[UnityTest]
74+
public IEnumerator ProcessorEnum_ShouldSerializeByValue_WhenSerializedToAsset()
75+
{
76+
// Serialize current asset to JSON, and check that initial JSON contains default enum value for OptionA
77+
var json = m_Window.currentAssetInEditor.ToJson();
78+
79+
Assert.That(json.Contains("Custom(SomeEnum=10)"), Is.True,
80+
"Serialized JSON does not contain the expected custom processor string for OptionA.");
81+
82+
// Query the dropdown with exactly two enum choices and check that the drop down is present in the UI
83+
var dropdownList = m_Window.rootVisualElement.Query<DropdownField>().Where(d => d.choices.Count == 2).ToList();
84+
Assume.That(dropdownList.Count > 0, Is.True, "Enum parameter dropdown not found in the UI.");
85+
86+
// Determine the new value to be set in the dropdown, focus the dropdown before dispatching the change
87+
var dropdown = dropdownList.First();
88+
var newValue = dropdown.choices[1];
89+
dropdown.Focus();
90+
dropdown.value = newValue;
91+
92+
// Create and send a change event from OptionA to OptionB
93+
var changeEvent = ChangeEvent<Enum>.GetPooled(SomeEnum.OptionA, SomeEnum.OptionB);
94+
changeEvent.target = dropdown;
95+
dropdown.SendEvent(changeEvent);
96+
97+
// Find the save button in the window, focus and click the save button to persist the changes
98+
var saveButton = m_Window.rootVisualElement.Q<Button>("save-asset-toolbar-button");
99+
Assume.That(saveButton, Is.Not.Null, "Save Asset button not found in the UI.");
100+
saveButton.Focus();
101+
SimulateClickOn(saveButton);
102+
103+
Assert.That(dropdown.value, Is.EqualTo(newValue));
104+
105+
// Verify that the updated JSON contains the new enum value for OpitonB
106+
var updatedJson = m_Window.currentAssetInEditor.ToJson();
107+
Assert.That(updatedJson.Contains("Custom(SomeEnum=20)"), Is.True, "Serialized JSON does not contain the updated custom processor string for OptionB.");
108+
109+
yield return null;
110+
}
111+
}
112+
#endif

Assets/Tests/InputSystem.Editor/CustomProcessorEnumTest.cs.meta

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Tests/InputSystem.Editor/ProjectWideInputActionsEditorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ public void Report(string message)
236236
}
237237
}
238238

239-
[Test(Description = "Verifies that the default asset do not generate any verification errors (Regardless of existing requirements)")]
239+
[Test(Description = "Verifies that the default asset does not generate any verification errors (Regardless of existing requirements)")]
240240
[Category(kTestCategory)]
241241
public void ProjectWideActions_ShouldSupportAssetVerification_AndHaveNoVerificationErrorsForDefaultAsset()
242242
{

Assets/Tests/InputSystem/CoreTests_Actions.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5215,8 +5215,8 @@ public void Actions_CanConvertAssetToAndFromJson()
52155215
static string MinimalJson(string name = null)
52165216
{
52175217
if (name != null)
5218-
return "{\n \"name\": \"" + name + "\",\n \"maps\": [],\n \"controlSchemes\": []\n}";
5219-
return "{\n \"maps\": [],\n \"controlSchemes\": []\n}";
5218+
return "{\n \"version\": 0,\n \"name\": \"" + name + "\",\n \"maps\": [],\n \"controlSchemes\": []\n}";
5219+
return "{\n \"version\": 0,\n \"maps\": [],\n \"controlSchemes\": []\n}";
52205220
}
52215221

52225222
[Test]

Assets/Tests/InputSystem/Plugins/UITests.InputModuleTests.cs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,23 @@ public IEnumerator PointerExitChildShouldFullyExit()
157157
Assert.IsTrue(callbackCheck.pointerData.fullyExited == true);
158158
}
159159

160+
[UnityTest]
161+
[Description("Regression test for https://jira.unity3d.com/browse/ISXB-1493")]
162+
public IEnumerator DisablingDoesNotResetUserActions()
163+
{
164+
var actions = new DefaultInputActions();
165+
m_InputModule.actionsAsset = actions.asset;
166+
m_InputModule.cancel = InputActionReference.Create(actions.UI.Cancel);
167+
168+
m_InputModule.enabled = false;
169+
170+
yield return null;
171+
172+
Assert.IsNotNull(m_InputModule.cancel, "Disabling component shouldn't lose its data.");
173+
174+
actions.Dispose();
175+
}
176+
160177
public class PointerExitCallbackCheck : MonoBehaviour, IPointerExitHandler
161178
{
162179
public PointerEventData pointerData { get; private set; }

Assets/Tests/InputSystem/Plugins/XRTests.cs

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// ENABLE_VR is not defined on Game Core but the assembly is available with limited features when the XR module is enabled.
22
#if ENABLE_VR || UNITY_GAMECORE
33
using System;
4+
using System.Collections;
45
using System.Collections.Generic;
56
using System.Runtime.InteropServices;
67
using NUnit.Framework;
@@ -11,6 +12,7 @@
1112
using UnityEngine.InputSystem.LowLevel;
1213
using UnityEngine.InputSystem.Utilities;
1314
using UnityEngine.InputSystem.XR;
15+
using UnityEngine.TestTools;
1416
using UnityEngine.XR;
1517

1618
using Usages = UnityEngine.InputSystem.CommonUsages;
@@ -629,6 +631,54 @@ public void Components_TrackedPoseDriver_DoesNotEnableOrDisableReferenceActions(
629631
Assert.That(trackingStateInput.action.enabled, Is.False);
630632
}
631633

634+
[UnityTest]
635+
[Category("Components")]
636+
public IEnumerator CanUseTrackedPoseDriverWithoutTrackingAction()
637+
{
638+
var go = new GameObject();
639+
var tpd = go.AddComponent<TrackedPoseDriver>();
640+
tpd.updateType = TrackedPoseDriver.UpdateType.UpdateAndBeforeRender;
641+
tpd.trackingType = TrackedPoseDriver.TrackingType.RotationAndPosition;
642+
tpd.ignoreTrackingState = false;
643+
var transform = tpd.transform;
644+
645+
var positionAction = new InputAction(binding: "<XRController>/devicePosition");
646+
var rotationAction = new InputAction(binding: "<XRController>/deviceRotation");
647+
tpd.positionInput = new InputActionProperty(positionAction);
648+
tpd.rotationInput = new InputActionProperty(rotationAction);
649+
650+
yield return null;
651+
652+
Assert.That(positionAction.controls.Count, Is.EqualTo(0));
653+
Assert.That(rotationAction.controls.Count, Is.EqualTo(0));
654+
655+
var device = InputSystem.AddDevice<XRController>();
656+
InputSystem.AddDeviceUsage(device, "RightHand");
657+
658+
yield return null;
659+
660+
Assert.That(positionAction.controls.Count, Is.EqualTo(1));
661+
Assert.That(rotationAction.controls.Count, Is.EqualTo(1));
662+
663+
var position = new Vector3(1f, 2f, 3f);
664+
var rotation = new Quaternion(0.09853293f, 0.09853293f, 0.09853293f, 0.9853293f);
665+
using (StateEvent.From(device, out var stateEvent))
666+
{
667+
device.devicePosition.WriteValueIntoEvent(position, stateEvent);
668+
device.deviceRotation.WriteValueIntoEvent(rotation, stateEvent);
669+
670+
transform.position = Vector3.zero;
671+
transform.rotation = Quaternion.identity;
672+
InputSystem.QueueEvent(stateEvent);
673+
InputSystem.Update(InputUpdateType.Dynamic);
674+
}
675+
676+
yield return null;
677+
678+
Assert.That(transform.position, Is.EqualTo(position));
679+
Assert.That(transform.rotation, Is.EqualTo(rotation));
680+
}
681+
632682
[Test]
633683
[Category("Components")]
634684
public void Components_TrackedPoseDriver_RequiresResolvedTrackingStateBindings()

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,17 @@ however, it has to be formatted properly to pass verification tests.
2828
- Fixed Gamepad stick up/down inputs that were not recognized in WebGL. [ISXB-1090](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1090)
2929
- Fixed reenabling the VirtualMouseInput component may sometimes lead to NullReferenceException. [ISXB-1096](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1096)
3030
- Fixed the default button press point not being respected in Editor (as well as some other Touchscreen properties). [ISXB-1152](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1152)
31+
- Fixed the TreeView compilation warnings when used with Unity 6.2 beta (ISX-2320)
32+
- Fixed actions being reset when disabling the InputSystemUIInputModule component [ISXB-1493](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1493)
33+
- Fixed a memory leak when disabling and enabling the InputSystemUIInputModule component at runtime [ISXB-1573](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1573)
34+
- Fixed all InputControls being changed at once when you change just one by reverting `2a37caac288ac09bc9122234339dc5df8d3a0ca6`, which was an attempt at fixing [ISXB-1221] that introduced this regression [ISXB-1531] (https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1493)
3135
- Fixed PlayerInput component automatically switching away from the default ActionMap set to 'None'.
3236
- Fixed a console error being shown when targeting visionOS builds in 2022.3.
3337
- Fixed a Tap Interaction issue with analog controls. The Tap interaction would keep re-starting after timeout. [ISXB-627](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-627)
38+
- Fixed the defaultActionMap dropdown in the PlayerInput component defaulting to <None> instead of the first ActionMap.
39+
- Fixed TrackedPoseDriver stops updating position and rotation when device is added after its initialization. [ISXB-1555](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1555)
3440
- Fixed PlayerInput component not working with C# Wrappers (ISXB-1535). This reverted changes done to fix [ISXB-920](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-920) but users can now fix it themselves.
41+
- Fixed an issue that caused input processors with enum properties to incorrectly serialise by index instead of by value [ISXB-1474](https://issuetracker.unity3d.com/product/unity/issues/guid/ISXB-1474)
3542

3643
## [1.14.0] - 2025-03-20
3744

@@ -43,6 +50,7 @@ however, it has to be formatted properly to pass verification tests.
4350

4451
### Changed
4552
- Changed enum value `Key.IMESelected` to obsolete which was not a real key. Please use the ButtonControl `imeSelected`.
53+
- Changed conditional guards inside Plugins/XR so that we don't unnecessarily wrap entire classes. This stops downstream packages from having to also wrap Input System objects with similar conditionals.
4654

4755
### Added
4856
- Added support of F13-F24 keys. [UUM-44328](https://issuetracker.unity3d.com/product/unity/issues/guid/UUM-44328)

Packages/com.unity.inputsystem/Documentation~/filter.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,54 @@ apiRules:
3737
- exclude:
3838
uidRegex: ^UnityEngine\.InputSystem\.InputSystem\.runInBackground$
3939
type: Member
40+
- exclude:
41+
uidRegex: ^Unity\.XR\.Oculus\.Input(?:\..+)*$
42+
type: Namespace
43+
- exclude:
44+
uidRegex: ^Unity\.XR\.GoogleVr(?:\..+)*$
45+
type: Namespace
46+
- exclude:
47+
uidRegex: ^Unity\.XR\.OpenVR(?:\..+)*$
48+
type: Namespace
49+
- exclude:
50+
uidRegex: ^UnityEngine\.XR\.WindowsMR\.Input(?:\..+)*$
51+
type: Namespace
52+
- exclude:
53+
uidRegex: ^UnityEngine\.InputSystem\.XR\.Haptics(?:\..+)*$
54+
type: Namespace
55+
- exclude:
56+
uidRegex: ^UnityEngine\.InputSystem\.XR\.XRControllerWithRumble$
57+
type: Type
58+
- exclude:
59+
uidRegex: ^UnityEngine\.InputSystem\.XR\.XRControllerWithRumble\..*$
60+
type: Member
61+
- exclude:
62+
uidRegex: ^UnityEngine\.InputSystem\.XR\.XRSupport$
63+
type: Type
64+
- exclude:
65+
uidRegex: ^UnityEngine\.InputSystem\.XR\.XRSupport\..*$
66+
type: Member
67+
- exclude:
68+
uidRegex: ^UnityEngine\.InputSystem\.XR\.FeatureType$
69+
type: Type
70+
- exclude:
71+
uidRegex: ^UnityEngine\.InputSystem\.XR\.UsageHint$
72+
type: Type
73+
- exclude:
74+
uidRegex: ^UnityEngine\.InputSystem\.XR\.XRFeatureDescriptor$
75+
type: Type
76+
- exclude:
77+
uidRegex: ^UnityEngine\.InputSystem\.XR\.XRDeviceDescriptor$
78+
type: Type
79+
- exclude:
80+
uidRegex: ^UnityEngine\.InputSystem\.XR\.Bone$
81+
type: Type
82+
- exclude:
83+
uidRegex: ^UnityEngine\.InputSystem\.XR\.Eyes$
84+
type: Type
85+
- exclude:
86+
uidRegex: ^UnityEngine\.InputSystem\.XR\.BoneControl$
87+
type: Type
88+
- exclude:
89+
uidRegex: ^UnityEngine\.InputSystem\.XR\.EyesControl$
90+
type: Type

0 commit comments

Comments
 (0)