Skip to content

Commit

Permalink
woops
Browse files Browse the repository at this point in the history
  • Loading branch information
Xlinka committed Dec 16, 2023
1 parent 60c5bc1 commit e6ab14e
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 9 deletions.
2 changes: 1 addition & 1 deletion ProjectObsidian.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<HintPath>$(ResonitePath)Resonite_Data/Managed/Elements.Assets.dll</HintPath>
</Reference>
<Reference Include="SteamVR">
<HintPath>Resonite_Data/Managed/SteamVR.dll</HintPath>
<HintPath>$(ResonitePath)/Managed/SteamVR.dll</HintPath>
</Reference>
<Reference Include="System.Net.Http" />
</ItemGroup>
Expand Down
50 changes: 42 additions & 8 deletions ProtoFlux/Hardware/OpenVR/TrackerBatteryBase.cs
Original file line number Diff line number Diff line change
@@ -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<FrooxEngineContext>
{
public ObjectArgument<User> User;
public readonly ValueOutput<float> BatteryLevel;
public readonly ValueOutput<bool> IsBatteryCharging;

private ViveTracker _lastTracker;
private SyncRef<ValueStream<float>> _batteryLevelStream;
private SyncRef<ValueStream<bool>> _batteryChargingStream;

protected abstract ViveTracker GetViveTracker();

protected override void ComputeOutputs(FrooxEngineContext context)
{
User user = 0.ReadObject<User>(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<float>(this);
IsBatteryCharging = new ValueOutput<bool>(this);
}
}
}

0 comments on commit e6ab14e

Please sign in to comment.