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

@ -10,12 +10,11 @@ class PlayerSetupPatches
[HarmonyPatch(typeof(PlayerSetup), nameof(PlayerSetup.Start))]
static void Post_PlayerSetup_Start(ref PlayerSetup __instance)
{
// Add TrackedControllerFix
var vrLeftHandTracker = __instance.vrLeftHandTracker.AddComponent<TrackedControllerFixer>();
vrLeftHandTracker.inputSource = SteamVR_Input_Sources.LeftHand;
var vrRightHandTracker = __instance.vrRightHandTracker.AddComponent<TrackedControllerFixer>();
vrRightHandTracker.inputSource = SteamVR_Input_Sources.RightHand;
vrLeftHandTracker.Initialize();
vrRightHandTracker.Initialize();
var leftFixer = __instance.vrLeftHandTracker.AddComponent<TrackedControllerFixer>();
leftFixer.inputSource = SteamVR_Input_Sources.LeftHand;
leftFixer.Initialize();
var rightFixer = __instance.vrRightHandTracker.AddComponent<TrackedControllerFixer>();
rightFixer.inputSource = SteamVR_Input_Sources.RightHand;
rightFixer.Initialize();
}
}

View file

@ -9,7 +9,7 @@ public class TrackedControllerFix : MelonMod
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
}
private void ApplyPatches(Type type)
void ApplyPatches(Type type)
{
try
{

View file

@ -25,6 +25,6 @@ using System.Reflection;
namespace NAK.TrackedControllerFix.Properties;
internal static class AssemblyInfoParams
{
public const string Version = "1.0.2";
public const string Version = "1.0.3";
public const string Author = "NotAKidoS";
}

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);
}
}
}