Skip to content

Commit a5c7754

Browse files
author
lawwong
committed
Add compatibility with OpenXRPlugin
There is ambiguous input control layout for "PoseControl" UnityEngine.InputSystem.XR.PoseControl UnityEngine.XR.OpenXR.Input.PoseControl
1 parent bf48eba commit a5c7754

2 files changed

Lines changed: 40 additions & 3 deletions

File tree

Assets/HTC.UnityPlugin/VRModule/Modules/Editor/UnityEngineVRModuleEditor.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,19 @@ public UnityEngineVRSymbolRequirementCollection()
138138
"OpenXRFeature.cs",
139139
},
140140
});
141+
142+
Add(new VRModuleManagerEditor.SymbolRequirement()
143+
{
144+
symbol = "VIU_OPENXR_PLUGIN_POSE_CONTROL",
145+
reqTypeNames = new string[]
146+
{
147+
"UnityEngine.XR.OpenXR.Input.PoseControl",
148+
},
149+
reqFileNames = new string[]
150+
{
151+
"PoseControl.cs",
152+
},
153+
});
141154
}
142155
}
143156
}

Assets/HTC.UnityPlugin/ViveInputUtility/Scripts/VIUSyntheticDevice.cs

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
using UnityEngine.InputSystem.Utilities;
1414
using UnityEngine.InputSystem.XR;
1515
using TrackingState = UnityEngine.XR.InputTrackingState;
16+
using UnityPoseControl = UnityEngine.InputSystem.XR.PoseControl;
17+
#if VIU_OPENXR_PLUGIN_POSE_CONTROL
18+
using OpenXRPoseControl = UnityEngine.XR.OpenXR.Input.PoseControl;
19+
#endif
1620

1721
namespace HTC.UnityPlugin.Vive
1822
{
@@ -263,7 +267,17 @@ private void OnRoleValueMappingChanged(ViveRole.IMap map, ViveRole.MappingChange
263267
public EnumArray<ControllerAxis, AxisControl>.IReadOnly axises { get { return _axises.ReadOnly; } }
264268
public StickControl pad { get; private set; }
265269
public StickControl joystick { get; private set; }
266-
public PoseControl pose { get; private set; }
270+
271+
public UnityPoseControl pose { get; private set; }
272+
#if VIU_OPENXR_PLUGIN_POSE_CONTROL
273+
public OpenXRPoseControl openxr_pose { get; private set; }
274+
#endif
275+
public ButtonControl isTracked { get; private set; }
276+
public IntegerControl trackingState { get; private set; }
277+
public Vector3Control position { get; private set; }
278+
public QuaternionControl rotation { get; private set; }
279+
public Vector3Control velocity { get; private set; }
280+
public Vector3Control angularVelocity { get; private set; }
267281

268282
static VIUSyntheticDevice()
269283
{
@@ -491,10 +505,20 @@ public static VIUSyntheticDevice InternalGetCreatedDeviceByRole(Type roleEnumTyp
491505

492506
protected override void FinishSetup()
493507
{
494-
pose = GetChildControl<PoseControl>("pose");
495-
496508
base.FinishSetup();
497509

510+
var poseGeneric = GetChildControl("pose");
511+
pose = poseGeneric as UnityPoseControl;
512+
#if VIU_OPENXR_PLUGIN_POSE_CONTROL
513+
openxr_pose = poseGeneric as OpenXRPoseControl;
514+
#endif
515+
isTracked = GetChildControl<ButtonControl>("pose/isTracked");
516+
trackingState = GetChildControl<IntegerControl>("pose/trackingState");
517+
position = GetChildControl<Vector3Control>("pose/position");
518+
rotation = GetChildControl<QuaternionControl>("pose/rotation");
519+
velocity = GetChildControl<Vector3Control>("pose/velocity");
520+
angularVelocity = GetChildControl<Vector3Control>("pose/angularVelocity");
521+
498522
pad = GetChildControl<StickControl>("PadAxis");
499523
joystick = GetChildControl<StickControl>("JoystickAxis");
500524

0 commit comments

Comments
 (0)