using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using FistVR;
using HarmonyLib;
using HarmonyLib.Tools;
using Microsoft.CodeAnalysis;
using UnityEngine;
using pYt;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyCompany("pYt")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("This mod lets you change the sensitivity of your controller triggers.")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2")]
[assembly: AssemblyProduct("pYt.triggeradjuster")]
[assembly: AssemblyTitle("Trigger activation adjuster")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[Microsoft.CodeAnalysis.Embedded]
[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
internal sealed class RefSafetyRulesAttribute : Attribute
{
public readonly int Version;
public RefSafetyRulesAttribute(int P_0)
{
Version = P_0;
}
}
}
public class Patcher
{
public static void Patch()
{
//IL_000b: Unknown result type (might be due to invalid IL or missing references)
HarmonyFileLog.Enabled = true;
new Harmony("pyt.triggercalibration.patch").PatchAll();
}
}
[HarmonyPatch(typeof(FVRViveHand))]
[HarmonyPatch("PollInput")]
internal class Patch00
{
private static FieldRef<FVRViveHand, HandInput> inputRef = AccessTools.FieldRefAccess<FVRViveHand, HandInput>("Input");
private static FieldRef<FVRViveHand, bool> isRightHandRef = AccessTools.FieldRefAccess<FVRViveHand, bool>("IsThisTheRightHand");
private static void Postfix(FVRViveHand __instance)
{
float triggerFloat = inputRef.Invoke(__instance).TriggerFloat;
float num = ((!isRightHandRef.Invoke(__instance)) ? TriggerCalibration.FullActivationPointLeft.Value : TriggerCalibration.FullActivationPointRight.Value);
if (triggerFloat > 0f && num > 0f)
{
inputRef.Invoke(__instance).TriggerFloat = Mathf.Clamp(triggerFloat / num, 0f, 1f);
}
}
}
namespace BepInEx
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class BepInAutoPluginAttribute : Attribute
{
public BepInAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace BepInEx.Preloader.Core.Patching
{
[AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
[Conditional("CodeGeneration")]
internal sealed class PatcherAutoPluginAttribute : Attribute
{
public PatcherAutoPluginAttribute(string id = null, string name = null, string version = null)
{
}
}
}
namespace pYt
{
[BepInProcess("h3vr.exe")]
[BepInPlugin("pYt.triggeradjuster", "Trigger activation adjuster", "0.0.2")]
public class TriggerCalibration : BaseUnityPlugin
{
internal static ConfigEntry<float> FullActivationPointRight;
internal static ConfigEntry<float> FullActivationPointLeft;
public const string Id = "pYt.triggeradjuster";
internal static ManualLogSource Logger { get; private set; }
public static string Name => "Trigger activation adjuster";
public static string Version => "0.0.2";
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
FullActivationPointRight = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FullActivationPointRight", 1f, "Full trigger activation point (0.0-1.0) for the right controller.");
FullActivationPointLeft = ((BaseUnityPlugin)this).Config.Bind<float>("General", "FullActivationPointLeft", 1f, "Full trigger activation point (0.0-1.0) for the left controller.");
FullActivationPointRight.Value = Mathf.Clamp(FullActivationPointRight.Value, Mathf.Epsilon, 1f);
FullActivationPointLeft.Value = Mathf.Clamp(FullActivationPointLeft.Value, Mathf.Epsilon, 1f);
Patcher.Patch();
}
}
}