Skip to content

Commit 912868f

Browse files
author
ChengNan Yang
committed
Allow SteamVR_Action listener callback function to work from SteamVR Plugin 2.0.1
1 parent 4ac51dc commit 912868f

File tree

1 file changed

+8
-12
lines changed

1 file changed

+8
-12
lines changed

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -377,12 +377,18 @@ public override void OnActivated()
377377
m_gamePoses = new TrackedDevicePose_t[0];
378378
m_originDataCache = new Dictionary<ulong, OriginData>((int)OpenVR.k_unMaxActionOriginCount);
379379

380+
InitializeHandles();
381+
380382
#if VIU_STEAMVR_2_1_0_OR_NEWER
381383
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+
}
382390
#endif
383391

384-
InitializeHandles();
385-
386392
#if !VIU_STEAMVR_2_1_0_OR_NEWER
387393
m_activeActionSets = new VRActiveActionSet_t[1] { new VRActiveActionSet_t() { ulActionSet = s_actionSetHandle, } };
388394
#endif
@@ -429,7 +435,6 @@ public override void OnDeactivated()
429435

430436
private void UpdateDeviceInput()
431437
{
432-
EVRInputError error;
433438
IVRModuleDeviceState prevState;
434439
IVRModuleDeviceStateRW currState;
435440

@@ -448,15 +453,6 @@ private void UpdateDeviceInput()
448453
}
449454
else
450455
{
451-
#if !VIU_STEAMVR_2_1_0_OR_NEWER
452-
// FIXME: Should update by SteamVR_Input? SteamVR_Input.GetActionSetFromPath(ACTIONSET_PATH).ActivatePrimary();
453-
error = vrInput.UpdateActionState(m_activeActionSets, m_activeActionSetSize);
454-
if (error != EVRInputError.None)
455-
{
456-
Debug.LogError("UpdateActionState failed! " + ACTION_SET_NAME + " error=" + error);
457-
}
458-
#endif
459-
460456
m_originDataCache.Clear();
461457

462458
for (pressActions.Reset(); pressActions.IsCurrentValid(); pressActions.MoveNext())

0 commit comments

Comments
 (0)