Skip to main content

OpenXRInputController

An abstract class in Root.Township, the global namespace.

Client: reads one hand's controller through OpenXR and fills the game's controller input, including velocity, finger curl and pose.

Constructors​

MemberWhat it is
OpenXRInputController(PlayerInput controller)Creates an OpenXRInputController from controller.

Fields​

MemberWhat it is
protected static readonly InputMap inputMapShared input map for OpenXR controllers.
protected static readonly OpenXRWrapper openXRWrapperShared wrapper that holds the left and right OpenXR inputs.
9 private and internal fields
MemberWhat it is
private Vector3 angularVelocityAngular velocity from UpdateAngularVelocity, passed into the input's velocities.
private const float AngularVelocityThresholdIf the frame's rotation change has a w above this, angular velocity is treated as zero.
private InputDeviceCharacteristics deviceCharacteristicsLeft or right device characteristics for this hand.
private static List<InputDevice> devicesShared scratch list of input devices.
private bool isRightHandTrue when this controller is for the right hand.
private const float LerpSpeedSeconds it takes the finger skeleton values to move fully towards their target.
private static Logger loggerNLog logger for this class.
private OpenXRControllerInput openXRInputThe hand's input state from the shared OpenXRWrapper.
private Quaternion previousRotationHand rotation from the previous frame, used for angular velocity.

Properties​

MemberWhat it is
protected override ControllerInput Input { get; }This hand's OpenXR controller input.
1 private and internal property
MemberWhat it is
private XRController Device { get; }The left or right XRController, used to send haptics.

Methods​

MemberWhat it is
override void TriggerHaptics(float strength, float frequency, float remainingTime)Sends a vibration of the given strength and time to this hand's controller.
override void UpdatePosition()Moves the hand target to the tracked controller pose, adjusted by the player height fix.
protected override void PopulateInput(ControllerInput input)Fills the input each frame: velocities, finger skeleton from touch and grip, swipe and photo button.
2 private and internal methods
MemberWhat it is
private void LerpTouchSkeleton(ControllerInput input, int index, bool isTouching, float axis, float lerp)Moves one finger's skeleton value towards its target, which depends on whether it's touching and the axis value.
private void UpdateAngularVelocity()Works out the hand's angular velocity from its rotation change since last frame, relative to the player's rotation.