Struct XRSimulatedControllerState
State for input device representing a simulated XR handed controller.
Implements
Inherited Members
Namespace: UnityEngine .XR.Interaction.Toolkit.Inputs.Simulation
Assembly: Unity.XR.Interaction.Toolkit.dll
Syntax
public struct XRSimulatedControllerState : IInputStateTypeInfo
Fields
batteryLevel
Value representing the current battery life of this device.
Declaration
[InputControl(usage = "BatteryLevel", layout = "Axis", offset = 26)]
public float batteryLevel
Field Value
Type | Description |
---|---|
float |
buttons
All the buttons on this device.
Declaration
[InputControl(name = "primaryButton", usage = "PrimaryButton", layout = "Button", bit = 0, offset = 24)]
[InputControl(name = "primaryTouch", usage = "PrimaryTouch", layout = "Button", bit = 1, offset = 24)]
[InputControl(name = "secondaryButton", usage = "SecondaryButton", layout = "Button", bit = 2, offset = 24)]
[InputControl(name = "secondaryTouch", usage = "SecondaryTouch", layout = "Button", bit = 3, offset = 24)]
[InputControl(name = "gripButton", usage = "GripButton", layout = "Button", bit = 4, offset = 24, alias = "gripPressed")]
[InputControl(name = "triggerButton", usage = "TriggerButton", layout = "Button", bit = 5, offset = 24, alias = "triggerPressed")]
[InputControl(name = "menuButton", usage = "MenuButton", layout = "Button", bit = 6, offset = 24)]
[InputControl(name = "primary2DAxisClick", usage = "Primary2DAxisClick", layout = "Button", bit = 7, offset = 24)]
[InputControl(name = "primary2DAxisTouch", usage = "Primary2DAxisTouch", layout = "Button", bit = 8, offset = 24)]
[InputControl(name = "secondary2DAxisClick", usage = "Secondary2DAxisClick", layout = "Button", bit = 9, offset = 24)]
[InputControl(name = "secondary2DAxisTouch", usage = "Secondary2DAxisTouch", layout = "Button", bit = 10, offset = 24)]
[InputControl(name = "userPresence", usage = "UserPresence", layout = "Button", bit = 11, offset = 24)]
public ushort buttons
Field Value
Type | Description |
---|---|
ushort |
devicePosition
The position of the device.
Declaration
[InputControl(usage = "DevicePosition", offset = 35)]
public Vector3 devicePosition
Field Value
Type | Description |
---|---|
Vector3 |
deviceRotation
The rotation of this device.
Declaration
[InputControl(usage = "DeviceRotation", offset = 47)]
public Quaternion deviceRotation
Field Value
Type | Description |
---|---|
Quaternion |
grip
Represents the user's grip on the controller.
Declaration
[InputControl(usage = "Grip", layout = "Axis", offset = 12)]
public float grip
Field Value
Type | Description |
---|---|
float |
isTracked
Informs to the developer whether the device is currently being tracked.
Declaration
[InputControl(usage = "IsTracked", layout = "Button", offset = 34)]
public bool isTracked
Field Value
Type | Description |
---|---|
bool |
primary2DAxis
The primary touchpad or joystick on a device.
Declaration
[InputControl(usage = "Primary2DAxis", aliases = new string[] { "thumbstick", "joystick" }, offset = 0)]
public Vector2 primary2DAxis
Field Value
Type | Description |
---|---|
Vector2 |
secondary2DAxis
A secondary touchpad or joystick on a device.
Declaration
[InputControl(usage = "Secondary2DAxis", offset = 16)]
public Vector2 secondary2DAxis
Field Value
Type | Description |
---|---|
Vector2 |
trackingState
Represents the values being tracked for this device.
Declaration
[InputControl(usage = "TrackingState", layout = "Integer", offset = 30)]
public int trackingState
Field Value
Type | Description |
---|---|
int |
trigger
A trigger-like control, pressed with the index finger.
Declaration
[InputControl(usage = "Trigger", layout = "Axis", offset = 8)]
public float trigger
Field Value
Type | Description |
---|---|
float |
Properties
format
The data format identifier of the state.
Declaration
public FourCC format { get; }
Property Value
Type | Description |
---|---|
Four |
formatId
Memory format identifier for XRSimulated
Declaration
public static FourCC formatId { get; }
Property Value
Type | Description |
---|---|
Four |
See Also
Methods
HasButton(ControllerButton)
Gets whether the button mask has the given button
set.
Declaration
public bool HasButton(ControllerButton button)
Parameters
Type | Name | Description |
---|---|---|
Controller |
button | Button whose state is queried. |
Returns
See Also
Reset()
Resets the value of all fields to default or the identity rotation.
Declaration
public void Reset()
ToggleButton(ControllerButton)
Toggles the button mask for the given button
.
Declaration
public XRSimulatedControllerState ToggleButton(ControllerButton button)
Parameters
Type | Name | Description |
---|---|---|
Controller |
button | Button whose state to toggle. |
Returns
Type | Description |
---|---|
XRSimulated |
The same XRSimulated |
See Also
WithButton(ControllerButton, bool)
Set the button mask for the given button
.
Declaration
public XRSimulatedControllerState WithButton(ControllerButton button, bool state = true)
Parameters
Type | Name | Description |
---|---|---|
Controller |
button | Button whose state to set. |
bool | state | Whether to set the bit on or off. |
Returns
Type | Description |
---|---|
XRSimulated |
The same XRSimulated |