Skip to content

Commit 0fe69c1

Browse files
author
lawwong
committed
Update to v1.10.4
* Improvement - Replace WWW to UnityWebRequest - Pointer3DInputModule no longer set EventSystem to DontDestroyOnLoad - Add VRModuleInput2DType - Split VIUSettings into partials - Add VIVE Cosmos controller enum - Improve OculusVR support - Add install package button in VIUSettings - Add WaveVR SDK 3.0.2 support - Add autoScaleReticle setting * Bug Fix - [OculusVRModule] Fix serial number conflict on Oculus device - [UnityEngineVRModule] Fix input manager index out of bound - [SteamVRModule] Fix swapping controllers will cause input events showing on wrong device - [WaveVRModule] Fix left hand mode cannot show controller model - [ExampleScene] Fix BodyRole center position transformation - [ExampleScene] Fix ResetButton teleports if moved after Start()
2 parents a95b4b4 + 600f805 commit 0fe69c1

Some content is hidden

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

53 files changed

+1933
-1145
lines changed

Assets/HTC.UnityPlugin/Pointer3D/Pointer3DInputModule.cs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,6 @@ public static void Initialize()
113113

114114
instance = eventSystem.gameObject.AddComponent<Pointer3DInputModule>();
115115
}
116-
117-
if (Active)
118-
{
119-
DontDestroyOnLoad(instance.gameObject);
120-
}
121116
}
122117

123118
public static void AssignPointerId(Pointer3DEventData eventData)

Assets/HTC.UnityPlugin/Utility/SingletonBehaviour.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ public abstract class SingletonBehaviour<T> : MonoBehaviour where T : SingletonB
1919

2020
public bool IsInstance { get { return this == Instance; } }
2121

22+
protected bool IsApplicationQuitting { get { return s_isApplicationQuitting; } }
23+
2224
public static T Instance
2325
{
2426
get

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

Lines changed: 22 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
//========= Copyright 2016-2019, HTC Corporation. All rights reserved. ===========
22

3-
using HTC.UnityPlugin.Utility;
3+
using System;
44
using UnityEditor;
55
using UnityEngine;
66

@@ -9,25 +9,37 @@ namespace HTC.UnityPlugin.VRModuleManagement
99
public static class UnityVRModuleEditor
1010
{
1111
#if UNITY_5_5_OR_NEWER
12+
[InitializeOnLoadMethod]
13+
private static void StartCheckEnforceInputManagerBindings()
14+
{
15+
EditorApplication.update += EnforceInputManagerBindings;
16+
}
17+
1218
// Add joystick axis input bindings to InputManager
1319
// See OpenVR/Oculus left/right controllers mapping at
1420
// https://docs.unity3d.com/Manual/OpenVRControllers.html
15-
[InitializeOnLoadMethod]
1621
private static void EnforceInputManagerBindings()
1722
{
1823
try
1924
{
25+
var inputSettings = AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset");
26+
if (inputSettings == null || inputSettings.Length <= 0) { return; }
27+
28+
var serializedInputSettings = new SerializedObject(inputSettings);
29+
2030
var axisObj = new Axis();
2131
for (int i = 0, imax = UnityEngineVRModule.GetUnityAxisCount(); i < imax; ++i)
2232
{
2333
axisObj.name = UnityEngineVRModule.GetUnityAxisNameByIndex(i);
2434
axisObj.axis = UnityEngineVRModule.GetUnityAxisIdByIndex(i) - 1;
25-
BindAxis(axisObj);
35+
BindAxis(serializedInputSettings, axisObj);
2636
}
37+
38+
EditorApplication.update -= EnforceInputManagerBindings;
2739
}
28-
catch
40+
catch (Exception e)
2941
{
30-
Debug.LogError("Failed to apply Vive Input Utility input manager bindings.");
42+
Debug.LogError(e + " Failed to apply Vive Input Utility input manager bindings.");
3143
}
3244
}
3345

@@ -42,18 +54,17 @@ private class Axis
4254
public string altPositiveButton = string.Empty;
4355
public float gravity = 0.0f;
4456
public float dead = 0.001f;
45-
public float sensitivity = 1.0f;
57+
public float sensitivity = 5.0f;
4658
public bool snap = false;
4759
public bool invert = false;
4860
public int type = 2;
4961
public int axis = 0;
5062
public int joyNum = 0;
5163
}
5264

53-
private static void BindAxis(Axis axis)
65+
private static void BindAxis(SerializedObject serializedInputSettings, Axis axis)
5466
{
55-
var serializedObject = new SerializedObject(AssetDatabase.LoadAllAssetsAtPath("ProjectSettings/InputManager.asset")[0]);
56-
var axesProperty = serializedObject.FindProperty("m_Axes");
67+
var axesProperty = serializedInputSettings.FindProperty("m_Axes");
5768

5869
var axisIter = axesProperty.Copy();
5970
axisIter.Next(true);
@@ -68,7 +79,7 @@ private static void BindAxis(Axis axis)
6879
}
6980

7081
axesProperty.arraySize++;
71-
serializedObject.ApplyModifiedProperties();
82+
serializedInputSettings.ApplyModifiedProperties();
7283

7384
SerializedProperty axisProperty = axesProperty.GetArrayElementAtIndex(axesProperty.arraySize - 1);
7485
axisProperty.FindPropertyRelative("m_Name").stringValue = axis.name;
@@ -86,7 +97,7 @@ private static void BindAxis(Axis axis)
8697
axisProperty.FindPropertyRelative("type").intValue = axis.type;
8798
axisProperty.FindPropertyRelative("axis").intValue = axis.axis;
8899
axisProperty.FindPropertyRelative("joyNum").intValue = axis.joyNum;
89-
serializedObject.ApplyModifiedProperties();
100+
serializedInputSettings.ApplyModifiedProperties();
90101
}
91102
#endif
92103
}

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

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,25 @@ public WaveVRSymbolRequirementCollection()
6060
},
6161
reqFileNames = new string[] { "wvr.cs" },
6262
});
63+
64+
Add(new SymbolRequirement()
65+
{
66+
symbol = "VIU_WAVEVR_3_0_0_OR_NEWER",
67+
reqTypeNames = new string[] { "wvr.WVR_Eye" },
68+
validateFunc = (req) =>
69+
{
70+
Type wvrEyeType;
71+
if (SymbolRequirement.s_foundTypes.TryGetValue("wvr.WVR_Eye", out wvrEyeType) && wvrEyeType.IsEnum)
72+
{
73+
if (Enum.IsDefined(wvrEyeType, "WVR_Eye_Both"))
74+
{
75+
return true;
76+
}
77+
}
78+
return false;
79+
},
80+
reqFileNames = new string[] { "wvr.cs" },
81+
});
6382
}
6483
}
6584
}

Assets/HTC.UnityPlugin/VRModule/Modules/GoogleVRModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ private void UpdateConnectedDevices()
157157
currState.modelNumber = XRDevice.model + " Controller Right";
158158
currState.deviceModel = VRModuleDeviceModel.DaydreamController;
159159
currState.renderModelName = string.Empty;
160+
currState.input2DType = VRModuleInput2DType.TouchpadOnly;
160161
m_rightIndex = RIGHT_HAND_INDEX;
161162
}
162163
}
@@ -180,6 +181,7 @@ private void UpdateConnectedDevices()
180181
currState.modelNumber = XRDevice.model + " Controller Left";
181182
currState.deviceModel = VRModuleDeviceModel.DaydreamController;
182183
currState.renderModelName = string.Empty;
184+
currState.input2DType = VRModuleInput2DType.TouchpadOnly;
183185
m_leftIndex = RIGHT_HAND_INDEX;
184186
}
185187
}

Assets/HTC.UnityPlugin/VRModule/Modules/OculusVRModule.cs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
using HTC.UnityPlugin.Utility;
44
#if VIU_OCULUSVR
55
using UnityEngine;
6-
using HTC.UnityPlugin.Utility;
76
using HTC.UnityPlugin.Vive;
87
#if UNITY_2017_2_OR_NEWER
98
using UnityEngine.XR;
@@ -163,7 +162,7 @@ public override void BeforeRenderUpdate()
163162
// FIXME: how to get device id from OVRPlugin?
164163
currState.modelNumber = ovrProductName + " " + deviceClass;
165164
currState.renderModelName = ovrProductName + " " + deviceClass;
166-
currState.serialNumber = ovrProductName + " " + deviceClass;
165+
currState.serialNumber = ovrProductName + " " + node;
167166

168167
switch (deviceClass)
169168
{
@@ -178,17 +177,19 @@ public override void BeforeRenderUpdate()
178177
{
179178
case OVRPlugin.SystemHeadset.Oculus_Go:
180179
currState.deviceModel = VRModuleDeviceModel.OculusGoController;
180+
currState.input2DType = VRModuleInput2DType.TouchpadOnly;
181181
break;
182-
182+
183183
case OVRPlugin.SystemHeadset.GearVR_R320:
184184
case OVRPlugin.SystemHeadset.GearVR_R321:
185185
case OVRPlugin.SystemHeadset.GearVR_R322:
186186
case OVRPlugin.SystemHeadset.GearVR_R323:
187187
case OVRPlugin.SystemHeadset.GearVR_R324:
188188
case OVRPlugin.SystemHeadset.GearVR_R325:
189189
currState.deviceModel = VRModuleDeviceModel.OculusGearVrController;
190+
currState.input2DType = VRModuleInput2DType.TouchpadOnly;
190191
break;
191-
192+
192193
case OVRPlugin.SystemHeadset.Rift_DK1:
193194
case OVRPlugin.SystemHeadset.Rift_DK2:
194195
case OVRPlugin.SystemHeadset.Rift_CV1:
@@ -203,6 +204,7 @@ public override void BeforeRenderUpdate()
203204
currState.deviceModel = VRModuleDeviceModel.OculusTouchRight;
204205
break;
205206
}
207+
currState.input2DType = VRModuleInput2DType.JoystickOnly;
206208
break;
207209
}
208210
break;
@@ -234,6 +236,7 @@ public override void BeforeRenderUpdate()
234236
currState.SetButtonTouch(VRModuleRawButton.A, (ctrlState.Touches & (uint)OVRInput.RawTouch.X) != 0u);
235237
currState.SetButtonTouch(VRModuleRawButton.Touchpad, (ctrlState.Touches & (uint)OVRInput.RawTouch.LThumbstick) != 0u);
236238
currState.SetButtonTouch(VRModuleRawButton.Trigger, (ctrlState.Touches & (uint)OVRInput.RawTouch.LIndexTrigger) != 0u);
239+
currState.SetButtonTouch(VRModuleRawButton.Grip, AxisToPress(currState.GetButtonTouch(VRModuleRawButton.Grip), ctrlState.LHandTrigger, 0.25f, 0.20f));
237240
currState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, AxisToPress(currState.GetButtonTouch(VRModuleRawButton.CapSenseGrip), ctrlState.LHandTrigger, 0.25f, 0.20f));
238241

239242
currState.SetAxisValue(VRModuleRawAxis.TouchpadX, ctrlState.LThumbstick.x);
@@ -257,6 +260,7 @@ public override void BeforeRenderUpdate()
257260
currState.SetButtonTouch(VRModuleRawButton.A, (ctrlState.Touches & (uint)OVRInput.RawTouch.A) != 0u);
258261
currState.SetButtonTouch(VRModuleRawButton.Touchpad, (ctrlState.Touches & (uint)OVRInput.RawTouch.RThumbstick) != 0u);
259262
currState.SetButtonTouch(VRModuleRawButton.Trigger, (ctrlState.Touches & (uint)OVRInput.RawTouch.RIndexTrigger) != 0u);
263+
currState.SetButtonTouch(VRModuleRawButton.Grip, AxisToPress(currState.GetButtonTouch(VRModuleRawButton.Grip), ctrlState.RHandTrigger, 0.25f, 0.20f));
260264
currState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, AxisToPress(currState.GetButtonTouch(VRModuleRawButton.CapSenseGrip), ctrlState.RHandTrigger, 0.25f, 0.20f));
261265

262266
currState.SetAxisValue(VRModuleRawAxis.TouchpadX, ctrlState.RThumbstick.x);

Assets/HTC.UnityPlugin/VRModule/Modules/SimulatorModule.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,7 @@ private void InitializeDevice(IVRModuleDeviceStateRW hmdState, IVRModuleDeviceSt
412412
deviceState.modelNumber = deviceState.serialNumber;
413413
deviceState.renderModelName = deviceState.serialNumber;
414414
deviceState.deviceModel = VRModuleDeviceModel.ViveController;
415+
deviceState.input2DType = VRModuleInput2DType.TouchpadOnly;
415416

416417
var pose = new RigidPose(new Vector3(0.3f, -0.25f, 0.7f), Quaternion.identity);
417418
deviceState.isPoseValid = true;
@@ -430,6 +431,7 @@ private void InitializeDevice(IVRModuleDeviceStateRW hmdState, IVRModuleDeviceSt
430431
deviceState.modelNumber = deviceState.serialNumber;
431432
deviceState.renderModelName = deviceState.serialNumber;
432433
deviceState.deviceModel = VRModuleDeviceModel.ViveController;
434+
deviceState.input2DType = VRModuleInput2DType.TouchpadOnly;
433435

434436
var pose = new RigidPose(new Vector3(-0.3f, -0.25f, 0.7f), Quaternion.identity);
435437
deviceState.isPoseValid = true;

Assets/HTC.UnityPlugin/VRModule/Modules/SteamVRv2Module.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ private static ulong SafeGetActionHandle(CVRInput vrInput, string path)
341341
}
342342
}
343343

344-
public static ulong GetInputSrouceHandleForDevice(uint deviceIndex)
344+
public static ulong GetInputSourceHandleForDevice(uint deviceIndex)
345345
{
346346
if (s_devicePathHandles == null || deviceIndex >= s_devicePathHandles.Length)
347347
{
@@ -446,6 +446,8 @@ private void UpdateDeviceInput()
446446
Debug.LogError("UpdateActionState failed! " + ACTION_SET_NAME + " error=" + error);
447447
}
448448

449+
m_originDataCache.Clear();
450+
449451
for (pressActions.Reset(); pressActions.IsCurrentValid(); pressActions.MoveNext())
450452
{
451453
for (pressActions.ResetOrigins(vrInput); pressActions.IsCurrentOriginValid(); pressActions.MoveNextOrigin())
@@ -636,7 +638,6 @@ private void OnInputFocus(bool value)
636638
private void OnTrackedDeviceRoleChanged(VREvent_t arg)
637639
{
638640
InvokeControllerRoleChangedEvent();
639-
m_originDataCache.Clear();
640641
}
641642

642643
public override uint GetLeftControllerDeviceIndex()
@@ -677,7 +678,7 @@ public override void TriggerViveControllerHaptic(uint deviceIndex, ushort durati
677678

678679
public override void TriggerHapticVibration(uint deviceIndex, float durationSeconds = 0.01f, float frequency = 85f, float amplitude = 0.125f, float startSecondsFromNow = 0f)
679680
{
680-
var handle = GetInputSrouceHandleForDevice(deviceIndex);
681+
var handle = GetInputSourceHandleForDevice(deviceIndex);
681682
if (handle == OpenVR.k_ulInvalidDriverHandle) { return; }
682683

683684
var vrInput = OpenVR.Input;

Assets/HTC.UnityPlugin/VRModule/Modules/UnityEngineVRModule.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ private static void Update_L_OculusTouch(IVRModuleDeviceState prevState, IVRModu
197197
var xPress = GetUnityButton(2);
198198
var yPress = GetUnityButton(3);
199199
var stickPress = GetUnityButton(8);
200+
var gripPress = GetUnityButton(4);
200201
var xTouch = GetUnityButton(12);
201202
var yTouch = GetUnityButton(13);
202203
var triggerTouch = GetUnityButton(14);
@@ -211,23 +212,28 @@ private static void Update_L_OculusTouch(IVRModuleDeviceState prevState, IVRModu
211212
currState.SetButtonPress(VRModuleRawButton.A, xPress);
212213
currState.SetButtonPress(VRModuleRawButton.Touchpad, stickPress);
213214
currState.SetButtonPress(VRModuleRawButton.Trigger, AxisToPress(prevState.GetButtonPress(VRModuleRawButton.Trigger), trigger, 0.55f, 0.45f));
214-
currState.SetButtonPress(VRModuleRawButton.Grip, grip >= 1.0f);
215+
currState.SetButtonPress(VRModuleRawButton.Grip, gripPress);
216+
currState.SetButtonPress(VRModuleRawButton.CapSenseGrip, gripPress);
215217

216218
currState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, yTouch);
217219
currState.SetButtonTouch(VRModuleRawButton.A, xTouch);
218220
currState.SetButtonTouch(VRModuleRawButton.Touchpad, stickTouch);
219221
currState.SetButtonTouch(VRModuleRawButton.Trigger, triggerTouch);
222+
currState.SetButtonTouch(VRModuleRawButton.Grip, grip >= 0.05f);
223+
currState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, grip >= 0.05f);
220224

221225
currState.SetAxisValue(VRModuleRawAxis.TouchpadX, stickX);
222226
currState.SetAxisValue(VRModuleRawAxis.TouchpadY, -stickY);
223227
currState.SetAxisValue(VRModuleRawAxis.Trigger, trigger);
228+
currState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, grip);
224229
}
225230

226231
private static void Update_R_OculusTouch(IVRModuleDeviceState prevState, IVRModuleDeviceStateRW currState)
227232
{
228233
var aPress = GetUnityButton(0);
229234
var bPress = GetUnityButton(1);
230235
var stickPress = GetUnityButton(9);
236+
var gripPress = GetUnityButton(5);
231237
var aTouch = GetUnityButton(10);
232238
var bTouch = GetUnityButton(11);
233239
var triggerTouch = GetUnityButton(15);
@@ -242,16 +248,20 @@ private static void Update_R_OculusTouch(IVRModuleDeviceState prevState, IVRModu
242248
currState.SetButtonPress(VRModuleRawButton.A, aPress);
243249
currState.SetButtonPress(VRModuleRawButton.Touchpad, stickPress);
244250
currState.SetButtonPress(VRModuleRawButton.Trigger, AxisToPress(prevState.GetButtonPress(VRModuleRawButton.Trigger), trigger, 0.55f, 0.45f));
245-
currState.SetButtonPress(VRModuleRawButton.Grip, grip >= 1.0f);
251+
currState.SetButtonPress(VRModuleRawButton.Grip, gripPress);
252+
currState.SetButtonPress(VRModuleRawButton.CapSenseGrip, gripPress);
246253

247254
currState.SetButtonTouch(VRModuleRawButton.ApplicationMenu, bTouch);
248255
currState.SetButtonTouch(VRModuleRawButton.A, aTouch);
249256
currState.SetButtonTouch(VRModuleRawButton.Touchpad, stickTouch);
250257
currState.SetButtonTouch(VRModuleRawButton.Trigger, triggerTouch);
258+
currState.SetButtonTouch(VRModuleRawButton.Grip, grip >= 0.05f);
259+
currState.SetButtonTouch(VRModuleRawButton.CapSenseGrip, grip >= 0.05f);
251260

252261
currState.SetAxisValue(VRModuleRawAxis.TouchpadX, stickX);
253262
currState.SetAxisValue(VRModuleRawAxis.TouchpadY, -stickY);
254263
currState.SetAxisValue(VRModuleRawAxis.Trigger, trigger);
264+
currState.SetAxisValue(VRModuleRawAxis.CapSenseGrip, grip);
255265
}
256266

257267
private static void Update_L_Knuckles(IVRModuleDeviceState prevState, IVRModuleDeviceStateRW currState)

Assets/HTC.UnityPlugin/VRModule/Modules/UnityEngineVRModule_5_5.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,14 +166,17 @@ public override void BeforeRenderUpdate()
166166
if (m_viveRgx.IsMatch(VRDevice.model))
167167
{
168168
rightCurrState.deviceModel = VRModuleDeviceModel.ViveController;
169+
rightCurrState.input2DType = VRModuleInput2DType.TouchpadOnly;
169170
}
170171
else if (m_oculusRgx.IsMatch(VRDevice.model))
171172
{
172173
rightCurrState.deviceModel = VRModuleDeviceModel.OculusTouchRight;
174+
rightCurrState.input2DType = VRModuleInput2DType.JoystickOnly;
173175
}
174176
else
175177
{
176178
rightCurrState.deviceModel = VRModuleDeviceModel.Unknown;
179+
rightCurrState.input2DType = VRModuleInput2DType.Unknown;
177180
}
178181

179182
rightCurrState.renderModelName = VRDevice.model + " " + rightCurrState.deviceModel.ToString();
@@ -242,14 +245,17 @@ public override void BeforeRenderUpdate()
242245
if (m_viveRgx.IsMatch(VRDevice.model))
243246
{
244247
leftCurrState.deviceModel = VRModuleDeviceModel.ViveController;
248+
leftCurrState.input2DType = VRModuleInput2DType.TouchpadOnly;
245249
}
246250
else if (m_oculusRgx.IsMatch(VRDevice.model))
247251
{
248252
leftCurrState.deviceModel = VRModuleDeviceModel.OculusTouchLeft;
253+
leftCurrState.input2DType = VRModuleInput2DType.JoystickOnly;
249254
}
250255
else
251256
{
252257
leftCurrState.deviceModel = VRModuleDeviceModel.Unknown;
258+
leftCurrState.input2DType = VRModuleInput2DType.Unknown;
253259
}
254260

255261
leftCurrState.renderModelName = VRDevice.model + " " + leftCurrState.deviceModel.ToString();

0 commit comments

Comments
 (0)