Added ability to trigger a refresh of TrackIR detection

This commit is contained in:
jonbons 2024-05-05 20:21:30 -05:00
parent 13c1040e77
commit cd7ffa2ce1
No known key found for this signature in database
2 changed files with 32 additions and 2 deletions

View File

@ -4,7 +4,7 @@
<TargetFramework>netstandard2.0</TargetFramework>
<AssemblyName>JBTrackIR</AssemblyName>
<Description>SPT TrackIR Support</Description>
<Version>1.0.1</Version>
<Version>1.0.2</Version>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>latest</LangVersion>
<RestoreAdditionalProjectSources>

View File

@ -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<bool> tirRefresh;
static ConfigEntry<bool> tirEnabled;
static ConfigEntry<float> tirSensitivityCoef;
static ConfigEntry<int> 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",