From faaa6230a1999b1a9d2c3e1d6a49145c1e7dbb00 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 21:17:07 +0800 Subject: [PATCH] revert long long change --- src/platforms/rcore_ios.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index fea3bfd12..e09ee6354 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -644,6 +644,15 @@ void ClosePlatform(void) return false; } +static int map_point_id(UITouch* touch){ + int value = (int)(long long)touch; + // handle collisions + while(array_index_of(value, CORE.Input.Touch.pointId, MAX_TOUCH_POINTS) >= 0){ + value++; + } + return value; +} + static void sync_all_touches(UIEvent* event) { CORE.Input.Touch.pointCount = (int)event.allTouches.count; @@ -652,14 +661,14 @@ static void sync_all_touches(UIEvent* event) { CGPoint location = [touch locationInView:platform.viewController.view]; CORE.Input.Touch.position[i] = (Vector2){ location.x, location.y }; - CORE.Input.Touch.pointId[i] = (long long)touch; + CORE.Input.Touch.pointId[i] = map_point_id(touch); i++; if(i >= MAX_TOUCH_POINTS) break; } // TODO: Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height } -static int array_index_of(long long needle, long long *haystack, int size) +static int array_index_of(int needle, int *haystack, int size) { for (int i = 0; i < size; i++) if(haystack[i] == needle) return i; return -1; @@ -693,7 +702,7 @@ static void send_gesture_event(NSSet * touches, int action) { int size = CORE.Input.Touch.pointCount; if(size > MAX_TOUCH_POINTS) size = MAX_TOUCH_POINTS; - int i = array_index_of((long long)touch, CORE.Input.Touch.pointId, size); + int i = array_index_of(map_point_id(touch), CORE.Input.Touch.pointId, size); if(i >= 0){ // remove i-th touch point for (int j = i; j < size - 1; j++)