Table of Contents

Class TouchController

Namespace
Stride.VirtualReality
Assembly
Stride.VirtualReality.dll

A VR hand controller. It is an input device: an owner such as a VR menu can capture it, and while it is captured its buttons, touches and axes report no input to scripts and systems. Its pose and haptics are not affected.

public abstract class TouchController : IInputDevice, IDisposable
Inheritance
object
TouchController
Implements
Extension Methods

Remarks

Backends provide the controller's input through the protected raw members. The public queries apply the controller's CaptureState to them.

Constructors

TouchController()

protected TouchController()

Properties

AngularVelocity

public abstract Vector3 AngularVelocity { get; }

Property Value

Vector3

CaptureState

The capture state of this device. Only InputManager changes it.

public DeviceCaptureState CaptureState { get; }

Property Value

DeviceCaptureState

Remarks

Return the same instance on every call, for example from { get; } = new DeviceCaptureState();.

Grip

Gets the grip value, from 0 to 1. It reads 0 while the controller is captured.

public float Grip { get; }

Property Value

float

HapticsSupport

Degree to which this touch controller type supports haptics. None: no haptics support, controller does not vibrate. Limited: cannot vibrate at any specific frequency or amplitude. Corresponding parameter is ignored. Full: vibrate method respects both frequency and vibration parameters

public abstract TouchController.ControllerHaptics HapticsSupport { get; }

Property Value

TouchController.ControllerHaptics

Id

The unique identifier of this device

public Guid Id { get; }

Property Value

Guid

IndexPointing

Gets whether the index finger points, off the trigger. It reads false while the controller is captured.

public bool IndexPointing { get; }

Property Value

bool

IndexResting

Gets whether the index finger rests on the trigger. It reads false while the controller is captured.

public bool IndexResting { get; }

Property Value

bool

LinearVelocity

public abstract Vector3 LinearVelocity { get; }

Property Value

Vector3

Name

The name of the device

public virtual string Name { get; }

Property Value

string

Position

public abstract Vector3 Position { get; }

Property Value

Vector3

Priority

The device priority. Larger means higher priority when selecting the first device of some type

public int Priority { get; set; }

Property Value

int

RawGrip

Gets the grip value reported by the backend, whether or not the controller is captured.

protected abstract float RawGrip { get; }

Property Value

float

RawIndexPointing

Gets whether the backend reports the index finger pointing, whether or not the controller is captured.

protected abstract bool RawIndexPointing { get; }

Property Value

bool

RawIndexResting

Gets whether the backend reports the index finger resting on the trigger, whether or not the controller is captured.

protected abstract bool RawIndexResting { get; }

Property Value

bool

RawThumbAxis

Gets the thumb position on the touchpad or the thumbstick reported by the backend, whether or not the controller is captured.

protected abstract Vector2 RawThumbAxis { get; }

Property Value

Vector2

RawThumbResting

Gets whether the backend reports the thumb resting on the thumb controls, whether or not the controller is captured.

protected abstract bool RawThumbResting { get; }

Property Value

bool

RawThumbUp

Gets whether the backend reports the thumb up, whether or not the controller is captured.

protected abstract bool RawThumbUp { get; }

Property Value

bool

RawThumbstickAxis

Gets the thumbstick position reported by the backend, whether or not the controller is captured.

protected abstract Vector2 RawThumbstickAxis { get; }

Property Value

Vector2

RawTrigger

Gets the trigger value reported by the backend, whether or not the controller is captured.

protected abstract float RawTrigger { get; }

Property Value

float

Rotation

public abstract Quaternion Rotation { get; }

Property Value

Quaternion

Source

Gets the input source the controller is registered with, or null before the VR system registers it.

public IInputSource Source { get; }

Property Value

IInputSource

State

public abstract DeviceState State { get; }

Property Value

DeviceState

ThumbAxis

Gets the thumb position on the touchpad or the thumbstick, depending on the backend. It reads zero while the controller is captured.

public Vector2 ThumbAxis { get; }

Property Value

Vector2

ThumbResting

Gets whether the thumb rests on the thumb controls. It reads false while the controller is captured.

public bool ThumbResting { get; }

Property Value

bool

ThumbUp

Gets whether the thumb is up, off the thumb controls. It reads false while the controller is captured.

public bool ThumbUp { get; }

Property Value

bool

ThumbstickAxis

Gets the thumbstick position. It reads zero while the controller is captured.

public Vector2 ThumbstickAxis { get; }

Property Value

Vector2

Trigger

Gets the trigger value, from 0 to 1. It reads 0 while the controller is captured.

public float Trigger { get; }

Property Value

float

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public virtual void Dispose()

IsPressReleased(TouchControllerButton)

Returns true if in this frame the button was released

public bool IsPressReleased(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsPressed(TouchControllerButton)

Returns true if button is in the pressed state

public bool IsPressed(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsPressedDown(TouchControllerButton)

Returns true if in this frame the button switched to pressed state

public bool IsPressedDown(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsRawPressReleased(TouchControllerButton)

Returns true if the backend reports that the button was released this frame.

protected abstract bool IsRawPressReleased(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsRawPressed(TouchControllerButton)

Returns true if the backend reports the button in the pressed state.

protected abstract bool IsRawPressed(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsRawPressedDown(TouchControllerButton)

Returns true if the backend reports that the button switched to the pressed state this frame.

protected abstract bool IsRawPressedDown(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsRawTouchReleased(TouchControllerButton)

Returns true if the backend reports that the button stopped being touched this frame.

protected abstract bool IsRawTouchReleased(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsRawTouched(TouchControllerButton)

Returns true if the backend reports the button in the touched state.

protected abstract bool IsRawTouched(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsRawTouchedDown(TouchControllerButton)

Returns true if the backend reports that the button switched to the touched state this frame.

protected abstract bool IsRawTouchedDown(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsTouchReleased(TouchControllerButton)

Returns true if in this frame the button stopped being touched

public bool IsTouchReleased(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsTouched(TouchControllerButton)

Returns true if button is in the touched state

public bool IsTouched(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

IsTouchedDown(TouchControllerButton)

Returns true if in this frame the button switched to touched state

public bool IsTouchedDown(TouchControllerButton button)

Parameters

button TouchControllerButton

Returns

bool

Update(GameTime)

public virtual void Update(GameTime time)

Parameters

time GameTime

Vibrate(int, float, float)

Vibrate the controller for a fixed duration. Do so at specified frequency/amplitude if supported by runtime. Oculus runtime supports vibrating at frequency 0.0, 0.5, or 1.0, and amplitude in range [0.0, 1.0] openVR supports vibrating, but does not support frequency or amplitude openXR and WindowsMixedReality currently do not support vibration.

public abstract Task Vibrate(int durationMs, float frequency = 1, float amplitude = 1)

Parameters

durationMs int

Vibration duration, in milliseconds

frequency float

Frequency of vibration in range [0.0, 1.0]

amplitude float

Amplitude of vibration in range [0.0, 1.0]

Returns

Task