[DesktopVRSwitch] Fixes for 2023r172.

This commit is contained in:
NotAKidoS 2023-09-23 19:35:46 -05:00
parent 39cbdf8ed5
commit 6b32a6475d
6 changed files with 43 additions and 38 deletions

View file

@ -118,32 +118,6 @@ internal class CVRPickupObjectPatches
}
}
internal class CohtmlUISystemPatches
{
[HarmonyPrefix]
[HarmonyPatch(typeof(UISystem), nameof(UISystem.RegisterGamepad), typeof(uint), typeof(string), typeof(uint), typeof(uint), typeof(IntPtr))]
[HarmonyPatch(typeof(UISystem), nameof(UISystem.RegisterGamepad), typeof(uint), typeof(string), typeof(uint), typeof(uint))]
[HarmonyPatch(typeof(UISystem), nameof(UISystem.UpdateGamepadState), typeof(cohtml.GamepadState))]
[HarmonyPatch(typeof(UISystem), nameof(UISystem.UpdateGamepadState), typeof(uint), typeof(float[]), typeof(float[]))]
[HarmonyPatch(typeof(UISystem), nameof(UISystem.UnregisterGamepad))]
[HarmonyPatch(typeof(UISystem), nameof(UISystem.UpdateGamepadStateExtended))]
private static bool Prefix_UISystem_FuckOff()
{
/**
GameFace Version 1.34.0.4 released 10 Nov 2022
Fixed a crash when registering and unregistering gamepads
Fix Fixed setting a gamepad object when creating GamepadEvent from JavaScript
Fix Fixed a crash when unregistering a gamepad twice
Fix Fixed a GamepadEvent related crash during garbage collector tracing
it is not fixed you fucking piece of shit
**/
// dont
return false;
}
}
internal class SteamVRBehaviourPatches
{
[HarmonyPrefix]

View file

@ -26,9 +26,6 @@ public class DesktopVRSwitch : MelonMod
// post processing fixes
ApplyPatches(typeof(HarmonyPatches.CVRWorldPatches));
// fuck you
ApplyPatches(typeof(HarmonyPatches.CohtmlUISystemPatches));
// prevent steamvr behaviour from closing game
ApplyPatches(typeof(HarmonyPatches.SteamVRBehaviourPatches));

View file

@ -0,0 +1,29 @@
using ABI_RC.Systems.IK;
using ABI_RC.Systems.IK.TrackingModules;
using ABI_RC.Systems.InputManagement;
using ABI_RC.Systems.InputManagement.XR.Modules;
namespace NAK.DesktopVRSwitch.Patches;
internal static class SteamVRNullReferencePatch
{
public static void DestroySteamVRInstancesImmediate()
{
// set to null so input manager doesnt attempt to access it
if (CVRInputManager._moduleXR != null)
{
if (CVRInputManager._moduleXR._leftModule != null)
if (CVRInputManager._moduleXR._leftModule is CVRXRModule_SteamVR leftModule) leftModule._steamVr = null;
if (CVRInputManager._moduleXR._rightModule != null)
if (CVRInputManager._moduleXR._rightModule is CVRXRModule_SteamVR rightModule) rightModule._steamVr = null;
}
if (IKSystem.Instance == null)
return;
// set to null so tracking module doesnt attempt to access it
foreach (TrackingModule module in IKSystem.Instance._trackingModules)
if (module is SteamVRTrackingModule steamVRModule)
steamVRModule._steamVr = null;
}
}

View file

@ -25,13 +25,6 @@ public class CVRInputManagerTracker : VRModeTracker
// IM CRYING
//CVRInputManager.Instance.reload = true;
// set to null so input manager doesnt attempt to access it
if (CVRInputManager._moduleXR._leftModule != null)
if (CVRInputManager._moduleXR._leftModule is CVRXRModule_SteamVR leftModule) leftModule._steamVr = null;
if (CVRInputManager._moduleXR._rightModule != null)
if (CVRInputManager._moduleXR._rightModule is CVRXRModule_SteamVR rightModule) rightModule._steamVr = null;
// TODO: MOVE THIS TO DIFFERENT TRACKER
RootLogic.Instance.ToggleMouse(args.IsUsingVr);
@ -50,7 +43,18 @@ public class CVRInputManagerTracker : VRModeTracker
//add input module if you started in desktop
if (CVRInputManager._moduleXR == null)
{
CVRInputManager.Instance.AddInputModule(CVRInputManager._moduleXR = new CVRInputModule_XR());
}
else
{
// set to null so input manager doesnt attempt to access it
if (CVRInputManager._moduleXR._leftModule != null)
if (CVRInputManager._moduleXR._leftModule is CVRXRModule_SteamVR leftModule) leftModule._steamVr = null;
if (CVRInputManager._moduleXR._rightModule != null)
if (CVRInputManager._moduleXR._rightModule is CVRXRModule_SteamVR rightModule) rightModule._steamVr = null;
}
//enable xr input or whatnot
CVRInputManager._moduleXR.InputEnabled = args.IsUsingVr;

View file

@ -35,6 +35,7 @@ internal static class XRHandler
// Remove SteamVR behaviour & render
UnityEngine.Object.DestroyImmediate(SteamVR_Behaviour.instance.gameObject);
SteamVR.enabled = false; // disposes SteamVR
Patches.SteamVRNullReferencePatch.DestroySteamVRInstancesImmediate();
// Disable UnityXR
XRGeneralSettings.Instance.Manager.StopSubsystems();

View file

@ -2,7 +2,7 @@
"_id": 103,
"name": "DesktopVRSwitch",
"modversion": "4.4.1",
"gameversion": "2023r171",
"gameversion": "2023r172",
"loaderversion": "0.6.1",
"modtype": "Mod",
"author": "NotAKidoS",
@ -18,6 +18,6 @@
],
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r20/DesktopVRSwitch.dll",
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/DesktopVRSwitch/",
"changelog": "- Fixes for 2023r171.",
"changelog": "- Fixes for 2023r172.\n- Mouse is now force unlocked once entering VR mode as QOL.",
"embedcolor": "3498db"
}