mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[DesktopVRSwitch] Nuke CohtmlUISystem Gamepad handling for now.
This commit is contained in:
parent
5f95755ad2
commit
0fb7c3d401
19 changed files with 146 additions and 21 deletions
|
@ -7,6 +7,7 @@ using HarmonyLib;
|
|||
using NAK.DesktopVRSwitch.Patches;
|
||||
using NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
using UnityEngine;
|
||||
using cohtml;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.HarmonyPatches;
|
||||
|
||||
|
@ -64,6 +65,49 @@ class CameraFacingObjectPatches
|
|||
[HarmonyPatch(typeof(CameraFacingObject), nameof(CameraFacingObject.Start))]
|
||||
static void Postfix_CameraFacingObject_Start(ref CameraFacingObject __instance)
|
||||
{
|
||||
__instance.gameObject.AddComponent<CameraFacingObjectTracker>();
|
||||
__instance.gameObject.AddComponent<CameraFacingObjectTracker>()._cameraFacingObject = __instance;
|
||||
}
|
||||
}
|
||||
|
||||
class CVRPickupObjectPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CVRPickupObject), nameof(CVRPickupObject.Start))]
|
||||
static void Prefix_CVRPickupObject_Start(ref CVRPickupObject __instance)
|
||||
{
|
||||
if (__instance.gripType == CVRPickupObject.GripType.Free)
|
||||
return;
|
||||
|
||||
Transform vrOrigin = __instance.gripOrigin;
|
||||
Transform desktopOrigin = __instance.gripOrigin.Find("[Desktop]");
|
||||
if (vrOrigin != null && desktopOrigin != null)
|
||||
{
|
||||
var tracker = __instance.gameObject.AddComponent<CVRPickupObjectTracker>();
|
||||
tracker._pickupObject = __instance;
|
||||
tracker._storedGripOrigin = (!MetaPort.Instance.isUsingVr ? vrOrigin : desktopOrigin);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class CohtmlUISystemPatches
|
||||
{
|
||||
[HarmonyPrefix]
|
||||
[HarmonyPatch(typeof(CohtmlUISystem), nameof(CohtmlUISystem.RegisterGamepad))]
|
||||
[HarmonyPatch(typeof(CohtmlUISystem), nameof(CohtmlUISystem.UnregisterGamepad))]
|
||||
[HarmonyPatch(typeof(CohtmlUISystem), nameof(CohtmlUISystem.UpdateGamepadState))]
|
||||
static bool Prefix_CohtmlUISystem_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
|
||||
|
||||
we are using 1.17.0 (released 10/09/21) :):):)
|
||||
**/
|
||||
|
||||
// dont
|
||||
return false;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using MelonLoader;
|
||||
|
||||
using MelonLoader;
|
||||
using NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
using UnityEngine;
|
||||
|
||||
|
@ -28,7 +29,10 @@ public class DesktopVRSwitch : MelonMod
|
|||
Category.CreateEntry("Enter Calibration on Switch", true, description: "Should you automatically be placed into calibration after switch if FBT is available? Overridden by Save Calibration IK setting.");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryUseTransitionOnSwitch =
|
||||
Category.CreateEntry("Use Transition on Switch", true, description: "Should the world transition play on VRMode switch?");
|
||||
Category.CreateEntry("Use Transition on Switch", true, description: "Should the world transition play on VRMode switch?");
|
||||
|
||||
public static readonly MelonPreferences_Entry<bool> EntryRenderVRGameView =
|
||||
Category.CreateEntry("Render VR Game View", true, description: "Should the VR view be displayed in the game window?");
|
||||
|
||||
public override void OnInitializeMelon()
|
||||
{
|
||||
|
@ -40,10 +44,14 @@ public class DesktopVRSwitch : MelonMod
|
|||
ApplyPatches(typeof(HarmonyPatches.CheckVRPatches));
|
||||
// nameplate fixes
|
||||
ApplyPatches(typeof(HarmonyPatches.CameraFacingObjectPatches));
|
||||
// pickup fixes
|
||||
ApplyPatches(typeof(HarmonyPatches.CVRPickupObjectPatches));
|
||||
// lazy fix to reset iksystem
|
||||
ApplyPatches(typeof(HarmonyPatches.IKSystemPatches));
|
||||
// post processing fixes
|
||||
ApplyPatches(typeof(HarmonyPatches.CVRWorldPatches));
|
||||
// cohtml gamepad handling nuke
|
||||
ApplyPatches(typeof(HarmonyPatches.CohtmlUISystemPatches));
|
||||
}
|
||||
|
||||
public override void OnUpdate()
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using ABI_RC.Systems.UI;
|
||||
using NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
|
@ -16,7 +17,7 @@ using Valve.VR;
|
|||
|
||||
**/
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
namespace NAK.DesktopVRSwitch;
|
||||
|
||||
public class VRModeSwitchManager : MonoBehaviour
|
||||
{
|
|
@ -1,4 +1,5 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVRInputManagerTracker : VRModeTracker
|
||||
|
|
|
@ -5,18 +5,17 @@ namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
|||
|
||||
public class CVRPickupObjectTracker : MonoBehaviour
|
||||
{
|
||||
private CVRPickupObject _pickupObject;
|
||||
private Transform _storedGripOrigin;
|
||||
internal CVRPickupObject _pickupObject;
|
||||
internal Transform _storedGripOrigin;
|
||||
|
||||
public CVRPickupObjectTracker(CVRPickupObject pickupObject, Transform storedGripOrigin)
|
||||
void Start()
|
||||
{
|
||||
this._pickupObject = pickupObject;
|
||||
this._storedGripOrigin = storedGripOrigin;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
void OnDestroy()
|
||||
{
|
||||
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
public void OnPostSwitch(bool intoVR)
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVR_InteractableManagerTracker : VRModeTracker
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CVR_MenuManagerTracker : VRModeTracker
|
||||
|
|
|
@ -5,21 +5,18 @@ namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
|||
|
||||
public class CameraFacingObjectTracker : MonoBehaviour
|
||||
{
|
||||
private CameraFacingObject _cameraFacingObject;
|
||||
internal CameraFacingObject _cameraFacingObject;
|
||||
|
||||
public CameraFacingObjectTracker(CameraFacingObject cameraFacingObject)
|
||||
void Start()
|
||||
{
|
||||
this._cameraFacingObject = cameraFacingObject;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
void OnDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
public void OnPreSwitch(bool intoVR) { }
|
||||
|
||||
public void OnFailedSwitch(bool intoVR) { }
|
||||
|
||||
public void OnPostSwitch(bool intoVR)
|
||||
{
|
||||
_cameraFacingObject.m_Camera = Utils.GetPlayerCameraObject(intoVR).GetComponent<Camera>();
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class CheckVRTracker : VRModeTracker
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core;
|
||||
using ABI_RC.Core.UI;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class HudOperationsTracker : VRModeTracker
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
using ABI_RC.Systems.IK.SubSystems;
|
||||
using ABI_RC.Systems.IK.TrackingModules;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class IKSystemTracker : VRModeTracker
|
||||
|
|
|
@ -1,9 +1,14 @@
|
|||
using ABI_RC.Core.Savior;
|
||||
using UnityEngine;
|
||||
using UnityEngine.XR;
|
||||
using Valve.VR;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class MetaPortTracker : VRModeTracker
|
||||
{
|
||||
private MetaPort _metaPort;
|
||||
|
||||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
|
@ -16,7 +21,7 @@ public class MetaPortTracker : VRModeTracker
|
|||
|
||||
private void OnPostSwitch(bool intoVR)
|
||||
{
|
||||
MetaPort _metaPort = MetaPort.Instance;
|
||||
_metaPort = MetaPort.Instance;
|
||||
if (_metaPort == null)
|
||||
{
|
||||
DesktopVRSwitch.Logger.Error("Error while getting MetaPort!");
|
||||
|
@ -27,6 +32,13 @@ public class MetaPortTracker : VRModeTracker
|
|||
// Main thing most of the game checks for if using VR
|
||||
_metaPort.isUsingVr = intoVR;
|
||||
|
||||
// replace
|
||||
UpdateRichPresence();
|
||||
ResetSteamVROverrides(intoVR);
|
||||
}
|
||||
|
||||
private void UpdateRichPresence()
|
||||
{
|
||||
// Hacky way of updating rich presence
|
||||
if (_metaPort.settings.GetSettingsBool("ImplementationRichPresenceDiscordEnabled", true))
|
||||
{
|
||||
|
@ -41,4 +53,43 @@ public class MetaPortTracker : VRModeTracker
|
|||
_metaPort.settings.SetSettingsBool("ImplementationRichPresenceSteamEnabled", true);
|
||||
}
|
||||
}
|
||||
|
||||
private void ResetSteamVROverrides(bool intoVR)
|
||||
{
|
||||
if (intoVR)
|
||||
{
|
||||
// Testing
|
||||
XRSettings.eyeTextureResolutionScale = 1;
|
||||
XRSettings.gameViewRenderMode = DesktopVRSwitch.EntryRenderVRGameView.Value ? GameViewRenderMode.LeftEye : GameViewRenderMode.None;
|
||||
SteamVR_Settings.instance.pauseGameWhenDashboardVisible = false;
|
||||
|
||||
if (MetaPort.Instance.settings.GetSettingsBool("InteractionTobiiEyeTracking", false))
|
||||
{
|
||||
MetaPort.Instance.TobiiXrInitializer.Initialize();
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Reset physics time to Desktop default
|
||||
Time.fixedDeltaTime = 0.02f;
|
||||
|
||||
// Reset queued frames
|
||||
QualitySettings.maxQueuedFrames = 2;
|
||||
|
||||
// Reset framerate target
|
||||
int graphicsFramerateTarget = MetaPort.Instance.settings.GetSettingInt("GraphicsFramerateTarget", 0);
|
||||
ABI_RC.Core.CVRTools.SetFramerateTarget(graphicsFramerateTarget);
|
||||
|
||||
// Reset VSync setting
|
||||
bool graphicsVSync = MetaPort.Instance.settings.GetSettingsBool("GraphicsVSync", false);
|
||||
QualitySettings.vSyncCount = graphicsVSync ? 1 : 0;
|
||||
|
||||
// Reset anti-aliasing
|
||||
int graphicsMsaaLevel = MetaPort.Instance.settings.GetSettingInt("GraphicsMsaaLevel", 0);
|
||||
QualitySettings.antiAliasing = graphicsMsaaLevel;
|
||||
|
||||
// Won't do anything if not already running
|
||||
MetaPort.Instance.TobiiXrInitializer.DeInitialize();
|
||||
}
|
||||
}
|
|
@ -1,4 +1,5 @@
|
|||
using ABI_RC.Systems.MovementSystem;
|
||||
|
||||
using UnityEngine;
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
@ -12,12 +13,14 @@ public class MovementSystemTracker : VRModeTracker
|
|||
public override void TrackerInit()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch += OnPreSwitch;
|
||||
VRModeSwitchManager.OnFailVRModeSwitch += OnFailedSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch += OnPostSwitch;
|
||||
}
|
||||
|
||||
public override void TrackerDestroy()
|
||||
{
|
||||
VRModeSwitchManager.OnPreVRModeSwitch -= OnPreSwitch;
|
||||
VRModeSwitchManager.OnFailVRModeSwitch -= OnFailedSwitch;
|
||||
VRModeSwitchManager.OnPostVRModeSwitch -= OnPostSwitch;
|
||||
}
|
||||
|
||||
|
@ -28,10 +31,16 @@ public class MovementSystemTracker : VRModeTracker
|
|||
preSwitchWorldPosition = Utils.GetPlayerRootPosition();
|
||||
preSwitchWorldRotation = _movementSystem.rotationPivot.transform.rotation;
|
||||
|
||||
_movementSystem.SetImmobilized(true);
|
||||
_movementSystem.ChangeCrouch(false);
|
||||
_movementSystem.ChangeProne(false);
|
||||
}
|
||||
|
||||
private void OnFailedSwitch(bool intoVR)
|
||||
{
|
||||
_movementSystem.SetImmobilized(false);
|
||||
}
|
||||
|
||||
private void OnPostSwitch(bool intoVR)
|
||||
{
|
||||
_movementSystem.rotationPivot = Utils.GetPlayerCameraObject(intoVR).transform;
|
||||
|
@ -40,6 +49,7 @@ public class MovementSystemTracker : VRModeTracker
|
|||
if (!intoVR)
|
||||
_movementSystem.UpdateColliderCenter(_movementSystem.transform.position);
|
||||
|
||||
_movementSystem.SetImmobilized(false);
|
||||
_movementSystem.ChangeCrouch(false);
|
||||
_movementSystem.ChangeProne(false);
|
||||
}
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class PlayerSetupTracker : VRModeTracker
|
||||
|
@ -29,8 +30,11 @@ public class PlayerSetupTracker : VRModeTracker
|
|||
|
||||
// This might error if we started in VR.
|
||||
// '_cam' is not set until Start().
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
if (CVR_DesktopCameraController._cam == null)
|
||||
CVR_DesktopCameraController._cam = _playerSetup.desktopCamera.GetComponent<UnityEngine.Camera>();
|
||||
|
||||
CVR_DesktopCameraController.UpdateFov();
|
||||
|
||||
// UICamera has a script that copies the FOV from the desktop cam.
|
||||
// Toggling the cameras on/off resets the aspect ratio,
|
||||
// so when rigs switch, that is already handled.
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Systems.Camera;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class PortableCameraTracker : VRModeTracker
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.Player;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class VRTrackerManagerTracker : VRModeTracker
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
using ABI_RC.Core.InteractionSystem;
|
||||
|
||||
|
||||
namespace NAK.DesktopVRSwitch.VRModeTrackers;
|
||||
|
||||
public class ViewManagerTracker : VRModeTracker
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue