docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Struct StateEvent

    A complete state snapshot for an entire input device.

    Implements
    IInputEventTypeInfo
    Inherited Members
    ValueType.Equals(object)
    ValueType.GetHashCode()
    ValueType.ToString()
    Namespace: UnityEngine.InputSystem.LowLevel
    Assembly: Unity.InputSystem.dll
    Syntax
    public struct StateEvent : IInputEventTypeInfo
    Remarks

    This is a variable-sized event.

    Fields

    Type

    Declaration
    public const int Type = 1398030676
    Field Value
    Type Description
    int

    baseEvent

    Declaration
    public InputEvent baseEvent
    Field Value
    Type Description
    InputEvent

    stateFormat

    Type code for the state stored in the event.

    Declaration
    public FourCC stateFormat
    Field Value
    Type Description
    FourCC

    Properties

    state

    Declaration
    public void* state { get; }
    Property Value
    Type Description
    void*

    stateSizeInBytes

    Declaration
    public uint stateSizeInBytes { get; }
    Property Value
    Type Description
    uint

    typeStatic

    Declaration
    public FourCC typeStatic { get; }
    Property Value
    Type Description
    FourCC

    Methods

    From(InputDevice, out InputEventPtr, Allocator)

    Read the current state of device and create a state event from it.

    Declaration
    public static NativeArray<byte> From(InputDevice device, out InputEventPtr eventPtr, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    InputDevice device

    Device to grab the state from. Must be a device that has been added to the system.

    InputEventPtr eventPtr

    Receives a pointer to the newly created state event.

    Allocator allocator

    Which native allocator to allocate memory for the event from. By default, the buffer is allocated as temporary memory (Temp. Note that this means the buffer will not be valid past the current frame. Use Persistent if the buffer for the state event is meant to persist for longer.

    Returns
    Type Description
    NativeArray<byte>

    Buffer of unmanaged memory allocated for the event.

    Exceptions
    Type Condition
    ArgumentException

    device has not been added to the system.

    ArgumentNullException

    device is null.

    From(InputEventPtr)

    Return the given InputEventPtr as a StateEvent pointer.

    Declaration
    public static StateEvent* From(InputEventPtr ptr)
    Parameters
    Type Name Description
    InputEventPtr ptr

    A pointer to an input event. The pointer is checked for null and for whether the type of event it refers to is indeed a StateEvent.

    Returns
    Type Description
    StateEvent*

    Pointer ptr converted to a StateEvent pointer.

    Exceptions
    Type Condition
    ArgumentNullException

    ptr is default(InputEventPtr).

    InvalidCastException

    ptr does not refer to a StateEvent.

    FromDefaultStateFor(InputDevice, out InputEventPtr, Allocator)

    Create a state event for the given device and copy the default state of the device into the event.

    Declaration
    public static NativeArray<byte> FromDefaultStateFor(InputDevice device, out InputEventPtr eventPtr, Allocator allocator = Allocator.Temp)
    Parameters
    Type Name Description
    InputDevice device

    Device to create a state event for. Must be a device that has been added to the system.

    InputEventPtr eventPtr

    Receives a pointer to the newly created state event.

    Allocator allocator

    Which native allocator to allocate memory for the event from. By default, the buffer is allocated as temporary memory (Temp. Note that this means the buffer will not be valid past the current frame. Use Persistent if the buffer for the state event is meant to persist for longer.

    Returns
    Type Description
    NativeArray<byte>

    Buffer of unmanaged memory allocated for the event.

    Exceptions
    Type Condition
    ArgumentException

    device has not been added to the system.

    ArgumentNullException

    device is null.

    GetEventSizeWithPayload<TState>()

    Declaration
    public static int GetEventSizeWithPayload<TState>() where TState : struct
    Returns
    Type Description
    int
    Type Parameters
    Name Description
    TState

    GetState<TState>()

    Retrieve the state stored in the event.

    Declaration
    public TState GetState<TState>() where TState : struct, IInputStateTypeInfo
    Returns
    Type Description
    TState

    Copy of the state stored in the event.

    Type Parameters
    Name Description
    TState

    Type of state expected to be stored in the event. format must match stateFormat.

    Remarks

    The event may contain less or more data than what is found in the struct. Only the data found in the event is copied. The remainder of the struct is left at default values.

    Exceptions
    Type Condition
    InvalidOperationException

    stateFormat does not match format of TState.

    See Also
    GetState<TState>(InputEventPtr)

    GetState<TState>(InputEventPtr)

    Retrieve the state stored in the event.

    Declaration
    public static TState GetState<TState>(InputEventPtr ptr) where TState : struct, IInputStateTypeInfo
    Parameters
    Type Name Description
    InputEventPtr ptr

    A pointer to an input event. The pointer is checked for null and for whether the type of event it refers to is indeed a StateEvent.

    Returns
    Type Description
    TState

    Copy of the state stored in the event.

    Type Parameters
    Name Description
    TState

    Type of state expected to be stored in the event. format must match stateFormat.

    Remarks

    The event may contain less or more data than what is found in the struct. Only the data found in the event is copied. The remainder of the struct is left at default values.

    Exceptions
    Type Condition
    InvalidOperationException

    stateFormat does not match format of TState.

    ArgumentNullException

    ptr is default(InputEventPtr).

    InvalidCastException

    ptr does not refer to a StateEvent.

    See Also
    GetState<TState>()

    ToEventPtr()

    Declaration
    public InputEventPtr ToEventPtr()
    Returns
    Type Description
    InputEventPtr

    Implements

    IInputEventTypeInfo
    In This Article
    Back to top
    Copyright © 2024 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)