Skip to content

Commit d7e0a17

Browse files
Merge branch 'develop' into input/add-focus-events-to-queue
2 parents e35484f + 0bb75c4 commit d7e0a17

40 files changed

Lines changed: 27792 additions & 35914 deletions

.yamato/wrench/player-build.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Auto-generated by Recipe Engine, do not modify manually.
2+
# This job is generated by the wrench recipe engine module, see find the docs here: http://Go/ii2fb
3+
{}
4+

.yamato/wrench/player-test.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Auto-generated by Recipe Engine, do not modify manually.
2+
# This job is generated by the wrench recipe engine module, see find the docs here: http://Go/ii2fb
3+
{}
4+

.yamato/wrench/pvp-exemptions.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,8 @@
127127
},
128128
"PVP-92-3": {
129129
"errors": [
130+
"InputSystem/Plugins/iOS/IOSGameController.cs: .Switch;",
131+
"InputSystem/Plugins/Switch/SwitchProController.cs: .Switch\n",
130132
"InputSystem/Plugins/Switch/SwitchProControllerHID.cs: .Switch.",
131133
"InputSystem/Plugins/Switch/SwitchProControllerHID.cs: .Switch\n",
132134
"InputSystem/Plugins/Switch/SwitchSupportHID.cs: .Switch\n",

.yamato/wrench/validation-jobs.yml

Lines changed: 18 additions & 18 deletions
Large diffs are not rendered by default.

Assets/Tests/InputSystem.Editor/InputActionReferenceEditorTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ private void DisableDomainReloads()
9898
EditorPrefsTestUtils.DisableDomainReload();
9999
}
100100

101-
private static InputActionBehaviour GetBehaviour() => Object.FindFirstObjectByType<InputActionBehaviour>();
101+
private static InputActionBehaviour GetBehaviour() => Object.FindAnyObjectByType<InputActionBehaviour>();
102102
private static InputActionAsset GetAsset() => AssetDatabase.LoadAssetAtPath<InputActionAsset>(assetPath);
103103

104104
// For unclear reason, NUnit fails to assert throwing exceptions after transition into play-mode.

Assets/Tests/InputSystem.Editor/XRIPackageTest.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public IEnumerator TearDown()
3838

3939
[UnityTest]
4040
[Category("Integration")]
41+
[Ignore("ISX-2531 - This test is currently ignored as it is causing issues in the CI. It should be re-enabled once the underlying issue is resolved.")]
4142
public IEnumerator AdddingLatestXRIPackageThrowsNoErrors()
4243
{
4344
Application.logMessageReceived += HandleLog;

Assets/Tests/InputSystem/CoreTests_Layouts.cs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -499,6 +499,40 @@ public void Layouts_CanFindLayoutFromDeviceDescription()
499499
Assert.That(layout, Is.EqualTo("MyDevice"));
500500
}
501501

502+
[Test]
503+
[Category("Layouts")]
504+
public void Layouts_CanMatchLayoutBasedOnCapabilitiesFromJson()
505+
{
506+
const string json = @"
507+
{
508+
""name"" : ""CapabilityTestLayout"",
509+
""extend"" : ""Gamepad"",
510+
""device"" : {
511+
""capabilities"" : [
512+
{ ""path"" : ""vendorId"", ""value"" : ""9999"" }
513+
]
514+
}
515+
}";
516+
517+
InputSystem.RegisterLayout(json);
518+
519+
try
520+
{
521+
var matchedLayout = InputSystem.TryFindMatchingLayout(
522+
new InputDeviceDescription
523+
{
524+
deviceClass = "Gamepad",
525+
capabilities = @"{""vendorId"":""9999""}"
526+
});
527+
528+
Assert.That(matchedLayout, Is.EqualTo("CapabilityTestLayout"));
529+
}
530+
finally
531+
{
532+
InputSystem.RemoveLayout("CapabilityTestLayout");
533+
}
534+
}
535+
502536
[Test]
503537
[Category("Layouts")]
504538
public void Layouts_CanFindAllLayoutsBasedOnGivenLayout()

Assets/Tests/InputSystem/Plugins/UITests.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4607,6 +4607,7 @@ private class UICallbackReceiver : MonoBehaviour, IPointerClickHandler, IPointer
46074607
IPointerMoveHandler, IPointerExitHandler, IPointerUpHandler, IMoveHandler, ISelectHandler, IDeselectHandler,
46084608
IInitializePotentialDragHandler, IBeginDragHandler, IDragHandler, IEndDragHandler, IDropHandler, ISubmitHandler, ICancelHandler, IScrollHandler
46094609
{
4610+
[Serializable]
46104611
public struct Event
46114612
{
46124613
public EventType type { get; }

Assets/Tests/InputSystem/Plugins/iOSTests.cs

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using UnityEngine.InputSystem.iOS.LowLevel;
1010
using UnityEngine.InputSystem.LowLevel;
1111
using UnityEngine.InputSystem.Processors;
12+
using UnityEngine.InputSystem.Switch;
1213
using UnityEngine.InputSystem.XInput;
1314
using UnityEngine.TestTools;
1415
using UnityEngine.TestTools.Utils;
@@ -56,13 +57,70 @@ public void Devices_SupportsiOSGamePad(string product, Type deviceType, Type par
5657
Assert.That(gamepad.rightTrigger.ReadValue(), Is.EqualTo(0.456).Within(0.000001));
5758

5859
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.A), gamepad.buttonSouth);
60+
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.A), gamepad.aButton);
5961
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.X), gamepad.buttonWest);
62+
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.X), gamepad.xButton);
6063
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.Y), gamepad.buttonNorth);
64+
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.Y), gamepad.yButton);
6165
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.B), gamepad.buttonEast);
66+
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.B), gamepad.bButton);
6267
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.LeftShoulder), gamepad.leftShoulder);
6368
AssertButtonPress(gamepad, new iOSGameControllerState().WithButton(iOSButton.RightShoulder), gamepad.rightShoulder);
6469
}
6570

71+
[Test]
72+
[Category("Devices")]
73+
// this is a new test, as we need to assert the Nintendo layout (e.g. buttonSouth == B button)
74+
public void Devices_SupportsSwitchProControlleriOS()
75+
{
76+
var device = InputSystem.AddDevice(
77+
new InputDeviceDescription
78+
{
79+
interfaceName = "iOS",
80+
deviceClass = "iOSGameController",
81+
product = "Pro Controller"
82+
});
83+
Assert.That(device, Is.TypeOf(typeof(SwitchProControlleriOS)));
84+
Assert.That(device, Is.InstanceOf(typeof(SwitchProController)));
85+
Assert.That(device, Is.InstanceOf(typeof(Gamepad)));
86+
87+
var gamepad = (SwitchProControlleriOS)device;
88+
89+
InputSystem.QueueStateEvent(gamepad,
90+
new iOSGameControllerStateSwappedFaceButtons()
91+
.WithButton(iOSButton.LeftTrigger, true, 0.123f)
92+
.WithButton(iOSButton.RightTrigger, true, 0.456f)
93+
.WithAxis(iOSAxis.LeftStickX, 0.789f)
94+
.WithAxis(iOSAxis.LeftStickY, 0.987f)
95+
.WithAxis(iOSAxis.RightStickX, 0.654f)
96+
.WithAxis(iOSAxis.RightStickY, 0.321f));
97+
InputSystem.Update();
98+
99+
var leftStickDeadzone = gamepad.leftStick.TryGetProcessor<StickDeadzoneProcessor>();
100+
var rightStickDeadzone = gamepad.leftStick.TryGetProcessor<StickDeadzoneProcessor>();
101+
102+
Assert.That(gamepad.leftStick.ReadValue(), Is.EqualTo(leftStickDeadzone.Process(new Vector2(0.789f, 0.987f))));
103+
Assert.That(gamepad.rightStick.ReadValue(), Is.EqualTo(rightStickDeadzone.Process(new Vector2(0.654f, 0.321f))));
104+
Assert.That(gamepad.leftTrigger.ReadValue(), Is.EqualTo(0.123).Within(0.000001));
105+
Assert.That(gamepad.rightTrigger.ReadValue(), Is.EqualTo(0.456).Within(0.000001));
106+
// testing for Pro Controller layout...
107+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.A), gamepad.buttonEast);
108+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.A), gamepad.aButton);
109+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.X), gamepad.buttonNorth);
110+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.X), gamepad.xButton);
111+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.Y), gamepad.buttonWest);
112+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.Y), gamepad.yButton);
113+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.B), gamepad.buttonSouth);
114+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.B), gamepad.bButton);
115+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.LeftShoulder), gamepad.leftShoulder);
116+
AssertButtonPress(gamepad, new iOSGameControllerStateSwappedFaceButtons().WithButton(iOSButton.RightShoulder), gamepad.rightShoulder);
117+
Assert.Contains("Submit", gamepad.buttonEast.usages.m_Array);
118+
Assert.Contains("PrimaryAction", gamepad.aButton.usages.m_Array);
119+
Assert.Contains("Back", gamepad.bButton.usages.m_Array);
120+
Assert.Contains("Cancel", gamepad.bButton.usages.m_Array);
121+
Assert.Contains("SecondaryAction", gamepad.yButton.usages.m_Array);
122+
}
123+
66124
[Test]
67125
[Category("Devices")]
68126
[TestCase("Gravity", typeof(GravitySensor))]

Assets/Tests/InputSystem/SwitchTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,13 @@ public void Devices_SupportsHIDNpad()
5656
Assert.That(currentRight, Is.EqualTo(expectedRight).Using(new Vector2EqualityComparer(0.01f)));
5757

5858
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.A), controller.buttonEast);
59+
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.A), controller.aButton);
5960
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.B), controller.buttonSouth);
61+
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.B), controller.bButton);
6062
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.X), controller.buttonNorth);
63+
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.X), controller.xButton);
6164
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.Y), controller.buttonWest);
65+
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.Y), controller.yButton);
6266
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.StickL), controller.leftStickButton);
6367
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.StickR), controller.rightStickButton);
6468
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.L), controller.leftShoulder);
@@ -67,6 +71,12 @@ public void Devices_SupportsHIDNpad()
6771
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.ZR), controller.rightTrigger);
6872
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.Plus), controller.startButton);
6973
AssertButtonPress(controller, StateWithButton(SwitchProControllerHIDInputState.Button.Minus), controller.selectButton);
74+
75+
Assert.Contains("Submit", controller.buttonEast.usages.m_Array);
76+
Assert.Contains("PrimaryAction", controller.aButton.usages.m_Array);
77+
Assert.Contains("Back", controller.bButton.usages.m_Array);
78+
Assert.Contains("Cancel", controller.bButton.usages.m_Array);
79+
Assert.Contains("SecondaryAction", controller.yButton.usages.m_Array);
7080
}
7181

7282
private static SwitchProControllerHIDInputState StateWithButton(SwitchProControllerHIDInputState.Button button)
@@ -168,6 +178,7 @@ public void Devices_SupportsSwitchLikeControllers(int vendorId, int productId)
168178
});
169179

170180
Assert.That(device, Is.TypeOf<SwitchProControllerHID>());
181+
Assert.That(device, Is.InstanceOf(typeof(SwitchProController)));
171182
}
172183

173184
#endif

0 commit comments

Comments
 (0)