Skip to content

Commit e299891

Browse files
committed
Merge branch 'develop' into stable
2 parents 0d0891e + 3fcf437 commit e299891

File tree

116 files changed

+3571
-3281
lines changed

Some content is hidden

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

116 files changed

+3571
-3281
lines changed

.yamato/config.metadata

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
editors:
2-
- version: 2020.3
3-
disable_tvos_run: true
42
- version: 2021.3
53
- version: 2022.3
64
- version: 2023.1
5+
- version: 2023.2
76
- version: trunk
87
disable_tvos_run: true
98

Assets/Samples/CustomDevice/CustomDevice.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,10 @@ private static void Initialize()
177177
// for it a little bit. One thing we can do is expose the controls for our
178178
// device directly. While anyone can look up our controls using strings, exposing
179179
// the controls as properties makes it simpler to work with the device in script.
180-
public ButtonControl firstButton { get; private set; }
181-
public ButtonControl secondButton { get; private set; }
182-
public ButtonControl thirdButton { get; private set; }
183-
public StickControl stick { get; private set; }
180+
public ButtonControl firstButton { get; protected set; }
181+
public ButtonControl secondButton { get; protected set; }
182+
public ButtonControl thirdButton { get; protected set; }
183+
public StickControl stick { get; protected set; }
184184

185185
// FinishSetup is where our device setup is finalized. Here we can look up
186186
// the controls that have been created.

Assets/Samples/InGameHints/InGameHintsActions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
4-
// version 1.6.3
4+
// version 1.7.0
55
// from Assets/Samples/InGameHints/InGameHintsActions.inputactions
66
//
77
// Changes to this file may cause incorrect behavior and will be lost if

Assets/Samples/SimpleDemo/SimpleControls.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
//------------------------------------------------------------------------------
22
// <auto-generated>
33
// This code was auto-generated by com.unity.inputsystem:InputActionCodeGenerator
4-
// version 1.6.3
4+
// version 1.7.0
55
// from Assets/Samples/SimpleDemo/SimpleControls.inputactions
66
//
77
// Changes to this file may cause incorrect behavior and will be lost if

Assets/Tests/InputSystem/APIVerificationTests.cs

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,98 @@ public void API_MonoBehavioursHaveHelpUrls()
368368
public ButtonControl tap { get; }
369369
public IntegerControl tapCount { get; }
370370
public IntegerControl touchId { get; }
371+
public UnityEngine.InputSystem.Controls.ButtonControl app { get; }
372+
public UnityEngine.InputSystem.Controls.Vector3Control deviceAcceleration { get; }
373+
public UnityEngine.InputSystem.Controls.Vector3Control deviceVelocity { get; }
374+
public UnityEngine.InputSystem.Controls.ButtonControl home { get; }
375+
public UnityEngine.InputSystem.Controls.ButtonControl recentered { get; }
376+
public UnityEngine.InputSystem.Controls.ButtonControl recentering { get; }
377+
public UnityEngine.InputSystem.Controls.Vector2Control touchpad { get; }
378+
public UnityEngine.InputSystem.Controls.ButtonControl touchpadClicked { get; }
379+
public UnityEngine.InputSystem.Controls.ButtonControl touchpadTouched { get; }
380+
public UnityEngine.InputSystem.Controls.ButtonControl volumeDown { get; }
381+
public UnityEngine.InputSystem.Controls.ButtonControl volumeUp { get; }
382+
public UnityEngine.InputSystem.Controls.ButtonControl back { get; }
383+
public UnityEngine.InputSystem.Controls.Vector3Control deviceAngularAcceleration { get; }
384+
public UnityEngine.InputSystem.Controls.Vector3Control deviceAngularVelocity { get; }
385+
public UnityEngine.InputSystem.Controls.AxisControl trigger { get; }
386+
public UnityEngine.InputSystem.Controls.ButtonControl triggerPressed { get; }
387+
public UnityEngine.InputSystem.Controls.Vector3Control centerEyeAcceleration { get; }
388+
public UnityEngine.InputSystem.Controls.Vector3Control centerEyeAngularAcceleration { get; }
389+
public UnityEngine.InputSystem.Controls.Vector3Control centerEyeAngularVelocity { get; }
390+
public UnityEngine.InputSystem.Controls.Vector3Control leftEyeAcceleration { get; }
391+
public UnityEngine.InputSystem.Controls.Vector3Control leftEyeAngularAcceleration { get; }
392+
public UnityEngine.InputSystem.Controls.Vector3Control leftEyeAngularVelocity { get; }
393+
public UnityEngine.InputSystem.Controls.Vector3Control rightEyeAcceleration { get; }
394+
public UnityEngine.InputSystem.Controls.Vector3Control rightEyeAngularAcceleration { get; }
395+
public UnityEngine.InputSystem.Controls.Vector3Control rightEyeAngularVelocity { get; }
396+
public UnityEngine.InputSystem.Controls.ButtonControl userPresence { get; }
397+
public UnityEngine.InputSystem.Controls.ButtonControl start { get; }
398+
public UnityEngine.InputSystem.Controls.AxisControl grip { get; }
399+
public UnityEngine.InputSystem.Controls.ButtonControl gripPressed { get; }
400+
public UnityEngine.InputSystem.Controls.ButtonControl primaryButton { get; }
401+
public UnityEngine.InputSystem.Controls.ButtonControl primaryTouched { get; }
402+
public UnityEngine.InputSystem.Controls.ButtonControl secondaryButton { get; }
403+
public UnityEngine.InputSystem.Controls.ButtonControl secondaryTouched { get; }
404+
public UnityEngine.InputSystem.Controls.Vector2Control thumbstick { get; }
405+
public UnityEngine.InputSystem.Controls.ButtonControl thumbstickClicked { get; }
406+
public UnityEngine.InputSystem.Controls.ButtonControl thumbstickTouched { get; }
407+
public UnityEngine.InputSystem.Controls.AxisControl triggerTouched { get; }
408+
public UnityEngine.InputSystem.Controls.ButtonControl isTracked { get; }
409+
public UnityEngine.InputSystem.Controls.IntegerControl trackingState { get; }
410+
public UnityEngine.InputSystem.Controls.ButtonControl primary { get; }
411+
public UnityEngine.InputSystem.Controls.ButtonControl trackpadPressed { get; }
412+
public UnityEngine.InputSystem.Controls.Vector2Control joystick { get; }
413+
public UnityEngine.InputSystem.Controls.ButtonControl menu { get; }
414+
public UnityEngine.InputSystem.Controls.ButtonControl touchpadClick { get; }
415+
public UnityEngine.InputSystem.Controls.ButtonControl touchpadTouch { get; }
416+
public UnityEngine.InputSystem.Controls.Vector3Control centerEyeVelocity { get; }
417+
public UnityEngine.InputSystem.Controls.Vector3Control leftEyeVelocity { get; }
418+
public UnityEngine.InputSystem.Controls.Vector3Control rightEyeVelocity { get; }
419+
public UnityEngine.InputSystem.Controls.Vector2Control trackpad { get; }
420+
public UnityEngine.InputSystem.Controls.ButtonControl trackpadTouched { get; }
421+
public Controls.Vector3Control acceleration { get; }
422+
public Controls.AxisControl ambientTemperature { get; }
423+
public Controls.QuaternionControl attitude { get; }
424+
public Controls.Vector3Control gravity { get; }
425+
public Controls.Vector3Control angularVelocity { get; }
426+
public Controls.AxisControl relativeHumidity { get; }
427+
public Controls.AxisControl lightLevel { get; }
428+
public Controls.Vector3Control magneticField { get; }
429+
public Controls.AxisControl atmosphericPressure { get; }
430+
public Controls.AxisControl distance { get; }
431+
public Controls.IntegerControl stepCounter { get; }
432+
public Controls.Vector3Control devicePosition { get; }
433+
public Controls.QuaternionControl deviceRotation { get; }
434+
public Controls.ButtonControl isTracked { get; }
435+
public Controls.IntegerControl trackingState { get; }
436+
public AxisControl w { get; }
437+
public AxisControl x { get; }
438+
public AxisControl y { get; }
439+
public AxisControl z { get; }
440+
public UnityEngine.InputSystem.Controls.ButtonControl leftTriggerButton { get; }
441+
public UnityEngine.InputSystem.Controls.ButtonControl playStationButton { get; }
442+
public UnityEngine.InputSystem.Controls.ButtonControl rightTriggerButton { get; }
443+
public UnityEngine.InputSystem.Controls.ButtonControl view { get; }
444+
public UnityEngine.InputSystem.Controls.IntegerControl parentBoneIndex { get; }
445+
public UnityEngine.InputSystem.Controls.Vector3Control position { get; }
446+
public UnityEngine.InputSystem.Controls.QuaternionControl rotation { get; }
447+
public UnityEngine.InputSystem.Controls.Vector3Control fixationPoint { get; }
448+
public UnityEngine.InputSystem.Controls.AxisControl leftEyeOpenAmount { get; }
449+
public UnityEngine.InputSystem.Controls.Vector3Control leftEyePosition { get; }
450+
public UnityEngine.InputSystem.Controls.QuaternionControl leftEyeRotation { get; }
451+
public UnityEngine.InputSystem.Controls.AxisControl rightEyeOpenAmount { get; }
452+
public UnityEngine.InputSystem.Controls.Vector3Control rightEyePosition { get; }
453+
public UnityEngine.InputSystem.Controls.QuaternionControl rightEyeRotation { get; }
454+
public UnityEngine.InputSystem.Controls.Vector3Control centerEyePosition { get; }
455+
public UnityEngine.InputSystem.Controls.QuaternionControl centerEyeRotation { get; }
456+
public UnityEngine.InputSystem.Controls.ButtonControl airTap { get; }
457+
public UnityEngine.InputSystem.Controls.Vector3Control sourceLossMitigationDirection { get; }
458+
public UnityEngine.InputSystem.Controls.AxisControl sourceLossRisk { get; }
459+
public UnityEngine.InputSystem.Controls.AxisControl batteryLevel { get; }
460+
public UnityEngine.InputSystem.Controls.ButtonControl joystickClicked { get; }
461+
public UnityEngine.InputSystem.Controls.Vector3Control pointerPosition { get; }
462+
public UnityEngine.InputSystem.Controls.QuaternionControl pointerRotation { get; }
371463
")]
372464
// InputActionAsset and InputActionMap changed from IInputActionCollection to IInputActionCollection2 with
373465
// the latter just being based on the former.

Assets/Tests/InputSystem/CoreTests_Controls.cs

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,16 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.Globalization;
34
using System.Linq;
5+
using System.Reflection;
46
using System.Threading;
57
using NUnit.Framework;
68
using Unity.Collections;
79
using Unity.Collections.LowLevel.Unsafe;
810
using UnityEngine;
911
using UnityEngine.InputSystem;
1012
using UnityEngine.InputSystem.Controls;
13+
using UnityEngine.InputSystem.Layouts;
1114
using UnityEngine.InputSystem.LowLevel;
1215
using UnityEngine.InputSystem.Processors;
1316
using UnityEngine.InputSystem.Utilities;
@@ -1524,4 +1527,67 @@ public void Controls_OptimizedControls_ParentChangesOptimization_IfChildIsNoLong
15241527
Assert.That(mouse.position.y.optimizedControlDataType, Is.EqualTo(InputStateBlock.FormatFloat));
15251528
Assert.That(mouse.position.optimizedControlDataType, Is.EqualTo(InputStateBlock.FormatInvalid));
15261529
}
1530+
1531+
[Test]
1532+
[Category("Controls")]
1533+
public void Controls_PrecompiledLayouts_AllChildControlPropertiesHaveSetters()
1534+
{
1535+
var inputDevice = typeof(InputDevice);
1536+
var inputControlType = typeof(InputControl);
1537+
var checkedTypes = new HashSet<Type>();
1538+
foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies())
1539+
{
1540+
try
1541+
{
1542+
foreach (var type in assembly.GetTypes())
1543+
{
1544+
// Skip base types
1545+
if (type == inputControlType || type == inputDevice)
1546+
continue;
1547+
1548+
if (!inputControlType.IsAssignableFrom(type))
1549+
continue;
1550+
1551+
CheckChildControls(type, checkedTypes);
1552+
}
1553+
}
1554+
catch (ReflectionTypeLoadException)
1555+
{
1556+
// Suppress type load exceptions
1557+
}
1558+
}
1559+
}
1560+
1561+
static void CheckChildControls(Type type, HashSet<Type> checkedTypes)
1562+
{
1563+
if (!checkedTypes.Add(type))
1564+
return;
1565+
1566+
foreach (var property in type.GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.DeclaredOnly))
1567+
{
1568+
if (!typeof(InputControl).IsAssignableFrom(property.PropertyType))
1569+
continue;
1570+
1571+
// Note: This will miss InputDevice controls that don't have an InputControlAttribute, but is necessary
1572+
// because not all InputControl properties are actually controls. We would need to build the device to know
1573+
// for sure if a given property is a control
1574+
if (!property.GetCustomAttributes<InputControlAttribute>().Any())
1575+
continue;
1576+
1577+
var setMethod = property.SetMethod;
1578+
if (typeof(InputDevice).IsAssignableFrom(type))
1579+
{
1580+
// Properties on an InputDevice can be protected, since the precompiled layout will be an inherited class
1581+
var inputDeviceMessage = $"A public or protected setter is required on {type.FullName}.{property.Name} in order to support precompiled layouts";
1582+
Assert.That(setMethod, Is.Not.Null, inputDeviceMessage);
1583+
Assert.That(setMethod.IsPrivate, Is.Not.True, inputDeviceMessage);
1584+
Assert.That(setMethod.IsAssembly, Is.Not.True, inputDeviceMessage);
1585+
continue;
1586+
}
1587+
1588+
var inputControlMessage = $"A public setter is required on {type.FullName}.{property.Name} in order to support precompiled layouts";
1589+
Assert.That(setMethod, Is.Not.Null, inputControlMessage);
1590+
Assert.That(setMethod.IsPublic, Is.True, inputControlMessage);
1591+
}
1592+
}
15271593
}

Assets/Tests/InputSystem/CoreTests_Devices.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,7 +1041,7 @@ public void Devices_ChangingStateOfDevice_TriggersNotification()
10411041
private class TestDeviceThatResetsStateInCallback : InputDevice, IInputStateCallbackReceiver
10421042
{
10431043
[InputControl(format = "FLT")]
1044-
public ButtonControl button { get; private set; }
1044+
public ButtonControl button { get; protected set; }
10451045

10461046
protected override void FinishSetup()
10471047
{
@@ -2029,7 +2029,7 @@ long DeviceCallback(int deviceId, InputDeviceCommand* command, ref bool received
20292029
class DeviceWithCustomReset : InputDevice, ICustomDeviceReset
20302030
{
20312031
[InputControl]
2032-
public AxisControl axis { get; private set; }
2032+
public AxisControl axis { get; protected set; }
20332033

20342034
protected override void FinishSetup()
20352035
{
@@ -5630,8 +5630,8 @@ public enum Behavior
56305630

56315631
public Behavior behavior = Behavior.PreserveEventsAsIs;
56325632

5633-
public IntegerControl value1 { get; private set; }
5634-
public IntegerControl value2 { get; private set; }
5633+
public IntegerControl value1 { get; protected set; }
5634+
public IntegerControl value2 { get; protected set; }
56355635

56365636
protected override void FinishSetup()
56375637
{

Assets/Tests/InputSystem/CoreTests_Events.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2081,7 +2081,7 @@ private struct CustomDeviceState : IInputStateTypeInfo
20812081
[InputControlLayout(stateType = typeof(CustomDeviceState))]
20822082
private class CustomDevice : InputDevice
20832083
{
2084-
public AxisControl axis { get; private set; }
2084+
public AxisControl axis { get; protected set; }
20852085

20862086
protected override void FinishSetup()
20872087
{
@@ -2549,7 +2549,7 @@ public class TestException : Exception
25492549
}
25502550

25512551
public bool throwExceptionOnState = true;
2552-
public AxisControl axis { get; private set; }
2552+
public AxisControl axis { get; protected set; }
25532553

25542554
protected override void FinishSetup()
25552555
{

Assets/Tests/InputSystem/CoreTests_Layouts.cs

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2546,6 +2546,50 @@ public void Layouts_CanForceMixedVariantsThroughLayout()
25462546
Assert.That(device.allControls, Has.Exactly(1).With.Property("name").EqualTo("ButtonC"));
25472547
}
25482548

2549+
[Test]
2550+
[Category("Layouts")]
2551+
public void Layouts_CanMatchControlPath()
2552+
{
2553+
const string jsonBase = @"
2554+
{
2555+
""name"" : ""BaseLayout"",
2556+
""extend"" : ""DeviceWithLayoutVariantA"",
2557+
""controls"" : [
2558+
{ ""name"" : ""ControlFromBase"", ""layout"" : ""Button"" },
2559+
{ ""name"" : ""OtherControlFromBase"", ""layout"" : ""Axis"" },
2560+
{ ""name"" : ""ControlWithExplicitDefaultVariant"", ""layout"" : ""Axis"", ""variants"" : ""default"" },
2561+
{ ""name"" : ""StickControl"", ""layout"" : ""Stick"" },
2562+
{ ""name"" : ""StickControl/x"", ""offset"" : 14, ""variants"" : ""A"" }
2563+
]
2564+
}
2565+
";
2566+
const string jsonDerived = @"
2567+
{
2568+
""name"" : ""DerivedLayout"",
2569+
""extend"" : ""BaseLayout"",
2570+
""controls"" : [
2571+
{ ""name"" : ""ControlFromBase"", ""variants"" : ""A"", ""offset"" : 20, ""usages"" : [""Submit""], ""aliases"" : [""A""] }
2572+
]
2573+
}
2574+
";
2575+
2576+
InputSystem.RegisterLayout<DeviceWithLayoutVariantA>();
2577+
InputSystem.RegisterLayout(jsonBase);
2578+
InputSystem.RegisterLayout(jsonDerived);
2579+
2580+
var layout = InputSystem.LoadLayout("DerivedLayout");
2581+
var parsedPath = InputControlPath.Parse("<BaseLayout>/ControlWithExplicitDefaultVariant").ToArray()[1];
2582+
Assert.That(layout.m_Controls.Any(x => InputControlPath.MatchControlComponent(ref parsedPath, ref x)), Is.True);
2583+
2584+
// Verify that we can match alias's when provided
2585+
var parsedAliasPath = InputControlPath.Parse("<BaseLayout>/A").ToArray()[1];
2586+
Assert.That(layout.m_Controls.Any(x => InputControlPath.MatchControlComponent(ref parsedAliasPath, ref x, true)), Is.True);
2587+
2588+
// Verify that we match usages when it is the only control path component provided
2589+
var parsedUsagesPath = InputControlPath.Parse("<BaseLayout>/{Submit}").ToArray()[1];
2590+
Assert.That(layout.m_Controls.Any(x => InputControlPath.MatchControlComponent(ref parsedUsagesPath, ref x)), Is.True);
2591+
}
2592+
25492593
[Test]
25502594
[Category("Layouts")]
25512595
[Ignore("TODO")]

Assets/Tests/InputSystem/CoreTests_Remoting.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -532,7 +532,7 @@ public void Dispose()
532532

533533
private class MyDevice : InputDevice
534534
{
535-
public ButtonControl myControl { get; private set; }
535+
public ButtonControl myControl { get; protected set; }
536536

537537
protected override void FinishSetup()
538538
{

0 commit comments

Comments
 (0)