DeviceInputController
An abstract class in Root.Township, the global namespace.
Base for a VR device or fly cam input source (SteamVR, OpenXR, fly cam). Fills a ControllerInput each update and pushes it into a PlayerInput. Client side.
- Listed in Global namespace: C to D
- Derived types
FlyCamInputController,OpenXRInputController,SteamVRInputController
Constructors
| Member | What it is |
|---|---|
protected DeviceInputController(PlayerInput controller) | Creates a DeviceInputController from controller. |
Fields
6 private and internal fields
| Member | What it is |
|---|---|
private const float DoubleTapSpeed | Window in seconds (1) for a second tap to count as a double tap. |
private float doubleTapTarget | Real time by which the second tap must land, or -1 when no tap is pending. |
private ControllerInput input | Backing field for Input, created on first use. |
private const float PhotoTime | Seconds (0.5) the photo action must be held to count as a long photo. |
private float targetPhotoTime | Real time when the held photo action becomes a long photo, or -1. |
private bool wasTapping | Tap state from the last CalculateDoubleTap call, to detect new presses. |
Properties
| Member | What it is |
|---|---|
PlayerInput PlayerInput { get; } | The PlayerInput (hand) this device feeds. |
protected virtual ControllerInput Input { get; } | The reused ControllerInput this device fills each update. |
Methods
| Member | What it is |
|---|---|
void SendInputTo(PlayerInput controller) | Fills the input from the device and applies it to the given PlayerInput, firing its events. |
abstract void TriggerHaptics(float strength, float frequency, float remainingTime) | Plays a vibration with the given strength, frequency and duration. |
virtual void UpdatePosition() | Per-device hook to update the tracked position. Does nothing in the base class. |
protected bool CalculateDoubleTap(bool isTapping) | Helper for subclasses: true on the second tap within one second. |
protected bool CalculatePhoto(ControllerInput input, bool photoAction) | Helper for subclasses: true once the photo action has been held for half a second. |
protected abstract void PopulateInput(ControllerInput input) | Implemented per device to read the hardware into the input. |
Used in
Members of other types that take, return or hold a DeviceInputController:
AutoCamDeviceController.CreateController, FlyCamDeviceController.CreateController, IXrDeviceSdkController.CreateController, OpenXRDeviceController.CreateController, PlayerInput.inputController, PlayerInput.InputController, PlayerInput.SetPlatformController, SteamVRDeviceController.CreateController, XrDeviceSdkController.CreateController.