Skip to content

Commit c0e9c15

Browse files
committed
Removed Doubled up Enum type
1 parent ca0eb0c commit c0e9c15

File tree

3 files changed

+19
-32
lines changed

3 files changed

+19
-32
lines changed

Assets/Tests/InputSystem/Plugins/XRTests.cs

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,18 +11,20 @@
1111
using UnityEngine.InputSystem.Layouts;
1212
using UnityEngine.InputSystem.LowLevel;
1313

14+
using InputDeviceRole = UnityEngine.XR.InputDeviceRole;
15+
1416
internal class XRTests : InputTestFixture
1517
{
1618
[Test]
1719
[Category("Devices")]
18-
[TestCase(DeviceRole.Generic, "XRHMD", typeof(XRHMD))]
19-
[TestCase(DeviceRole.LeftHanded, "XRController", typeof(XRController))]
20-
[TestCase(DeviceRole.RightHanded, "XRController", typeof(XRController))]
21-
[TestCase(DeviceRole.HardwareTracker, null, typeof(InputDevice))]
22-
[TestCase(DeviceRole.TrackingReference, null, typeof(InputDevice))]
23-
[TestCase(DeviceRole.GameController, null, typeof(InputDevice))]
24-
[TestCase(DeviceRole.Unknown, null, typeof(InputDevice))]
25-
public void Devices_XRDeviceRoleDeterminesTypeOfDevice(DeviceRole role, string baseLayoutName, Type expectedType)
20+
[TestCase(InputDeviceRole.Generic, "XRHMD", typeof(XRHMD))]
21+
[TestCase(InputDeviceRole.LeftHanded, "XRController", typeof(XRController))]
22+
[TestCase(InputDeviceRole.RightHanded, "XRController", typeof(XRController))]
23+
[TestCase(InputDeviceRole.HardwareTracker, null, typeof(InputDevice))]
24+
[TestCase(InputDeviceRole.TrackingReference, null, typeof(InputDevice))]
25+
[TestCase(InputDeviceRole.GameController, null, typeof(InputDevice))]
26+
[TestCase(InputDeviceRole.Unknown, null, typeof(InputDevice))]
27+
public void Devices_XRDeviceRoleDeterminesTypeOfDevice(InputDeviceRole role, string baseLayoutName, Type expectedType)
2628
{
2729
var deviceDescription = CreateSimpleDeviceDescriptionByRole(role);
2830
runtime.ReportNewInputDevice(deviceDescription.ToJson());
@@ -44,7 +46,7 @@ public void Devices_XRDeviceRoleDeterminesTypeOfDevice(DeviceRole role, string b
4446
[Category("Devices")]
4547
public void Devices_CanChangeHandednessOfXRController()
4648
{
47-
var deviceDescription = CreateSimpleDeviceDescriptionByRole(DeviceRole.LeftHanded);
49+
var deviceDescription = CreateSimpleDeviceDescriptionByRole(InputDeviceRole.LeftHanded);
4850
runtime.ReportNewInputDevice(deviceDescription.ToJson());
4951

5052
InputSystem.Update();
@@ -68,7 +70,7 @@ public void Devices_CanChangeHandednessOfXRController()
6870
[Category("Layouts")]
6971
public void Layouts_XRLayoutIsNamespacedAsInterfaceManufacturerDevice()
7072
{
71-
var deviceDescription = CreateSimpleDeviceDescriptionByRole(DeviceRole.Generic);
73+
var deviceDescription = CreateSimpleDeviceDescriptionByRole(InputDeviceRole.Generic);
7274
runtime.ReportNewInputDevice(deviceDescription.ToJson());
7375

7476
InputSystem.Update();
@@ -85,7 +87,7 @@ public void Layouts_XRLayoutIsNamespacedAsInterfaceManufacturerDevice()
8587
[Category("Layouts")]
8688
public void Layouts_XRLayoutWithoutManufacturer_IsNamespacedAsInterfaceDevice()
8789
{
88-
var deviceDescription = CreateSimpleDeviceDescriptionByRole(DeviceRole.Generic);
90+
var deviceDescription = CreateSimpleDeviceDescriptionByRole(InputDeviceRole.Generic);
8991
deviceDescription.manufacturer = null;
9092
runtime.ReportNewInputDevice(deviceDescription.ToJson());
9193

@@ -135,7 +137,7 @@ public void Layouts_XRLayoutFeatures_OnlyContainAllowedCharacters()
135137
[Category("Layouts")]
136138
public void Layouts_XRDevicesWithNoOrInvalidCapabilities_DoNotCreateLayouts()
137139
{
138-
var deviceDescription = CreateSimpleDeviceDescriptionByRole(DeviceRole.Generic);
140+
var deviceDescription = CreateSimpleDeviceDescriptionByRole(InputDeviceRole.Generic);
139141
deviceDescription.capabilities = null;
140142
runtime.ReportNewInputDevice(deviceDescription.ToJson());
141143

@@ -186,7 +188,7 @@ public void Layouts_XRDevicesWithNoOrInvalidCapabilities_DoNotCreateLayouts()
186188
[TestCase("OpenVR Controller(Knuckles EV3.0 Left) - Left", "Valve", typeof(KnucklesController))]
187189
public void Devices_KnownDevice_UsesSpecializedDeviceType(string name, string manufacturer, Type expectedDeviceType)
188190
{
189-
var deviceDescription = CreateSimpleDeviceDescriptionByRole(DeviceRole.Generic);
191+
var deviceDescription = CreateSimpleDeviceDescriptionByRole(InputDeviceRole.Generic);
190192
deviceDescription.product = name;
191193
deviceDescription.manufacturer = manufacturer;
192194
runtime.ReportNewInputDevice(deviceDescription.ToJson());
@@ -464,7 +466,7 @@ public void Components_CanUpdateGameObjectTransformThroughTrackedPoseDriver()
464466
}
465467
}
466468

467-
private static InputDeviceDescription CreateSimpleDeviceDescriptionByRole(DeviceRole role)
469+
private static InputDeviceDescription CreateSimpleDeviceDescriptionByRole(InputDeviceRole role)
468470
{
469471
return new InputDeviceDescription
470472
{
@@ -474,7 +476,7 @@ private static InputDeviceDescription CreateSimpleDeviceDescriptionByRole(Device
474476
capabilities = new XRDeviceDescriptor
475477
{
476478
#if !UNITY_2019_3_OR_NEWER
477-
deviceRole = role,
479+
InputDeviceRole = role,
478480
#endif
479481
inputFeatures = new List<XRFeatureDescriptor>()
480482
{

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

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,6 @@ struct XRFeatureDescriptor
5555
public uint customSize;
5656
}
5757

58-
// Sync to UnityXRInputDeviceRole in IUnityXRInput.h
59-
/// <summary>
60-
/// The generalized role that the device plays. This can help in grouping devices by type (HMD, vs. hardware tracker vs. handed controller).
61-
/// </summary>
62-
public enum DeviceRole
63-
{
64-
Unknown = 0,
65-
Generic,
66-
LeftHanded,
67-
RightHanded,
68-
GameController,
69-
TrackingReference,
70-
HardwareTracker,
71-
}
72-
7358
//Sync to XRInputDeviceDefinition in XRInputDeviceDefinition.h
7459
[Serializable]
7560
class XRDeviceDescriptor

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,9 @@ internal static string OnFindLayoutForDevice(int deviceId, ref InputDeviceDescri
9797
else if ((deviceDescriptor.characteristics & controllerCharacteristics) == controllerCharacteristics)
9898
matchedLayout = "XRController";
9999
#else
100-
if (deviceDescriptor.deviceRole == DeviceRole.LeftHanded || deviceDescriptor.deviceRole == DeviceRole.RightHanded)
100+
if (deviceDescriptor.deviceRole == InputDeviceRole.LeftHanded || deviceDescriptor.deviceRole == InputDeviceRole.RightHanded)
101101
matchedLayout = "XRController";
102-
else if (deviceDescriptor.deviceRole == DeviceRole.Generic)
102+
else if (deviceDescriptor.deviceRole == InputDeviceRole.Generic)
103103
matchedLayout = "XRHMD";
104104
#endif
105105
}

0 commit comments

Comments
 (0)