From 01ac535afde3f7c67ab6de5178fd3d2b6fbf6539 Mon Sep 17 00:00:00 2001 From: jonbons Date: Sun, 5 May 2024 20:21:30 -0500 Subject: [PATCH] Added ability to trigger a refresh of TrackIR detection --- JBTrackIR/JBTrackIR.csproj | 2 +- JBTrackIR/Plugin.cs | 32 +++++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/JBTrackIR/JBTrackIR.csproj b/JBTrackIR/JBTrackIR.csproj index 92fbffd..9ea732b 100644 --- a/JBTrackIR/JBTrackIR.csproj +++ b/JBTrackIR/JBTrackIR.csproj @@ -4,7 +4,7 @@ netstandard2.0 JBTrackIR SPT TrackIR Support - 1.0.1 + 1.0.2 true latest diff --git a/JBTrackIR/Plugin.cs b/JBTrackIR/Plugin.cs index 8822f77..0a6ddd4 100644 --- a/JBTrackIR/Plugin.cs +++ b/JBTrackIR/Plugin.cs @@ -16,9 +16,10 @@ using UnityEngine; namespace JBTrackIR; -[BepInPlugin("com.jonbons.trackir", "JonBons.TrackIR", "1.0.1")] +[BepInPlugin("com.jonbons.trackir", "JonBons.TrackIR", "1.0.2")] public class Plugin : BaseUnityPlugin { + static ConfigEntry tirRefresh; static ConfigEntry tirEnabled; static ConfigEntry tirSensitivityCoef; static ConfigEntry tirLimitPitchLower; @@ -53,6 +54,27 @@ public class Plugin : BaseUnityPlugin new Transpiler().Enable(); } + private void Update() { + if (tirRefresh.Value) + { + tirRefresh.BoxedValue = false; + tirRefresh.Value = false; + + if (tirRunning) tirClient.TrackIR_Shutdown(); + + var result = tirClient.TrackIR_Enhanced_Init(); + if (!string.IsNullOrEmpty(result)) + { + tirRunning = true; + Logger.LogInfo($"com.jonbons.trackir: detected"); + } + else + { + Logger.LogInfo($"com.jonbons.trackir: not detected"); + } + } + } + private void OnDestroy() { if (tirClient != null && tirRunning) @@ -64,6 +86,14 @@ public class Plugin : BaseUnityPlugin private void BindSettings() { + + tirRefresh = Config.Bind( + "Main Settings", + "Refresh TrackIR", + true, + new ConfigDescription("Refresh TrackIR detection") + ); + tirEnabled = Config.Bind( "Main Settings", "TrackIR Enabled",