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; }