Interface IInputRuntime
Input functions that have to be performed by the underlying input runtime.
Namespace: UnityEngine.Experimental.Input.LowLevel
Syntax
public interface IInputRuntime
Remarks
The runtime owns the input event queue, reports device discoveries, and runs periodic updates that flushes out events from the queue. Updates can also be manually triggered by calling Update(InputUpdateType).
Properties
currentTime
The current time on the same timeline that input events are delivered on.
Declaration
double currentTime { get; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
This is used to timestamp events that are not explicitly supplied with timestamps.
Time in the input system progresses linearly and in real-time and relates to when Unity was started.
In the editor, this always corresponds to
Input time, however, is offset in relation to
currentTimeOffsetToRealtimeSinceStartup
The time offset that currentTime currently has to
Declaration
double currentTimeOffsetToRealtimeSinceStartup { get; }
Property Value
Type | Description |
---|---|
System.Double |
fixedUpdateIntervalInSeconds
Frequency at which fixed updates are being run.
Declaration
double fixedUpdateIntervalInSeconds { get; }
Property Value
Type | Description |
---|---|
System.Double |
frameCount
Declaration
int frameCount { get; }
Property Value
Type | Description |
---|---|
System.Int32 |
onBeforeUpdate
Set delegate to be called right before onUpdate.
Declaration
Action<InputUpdateType> onBeforeUpdate { set; }
Property Value
Type | Description |
---|---|
Action<InputUpdateType> |
Remarks
This delegate is meant to allow events to be queued that should be processed right in the upcoming update.
onDeviceDiscovered
Set delegate to be called when a new device is discovered.
Declaration
Action<int, string> onDeviceDiscovered { set; }
Property Value
Type | Description |
---|---|
Action<System.Int32, System.String> |
Remarks
The runtime should delay reporting of already present devices until the delegate has been put in place and then call the delegate for every device already in the system.
First parameter is the ID assigned to the device, second parameter is a description
in JSON format of the device (see
onFocusChanged
Declaration
Action<bool> onFocusChanged { set; }
Property Value
Type | Description |
---|---|
Action<System.Boolean> |
onShutdown
Set delegate to invoke when system is shutting down.
Declaration
Action onShutdown { set; }
Property Value
Type | Description |
---|---|
Action |
onUpdate
Set delegate to be called on input updates.
Declaration
InputUpdateDelegate onUpdate { set; }
Property Value
Type | Description |
---|---|
InputUpdateDelegate |
pollingFrequency
Set the background polling frequency for devices that have to be polled.
Declaration
float pollingFrequency { set; }
Property Value
Type | Description |
---|---|
System.Single |
Remarks
The frequency is in Hz. A value of 60 means that polled devices get sampled 60 times a second.
screenOrientation
Declaration
ScreenOrientation screenOrientation { get; }
Property Value
Type | Description |
---|---|
ScreenOrientation |
screenSize
Declaration
Vector2 screenSize { get; }
Property Value
Type | Description |
---|---|
Vector2 |
updateMask
Mask that determines which input updates are executed by the runtime.
Declaration
InputUpdateType updateMask { set; }
Property Value
Type | Description |
---|---|
InputUpdateType |
Remarks
This can be used to turn off unneeded updates (like fixed updates) or turn on updates that are disabled by default (like before-render updates).
Methods
AllocateDeviceId()
Allocate a new unique device ID.
Declaration
int AllocateDeviceId()
Returns
Type | Description |
---|---|
System.Int32 | A numeric device ID that is not kInvalidDeviceId. |
Remarks
Device IDs are managed by the runtime. This method allows creating devices that can use the same ID system but are not known to the underlying runtime.
DeviceCommand(Int32, InputDeviceCommand*)
Perform an I/O transaction directly against a specific device.
Declaration
long DeviceCommand(int deviceId, InputDeviceCommand*commandPtr)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | deviceId | Device to send the command to. |
InputDeviceCommand* | commandPtr | Pointer to the command buffer. |
Returns
Type | Description |
---|---|
System.Int64 | Negative value on failure, >=0 on success. Meaning of return values depends on the command sent to the device. |
Remarks
This function is used to set up device-specific communication controls between a device and the user of a device. The interface does not dictate a set of supported IOCTL control codes.
QueueEvent(IntPtr)
Queue an input event.
Declaration
void QueueEvent(IntPtr ptr)
Parameters
Type | Name | Description |
---|---|---|
IntPtr | ptr | Pointer to the event data. Uses the InputEvent format. |
Remarks
This method has to be thread-safe.
Update(InputUpdateType)
Manually trigger an update.
Declaration
void Update(InputUpdateType type)
Parameters
Type | Name | Description |
---|---|---|
InputUpdateType | type | Type of update to run. If this is a combination of updates, each flag that is set in the mask will run a separate update. |
Remarks
Updates will flush out events and trigger onBeforeUpdate and onUpdate. Also, newly discovered devices will be reported by an update is run.