diff --git a/MenuScalePatch/HarmonyPatches.cs b/MenuScalePatch/HarmonyPatches.cs index 999c87d..29b44ab 100644 --- a/MenuScalePatch/HarmonyPatches.cs +++ b/MenuScalePatch/HarmonyPatches.cs @@ -193,48 +193,4 @@ internal class HarmonyPatches MenuScalePatch.Logger.Error(e); } } - - //[HarmonyTranspiler] - //[HarmonyPatch(typeof(ControllerRay), "LateUpdate")] - private static IEnumerable Transpiler_ControllerRay_UpdateInput( - IEnumerable instructions, ILGenerator il) - { - - // Stop calling move mouse events on the menus, the ones that instantiate and the send the event (easy) - // Makes this: "component.View.MouseEvent(mouseEventData1);" go POOF - instructions = new CodeMatcher(instructions) - .MatchForward(false, - new CodeMatch(OpCodes.Ldloc_S), - new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "get_View" }), - new CodeMatch(OpCodes.Ldloc_S), - new CodeMatch(i => i.opcode == OpCodes.Callvirt && i.operand is MethodInfo { Name: "MouseEvent" })) - .Repeat(matcher => matcher - .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop)) - .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop)) - .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop)) - .SetInstructionAndAdvance(new CodeInstruction(OpCodes.Nop)) - ) - .InstructionEnumeration(); - - // Look for the if flag2 and replace flag 2 with false, for the ones that create the event and send inline (hard ;_;) - // Makes this: "if (flag2 && this._mouseDownOnMenu != ControllerRay.Menu.None || ..." into: - // this: "if (false && this._mouseDownOnMenu != ControllerRay.Menu.None || ..." - instructions = new CodeMatcher(instructions) - .MatchForward(false, - new CodeMatch(OpCodes.Ldloc_2), - new CodeMatch(OpCodes.Brfalse), - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(i => - i.opcode == OpCodes.Ldfld && i.operand is FieldInfo { Name: "_mouseDownOnMenu" }), - new CodeMatch(OpCodes.Brtrue), - new CodeMatch(OpCodes.Ldarg_0), - new CodeMatch(i => - i.opcode == OpCodes.Ldfld && i.operand is FieldInfo { Name: "_mouseDownOnMenu" }), - new CodeMatch(OpCodes.Ldc_I4_1), - new CodeMatch(OpCodes.Bne_Un)) - .SetOpcodeAndAdvance(OpCodes.Ldc_I4_0) // replace flag2 with false - .InstructionEnumeration(); - - return instructions; - } } \ No newline at end of file diff --git a/MenuScalePatch/MSP_Menus.cs b/MenuScalePatch/MSP_Menus.cs index facd5e0..b8e0c92 100644 --- a/MenuScalePatch/MSP_Menus.cs +++ b/MenuScalePatch/MSP_Menus.cs @@ -28,16 +28,20 @@ public class MSP_MenuInfo internal static bool DisableMMHelper_VR; //reflection (traverse sucks ass) - private static readonly FieldInfo _desktopMouseMode = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance); + private static readonly FieldInfo _desktopMouseModeQM = typeof(ViewManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance); + private static readonly FieldInfo _desktopMouseModeMM = typeof(CVR_MenuManager).GetField("_desktopMouseMode", BindingFlags.NonPublic | BindingFlags.Instance); internal static void ToggleDesktopInputMethod(bool flag) { if (MetaPort.Instance.isUsingVr) return; - PlayerSetup.Instance._movementSystem.disableCameraControl = flag; - CVRInputManager.Instance.inputEnabled = !flag; + + _desktopMouseModeQM.SetValue(ViewManager.Instance, flag); + _desktopMouseModeMM.SetValue(CVR_MenuManager.Instance, flag); + RootLogic.Instance.ToggleMouse(flag); + CVRInputManager.Instance.inputEnabled = !flag; + PlayerSetup.Instance._movementSystem.disableCameraControl = flag; CVR_MenuManager.Instance.desktopControllerRay.enabled = !flag; - _desktopMouseMode.SetValue(CVR_MenuManager.Instance, flag); } internal static readonly FieldInfo ms_followAngleY = typeof(MovementSystem).GetField("_followAngleY", BindingFlags.NonPublic | BindingFlags.Instance); diff --git a/MenuScalePatch/MenuScalePatch.csproj b/MenuScalePatch/MenuScalePatch.csproj index 7293ed3..72168e2 100644 --- a/MenuScalePatch/MenuScalePatch.csproj +++ b/MenuScalePatch/MenuScalePatch.csproj @@ -16,13 +16,13 @@ C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll - ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll + C:\Program Files (x86)\\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Cohtml.Runtime.dll C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll - ..\..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll + C:\Program Files (x86)\\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.AnimationModule.dll C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll