i have no fucking clue

This commit is contained in:
NotAKidoS 2023-05-24 05:44:32 -05:00
parent 730ff58adc
commit f783fe612d
21 changed files with 496 additions and 49 deletions

View file

@ -6,11 +6,13 @@ namespace NAK.TrackedControllerFix;
public class TrackedControllerFixer : MonoBehaviour
{
public SteamVR_Input_Sources inputSource;
public int deviceIndex;
public int deviceIndex = -1;
SteamVR_TrackedObject trackedObject;
SteamVR_Behaviour_Pose oldBehaviourPose;
SteamVR_Action_Pose actionPose;
SteamVR_RenderModel renderModel;
public void Initialize()
{
@ -19,6 +21,8 @@ public class TrackedControllerFixer : MonoBehaviour
oldBehaviourPose.broadcastDeviceChanges = false; //this fucks us
oldBehaviourPose.enabled = false;
renderModel = gameObject.GetComponentInChildren<SteamVR_RenderModel>();
actionPose = SteamVR_Input.GetAction<SteamVR_Action_Pose>("Pose", false);
if (actionPose != null) CheckDeviceIndex();
}
@ -39,6 +43,14 @@ public class TrackedControllerFixer : MonoBehaviour
oldBehaviourPose.enabled = true;
}
void Update()
{
if (deviceIndex < 0)
{
CheckDeviceIndex();
}
}
void OnDeviceConnectedChanged(SteamVR_Action_Pose changedAction, SteamVR_Input_Sources changedSource, bool connected)
{
if (actionPose != changedAction) actionPose = changedAction;
@ -54,7 +66,8 @@ public class TrackedControllerFixer : MonoBehaviour
if (deviceIndex != trackedDeviceIndex)
{
deviceIndex = trackedDeviceIndex;
trackedObject.SetDeviceIndex(deviceIndex);
trackedObject?.SetDeviceIndex(deviceIndex);
renderModel?.SetDeviceIndex(deviceIndex);
}
}
}