mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 14:29:25 +00:00
[GestureLock] Fixes for 2023r171
This commit is contained in:
parent
eef6f1bf51
commit
0e9f7566da
4 changed files with 42 additions and 48 deletions
|
@ -1,58 +1,49 @@
|
||||||
using ABI_RC.Core.Player;
|
using ABI_RC.Core.Savior;
|
||||||
using ABI_RC.Core.Savior;
|
|
||||||
using ABI_RC.Core.UI;
|
using ABI_RC.Core.UI;
|
||||||
|
using ABI_RC.Systems.InputManagement.InputModules;
|
||||||
|
using ABI_RC.Systems.InputManagement.XR;
|
||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using Valve.VR;
|
using Valve.VR;
|
||||||
|
|
||||||
namespace NAK.GestureLock.HarmonyPatches;
|
namespace NAK.GestureLock.HarmonyPatches;
|
||||||
|
|
||||||
class Patches
|
internal class CVRInputModule_XRPatches
|
||||||
{
|
{
|
||||||
private static bool isLocked;
|
// Get input from SteamVR because new input system is nerfed for OpenXR...
|
||||||
private static float oldGestureLeft;
|
private static readonly SteamVR_Action_Boolean _gestureToggleButton = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("ControllerToggleGestures", false);
|
||||||
private static float oldGestureRight;
|
|
||||||
|
private static bool _isLocked;
|
||||||
|
private static float _oldGestureLeft;
|
||||||
|
private static float _oldGestureRight;
|
||||||
|
|
||||||
[HarmonyPostfix]
|
[HarmonyPostfix]
|
||||||
[HarmonyPatch(typeof(InputModuleSteamVR), nameof(InputModuleSteamVR.UpdateInput))]
|
[HarmonyPatch(typeof(CVRInputModule_XR), nameof(CVRInputModule_XR.Update_Emotes))]
|
||||||
private static void Postfix_InputModuleSteamVR_UpdateInput
|
private static void Postfix_CVRInputModule_XR_Update_Emotes(ref CVRInputModule_XR __instance)
|
||||||
(
|
|
||||||
ref CVRInputManager ____inputManager,
|
|
||||||
ref VRTrackerManager ____trackerManager,
|
|
||||||
ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle
|
|
||||||
)
|
|
||||||
{
|
{
|
||||||
if (!MetaPort.Instance.isUsingVr)
|
if (!MetaPort.Instance.isUsingVr)
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
if (___steamVrIndexGestureToggle.stateDown && !____trackerManager.trackerNames.Contains("knuckles"))
|
bool leftInput = _gestureToggleButton.GetLastStateDown(SteamVR_Input_Sources.LeftHand);
|
||||||
{
|
bool rightInput = _gestureToggleButton.GetLastStateDown(SteamVR_Input_Sources.RightHand);
|
||||||
isLocked = !isLocked;
|
|
||||||
oldGestureLeft = ____inputManager.gestureLeft;
|
|
||||||
oldGestureRight = ____inputManager.gestureRight;
|
|
||||||
CohtmlHud.Instance.ViewDropTextImmediate("", "Gesture Lock", "Gestures " + (isLocked ? "Locked" : "Unlocked"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[HarmonyPostfix]
|
if (leftInput && __instance._leftModule.Type == EXRControllerType.Index || __instance._inputManager.oneHanded)
|
||||||
[HarmonyPatch(typeof(CVRInputManager), nameof(CVRInputManager.Update))]
|
|
||||||
private static void Postfix_CVRInputManager_Update
|
|
||||||
(
|
|
||||||
ref float ___gestureLeft,
|
|
||||||
ref float ___gestureRight
|
|
||||||
)
|
|
||||||
{
|
|
||||||
if (!MetaPort.Instance.isUsingVr)
|
|
||||||
{
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (rightInput && __instance._rightModule.Type == EXRControllerType.Index || __instance._inputManager.oneHanded)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (leftInput || rightInput)
|
||||||
|
{
|
||||||
|
_isLocked = !_isLocked;
|
||||||
|
_oldGestureLeft = __instance._inputManager.gestureLeft;
|
||||||
|
_oldGestureRight = __instance._inputManager.gestureRight;
|
||||||
|
CohtmlHud.Instance.ViewDropTextImmediate("", "Gesture Lock", "Gestures " + (_isLocked ? "Locked" : "Unlocked"));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isLocked)
|
if (!_isLocked)
|
||||||
{
|
return;
|
||||||
// Dont override raw, other systems like the camera gesture recognizer need it.
|
|
||||||
___gestureLeft = oldGestureLeft;
|
__instance._inputManager.gestureLeft = _oldGestureLeft;
|
||||||
___gestureRight = oldGestureRight;
|
__instance._inputManager.gestureRight = _oldGestureRight;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -6,10 +6,10 @@ public class GestureLock : MelonMod
|
||||||
{
|
{
|
||||||
public override void OnInitializeMelon()
|
public override void OnInitializeMelon()
|
||||||
{
|
{
|
||||||
ApplyPatches(typeof(HarmonyPatches.Patches));
|
ApplyPatches(typeof(HarmonyPatches.CVRInputModule_XRPatches));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ApplyPatches(Type type)
|
private void ApplyPatches(Type type)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
|
@ -20,10 +20,13 @@ using System.Reflection;
|
||||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||||
|
[assembly: MelonColor(255, 128, 66, 33)]
|
||||||
|
[assembly: MelonAuthorColor(255, 158, 21, 32)]
|
||||||
|
[assembly: HarmonyDontPatchAll]
|
||||||
|
|
||||||
namespace NAK.GestureLock.Properties;
|
namespace NAK.GestureLock.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "2.0.0";
|
public const string Version = "2.0.1";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -1,8 +1,8 @@
|
||||||
{
|
{
|
||||||
"_id": 93,
|
"_id": 93,
|
||||||
"name": "GestureLock",
|
"name": "GestureLock",
|
||||||
"modversion": "2.0.0",
|
"modversion": "2.0.1",
|
||||||
"gameversion": "2022r170p1",
|
"gameversion": "2023r171",
|
||||||
"loaderversion": "0.6.1",
|
"loaderversion": "0.6.1",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
"author": "NotAKidoS",
|
"author": "NotAKidoS",
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r3/GestureLock.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/releases/download/r16/GestureLock.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/GestureLock/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/NAK_CVR_Mods/tree/main/GestureLock/",
|
||||||
"changelog": "- Simplification & refactor.",
|
"changelog": "- Fixes for 2023r171.",
|
||||||
"embedcolor": "804221"
|
"embedcolor": "#804221"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue