-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |