Class InputDevice
The root of a control hierarchy.
Inherited Members
Namespace: UnityEngine.Experimental.Input
Syntax
public class InputDevice : InputControl
Remarks
Input devices act as the container for control hierarchies. Every hierarchy has to have a device at the root. Devices cannot occur inside of hierarchies.
Unlike other controls, usages of InputDevices are allowed to be changed on the fly without requiring a change to the device layout (SetDeviceUsage(InputDevice, String)).
Constructors
InputDevice()
Declaration
public InputDevice()
Fields
kInvalidDeviceId
Declaration
public const int kInvalidDeviceId = 0
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
added
Whether the device has been added to the system.
Declaration
public bool added { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Input devices can be constructed manually through
Note that devices in disconnectedDevices will all have this property return false.
See Also
allControls
A flattened list of controls that make up the device.
Declaration
public ReadOnlyArray<InputControl> allControls { get; }
Property Value
Type | Description |
---|---|
ReadOnlyArray<InputControl> |
Remarks
Does not allocate.
canRunInBackground
If true, the device is capable of delivering input while the application is running in the background.
Declaration
public bool canRunInBackground { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Note that by default, even if capable of doing so, devices will not generate input while the application is not focused. To enable the behavior, use runInBackground.
See Also
description
Metadata describing the device (product name etc.).
Declaration
public InputDeviceDescription description { get; }
Property Value
Type | Description |
---|---|
InputDeviceDescription |
Remarks
The description of a device is unchanging over its lifetime and does not comprise data about a device's configuration (which is considered mutable).
enabled
Whether the device is currently enabled (i.e. sends and receives events).
Declaration
public bool enabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
A device that is disabled will not receive events. I.e. events that are being sent to the device will be ignored.
When disabling a native device, a
Specific types of devices can choose to start out in disabled state by default. This is generally the case for Sensor to ensure that their overhead is only incurred when actually being used by the application.
See Also
id
Unique numeric ID for the device.
Declaration
public int id { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
This is only assigned once a device has been added to the system. No two devices will receive the same ID and no device will receive an ID that another device used before even if the device was removed.
IDs are assigned by the input runtime.
lastUpdateTime
Timestamp of last state event used to update the device.
Declaration
public double lastUpdateTime { get; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
Events other than StateEvent and DeltaStateEvent will not cause lastUpdateTime to be changed.
native
Whether the device comes from the
Declaration
public bool native { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
Devices can be discovered when
Devices reported by the runtime will usually come from the Unity engine itself.
remote
Whether the device is mirrored from a remote input system and not actually present as a "real" device in the local system.
Declaration
public bool remote { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
See Also
updateBeforeRender
Whether the device requires an extra update before rendering.
Declaration
public bool updateBeforeRender { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Remarks
The value of this property is determined by
The extra update is necessary for tracking devices that are used in rendering code. For example, the eye transforms of an HMD should be refreshed right before rendering as refreshing only in the beginning of the frame will lead to a noticeable lag.
See Also
valueSizeInBytes
Declaration
public override int valueSizeInBytes { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
Overrides
valueType
Declaration
public override Type valueType { get; }
Property Value
Type | Description |
---|---|
Type |
Overrides
wasUpdatedThisFrame
Declaration
public bool wasUpdatedThisFrame { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
Methods
CompareValue(Void*, Void*)
Declaration
public override bool CompareValue(void *firstStatePtr, void *secondStatePtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | firstStatePtr | |
System.Void* | secondStatePtr |
Returns
Type | Description |
---|---|
System.Boolean |
Overrides
ExecuteCommand<TCommand>(ref TCommand)
Declaration
public long ExecuteCommand<TCommand>(ref TCommand command)where TCommand : struct, IInputDeviceCommandInfo
Parameters
Type | Name | Description |
---|---|---|
TCommand | command |
Returns
Type | Description |
---|---|
System.Int64 |
Type Parameters
Name | Description |
---|---|
TCommand |
MakeCurrent()
Make this the current device of its type.
Declaration
public virtual void MakeCurrent()
Remarks
Use this to set static properties that give fast access to the latest device used of a given
type (current or
This functionality is somewhat like a 'pwd' for the semantic paths but one where there can be multiple current working directories, one for each type.
A device will be made current by the system initially when it is created and subsequently whenever it receives an event.
OnAdded()
Declaration
protected virtual void OnAdded()
OnRemoved()
Declaration
protected virtual void OnRemoved()
ReadValueFromStateAsObject(Void*)
Declaration
public override object ReadValueFromStateAsObject(void *statePtr)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | statePtr |
Returns
Type | Description |
---|---|
System.Object |
Overrides
ReadValueFromStateIntoBuffer(Void*, Void*, Int32)
Declaration
public override void ReadValueFromStateIntoBuffer(void *statePtr, void *bufferPtr, int bufferSize)
Parameters
Type | Name | Description |
---|---|---|
System.Void* | statePtr | |
System.Void* | bufferPtr | |
System.Int32 | bufferSize |