Struct StateEvent
A complete state snapshot for an entire input device.
Namespace: UnityEngine.InputSystem.LowLevel
Syntax
public struct StateEvent : IInputEventTypeInfo
Remarks
This is a variable-sized event.
Fields
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 |
Type
Declaration
public const int Type = null
Field Value
| Type | Description |
|---|---|
| Int32 |
Properties
state
Declaration
public void *state { get; }
Property Value
| Type | Description |
|---|---|
| Void* |
stateSizeInBytes
Declaration
public uint stateSizeInBytes { get; }
Property Value
| Type | Description |
|---|---|
| UInt32 |
typeStatic
Declaration
public FourCC typeStatic { get; }
Property Value
| Type | Description |
|---|---|
| FourCC |
Implements
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 = null)
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 ( |
Returns
| Type | Description |
|---|---|
| NativeArray<Byte> | Buffer of unmanaged memory allocated for the event. |
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 |
Returns
| Type | Description |
|---|---|
| StateEvent* | Pointer |
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 = null)
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 ( |
Returns
| Type | Description |
|---|---|
| NativeArray<Byte> | Buffer of unmanaged memory allocated for the event. |
GetEventSizeWithPayload<TState>()
Declaration
public static int GetEventSizeWithPayload<TState>()
where TState : struct
Returns
| Type | Description |
|---|---|
| Int32 |
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.
See Also
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 |
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.
See Also
ToEventPtr()
Declaration
public InputEventPtr ToEventPtr()
Returns
| Type | Description |
|---|---|
| InputEventPtr |