natiny_input_get_touch_at

C
uint32_t natiny_input_get_touch_at(int index);

Returns the stable touch identifier at an index in the current frame's touch list.

Parameters

Name Type Description
index int Zero-based index from 0 to natiny_input_get_touch_count() minus one

Returns

Type Description
uint32_t Touch identifier, or 0 when index is outside the current list

Example

C
for (int index = 0; index < natiny_input_get_touch_count(); index++) {
    uint32_t touch = natiny_input_get_touch_at(index);
    if (natiny_input_get_touch_pressed(touch))
        begin_drag(touch);
}

Notes

  • The touch list and its indexes remain fixed for the current frame only. Store the returned identifier when tracking a touch across frames.
  • A touch identifier remains valid through its release frame and is never reused. Accessors return 0 or false after the identifier expires.
  • 0 is reserved as the invalid touch identifier.
  • Natiny tracks at most 24 touches. Additional touches are ignored until a slot becomes available.
  • Touch input is available on Android and in touch-enabled browsers. Other platforms report a touch count of 0.
  • The first active touch is also reported as the left mouse button. Do not process both APIs unless duplicate input is intended.