mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-01 22:09:23 +00:00
buimp
This commit is contained in:
parent
49563a00d3
commit
d9b41dc5cc
3 changed files with 65 additions and 57 deletions
|
@ -5,57 +5,66 @@ using HarmonyLib;
|
||||||
using MelonLoader;
|
using MelonLoader;
|
||||||
using Valve.VR;
|
using Valve.VR;
|
||||||
|
|
||||||
namespace GestureLock;
|
//I legitimately threw this at ChatGPT to rewrite cause i couldn't be bothered.
|
||||||
|
|
||||||
public class GestureLock : MelonMod
|
namespace NAK.Melons.GestureLock
|
||||||
{
|
{
|
||||||
[HarmonyPatch]
|
public class GestureLockMod : MelonMod
|
||||||
private class HarmonyPatches
|
|
||||||
{
|
{
|
||||||
private static bool isLocked = false;
|
[HarmonyPatch]
|
||||||
private static bool toggleLock = false;
|
private class HarmonyPatches
|
||||||
private static float oldGestureLeft = 0;
|
|
||||||
private static float oldGestureRight = 0;
|
|
||||||
|
|
||||||
//Read VR Buttons
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(InputModuleSteamVR), "UpdateInput")]
|
|
||||||
private static void AfterUpdateInput(ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle, ref VRTrackerManager ____trackerManager)
|
|
||||||
{
|
{
|
||||||
if (!MetaPort.Instance.isUsingVr) return;
|
private static bool isLocked;
|
||||||
|
private static float oldGestureLeft;
|
||||||
|
private static float oldGestureRight;
|
||||||
|
|
||||||
toggleLock = false;
|
[HarmonyPostfix]
|
||||||
if (___steamVrIndexGestureToggle.stateDown)
|
[HarmonyPatch(typeof(InputModuleSteamVR), "UpdateInput")]
|
||||||
|
private static void Postfix_InputModuleSteamVR_UpdateInput
|
||||||
|
(
|
||||||
|
ref CVRInputManager ____inputManager,
|
||||||
|
ref VRTrackerManager ____trackerManager,
|
||||||
|
ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle
|
||||||
|
)
|
||||||
{
|
{
|
||||||
if (!____trackerManager.trackerNames.Contains("knuckles"))
|
if (!MetaPort.Instance.isUsingVr)
|
||||||
{
|
{
|
||||||
toggleLock = true;
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (___steamVrIndexGestureToggle.stateDown && !____trackerManager.trackerNames.Contains("knuckles"))
|
||||||
|
{
|
||||||
|
isLocked = !isLocked;
|
||||||
|
oldGestureLeft = ____inputManager.gestureLeft;
|
||||||
|
oldGestureRight = ____inputManager.gestureRight;
|
||||||
|
CohtmlHud.Instance.ViewDropTextImmediate("", "Gesture Lock", "Gestures " + (isLocked ? "Locked" : "Unlocked"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPostfix]
|
||||||
|
[HarmonyPatch(typeof(CVRInputManager), "Update")]
|
||||||
|
private static void Postfix_CVRInputManager_Update
|
||||||
|
(
|
||||||
|
ref float ___gestureLeft,
|
||||||
|
ref float ___gestureRight,
|
||||||
|
ref float ___gestureLeftRaw,
|
||||||
|
ref float ___gestureRightRaw
|
||||||
|
)
|
||||||
|
{
|
||||||
|
if (!MetaPort.Instance.isUsingVr)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isLocked)
|
||||||
|
{
|
||||||
|
// Dont override raw, other systems like the camera gesture recognizer need it.
|
||||||
|
//gestureLeftRaw = gestureLeft;
|
||||||
|
//gestureRightRaw = gestureRight;
|
||||||
|
___gestureLeft = oldGestureLeft;
|
||||||
|
___gestureRight = oldGestureRight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//Apply GestureLock
|
|
||||||
[HarmonyPostfix]
|
|
||||||
[HarmonyPatch(typeof(CVRInputManager), "Update")]
|
|
||||||
private static void AfterUpdate(ref float ___gestureLeftRaw, ref float ___gestureLeft, ref float ___gestureRightRaw, ref float ___gestureRight)
|
|
||||||
{
|
|
||||||
if (!MetaPort.Instance.isUsingVr) return;
|
|
||||||
|
|
||||||
if (toggleLock)
|
|
||||||
{
|
|
||||||
isLocked = !isLocked;
|
|
||||||
oldGestureLeft = ___gestureLeft;
|
|
||||||
oldGestureRight = ___gestureRight;
|
|
||||||
MelonLogger.Msg("Gestures " + (isLocked ? "Locked" : "Unlocked"));
|
|
||||||
CohtmlHud.Instance.ViewDropTextImmediate("", "Gesture Lock ", "Gestures " + (isLocked ? "Locked" : "Unlocked"));
|
|
||||||
}
|
|
||||||
if (isLocked)
|
|
||||||
{
|
|
||||||
//___gestureLeftRaw = oldGestureLeft;
|
|
||||||
___gestureLeft = oldGestureLeft;
|
|
||||||
//___gestureRightRaw = oldGestureRight;
|
|
||||||
___gestureRight = oldGestureRight;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,18 +1,17 @@
|
||||||
using GestureLock.Properties;
|
using MelonLoader;
|
||||||
using MelonLoader;
|
using NAK.Melons.GestureLock.Properties;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
|
|
||||||
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)]
|
||||||
[assembly: AssemblyTitle(nameof(GestureLock))]
|
[assembly: AssemblyTitle(nameof(NAK.Melons.GestureLock))]
|
||||||
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
[assembly: AssemblyCompany(AssemblyInfoParams.Author)]
|
||||||
[assembly: AssemblyProduct(nameof(GestureLock))]
|
[assembly: AssemblyProduct(nameof(NAK.Melons.GestureLock))]
|
||||||
|
|
||||||
[assembly: MelonInfo(
|
[assembly: MelonInfo(
|
||||||
typeof(GestureLock.GestureLock),
|
typeof(NAK.Melons.GestureLock.GestureLockMod),
|
||||||
nameof(GestureLock),
|
nameof(NAK.Melons.GestureLock),
|
||||||
AssemblyInfoParams.Version,
|
AssemblyInfoParams.Version,
|
||||||
AssemblyInfoParams.Author,
|
AssemblyInfoParams.Author,
|
||||||
downloadLink: "https://github.com/NotAKidOnSteam/GestureLock"
|
downloadLink: "https://github.com/NotAKidOnSteam/GestureLock"
|
||||||
|
@ -22,9 +21,9 @@ using System.Reflection;
|
||||||
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)]
|
||||||
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)]
|
||||||
|
|
||||||
namespace GestureLock.Properties;
|
namespace NAK.Melons.GestureLock.Properties;
|
||||||
internal static class AssemblyInfoParams
|
internal static class AssemblyInfoParams
|
||||||
{
|
{
|
||||||
public const string Version = "1.1.1";
|
public const string Version = "2.0.0";
|
||||||
public const string Author = "NotAKidoS";
|
public const string Author = "NotAKidoS";
|
||||||
}
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
{
|
{
|
||||||
"_id": 93,
|
"_id": 93,
|
||||||
"name": "GestureLock",
|
"name": "GestureLock",
|
||||||
"modversion": "1.1.1",
|
"modversion": "2.0.0",
|
||||||
"gameversion": "2022r168",
|
"gameversion": "2022r170",
|
||||||
"loaderversion": "0.5.4",
|
"loaderversion": "0.5.7",
|
||||||
"modtype": "Mod",
|
"modtype": "Mod",
|
||||||
"author": "NotAKidoS",
|
"author": "NotAKidoS",
|
||||||
"description": "Locks GestureLeft & GestureRight on SteamVR binding.\nDoes nothing on Knuckles controllers.\n\nMake sure to bind Controller Toggle Gestures in SteamVR.",
|
"description": "Locks GestureLeft & GestureRight on SteamVR binding.\nDoes nothing on Knuckles controllers.\n\nMake sure to bind Controller Toggle Gestures in SteamVR.",
|
||||||
|
@ -16,8 +16,8 @@
|
||||||
"requirements": [
|
"requirements": [
|
||||||
"None"
|
"None"
|
||||||
],
|
],
|
||||||
"downloadlink": "https://github.com/NotAKidOnSteam/GestureLock/releases/download/r4/GestureLock.dll",
|
"downloadlink": "https://github.com/NotAKidOnSteam/GestureLock/releases/download/v2.0.0/GestureLock.dll",
|
||||||
"sourcelink": "https://github.com/NotAKidOnSteam/GestureLock/",
|
"sourcelink": "https://github.com/NotAKidOnSteam/GestureLock/",
|
||||||
"changelog": "Gesture recognizer now works properly while gestures are locked.\nCan pull camera out with gestures while locked.",
|
"changelog": "- Simplification & refactor.",
|
||||||
"embedcolor": "804221"
|
"embedcolor": "804221"
|
||||||
}
|
}
|
Loading…
Add table
Add a link
Reference in a new issue