Struct InputEvent
A chunk of memory signaling a data transfer in the input system.
Namespace: UnityEngine.InputSystem.LowLevel
Syntax
public struct InputEvent
Constructors
InputEvent(FourCC, Int32, Int32, Double)
Declaration
public InputEvent(FourCC type, int sizeInBytes, int deviceId, double time = -1)
Parameters
Type | Name | Description |
---|---|---|
FourCC | type | |
System.Int32 | sizeInBytes | |
System.Int32 | deviceId | |
System.Double | time |
Fields
InvalidId
Declaration
public const int InvalidId = 0
Field Value
Type | Description |
---|---|
System.Int32 |
Properties
deviceId
ID of the device that the event is for.
Declaration
public int deviceId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Device IDs are allocated by the IInputRuntime. No two devices will receive the same ID over an application lifecycle regardless of whether the devices existed at the same time or not.
See Also
eventId
Unique serial ID of the event.
Declaration
public int eventId { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Remarks
Events are assigned running IDs when they are put on an event queue.
handled
Declaration
public bool handled { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
sizeInBytes
Total size of the event in bytes.
Declaration
public uint sizeInBytes { get; set; }
Property Value
Type | Description |
---|---|
System.UInt32 |
Remarks
Events are variable-size structs. This field denotes the total size of the event as stored in memory. This includes the full size of this struct and not just the "payload" of the event.
Examples
Store event in private buffer:
unsafe byte[] CopyEventData(InputEventPtr eventPtr)
{
var sizeInBytes = eventPtr.sizeInBytes;
var buffer = new byte[sizeInBytes];
fixed (byte* bufferPtr = buffer)
{
UnsafeUtility.MemCpy(new IntPtr(bufferPtr), eventPtr.data, sizeInBytes);
}
return buffer;
}
time
Time that the event was generated at.
Declaration
public double time { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
Times are in seconds and progress linearly in real-time. The timeline is the
same as for
type
Type code for the event.
Declaration
public FourCC type { get; set; }
Property Value
Type | Description |
---|---|
FourCC |
Methods
ToString()
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String |