Compare commits
5 Commits
Author | SHA1 | Date | |
---|---|---|---|
a125b00eea | |||
36bc9014fd | |||
1b2fc9b3ef | |||
01ac535afd | |||
13c1040e77 |
@ -1,10 +1,10 @@
|
|||||||
<Project Sdk="Microsoft.NET.Sdk">
|
<Project Sdk="Microsoft.NET.Sdk">
|
||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<TargetFramework>netstandard2.0</TargetFramework>
|
<TargetFramework>netstandard2.0</TargetFramework>
|
||||||
<AssemblyName>JBTrackIR</AssemblyName>
|
<AssemblyName>JBTrackIR</AssemblyName>
|
||||||
<Description>My first plugin</Description>
|
<Description>SPT TrackIR Support</Description>
|
||||||
<Version>1.0.0</Version>
|
<Version>1.0.3</Version>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<LangVersion>latest</LangVersion>
|
<LangVersion>latest</LangVersion>
|
||||||
<RestoreAdditionalProjectSources>
|
<RestoreAdditionalProjectSources>
|
||||||
@ -23,15 +23,21 @@
|
|||||||
<Reference Include="0Harmony">
|
<Reference Include="0Harmony">
|
||||||
<HintPath>..\References\0Harmony.dll</HintPath>
|
<HintPath>..\References\0Harmony.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="Aki.Reflection">
|
|
||||||
<HintPath>..\References\Aki.Reflection.dll</HintPath>
|
|
||||||
</Reference>
|
|
||||||
<Reference Include="Assembly-CSharp">
|
<Reference Include="Assembly-CSharp">
|
||||||
<HintPath>..\References\Assembly-CSharp.dll</HintPath>
|
<HintPath>..\References\Assembly-CSharp.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
<Reference Include="BepInEx">
|
<Reference Include="BepInEx">
|
||||||
<HintPath>..\References\BepInEx.dll</HintPath>
|
<HintPath>..\References\BepInEx.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="spt-common">
|
||||||
|
<HintPath>..\References\spt-common.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="spt-core">
|
||||||
|
<HintPath>..\References\spt-core.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
|
<Reference Include="spt-reflection">
|
||||||
|
<HintPath>..\References\spt-reflection.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="TrackIRUnity">
|
<Reference Include="TrackIRUnity">
|
||||||
<HintPath>..\References\TrackIRUnity.dll</HintPath>
|
<HintPath>..\References\TrackIRUnity.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
using Aki.Reflection.Patching;
|
using SPT.Reflection.Patching;
|
||||||
using BepInEx;
|
using BepInEx;
|
||||||
using BepInEx.Configuration;
|
using BepInEx.Configuration;
|
||||||
using EFT;
|
using EFT;
|
||||||
@ -16,9 +16,10 @@ using UnityEngine;
|
|||||||
|
|
||||||
namespace JBTrackIR;
|
namespace JBTrackIR;
|
||||||
|
|
||||||
[BepInPlugin("com.jonbons.trackir", "JonBons.TrackIR", "1.0.0")]
|
[BepInPlugin("com.jonbons.trackir", "JonBons.TrackIR", "1.0.3")]
|
||||||
public class Plugin : BaseUnityPlugin
|
public class Plugin : BaseUnityPlugin
|
||||||
{
|
{
|
||||||
|
static ConfigEntry<bool> tirRefresh;
|
||||||
static ConfigEntry<bool> tirEnabled;
|
static ConfigEntry<bool> tirEnabled;
|
||||||
static ConfigEntry<float> tirSensitivityCoef;
|
static ConfigEntry<float> tirSensitivityCoef;
|
||||||
static ConfigEntry<int> tirLimitPitchLower;
|
static ConfigEntry<int> tirLimitPitchLower;
|
||||||
@ -36,9 +37,16 @@ public class Plugin : BaseUnityPlugin
|
|||||||
tirClient = new TrackIRClient();
|
tirClient = new TrackIRClient();
|
||||||
if (tirClient != null && !tirRunning)
|
if (tirClient != null && !tirRunning)
|
||||||
{
|
{
|
||||||
tirClient.TrackIR_Enhanced_Init();
|
var result = tirClient.TrackIR_Enhanced_Init();
|
||||||
tirRunning = true;
|
Logger.LogInfo($"com.jonbons.trackir: detecting... {result}");
|
||||||
Logger.LogInfo($"com.jonbons.trackir: trackir is running");
|
if (!string.IsNullOrEmpty(result))
|
||||||
|
{
|
||||||
|
tirRunning = true;
|
||||||
|
Logger.LogInfo($"com.jonbons.trackir: detected");
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Logger.LogInfo($"com.jonbons.trackir: not detected");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BindSettings();
|
BindSettings();
|
||||||
@ -46,6 +54,27 @@ public class Plugin : BaseUnityPlugin
|
|||||||
new Transpiler().Enable();
|
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()
|
private void OnDestroy()
|
||||||
{
|
{
|
||||||
if (tirClient != null && tirRunning)
|
if (tirClient != null && tirRunning)
|
||||||
@ -57,6 +86,14 @@ public class Plugin : BaseUnityPlugin
|
|||||||
|
|
||||||
private void BindSettings()
|
private void BindSettings()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
tirRefresh = Config.Bind(
|
||||||
|
"Main Settings",
|
||||||
|
"Refresh TrackIR",
|
||||||
|
true,
|
||||||
|
new ConfigDescription("Refresh TrackIR detection")
|
||||||
|
);
|
||||||
|
|
||||||
tirEnabled = Config.Bind(
|
tirEnabled = Config.Bind(
|
||||||
"Main Settings",
|
"Main Settings",
|
||||||
"TrackIR Enabled",
|
"TrackIR Enabled",
|
||||||
@ -167,6 +204,7 @@ public class Plugin : BaseUnityPlugin
|
|||||||
//rot.z = Mathf.Clamp(-tid.fNPRoll * rotationReductionFactor, rollLimits.lower, rollLimits.upper);
|
//rot.z = Mathf.Clamp(-tid.fNPRoll * rotationReductionFactor, rollLimits.lower, rollLimits.upper);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
__instance.HeadRotation = rot; // sync head angles
|
||||||
__instance.ProceduralWeaponAnimation.SetHeadRotation(rot);
|
__instance.ProceduralWeaponAnimation.SetHeadRotation(rot);
|
||||||
//Logger.LogInfo(string.Format("TIR DATA Final pos = {0}; Final rot = {1}", pos, rot));
|
//Logger.LogInfo(string.Format("TIR DATA Final pos = {0}; Final rot = {1}", pos, rot));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user