mirror of
https://github.com/NotAKidoS/NAK_CVR_Mods.git
synced 2025-09-02 22:39:22 +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.Systems.InputManagement.InputModules;
|
||||
using ABI_RC.Systems.InputManagement.XR;
|
||||
using HarmonyLib;
|
||||
using Valve.VR;
|
||||
|
||||
namespace NAK.GestureLock.HarmonyPatches;
|
||||
|
||||
class Patches
|
||||
internal class CVRInputModule_XRPatches
|
||||
{
|
||||
private static bool isLocked;
|
||||
private static float oldGestureLeft;
|
||||
private static float oldGestureRight;
|
||||
// Get input from SteamVR because new input system is nerfed for OpenXR...
|
||||
private static readonly SteamVR_Action_Boolean _gestureToggleButton = SteamVR_Input.GetAction<SteamVR_Action_Boolean>("ControllerToggleGestures", false);
|
||||
|
||||
private static bool _isLocked;
|
||||
private static float _oldGestureLeft;
|
||||
private static float _oldGestureRight;
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(InputModuleSteamVR), nameof(InputModuleSteamVR.UpdateInput))]
|
||||
private static void Postfix_InputModuleSteamVR_UpdateInput
|
||||
(
|
||||
ref CVRInputManager ____inputManager,
|
||||
ref VRTrackerManager ____trackerManager,
|
||||
ref SteamVR_Action_Boolean ___steamVrIndexGestureToggle
|
||||
)
|
||||
[HarmonyPatch(typeof(CVRInputModule_XR), nameof(CVRInputModule_XR.Update_Emotes))]
|
||||
private static void Postfix_CVRInputModule_XR_Update_Emotes(ref CVRInputModule_XR __instance)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
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"));
|
||||
}
|
||||
}
|
||||
bool leftInput = _gestureToggleButton.GetLastStateDown(SteamVR_Input_Sources.LeftHand);
|
||||
bool rightInput = _gestureToggleButton.GetLastStateDown(SteamVR_Input_Sources.RightHand);
|
||||
|
||||
[HarmonyPostfix]
|
||||
[HarmonyPatch(typeof(CVRInputManager), nameof(CVRInputManager.Update))]
|
||||
private static void Postfix_CVRInputManager_Update
|
||||
(
|
||||
ref float ___gestureLeft,
|
||||
ref float ___gestureRight
|
||||
)
|
||||
{
|
||||
if (!MetaPort.Instance.isUsingVr)
|
||||
{
|
||||
if (leftInput && __instance._leftModule.Type == EXRControllerType.Index || __instance._inputManager.oneHanded)
|
||||
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)
|
||||
{
|
||||
// Dont override raw, other systems like the camera gesture recognizer need it.
|
||||
___gestureLeft = oldGestureLeft;
|
||||
___gestureRight = oldGestureRight;
|
||||
}
|
||||
if (!_isLocked)
|
||||
return;
|
||||
|
||||
__instance._inputManager.gestureLeft = _oldGestureLeft;
|
||||
__instance._inputManager.gestureRight = _oldGestureRight;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue