natiny_input_get_touch_count
int natiny_input_get_touch_count(void);
Returns the number of touch identifiers available in the current frame. The count includes touches released during this frame.
Returns
| Type | Description |
|---|---|
int |
Number of available touch identifiers, from 0 to 24 |
Example
for (int i = 0; i < natiny_input_get_touch_count(); i++) {
uint32_t touch = natiny_input_get_touch_at(i);
natiny_render_circle((float)natiny_input_get_touch_x(touch),
(float)natiny_input_get_touch_y(touch), 24.0f);
}
Notes
- The count remains fixed for the current frame. A touch that starts during a frame appears in the next frame.
- A released touch remains in the list for its release frame. This preserves a
tap that starts and ends between two frames. See
natiny_input_get_touch_released. - Pass each index to
natiny_input_get_touch_at. The other touch functions take the returned identifier, not the index. - 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 return
0. - The first active touch is also reported as the left mouse button. Do not process both APIs unless duplicate input is intended.