Struct InputEventBuffer | Package Manager UI website
docs.unity3d.com
    Show / Hide Table of Contents

    Struct InputEventBuffer

    A buffer of raw memory holding a sequence of InputEvent.

    Namespace: UnityEngine.InputSystem.LowLevel
    Syntax
    public struct InputEventBuffer : IEnumerable<InputEventPtr>, IEnumerable, IDisposable, ICloneable
    Remarks

    Note that event buffers are not thread-safe. It is not safe to write events to the buffer concurrently from multiple threads. It is, however, safe to traverse the contents of an existing buffer from multiple threads as long as it is not mutated at the same time.

    Constructors

    InputEventBuffer(NativeArray<Byte>, Int32, Int32)

    Declaration
    public InputEventBuffer(NativeArray<byte> buffer, int eventCount, int sizeInBytes = -1)
    Parameters
    Type Name Description
    NativeArray<System.Byte> buffer
    System.Int32 eventCount
    System.Int32 sizeInBytes

    InputEventBuffer(InputEvent*, Int32, Int32, Int32)

    Declaration
    public InputEventBuffer(InputEvent*eventPtr, int eventCount, int sizeInBytes = -1, int capacityInBytes = -1)
    Parameters
    Type Name Description
    InputEvent* eventPtr
    System.Int32 eventCount
    System.Int32 sizeInBytes
    System.Int32 capacityInBytes

    Fields

    BufferSizeUnknown

    Declaration
    public const long BufferSizeUnknown = -1L
    Field Value
    Type Description
    System.Int64

    Properties

    bufferPtr

    Declaration
    public InputEventPtr bufferPtr { get; }
    Property Value
    Type Description
    InputEventPtr

    capacityInBytes

    Amount of unused bytes in the currently allocated buffer.

    Declaration
    public long capacityInBytes { get; }
    Property Value
    Type Description
    System.Int64
    Remarks

    A buffer's capacity determines how much event data can be written to the buffer before it has to be reallocated.

    data

    Declaration
    public NativeArray<byte> data { get; }
    Property Value
    Type Description
    NativeArray<System.Byte>

    eventCount

    Total number of events in the buffer.

    Declaration
    public int eventCount { get; }
    Property Value
    Type Description
    System.Int32

    sizeInBytes

    Size of the buffer in bytes.

    Declaration
    public long sizeInBytes { get; }
    Property Value
    Type Description
    System.Int64
    Remarks

    If the size is not known, returns BufferSizeUnknown.

    Note that the size does not usually correspond to eventCount times sizeof(InputEvent). InputEvent are variable in size.

    Methods

    AllocateEvent(Int32, Int32)

    Declaration
    public InputEvent*AllocateEvent(int sizeInBytes, int capacityIncrementInBytes = 2048)
    Parameters
    Type Name Description
    System.Int32 sizeInBytes
    System.Int32 capacityIncrementInBytes
    Returns
    Type Description
    InputEvent*

    AppendEvent(InputEvent*, Int32)

    Append a new event to the end of the buffer.

    Declaration
    public void AppendEvent(InputEvent*eventPtr, int capacityIncrementInBytes = 2048)
    Parameters
    Type Name Description
    InputEvent* eventPtr
    System.Int32 capacityIncrementInBytes
    Remarks

    If the buffer's current capacityInBytes is smaller than the sizeInBytes of the given eventPtr,

    Exceptions
    Type Condition
    System.ArgumentNullException
    System.ArgumentException

    Clone()

    Declaration
    public InputEventBuffer Clone()
    Returns
    Type Description
    InputEventBuffer

    Contains(InputEvent*)

    Whether the given event pointer refers to data within the event buffer.

    Declaration
    public bool Contains(InputEvent*eventPtr)
    Parameters
    Type Name Description
    InputEvent* eventPtr
    Returns
    Type Description
    System.Boolean
    Remarks

    Note that this method does NOT check whether the given pointer points to an actual event in the buffer. It solely performs a pointer out-of-bounds check.

    Also note that if the size of the memory buffer is unknown (BufferSizeUnknown, only a lower-bounds check is performed.

    Dispose()

    Declaration
    public void Dispose()

    GetEnumerator()

    Declaration
    public IEnumerator<InputEventPtr> GetEnumerator()
    Returns
    Type Description
    System.Collections.Generic.IEnumerator<InputEventPtr>

    Reset()

    Declaration
    public void Reset()
    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