diff --git a/TrackedControllerFix/TrackedControllerFix.cs b/TrackedControllerFix/TrackedControllerFix.cs index 0a0955c..30cf2f4 100644 --- a/TrackedControllerFix/TrackedControllerFix.cs +++ b/TrackedControllerFix/TrackedControllerFix.cs @@ -10,18 +10,22 @@ public class TrackedControllerFixer : MonoBehaviour SteamVR_TrackedObject trackedObject; SteamVR_Behaviour_Pose oldBehaviourPose; - SteamVR_Action_Pose actionPose = SteamVR_Input.GetAction("Pose", false); + SteamVR_Action_Pose actionPose; public void Initialize() { trackedObject = gameObject.AddComponent(); oldBehaviourPose = gameObject.GetComponent(); oldBehaviourPose.broadcastDeviceChanges = false; //this fucks us + oldBehaviourPose.enabled = false; + + actionPose = SteamVR_Input.GetAction("Pose", false); if (actionPose != null) CheckDeviceIndex(); } void OnEnable() { + // DesktopVRSwitch support if (actionPose != null) actionPose[inputSource].onDeviceConnectedChanged += OnDeviceConnectedChanged; if (oldBehaviourPose != null) oldBehaviourPose.enabled = false; @@ -29,6 +33,7 @@ public class TrackedControllerFixer : MonoBehaviour void OnDisable() { + // DesktopVRSwitch support if (actionPose != null) actionPose[inputSource].onDeviceConnectedChanged -= OnDeviceConnectedChanged; if (oldBehaviourPose != null) oldBehaviourPose.enabled = true; @@ -43,7 +48,7 @@ public class TrackedControllerFixer : MonoBehaviour void CheckDeviceIndex() { - if (actionPose[inputSource].active && actionPose[inputSource].deviceIsConnected) + if (actionPose[inputSource].deviceIsConnected) { int trackedDeviceIndex = (int)actionPose[inputSource].trackedDeviceIndex; if (deviceIndex != trackedDeviceIndex)