From 278c96d07cb8328f967f42e5aa7789d7869431e7 Mon Sep 17 00:00:00 2001 From: Igor Chernakov Date: Mon, 5 Oct 2026 19:47:42 +0200 Subject: [PATCH] Tag finger touches and stamp touch samples with their time iOS marks direct finger touches with AX_POINTER_TOUCH and records each sample's UITouch timestamp in ax_pointer_t.time, so the framework can tell fingers from mouse and stylus and measure holds and swipe velocity. Co-Authored-By: Claude Opus 5.5 --- events.h | 5 +++-- ios/ios_window.m | 3 +++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/events.h b/events.h index 0e79454..a2b88ce 100644 --- a/events.h +++ b/events.h @@ -42,10 +42,11 @@ typedef struct { float scale, rotation; // Incremental scale factor and clockwise radians. } ax_gesture_t; -enum { AX_POINTER_STYLUS = 1u << 0 }; +enum { AX_POINTER_STYLUS = 1u << 0, AX_POINTER_TOUCH = 1u << 1 }; typedef struct { - uint32_t flags; /**< AX_POINTER_STYLUS when the sample is a stylus / Apple Pencil. */ + uint32_t flags; /**< AX_POINTER_STYLUS for a stylus / Apple Pencil, AX_POINTER_TOUCH for a finger. */ float altitude; /**< Radians: 0 = parallel to the surface, π/2 = perpendicular. */ + uint32_t time; /**< Sample time in milliseconds for touch samples; 0 when unknown. */ } ax_pointer_t; #endif diff --git a/ios/ios_window.m b/ios/ios_window.m index 34e9394..344f7d2 100644 --- a/ios/ios_window.m +++ b/ios/ios_window.m @@ -20,7 +20,10 @@ static ax_pointer_t ios_pointer(UITouch *touch) { if (touch.type == UITouchTypePencil) { p.flags = AX_POINTER_STYLUS; p.altitude = (float)touch.altitudeAngle; + } else if (touch.type == UITouchTypeDirect) { + p.flags = AX_POINTER_TOUCH; } + p.time = (uint32_t)(uint64_t)(touch.timestamp * 1000); return p; }