Skip to content

Commit a80ba81

Browse files
committed
Fixing API Naming Tests
1 parent 97438f1 commit a80ba81

File tree

4 files changed

+99
-31
lines changed

4 files changed

+99
-31
lines changed

Assets/Tests/InputSystem/Plugins/XRTests.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void Devices_XRDeviceRoleDeterminesTypeOfDevice(InputDeviceRole role, str
4141
Assert.That(createdDevice, Is.TypeOf(expectedType));
4242

4343
var generatedLayout = InputSystem.LoadLayout(
44-
$"{XRUtilities.kXRInterfaceCurrent}::{deviceDescription.manufacturer}::{deviceDescription.product}");
44+
$"{XRUtilities.InterfaceCurrent}::{deviceDescription.manufacturer}::{deviceDescription.product}");
4545
Assert.That(generatedLayout, Is.Not.Null);
4646
Assert.That(generatedLayout.baseLayouts, Is.EquivalentTo(new[] { new InternedString(baseLayoutName) }));
4747
}
@@ -83,7 +83,7 @@ public void Layouts_XRLayoutIsNamespacedAsInterfaceManufacturerDevice()
8383
var createdDevice = InputSystem.devices[0];
8484

8585
var expectedLayoutName =
86-
$"{XRUtilities.kXRInterfaceCurrent}::{deviceDescription.manufacturer}::{deviceDescription.product}";
86+
$"{XRUtilities.InterfaceCurrent}::{deviceDescription.manufacturer}::{deviceDescription.product}";
8787
Assert.AreEqual(createdDevice.layout, expectedLayoutName);
8888
}
8989

@@ -100,7 +100,7 @@ public void Layouts_XRLayoutWithoutManufacturer_IsNamespacedAsInterfaceDevice()
100100
Assert.That(InputSystem.devices, Has.Count.EqualTo(1));
101101
var createdDevice = InputSystem.devices[0];
102102

103-
var expectedLayoutName = $"{XRUtilities.kXRInterfaceCurrent}::{deviceDescription.product}";
103+
var expectedLayoutName = $"{XRUtilities.InterfaceCurrent}::{deviceDescription.product}";
104104
Assert.AreEqual(expectedLayoutName, createdDevice.layout);
105105
}
106106

@@ -475,7 +475,7 @@ private static InputDeviceDescription CreateSimpleDeviceDescriptionByRole(InputD
475475
{
476476
return new InputDeviceDescription
477477
{
478-
interfaceName = XRUtilities.kXRInterfaceCurrent,
478+
interfaceName = XRUtilities.InterfaceCurrent,
479479
product = "Device",
480480
manufacturer = "Manufacturer",
481481
capabilities = new XRDeviceDescriptor
@@ -499,7 +499,7 @@ private static InputDeviceDescription CreateMangledNameDeviceDescription()
499499
{
500500
return new InputDeviceDescription
501501
{
502-
interfaceName = XRUtilities.kXRInterfaceCurrent,
502+
interfaceName = XRUtilities.InterfaceCurrent,
503503
product = "XR_This.Layout/Should have 1 Valid::Name",
504504
manufacturer = "__Manufacturer::",
505505
capabilities = new XRDeviceDescriptor
@@ -536,7 +536,7 @@ public static InputDeviceDescription CreateDeviceDescription()
536536
{
537537
return new InputDeviceDescription
538538
{
539-
interfaceName = XRUtilities.kXRInterfaceCurrent,
539+
interfaceName = XRUtilities.InterfaceCurrent,
540540
product = "XRDevice",
541541
manufacturer = "XRManufacturer",
542542
capabilities = new XRDeviceDescriptor
@@ -613,7 +613,7 @@ public static InputDeviceDescription CreateDeviceDescription()
613613
{
614614
return new InputDeviceDescription()
615615
{
616-
interfaceName = XRUtilities.kXRInterfaceCurrent,
616+
interfaceName = XRUtilities.InterfaceCurrent,
617617
product = "XRDevice",
618618
manufacturer = "XRManufacturer",
619619
capabilities = new XRDeviceDescriptor

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/MagicLeap.cs

Lines changed: 69 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,39 @@
33

44
namespace UnityEngine.InputSystem.XR
55
{
6+
[Scripting.Preserve]
67
[InputControlLayout]
78
public class MagicLeapLightwear : XRHMD
89
{
10+
[Scripting.Preserve]
11+
[InputControl]
912
public IntegerControl trackingState { get; private set; }
13+
[Scripting.Preserve]
14+
[InputControl]
1015
public ButtonControl isTracked { get; private set; }
16+
[Scripting.Preserve]
17+
[InputControl]
1118
public Vector3Control devicePosition { get; private set; }
19+
[Scripting.Preserve]
20+
[InputControl]
1221
public QuaternionControl deviceRotation { get; private set; }
22+
[Scripting.Preserve]
23+
[InputControl]
1324
public Vector3Control centerEyePosition { get; private set; }
25+
[Scripting.Preserve]
26+
[InputControl]
1427
public QuaternionControl centerEyeRotation { get; private set; }
28+
[Scripting.Preserve]
29+
[InputControl]
1530
public AxisControl confidence { get; private set; }
31+
[Scripting.Preserve]
32+
[InputControl]
1633
public AxisControl fixationPointConfidence { get; private set; }
34+
[Scripting.Preserve]
35+
[InputControl]
1736
public AxisControl eyeLeftCenterConfidence { get; private set; }
37+
[Scripting.Preserve]
38+
[InputControl]
1839
public AxisControl eyeRightCenterConfidence { get; private set; }
1940

2041
//Need Discrete State for CalibrationStatus
@@ -38,18 +59,37 @@ protected override void FinishSetup()
3859
}
3960
}
4061

62+
[Scripting.Preserve]
4163
[InputControlLayout(commonUsages = new[] { "LeftHand", "RightHand" })]
4264
public class MagicLeapHand : XRController
4365
{
66+
[Scripting.Preserve]
67+
[InputControl]
4468
public IntegerControl trackingState { get; private set; }
69+
[Scripting.Preserve]
70+
[InputControl]
4571
public ButtonControl isTracked { get; private set; }
72+
[Scripting.Preserve]
73+
[InputControl]
4674
public Vector3Control center { get; private set; }
75+
[Scripting.Preserve]
76+
[InputControl]
4777
public QuaternionControl rotation { get; private set; }
4878

79+
[Scripting.Preserve]
80+
[InputControl]
4981
public AxisControl handConfidence { get; private set; }
82+
[Scripting.Preserve]
83+
[InputControl]
5084
public Vector3Control normalizeCenter { get; private set; }
85+
[Scripting.Preserve]
86+
[InputControl]
5187
public Vector3Control wristCenter { get; private set; }
88+
[Scripting.Preserve]
89+
[InputControl]
5290
public Vector3Control wristUlnar { get; private set; }
91+
[Scripting.Preserve]
92+
[InputControl]
5393
public Vector3Control wristRadial { get; private set; }
5494

5595
//Need Bone control and Hand Control
@@ -71,26 +111,54 @@ protected override void FinishSetup()
71111
}
72112
}
73113

74-
114+
[Scripting.Preserve]
75115
[InputControlLayout(commonUsages = new[] { "LeftHand", "RightHand" })]
76116
public class MagicLeapController : XRController
77117
{
118+
[Scripting.Preserve]
119+
[InputControl]
78120
public IntegerControl trackingState { get; private set; }
121+
[Scripting.Preserve]
122+
[InputControl]
79123
public ButtonControl isTracked { get; private set; }
124+
[Scripting.Preserve]
125+
[InputControl]
80126
public Vector3Control position { get; private set; }
127+
[Scripting.Preserve]
128+
[InputControl]
81129
public QuaternionControl rotation { get; private set; }
82130

131+
[Scripting.Preserve]
132+
[InputControl]
83133
public ButtonControl touchpad1Pressed { get; private set; }
134+
[Scripting.Preserve]
135+
[InputControl]
84136
public Vector2Control touchpad1Position { get; private set; }
137+
[Scripting.Preserve]
138+
[InputControl]
85139
public AxisControl touchpad1Force { get; private set; }
86140

141+
[Scripting.Preserve]
142+
[InputControl]
87143
public ButtonControl touchpad2Pressed { get; private set; }
144+
[Scripting.Preserve]
145+
[InputControl]
88146
public Vector2Control touchpad2Position { get; private set; }
147+
[Scripting.Preserve]
148+
[InputControl]
89149
public AxisControl touchpad2Force { get; private set; }
90150

151+
[Scripting.Preserve]
152+
[InputControl]
91153
public ButtonControl triggerButton { get; private set; }
154+
[Scripting.Preserve]
155+
[InputControl]
92156
public AxisControl trigger { get; private set; }
157+
[Scripting.Preserve]
158+
[InputControl]
93159
public ButtonControl bumper { get; private set; }
160+
[Scripting.Preserve]
161+
[InputControl]
94162
public ButtonControl menu { get; private set; }
95163

96164
//Need Discrete State for DOF and Type and CalibrationAccuracy

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRSupport.cs

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,17 @@ public static class XRUtilities
1212
/// <summary>
1313
/// A simple Regex pattern that allows InputDeviceMatchers to match to any version of the XRInput interface.
1414
/// </summary>
15-
public const string kXRInterfaceMatchAnyVersion = "^(XRInput)";
15+
public const string InterfaceMatchAnyVersion = "^(XRInput)";
1616

1717
/// <summary>
1818
/// The initial, now deprecated interface for XRInput. This version handles button packing for Android differently from current.
1919
/// </summary>
20-
public const string kXRInterfaceV1 = "XRInput";
20+
public const string InterfaceV1 = "XRInput";
2121

2222
/// <summary>
2323
/// The current interface code sent with devices to identify as XRInput devices.
2424
/// </summary>
25-
public const string kXRInterfaceCurrent = "XRInputV1";
25+
public const string InterfaceCurrent = "XRInputV1";
2626
}
2727

2828
// Sync to UnityXRInputFeatureType in IUnityXRInput.h
@@ -104,93 +104,93 @@ public static void Initialize()
104104

105105
InputSystem.RegisterLayout<WMRHMD>(
106106
matches: new InputDeviceMatcher()
107-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
107+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
108108
.WithProduct("(Windows Mixed Reality HMD)|(Microsoft HoloLens)|(Acer AH100)|(Samsung Windows Mixed Reality 800ZAA)")
109109
);
110110
InputSystem.RegisterLayout<WMRSpatialController>(
111111
matches: new InputDeviceMatcher()
112-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
112+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
113113
.WithProduct(@"(^(Spatial Controller))|(^(OpenVR Controller\(WindowsMR))")
114114
);
115115
InputSystem.RegisterLayout<HololensHand>(
116116
matches: new InputDeviceMatcher()
117-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
117+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
118118
.WithProduct(@"(^(Hand -))")
119119
);
120120

121121
InputSystem.RegisterLayout<OculusHMD>(
122122
matches: new InputDeviceMatcher()
123-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
123+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
124124
.WithManufacturer("Oculus")
125125
.WithProduct("^(Oculus Rift)"));
126126
InputSystem.RegisterLayout<OculusTouchController>(
127127
matches: new InputDeviceMatcher()
128-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
128+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
129129
.WithManufacturer("Oculus")
130130
.WithProduct(@"((Oculus Touch Controller)|(^(OpenVR Controller\(Oculus Rift [a-zA-Z0-9]*)))"));
131131
InputSystem.RegisterLayout<OculusRemote>(
132132
matches: new InputDeviceMatcher()
133-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
133+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
134134
.WithManufacturer("Oculus")
135135
.WithProduct(@"Oculus Remote"));
136136
InputSystem.RegisterLayout<OculusTrackingReference>(
137137
matches: new InputDeviceMatcher()
138-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
138+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
139139
.WithProduct(@"((Tracking Reference)|(^(Oculus Rift [a-zA-Z0-9]* \(Camera)))"));
140140

141141
InputSystem.RegisterLayout<OculusStandaloneHMDBase>(
142142
name: "Oculus Go",
143143
matches: new InputDeviceMatcher()
144-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
144+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
145145
.WithProduct("Oculus Go"));
146146

147147
InputSystem.RegisterLayout<OculusStandaloneHMDExtended>(
148148
name: "GearVR",
149149
matches: new InputDeviceMatcher()
150-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
150+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
151151
.WithProduct("Oculus HMD"));
152152
InputSystem.RegisterLayout<GearVRTrackedController>(
153153
matches: new InputDeviceMatcher()
154-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
154+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
155155
.WithProduct("^(Oculus Tracked Remote)"));
156156

157157
InputSystem.RegisterLayout<DaydreamHMD>(
158158
matches: new InputDeviceMatcher()
159-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
159+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
160160
.WithProduct("Daydream HMD"));
161161
InputSystem.RegisterLayout<DaydreamController>(
162162
matches: new InputDeviceMatcher()
163-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
163+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
164164
.WithProduct("^(Daydream Controller)"));
165165

166166
InputSystem.RegisterLayout<ViveHMD>(
167167
matches: new InputDeviceMatcher()
168-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
168+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
169169
.WithManufacturer("HTC")
170170
.WithProduct(@"^((Vive DVT)|(Vive MV.)|(Vive Pro)|(Vive. MV))"));
171171
InputSystem.RegisterLayout<ViveWand>(
172172
matches: new InputDeviceMatcher()
173-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
173+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
174174
.WithManufacturer("HTC")
175175
.WithProduct(@"^(OpenVR Controller\(((Vive. Controller)|(VIVE. Controller)|(Vive Controller)))"));
176176
InputSystem.RegisterLayout<KnucklesController>(
177177
matches: new InputDeviceMatcher()
178-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
178+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
179179
.WithManufacturer("Valve")
180180
.WithProduct(@"^(OpenVR Controller\(Knuckles)"));
181181
InputSystem.RegisterLayout<ViveTracker>(
182182
matches: new InputDeviceMatcher()
183-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
183+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
184184
.WithManufacturer("HTC")
185185
.WithProduct(@"^(VIVE Tracker)"));
186186
InputSystem.RegisterLayout<HandedViveTracker>(
187187
matches: new InputDeviceMatcher()
188-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
188+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
189189
.WithManufacturer("HTC")
190190
.WithProduct(@"^(OpenVR Controller\(VIVE Tracker)"));
191191
InputSystem.RegisterLayout<ViveLighthouse>(
192192
matches: new InputDeviceMatcher()
193-
.WithInterface(XRUtilities.kXRInterfaceMatchAnyVersion)
193+
.WithInterface(XRUtilities.InterfaceMatchAnyVersion)
194194
.WithManufacturer("HTC")
195195
.WithProduct(@"^(HTC V2-XD/XE)"));
196196

Packages/com.unity.inputsystem/InputSystem/Plugins/XR/XRTemplateBuilder.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ static string SanitizeName(string originalName)
5858
internal static string OnFindLayoutForDevice(int deviceId, ref InputDeviceDescription description, string matchedLayout, IInputRuntime runtime)
5959
{
6060
// If the device isn't a XRInput, we're not interested.
61-
if (description.interfaceName != XRUtilities.kXRInterfaceCurrent && description.interfaceName != XRUtilities.kXRInterfaceV1)
61+
if (description.interfaceName != XRUtilities.InterfaceCurrent && description.interfaceName != XRUtilities.InterfaceV1)
6262
{
6363
return null;
6464
}
@@ -176,7 +176,7 @@ internal InputControlLayout Build()
176176

177177
uint nextOffset = GetSizeOfFeature(feature);
178178

179-
if (interfaceName == XRUtilities.kXRInterfaceV1)
179+
if (interfaceName == XRUtilities.InterfaceV1)
180180
{
181181
#if UNITY_ANDROID
182182
if (nextOffset < 4)

0 commit comments

Comments
 (0)