From e6ab14ef127feb8a2ebf432b0f697b0f902dbedb Mon Sep 17 00:00:00 2001 From: xLinka Date: Sat, 16 Dec 2023 16:08:32 +0000 Subject: [PATCH] woops --- ProjectObsidian.csproj | 2 +- .../Hardware/OpenVR/TrackerBatteryBase.cs | 50 ++++++++++++++++--- 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/ProjectObsidian.csproj b/ProjectObsidian.csproj index e6ed960..9738e67 100644 --- a/ProjectObsidian.csproj +++ b/ProjectObsidian.csproj @@ -41,7 +41,7 @@ $(ResonitePath)Resonite_Data/Managed/Elements.Assets.dll - Resonite_Data/Managed/SteamVR.dll + $(ResonitePath)/Managed/SteamVR.dll diff --git a/ProtoFlux/Hardware/OpenVR/TrackerBatteryBase.cs b/ProtoFlux/Hardware/OpenVR/TrackerBatteryBase.cs index 5bb0dca..3f5816d 100644 --- a/ProtoFlux/Hardware/OpenVR/TrackerBatteryBase.cs +++ b/ProtoFlux/Hardware/OpenVR/TrackerBatteryBase.cs @@ -1,12 +1,46 @@ using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; +using FrooxEngine; +using FrooxEngine.ProtoFlux; +using ProtoFlux.Core; +using ProtoFlux.Runtimes.Execution; -namespace Project-Obsidian.ProtoFlux.Hardware.OpenVR +namespace Obsidian { - internal class FileName -{ -} + public abstract class TrackerBatteryBase : VoidNode + { + public ObjectArgument User; + public readonly ValueOutput BatteryLevel; + public readonly ValueOutput IsBatteryCharging; + + private ViveTracker _lastTracker; + private SyncRef> _batteryLevelStream; + private SyncRef> _batteryChargingStream; + + protected abstract ViveTracker GetViveTracker(); + + protected override void ComputeOutputs(FrooxEngineContext context) + { + User user = 0.ReadObject(context); + if (user != null && user.IsRemoved) + { + user = null; + } + ViveTracker device = GetViveTracker(); + if (device != _lastTracker) + { + _batteryLevelStream.Target = device?.BatteryLevel.GetStream(context.World); + _batteryChargingStream.Target = device?.BatteryCharging.GetStream(context.World); + _lastTracker = device; + } + + BatteryLevel.Write(_batteryLevelStream.Target?.Value ?? -1f, context); + IsBatteryCharging.Write(_batteryChargingStream.Target?.Value ?? false, context); + } + + public TrackerBatteryBase() + { + BatteryLevel = new ValueOutput(this); + IsBatteryCharging = new ValueOutput(this); + } + } }