mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +00:00
i have no fucking clue
This commit is contained in:
parent
730ff58adc
commit
f783fe612d
21 changed files with 496 additions and 49 deletions
|
@ -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();
|
||||
}
|
||||
}
|
|
@ -9,7 +9,7 @@ public class TrackedControllerFix : MelonMod
|
|||
ApplyPatches(typeof(HarmonyPatches.PlayerSetupPatches));
|
||||
}
|
||||
|
||||
private void ApplyPatches(Type type)
|
||||
void ApplyPatches(Type type)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
|
|
@ -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";
|
||||
}
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue