Skip to content

Commit 0e84d82

Browse files
author
Rene Damm
authored
FIX: Several issues uncovered in QA pass (#1018).
1 parent 67515cf commit 0e84d82

File tree

14 files changed

+111
-101
lines changed

14 files changed

+111
-101
lines changed

Assets/Tests/InputSystem/CoreTests_Controls.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -818,6 +818,20 @@ public void Controls_CanFindControlsByUsage()
818818
}
819819
}
820820

821+
[Test]
822+
[Category("Controls")]
823+
public void Controls_FindingControlsByUsage_IgnoresUsagesOnDevice()
824+
{
825+
var gamepad = InputSystem.AddDevice<Gamepad>();
826+
InputSystem.SetDeviceUsage(gamepad, "Primary2DMotion");
827+
828+
using (var matches = InputSystem.FindControls("<Gamepad>/{Primary2DMotion}"))
829+
{
830+
Assert.That(matches, Has.Count.EqualTo(1));
831+
Assert.That(matches, Has.Exactly(1).SameAs(gamepad.leftStick));
832+
}
833+
}
834+
821835
[Test]
822836
[Category("Controls")]
823837
public void Controls_CanFindChildControlsOfControlsFoundByUsage()

Packages/com.unity.inputsystem/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ This release includes a number of Quality-of-Life improvements for a range of co
111111
* This bug led to input being missed on a device once another device had been removed.
112112
- `TrackedDevice` layout is no longer incorrectly registered as `Tracked Device`.
113113
- Event traces in the input debugger are no longer lost on domain reloads.
114+
- `IndexOutOfRangeException` being thrown when looking up controls on XR devices.
114115

115116
#### Actions
116117

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Known Limitations
2+
3+
The following is a list of known limitations that the Input System currently has.
4+
5+
## Compatibility with other Unity features
6+
7+
* `PlayerInput` split-screen support does not work with Cinemachine virtual cameras.
8+
* The Input System cannot generate input for IMGUI or UIElements.
9+
* The Input System does not yet support the new 2019.3 mode where domain reloads are disabled when entering play mode.
10+
11+
## Device support
12+
13+
* (Windows) Mouse input from remote desktop connections does not come through properly.
14+
* (Windows) Pen input will not work with Wacom devices if "Windows Ink" support is turned off.
15+
* Joy-Cons are only supported on Switch.
16+
* Sensors in the PS4 controller are currently only supported on PS4.
17+
>NOTE: Support for NDA platforms is distributed as separate packages due to licensing restrictions. The packages, at this point, are made available separately to licensees for download and installation.
18+
19+
## Features Supported by Old Input Manager
20+
21+
* `MonoBehaviour` mouse methods (`OnMouseEnter`, `OnMouseDrag`, etc) will not be called by the Input System.

Packages/com.unity.inputsystem/Documentation~/TableOfContents.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
* [Debugging](Debugging.md)
1111
* [Input testing](Testing.md)
1212
* [Contributing](Contributing.md)
13+
* [Known Limitations](KnownLimitations.md)
1314

1415
* Reference
1516
* [Input settings](Settings.md)

Packages/com.unity.inputsystem/InputSystem/Controls/InputControlPath.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ private static TControl MatchByUsageAtDeviceRootRecursive<TControl>(InputDevice
925925
if (usages == null)
926926
return null;
927927

928-
var usageCount = usages.Length;
928+
var usageCount = device.m_UsageToControl.Length;
929929
var startIndex = indexInPath + 1;
930930
var pathCanMatchMultiple = PathComponentCanYieldMultipleMatches(path, indexInPath);
931931
var pathLength = path.Length;

Packages/com.unity.inputsystem/InputSystem/Devices/Keyboard.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -909,7 +909,7 @@ public event Action<char> onTextInput
909909
{
910910
if (value == null)
911911
throw new ArgumentNullException(nameof(value));
912-
if (!m_TextInputListeners.ContainsReference(value))
912+
if (!m_TextInputListeners.Contains(value))
913913
m_TextInputListeners.Append(value);
914914
}
915915
remove => m_TextInputListeners.Remove(value);
@@ -931,7 +931,7 @@ public event Action<IMECompositionString> onIMECompositionChange
931931
{
932932
if (value == null)
933933
throw new ArgumentNullException(nameof(value));
934-
if (!m_ImeCompositionListeners.ContainsReference(value))
934+
if (!m_ImeCompositionListeners.Contains(value))
935935
m_ImeCompositionListeners.Append(value);
936936
}
937937
remove => m_ImeCompositionListeners.Remove(value);

Packages/com.unity.inputsystem/InputSystem/Editor/Debugger/InputDeviceDebuggerWindow.cs

Lines changed: 46 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515

1616
////TODO: add diff-to-previous-event ability to event window
1717

18-
////FIXME: doesn't survive domain reload correctly (could be, it's even leaking unmanaged memory)
19-
2018
////FIXME: the repaint triggered from IInputStateCallbackReceiver somehow comes with a significant delay
2119

2220
////TODO: Add "Remote:" field in list that also has a button for local devices that allows to mirror them and their input
@@ -39,7 +37,7 @@ namespace UnityEngine.InputSystem.Editor
3937
// Can also be used to alter the state of a device by making up state events.
4038
internal sealed class InputDeviceDebuggerWindow : EditorWindow, ISerializationCallbackReceiver, IDisposable
4139
{
42-
internal const int kDefaultEventTraceSizeInMB = 1;
40+
private const int kDefaultEventTraceSizeInMB = 1;
4341

4442
internal static InlinedArray<Action<InputDevice>> s_OnToolbarGUIActions;
4543

@@ -90,11 +88,15 @@ internal void OnDestroy()
9088

9189
m_EventTrace?.Dispose();
9290
m_EventTrace = null;
91+
92+
m_ReplayController?.Dispose();
93+
m_ReplayController = null;
9394
}
9495

9596
public void Dispose()
9697
{
9798
m_EventTrace?.Dispose();
99+
m_ReplayController?.Dispose();
98100
}
99101

100102
internal void OnGUI()
@@ -179,6 +181,9 @@ private void DrawEventList()
179181
GUILayout.Label("Events", GUILayout.MinWidth(100), GUILayout.ExpandWidth(true));
180182
GUILayout.FlexibleSpace();
181183

184+
if (m_ReplayController != null && !m_ReplayController.finished)
185+
EditorGUILayout.LabelField("Playing...", EditorStyles.miniLabel);
186+
182187
// Text field to determine size of event trace.
183188
var currentTraceSizeInBytes = m_EventTrace.allocatedSizeInBytes / (1024 * 1024);
184189
var oldSizeText = currentTraceSizeInBytes + " MB";
@@ -194,14 +199,18 @@ private void DrawEventList()
194199
}
195200

196201
// Button to disable event tracing.
197-
var eventTraceDisabledNow = GUILayout.Toggle(!m_EventTraceDisabled, Contents.pauseContent, Styles.toolbarButton);
198-
if (eventTraceDisabledNow != m_EventTraceDisabled)
202+
// NOTE: We force-disable event tracing while a replay is in progress.
203+
using (new EditorGUI.DisabledScope(m_ReplayController != null && !m_ReplayController.finished))
199204
{
200-
m_EventTraceDisabled = eventTraceDisabledNow;
201-
if (eventTraceDisabledNow)
202-
m_EventTrace.Disable();
203-
else
204-
m_EventTrace.Enable();
205+
var eventTraceDisabledNow = GUILayout.Toggle(!m_EventTraceDisabled, Contents.pauseContent, Styles.toolbarButton);
206+
if (eventTraceDisabledNow != m_EventTraceDisabled)
207+
{
208+
m_EventTraceDisabled = eventTraceDisabledNow;
209+
if (eventTraceDisabledNow)
210+
m_EventTrace.Disable();
211+
else
212+
m_EventTrace.Enable();
213+
}
205214
}
206215

207216
// Button to toggle recording of frame markers.
@@ -223,11 +232,28 @@ private void DrawEventList()
223232
var fileName = EditorUtility.OpenFilePanel("Choose event trace to load", string.Empty, "inputtrace");
224233
if (!string.IsNullOrEmpty(fileName))
225234
{
235+
// If replay is in progress, stop it.
236+
if (m_ReplayController != null)
237+
{
238+
m_ReplayController.Dispose();
239+
m_ReplayController = null;
240+
}
241+
242+
// Make sure event trace isn't recording while we're playing.
226243
m_EventTrace.Disable();
227244
m_EventTraceDisabled = true;
245+
228246
m_EventTrace.ReadFrom(fileName);
229247
m_EventTree.Reload();
230-
m_EventTrace.Replay().PlayAllFramesOneByOne();
248+
249+
m_ReplayController = m_EventTrace.Replay()
250+
.PlayAllFramesOneByOne()
251+
.OnFinished(() =>
252+
{
253+
m_ReplayController.Dispose();
254+
m_ReplayController = null;
255+
Repaint();
256+
});
231257
}
232258
}
233259

@@ -301,21 +327,22 @@ private void RefreshControlTreeValues()
301327
// We will lose our device on domain reload and then look it back up the first
302328
// time we hit a repaint after a reload. By that time, the input system should have
303329
// fully come back to life as well.
304-
[NonSerialized] private InputDevice m_Device;
305-
[NonSerialized] private string m_DeviceIdString;
306-
[NonSerialized] private string m_DeviceUsagesString;
307-
[NonSerialized] private string m_DeviceFlagsString;
308-
[NonSerialized] private InputControlTreeView m_ControlTree;
309-
[NonSerialized] private InputEventTreeView m_EventTree;
310-
[NonSerialized] private bool m_NeedControlValueRefresh;
330+
private InputDevice m_Device;
331+
private string m_DeviceIdString;
332+
private string m_DeviceUsagesString;
333+
private string m_DeviceFlagsString;
334+
private InputControlTreeView m_ControlTree;
335+
private InputEventTreeView m_EventTree;
336+
private bool m_NeedControlValueRefresh;
337+
private InputEventTrace.ReplayController m_ReplayController;
338+
private InputEventTrace m_EventTrace;
311339

312340
[SerializeField] private int m_DeviceId = InputDevice.InvalidDeviceId;
313341
[SerializeField] private TreeViewState m_ControlTreeState;
314342
[SerializeField] private TreeViewState m_EventTreeState;
315343
[SerializeField] private MultiColumnHeaderState m_ControlTreeHeaderState;
316344
[SerializeField] private MultiColumnHeaderState m_EventTreeHeaderState;
317345
[SerializeField] private Vector2 m_ControlTreeScrollPosition;
318-
[SerializeField] private InputEventTrace m_EventTrace;
319346
[SerializeField] private bool m_EventTraceDisabled;
320347

321348
private static List<InputDeviceDebuggerWindow> s_OpenDebuggerWindows;

Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputControlTreeView.cs

Lines changed: 2 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,9 @@
22
using System;
33
using System.Collections.Generic;
44
using System.Linq;
5-
using UnityEngine.InputSystem.LowLevel;
6-
using UnityEngine.InputSystem.Utilities;
75
using UnityEditor.IMGUI.Controls;
86
using UnityEngine.Profiling;
97

10-
////TODO: switch to ReadValueFromState (the current value reading code dates back to very early versions of the input system)
11-
//// (note that doing so will have an impact on mouse coordinates which then will go through EditorWindowSpaceProcessor)
12-
138
////TODO: make control values editable (create state events from UI and pump them into the system)
149

1510
////TODO: show processors attached to controls
@@ -319,71 +314,8 @@ private unsafe string ReadRawValueAsString(InputControl control, byte[] state)
319314
{
320315
fixed(byte* statePtr = state)
321316
{
322-
var ptr = statePtr + control.m_StateBlock.byteOffset - m_RootControl.m_StateBlock.byteOffset;
323-
var format = control.m_StateBlock.format;
324-
325-
object value = null;
326-
if (format == InputStateBlock.FormatBit)
327-
{
328-
if (control.valueSizeInBytes == 1)
329-
{
330-
value = MemoryHelpers.ReadSingleBit(ptr, control.m_StateBlock.bitOffset) ? "1" : "0";
331-
}
332-
else
333-
{
334-
value = MemoryHelpers.ReadIntFromMultipleBits(ptr, control.m_StateBlock.bitOffset, control.m_StateBlock.sizeInBits);
335-
}
336-
}
337-
else if (format == InputStateBlock.FormatSBit)
338-
{
339-
if (control.valueSizeInBytes == 1)
340-
{
341-
value = MemoryHelpers.ReadSingleBit(ptr, control.m_StateBlock.bitOffset) ? "1" : "-1";
342-
}
343-
else
344-
{
345-
var halfMaxValue = ((1 << (int)control.m_StateBlock.sizeInBits) - 1) / 2;
346-
var fullValue = (MemoryHelpers.ReadIntFromMultipleBits(ptr, control.m_StateBlock.bitOffset, control.m_StateBlock.sizeInBits));
347-
value = fullValue - halfMaxValue;
348-
}
349-
}
350-
else if (format == InputStateBlock.FormatByte || format == InputStateBlock.FormatSByte)
351-
{
352-
value = *ptr;
353-
}
354-
else if (format == InputStateBlock.FormatShort)
355-
{
356-
value = *(short*)ptr;
357-
}
358-
else if (format == InputStateBlock.FormatUShort)
359-
{
360-
value = *(ushort*)ptr;
361-
}
362-
else if (format == InputStateBlock.FormatInt)
363-
{
364-
value = *(int*)ptr;
365-
}
366-
else if (format == InputStateBlock.FormatUInt)
367-
{
368-
value = *(uint*)ptr;
369-
}
370-
else if (format == InputStateBlock.FormatFloat)
371-
{
372-
value = *(float*)ptr;
373-
}
374-
else if (format == InputStateBlock.FormatDouble)
375-
{
376-
value = *(double*)ptr;
377-
}
378-
379-
// Stringify enum values, for. ex., TouchPhase
380-
if (value != null && control.valueType.IsEnum)
381-
{
382-
var intValue = Convert.ToInt32(value);
383-
value = Enum.ToObject(control.valueType, intValue);
384-
}
385-
386-
return value?.ToString();
317+
var ptr = statePtr - m_RootControl.m_StateBlock.byteOffset;
318+
return control.ReadValueFromStateAsObject(ptr).ToString();
387319
}
388320
}
389321

Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputEventTreeView.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
////TODO: add diagnostics to immediately highlight problems with events (e.g. events getting ignored because of incorrect type codes)
1616

17-
////TODO: implement support for sorting data by different property collumns (we currently always sort events by ID)
17+
////TODO: implement support for sorting data by different property columns (we currently always sort events by ID)
1818

1919
namespace UnityEngine.InputSystem.Editor
2020
{

Packages/com.unity.inputsystem/InputSystem/Editor/Internal/InputStateWindow.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ public void InitializeWithEvent(InputEventPtr eventPtr, InputControl control)
3737
m_StateBuffers = new byte[1][];
3838
m_StateBuffers[0] = GetEventStateBuffer(eventPtr, control);
3939
m_SelectedStateBuffer = 0;
40+
41+
titleContent = new GUIContent(control.displayName);
4042
}
4143

4244
public void InitializeWithEvents(InputEventPtr[] eventPtrs, InputControl control)
@@ -49,6 +51,8 @@ public void InitializeWithEvents(InputEventPtr[] eventPtrs, InputControl control
4951
m_StateBuffers[i] = GetEventStateBuffer(eventPtrs[i], control);
5052
m_CompareStateBuffers = true;
5153
m_ShowDifferentOnly = true;
54+
55+
titleContent = new GUIContent(control.displayName);
5256
}
5357

5458
private unsafe byte[] GetEventStateBuffer(InputEventPtr eventPtr, InputControl control)
@@ -124,6 +128,8 @@ public unsafe void InitializeWithControl(InputControl control)
124128

125129
m_BufferChoices = bufferChoices.ToArray();
126130
m_BufferChoiceValues = bufferChoiceValues.ToArray();
131+
132+
titleContent = new GUIContent(control.displayName);
127133
}
128134

129135
private static unsafe void* TryGetDeviceState(InputDevice device, BufferSelector selector)

0 commit comments

Comments
 (0)