using Facepunch.XR; namespace Sandbox.VR; /// /// Represents a VR digital input action (e.g. X button) /// public struct DigitalInput { internal readonly InputBooleanActionState _data; /// /// The current value of this input - true if pressed, false if not pressed. /// public readonly bool IsPressed => _data.state != 0; /// /// The previous value of this input - true if it was pressed, false if it was not pressed. /// public readonly bool WasPressed { get; private init; } /// /// How much has changed since the last update. /// public readonly bool Delta { get; private init; } /// /// Whether or not this action is currently accessible (if false, then will always be false and will never change). /// public readonly bool Active => _data.isActive; internal DigitalInput( DigitalInput? previous, VRNative.BooleanAction action, InputSource inputSource ) { _data = VRNative.GetBooleanActionState( action, inputSource ); if ( previous != null ) { WasPressed = previous.Value.IsPressed; Delta = IsPressed != WasPressed; } } /// /// Implicitly returns as a . /// public static implicit operator bool( DigitalInput o ) { return o.IsPressed; } }