Interface IInputRuntime | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Interface IInputRuntime

    Input functions that have to be performed by the underlying input runtime.

    Namespace: UnityEngine.InputSystem.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 . This is because in the player, is reset to 0 upon loading the first scene and in the editor, is reset to 0 whenever the editor enters play mode. As the resetting runs counter to the need of linearly progressing time for input, the input system will not reset time along with .

    currentTimeForFixedUpdate

    The current time on the same timeline that input events are delivered on, for the current FixedUpdate.

    Declaration
    double currentTimeForFixedUpdate { get; }
    Property Value
    Type Description
    System.Double
    Remarks

    This should be used inside FixedUpdate calls instead of currentTime, as FixedUpdates are simulated at times not matching the real time the simulation corresponds to.

    currentTimeOffsetToRealtimeSinceStartup

    The time offset that currentTime currently has to .

    Declaration
    double currentTimeOffsetToRealtimeSinceStartup { get; }
    Property Value
    Type Description
    System.Double

    isInBatchMode

    Declaration
    bool isInBatchMode { get; }
    Property Value
    Type Description
    System.Boolean

    onBeforeUpdate

    Set delegate to be called right before onUpdate.

    Declaration
    Action<InputUpdateType> onBeforeUpdate { get; set; }
    Property Value
    Type Description
    System.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 { get; set; }
    Property Value
    Type Description
    System.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 FromJson(String)).

    onPlayerFocusChanged

    Set delegate to call when the application changes focus.

    Declaration
    Action<bool> onPlayerFocusChanged { get; set; }
    Property Value
    Type Description
    System.Action<System.Boolean>

    onShouldRunUpdate

    Declaration
    Func<InputUpdateType, bool> onShouldRunUpdate { get; set; }
    Property Value
    Type Description
    System.Func<InputUpdateType, System.Boolean>

    onShutdown

    Set delegate to invoke when system is shutting down.

    Declaration
    Action onShutdown { get; set; }
    Property Value
    Type Description
    System.Action

    onUpdate

    Set delegate to be called on input updates.

    Declaration
    InputUpdateDelegate onUpdate { get; set; }
    Property Value
    Type Description
    InputUpdateDelegate

    pollingFrequency

    Set the background polling frequency for devices that have to be polled.

    Declaration
    float pollingFrequency { get; 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

    Methods

    AllocateDeviceId()

    Allocate a new unique device ID.

    Declaration
    int AllocateDeviceId()
    Returns
    Type Description
    System.Int32

    A numeric device ID that is not InvalidDeviceId.

    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(InputEvent*)

    Queue an input event.

    Declaration
    void QueueEvent(InputEvent*ptr)
    Parameters
    Type Name Description
    InputEvent* 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.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023