Skip to content

TouchEvent ​

Struct

Source: TouchEvent.h

Description ​

Compact touch event structure (12 bytes total, naturally aligned)

Memory layout (naturally aligned, no packing needed):

  • timestamp: 4 bytes (offset 0)
  • x: 2 bytes (offset 4)
  • y: 2 bytes (offset 6)
  • type: 1 byte (offset 8)
  • flags: 1 byte (offset 9)
  • id: 1 byte (offset 10)
  • _padding: 1 byte (offset 11) Total: 12 bytes

Invariants:

  • timestamp always monotonically increasing per touch ID
  • x, y always valid (within display bounds)
  • type always non-None when queued

Properties ​

NameTypeDescription
timestampuint32_tTimestamp in milliseconds
xint16_tX coordinate
yint16_tY coordinate
typeuint8_tEvent type
flagsuint8_tEvent flags
iduint8_tTouch ID (0-4)
_paddinguint8_tExplicit padding for alignment

Methods ​

, x(0) ​

, y(0) ​

, type(0) ​

, flags(0) ​

, id(0) ​

, _padding(0) ​

, x(xPos) ​

, y(yPos) ​

, type(static_cast<uint8_t>(eventType)) ​

, flags(static_cast<uint8_t>(eventFlags)) ​

, id(touchId) ​

TouchEventType getType() const ​

Description:

Get event type as enum

Returns: Event type

TouchEventFlags getFlags() const ​

Description:

Get event flags as enum

Returns: Event flags

void setType(TouchEventType eventType) ​

Description:

Set event type from enum

Parameters:

  • eventType: Type of event

void setFlags(TouchEventFlags eventFlags) ​

Description:

Set event flags from enum

Parameters:

  • eventFlags: Event flags

bool isValid() const ​

Description:

Check if event is valid (has a type)

Returns: true if type is not None

bool isPrimary() const ​

Description:

Check if this is a primary touch

Returns: true if Primary flag is set

bool isConsumed() const ​

Description:

Check if event was consumed

Returns: true if Consumed flag is set

void consume() ​

Description:

Mark event as consumed

void setPrimary() ​

Description:

Set primary flag

Released under the MIT License.