diff --git a/GestureLock/GestureLock.csproj b/GestureLock/GestureLock.csproj new file mode 100644 index 0000000..b987c6c --- /dev/null +++ b/GestureLock/GestureLock.csproj @@ -0,0 +1,37 @@ + + + + + net472 + enable + latest + false + + + + + C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\0Harmony.dll + + + C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\Assembly-CSharp.dll + + + C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll + + + C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\SteamVR.dll + + + C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll + + + C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.InputLegacyModule.dll + + + + + + + + + diff --git a/GestureLock/GestureLock.sln b/GestureLock/GestureLock.sln new file mode 100644 index 0000000..65fa197 --- /dev/null +++ b/GestureLock/GestureLock.sln @@ -0,0 +1,25 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.2.32630.192 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GestureLock", "GestureLock.csproj", "{B318B038-DA12-4960-A35E-613BE26B7965}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B318B038-DA12-4960-A35E-613BE26B7965}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B318B038-DA12-4960-A35E-613BE26B7965}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B318B038-DA12-4960-A35E-613BE26B7965}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B318B038-DA12-4960-A35E-613BE26B7965}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {0ABE9CFE-D4F5-4B5B-9D1A-5D0B1DA7E2CD} + EndGlobalSection +EndGlobal diff --git a/GestureLock/Main.cs b/GestureLock/Main.cs new file mode 100644 index 0000000..e349807 --- /dev/null +++ b/GestureLock/Main.cs @@ -0,0 +1,70 @@ +using ABI_RC.Core.Player; +using ABI_RC.Core.Savior; +using ABI_RC.Core.UI; +using HarmonyLib; +using MelonLoader; +using Valve.VR; + +//I legitimately threw this at ChatGPT to rewrite cause i couldn't be bothered. + +namespace NAK.Melons.GestureLock +{ + public class GestureLockMod : MelonMod + { + [HarmonyPatch] + private class HarmonyPatches + { + private static bool isLocked; + private static float oldGestureLeft; + private static float oldGestureRight; + + [HarmonyPostfix] + [HarmonyPatch(typeof(InputModuleSteamVR), "UpdateInput")] + private static void Postfix_InputModuleSteamVR_UpdateInput + ( + ref CVRInputManager ____inputManager, + ref VRTrackerManager ____trackerManager, + ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle + ) + { + if (!MetaPort.Instance.isUsingVr) + { + 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; + } + } + } + } +} \ No newline at end of file diff --git a/GestureLock/Properties/AssemblyInfo.cs b/GestureLock/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..8eb8fcb --- /dev/null +++ b/GestureLock/Properties/AssemblyInfo.cs @@ -0,0 +1,29 @@ +using MelonLoader; +using NAK.Melons.GestureLock.Properties; +using System.Reflection; + +[assembly: AssemblyVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyFileVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyInformationalVersion(AssemblyInfoParams.Version)] +[assembly: AssemblyTitle(nameof(NAK.Melons.GestureLock))] +[assembly: AssemblyCompany(AssemblyInfoParams.Author)] +[assembly: AssemblyProduct(nameof(NAK.Melons.GestureLock))] + +[assembly: MelonInfo( + typeof(NAK.Melons.GestureLock.GestureLockMod), + nameof(NAK.Melons.GestureLock), + AssemblyInfoParams.Version, + AssemblyInfoParams.Author, + downloadLink: "https://github.com/NotAKidOnSteam/GestureLock" +)] + +[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")] +[assembly: MelonPlatform(MelonPlatformAttribute.CompatiblePlatforms.WINDOWS_X64)] +[assembly: MelonPlatformDomain(MelonPlatformDomainAttribute.CompatibleDomains.MONO)] + +namespace NAK.Melons.GestureLock.Properties; +internal static class AssemblyInfoParams +{ + public const string Version = "2.0.0"; + public const string Author = "NotAKidoS"; +} \ No newline at end of file diff --git a/GestureLock/format.json b/GestureLock/format.json new file mode 100644 index 0000000..4baff42 --- /dev/null +++ b/GestureLock/format.json @@ -0,0 +1,23 @@ +{ + "_id": 93, + "name": "GestureLock", + "modversion": "2.0.0", + "gameversion": "2022r170", + "loaderversion": "0.5.7", + "modtype": "Mod", + "author": "NotAKidoS", + "description": "Locks GestureLeft & GestureRight on SteamVR binding.\nDoes nothing on Knuckles controllers.\n\nMake sure to bind Controller Toggle Gestures in SteamVR.", + "searchtags": [ + "gesture", + "lock", + "GestureLeft", + "GestureRight" + ], + "requirements": [ + "None" + ], + "downloadlink": "https://github.com/NotAKidOnSteam/GestureLock/releases/download/v2.0.0/GestureLock.dll", + "sourcelink": "https://github.com/NotAKidOnSteam/GestureLock/", + "changelog": "- Simplification & refactor.", + "embedcolor": "804221" +} \ No newline at end of file diff --git a/README.md b/README.md index 8fcccae..638122d 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,15 @@ Prevents VRIK from autodetecting toes in HalfbodyIK. Optionally can be applied in FBT, but toes in FBT are nice so you are a monster if so. ![fuckthetoes](https://user-images.githubusercontent.com/37721153/216518012-ae3b1dde-17ea-419a-a875-48d57e13f3dd.png) +# GestureLock + Simple GestureLock for CVR. + +Uses ChilloutVR's "Controller Toggle Gestures" binding in SteamVR to lock GestureLeft & GestureRight input. + +Does nothing on Knuckles controllers as the bind is used for finger tracking. + +![VirtualDesktop Android-20220907-172923](https://user-images.githubusercontent.com/37721153/188999382-7663a863-49be-4b9b-8839-8b6e8c32783b.jpg) + --- @@ -135,4 +144,4 @@ https://documentation.abinteractive.net/official/legal/tos/#7-modding-our-games > Use of this mod is done so at the user's own risk and the creator cannot be held responsible for any issues arising from its use. -> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive. \ No newline at end of file +> To the best of my knowledge, I have adhered to the Modding Guidelines established by Alpha Blend Interactive.