mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-01 22:09:23 +00:00
Use Controller Toggle Gestures bind.
Toggle will not do anything if using Knuckles controllers. I do not own Knuckles so idk what it should do. 🤷
This commit is contained in:
parent
0f544878c1
commit
78c500598e
5 changed files with 42 additions and 99 deletions
|
@ -19,10 +19,7 @@
|
|||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\MelonLoader\MelonLoader.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SteamVR">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\SteamVR.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UIExpansionKit">
|
||||
<HintPath>..\..\..\..\..\..\Program Files (x86)\Steam\steamapps\common\ChilloutVR\Mods\UIExpansionKit.dll</HintPath>
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\SteamVR.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="UnityEngine.CoreModule">
|
||||
<HintPath>C:\Program Files (x86)\Steam\steamapps\common\ChilloutVR\ChilloutVR_Data\Managed\UnityEngine.CoreModule.dll</HintPath>
|
||||
|
|
|
@ -1,115 +1,36 @@
|
|||
using ABI_RC.Core.UI;
|
||||
using ABI_RC.Core.Player;
|
||||
using ABI_RC.Core.Savior;
|
||||
using ABI_RC.Core.UI;
|
||||
using HarmonyLib;
|
||||
using MelonLoader;
|
||||
using UnityEngine;
|
||||
using Valve.VR;
|
||||
|
||||
namespace GestureLock;
|
||||
|
||||
public class GestureLock : MelonMod
|
||||
{
|
||||
private static MelonPreferences_Category m_catagoryGestureLock;
|
||||
private static MelonPreferences_Entry<bool> m_entryGestureLock;
|
||||
private static MelonPreferences_Entry<BindingOptions> m_entryGestureBind;
|
||||
private static MelonPreferences_Entry<BindHand> m_entryGestureHand;
|
||||
|
||||
private enum BindHand
|
||||
{
|
||||
LeftHand,
|
||||
RightHand
|
||||
}
|
||||
private enum BindingOptions
|
||||
{
|
||||
ButtonATouch,
|
||||
ButtonBTouch,
|
||||
StickTouch,
|
||||
TriggerTouch
|
||||
}
|
||||
|
||||
public override void OnApplicationStart()
|
||||
{
|
||||
m_catagoryGestureLock = MelonPreferences.CreateCategory(nameof(GestureLock));
|
||||
m_entryGestureLock = m_catagoryGestureLock.CreateEntry<bool>("Enabled", true, description: "Double-touch VR binding.");
|
||||
m_entryGestureHand = m_catagoryGestureLock.CreateEntry("VR Hand", BindHand.LeftHand);
|
||||
m_entryGestureBind = m_catagoryGestureLock.CreateEntry("VR Binding", BindingOptions.StickTouch);
|
||||
|
||||
m_catagoryGestureLock.SaveToFile(false);
|
||||
m_entryGestureLock.OnValueChangedUntyped += UpdateSettings;
|
||||
m_entryGestureHand.OnValueChangedUntyped += UpdateSettings;
|
||||
m_entryGestureBind.OnValueChangedUntyped += UpdateSettings;
|
||||
|
||||
UpdateSettings();
|
||||
}
|
||||
private static void UpdateSettings()
|
||||
{
|
||||
HarmonyPatches.enabled = m_entryGestureLock.Value;
|
||||
HarmonyPatches.bind = m_entryGestureBind.Value;
|
||||
HarmonyPatches.hand = (SteamVR_Input_Sources)m_entryGestureHand.Value+1;
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
private class HarmonyPatches
|
||||
{
|
||||
public static bool enabled = m_entryGestureLock.Value;
|
||||
public static BindingOptions bind = m_entryGestureBind.Value;
|
||||
public static SteamVR_Input_Sources hand = SteamVR_Input_Sources.LeftHand;
|
||||
|
||||
private static bool isLocked = false;
|
||||
private static bool toggleLock = false;
|
||||
private static float oldGestureLeft = 0;
|
||||
private static float oldGestureRight = 0;
|
||||
|
||||
private static bool toggleLock = false;
|
||||
private static float touchDoubleTimer = 0f;
|
||||
private static bool touchArmed = false;
|
||||
|
||||
private static void CheckTouch(bool input)
|
||||
{
|
||||
if (input)
|
||||
{
|
||||
if (touchArmed && touchDoubleTimer < 0.25f)
|
||||
{
|
||||
touchArmed = false;
|
||||
toggleLock = true;
|
||||
touchDoubleTimer = 1f;
|
||||
}
|
||||
else
|
||||
{
|
||||
touchDoubleTimer = 0f;
|
||||
}
|
||||
touchArmed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
touchArmed = true;
|
||||
}
|
||||
}
|
||||
|
||||
//Read VR Buttons
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(InputModuleSteamVR), "UpdateInput")]
|
||||
private static void AfterUpdateInput(ref SteamVR_Action_Boolean ___steamVrButtonATouch, ref SteamVR_Action_Boolean ___steamVrButtonBTouch, ref SteamVR_Action_Boolean ___steamVrStickTouch, ref SteamVR_Action_Boolean ___steamVrTriggerTouch)
|
||||
private static void AfterUpdateInput(ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle, ref VRTrackerManager ____trackerManager)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr || !enabled) return;
|
||||
if (!MetaPort.Instance.isUsingVr) return;
|
||||
|
||||
touchDoubleTimer += Time.deltaTime;
|
||||
toggleLock = false;
|
||||
|
||||
switch (bind)
|
||||
if (___steamVrIndexGestureToggle.stateDown)
|
||||
{
|
||||
case BindingOptions.ButtonATouch:
|
||||
CheckTouch(___steamVrButtonATouch.GetState(hand));
|
||||
return;
|
||||
case BindingOptions.ButtonBTouch:
|
||||
CheckTouch(___steamVrButtonBTouch.GetState(hand));
|
||||
return;
|
||||
case BindingOptions.StickTouch:
|
||||
CheckTouch(___steamVrStickTouch.GetState(hand));
|
||||
return;
|
||||
case BindingOptions.TriggerTouch:
|
||||
CheckTouch(___steamVrTriggerTouch.GetState(hand));
|
||||
return;
|
||||
default: break;
|
||||
if (!____trackerManager.trackerNames.Contains("knuckles"))
|
||||
{
|
||||
toggleLock = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -118,7 +39,7 @@ public class GestureLock : MelonMod
|
|||
[HarmonyPatch(typeof(CVRInputManager), "Update")]
|
||||
private static void AfterUpdate(ref float ___gestureLeftRaw, ref float ___gestureLeft, ref float ___gestureRightRaw, ref float ___gestureRight)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr || !enabled) return;
|
||||
if (!MetaPort.Instance.isUsingVr) return;
|
||||
|
||||
if (toggleLock)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
using MelonLoader;
|
||||
using GestureLock.Properties;
|
||||
using GestureLock.Properties;
|
||||
using MelonLoader;
|
||||
using System.Reflection;
|
||||
|
||||
|
||||
|
@ -15,7 +15,7 @@ using System.Reflection;
|
|||
nameof(GestureLock),
|
||||
AssemblyInfoParams.Version,
|
||||
AssemblyInfoParams.Author,
|
||||
downloadLink: ""
|
||||
downloadLink: "https://github.com/NotAKidOnSteam/GestureLock"
|
||||
)]
|
||||
|
||||
[assembly: MelonGame("Alpha Blend Interactive", "ChilloutVR")]
|
||||
|
@ -25,6 +25,6 @@ using System.Reflection;
|
|||
namespace GestureLock.Properties;
|
||||
internal static class AssemblyInfoParams
|
||||
{
|
||||
public const string Version = "1.0.0";
|
||||
public const string Version = "1.1.0";
|
||||
public const string Author = "NotAKidoS";
|
||||
}
|
23
GestureLock/format.json
Normal file
23
GestureLock/format.json
Normal file
|
@ -0,0 +1,23 @@
|
|||
{
|
||||
"_id": 93,
|
||||
"name": "GestureLock",
|
||||
"modversion": "1.1.0",
|
||||
"gameversion": "2022r168",
|
||||
"loaderversion": "0.5.4",
|
||||
"modtype": "Mod",
|
||||
"author": "NotAKidoS",
|
||||
"description": "Locks GestureLeft & GestureRight on SteamVR binding.",
|
||||
"searchtags": [
|
||||
"gesture",
|
||||
"lock",
|
||||
"GestureLeft",
|
||||
"GestureRight"
|
||||
],
|
||||
"requirements": [
|
||||
"None"
|
||||
],
|
||||
"downloadlink": "https://github.com/NotAKidOnSteam/GestureLock/releases/download/r1/GestureLock.dll",
|
||||
"sourcelink": "https://github.com/NotAKidOnSteam/GestureLock/",
|
||||
"changelog": "Use SteamVR Index Gesture Lock binding instead of touch input.",
|
||||
"embedcolor": "804221"
|
||||
}
|
|
@ -1,7 +1,9 @@
|
|||
# GestureLock
|
||||
Simple GestureLock for CVR.
|
||||
|
||||
Double-touch the selected binding for the selected hand to toggle.
|
||||
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.
|
||||
|
||||
---
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue