Skip to content

Commit fcedea8

Browse files
author
lawwong
committed
Update to v1.10.7
* Bug Fix - Fix device AngularVelocity have zero value when UnityEngineVRModule activated - Fix showing wrong model when Oculus Quest Controller connected - Fix SteamVR_Action callback function isn't working when VIU input system is activated - Fix bumper key isn't working when Vive Cosmos Controller connected - Fix controller scroll isn't working in WaveVRModule * Improvement - Now support WaveVR SDK new haptic API - Hide most "field never assigned" warnings for serialized field in MonoBehaviour - Add static controller model for Valve Index Controller - Avoid ListPool from ambiguous reference (when Core RP Library installed)
2 parents 2ed8d93 + 83ec941 commit fcedea8

File tree

36 files changed

+27320
-39183
lines changed

36 files changed

+27320
-39183
lines changed

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

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public void Set(T e, string pathName, string alias)
144144
{
145145
var index = EqualityComparer<T>.Default.GetHashCode(e) - s_enumInfo.minValue;
146146
m_aliases[index] = alias;
147-
m_paths[index] = ACTION_SET_NAME + m_pathPrefix + pathName;
147+
m_paths[index] = ACTION_SET_PATH + m_pathPrefix + pathName;
148148
}
149149

150150
public void InitiateHandles(CVRInput vrInput)
@@ -158,7 +158,8 @@ public void InitiateHandles(CVRInput vrInput)
158158

159159
public enum HapticStruct { Haptic }
160160

161-
public const string ACTION_SET_NAME = "/actions/htc_viu";
161+
public const string ACTION_SET_NAME = "htc_viu";
162+
public const string ACTION_SET_PATH = "/actions/" + ACTION_SET_NAME;
162163

163164
private static bool s_pathInitialized;
164165
private static bool s_actionInitialized;
@@ -306,7 +307,7 @@ public static void InitializeHandles()
306307
v2Actions.InitiateHandles(vrInput);
307308
vibrateActions.InitiateHandles(vrInput);
308309

309-
s_actionSetHandle = SafeGetActionSetHandle(vrInput, ACTION_SET_NAME);
310+
s_actionSetHandle = SafeGetActionSetHandle(vrInput, ACTION_SET_PATH);
310311
}
311312

312313
private static ulong SafeGetActionSetHandle(CVRInput vrInput, string path)
@@ -378,7 +379,19 @@ public override void OnActivated()
378379

379380
InitializeHandles();
380381

382+
#if VIU_STEAMVR_2_1_0_OR_NEWER
383+
SteamVR_Input.GetActionSet(ACTION_SET_NAME).Activate(SteamVR_Input_Sources.Any, 0, false);
384+
#else
385+
var actionSet = SteamVR_Input.GetActionSetFromPath(ACTION_SET_PATH);
386+
if (actionSet != null)
387+
{
388+
actionSet.ActivatePrimary();
389+
}
390+
#endif
391+
392+
#if !VIU_STEAMVR_2_1_0_OR_NEWER
381393
m_activeActionSets = new VRActiveActionSet_t[1] { new VRActiveActionSet_t() { ulActionSet = s_actionSetHandle, } };
394+
#endif
382395

383396
#if VIU_STEAMVR_2_2_0_OR_NEWER
384397
SteamVR_Input.onNonVisualActionsUpdated += UpdateDeviceInput;
@@ -422,7 +435,6 @@ public override void OnDeactivated()
422435

423436
private void UpdateDeviceInput()
424437
{
425-
EVRInputError error;
426438
IVRModuleDeviceState prevState;
427439
IVRModuleDeviceStateRW currState;
428440

@@ -441,13 +453,6 @@ private void UpdateDeviceInput()
441453
}
442454
else
443455
{
444-
// FIXME: Should update by SteamVR_Input? SteamVR_Input.GetActionSetFromPath(ACTIONSET_PATH).ActivatePrimary();
445-
error = vrInput.UpdateActionState(m_activeActionSets, m_activeActionSetSize);
446-
if (error != EVRInputError.None)
447-
{
448-
Debug.LogError("UpdateActionState failed! " + ACTION_SET_NAME + " error=" + error);
449-
}
450-
451456
m_originDataCache.Clear();
452457

453458
for (pressActions.Reset(); pressActions.IsCurrentValid(); pressActions.MoveNext())
@@ -696,5 +701,5 @@ public override void TriggerHapticVibration(uint deviceIndex, float durationSeco
696701
}
697702
}
698703
#endif
704+
}
699705
}
700-
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,11 @@ public override void BeforeRenderUpdate()
266266

267267
var rotation = default(Quaternion);
268268
if (m_nodeStateList[i].TryGetRotation(out rotation)) { currState.rotation = rotation; }
269+
270+
#if UNITY_2017_2_OR_NEWER
271+
var angularVelocity = default(Vector3);
272+
if (m_nodeStateList[i].TryGetAngularVelocity(out angularVelocity)) { currState.angularVelocity = angularVelocity; }
273+
#endif
269274
}
270275

271276
m_nodeStateList.Clear();

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

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -520,6 +520,7 @@ private IVRModuleDeviceStateRW UpdateDevicePose(uint deviceIndex, WaveVR.Device
520520
currState.serialNumber = content.type.ToString();
521521
currState.modelNumber = content.type.ToString();
522522
currState.renderModelName = content.type.ToString();
523+
currState.input2DType = VRModuleInput2DType.TouchpadOnly;
523524
}
524525

525526
// update pose
@@ -769,6 +770,36 @@ public override void TriggerViveControllerHaptic(uint deviceIndex, ushort durati
769770
deviceInput.TriggerHapticPulse(durationMicroSec);
770771
}
771772
}
772-
#endif
773+
774+
#if VIU_WAVEVR_3_1_0_OR_NEWER
775+
public override void TriggerHapticVibration(uint deviceIndex, float durationSeconds = 0.01f, float frequency = 85, float amplitude = 0.125f, float startSecondsFromNow = 0)
776+
{
777+
var deviceInput = WaveVR_Controller.Input(s_index2type[deviceIndex]);
778+
if (deviceInput != null)
779+
{
780+
if (0 <= amplitude || amplitude <= 0.2)
781+
{
782+
Interop.WVR_TriggerVibration(deviceInput.DeviceType, WVR_InputId.WVR_InputId_Alias1_Touchpad, (uint)(durationSeconds * 1000000), (uint)frequency, WVR_Intensity.WVR_Intensity_Weak);
783+
}
784+
else if (0.2 < amplitude || amplitude <= 0.4)
785+
{
786+
Interop.WVR_TriggerVibration(deviceInput.DeviceType, WVR_InputId.WVR_InputId_Alias1_Touchpad, (uint)(durationSeconds * 1000000), (uint)frequency, WVR_Intensity.WVR_Intensity_Light);
787+
}
788+
else if (0.4 < amplitude || amplitude <= 0.6)
789+
{
790+
Interop.WVR_TriggerVibration(deviceInput.DeviceType, WVR_InputId.WVR_InputId_Alias1_Touchpad, (uint)(durationSeconds * 1000000), (uint)frequency, WVR_Intensity.WVR_Intensity_Normal);
791+
}
792+
else if (0.6 < amplitude || amplitude <= 0.8)
793+
{
794+
Interop.WVR_TriggerVibration(deviceInput.DeviceType, WVR_InputId.WVR_InputId_Alias1_Touchpad, (uint)(durationSeconds * 1000000), (uint)frequency, WVR_Intensity.WVR_Intensity_Strong);
795+
}
796+
else if (0.8 < amplitude || amplitude <= 1)
797+
{
798+
Interop.WVR_TriggerVibration(deviceInput.DeviceType, WVR_InputId.WVR_InputId_Alias1_Touchpad, (uint)(durationSeconds * 1000000), (uint)frequency, WVR_Intensity.WVR_Intensity_Severe);
799+
}
800+
}
773801
}
774-
}
802+
#endif
803+
#endif
804+
}
805+
}

0 commit comments

Comments
 (0)