From bc34ea6faab5bed6d2a7ef1293d1ad8f869306e0 Mon Sep 17 00:00:00 2001 From: blueloveTH Date: Wed, 27 Mar 2024 21:55:50 +0800 Subject: [PATCH] Update rcore_ios.c --- src/platforms/rcore_ios.c | 38 ++++++++++++++++++++++++++++---------- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/src/platforms/rcore_ios.c b/src/platforms/rcore_ios.c index e09ee6354..24598c964 100644 --- a/src/platforms/rcore_ios.c +++ b/src/platforms/rcore_ios.c @@ -73,7 +73,7 @@ extern void ios_destroy(); //---------------------------------------------------------------------------------- typedef struct { GameViewController *viewController; // Root view controller - + // Display data EGLDisplay device; // Native display device (physical screen connection) EGLSurface surface; // Surface to draw on, framebuffers (connected to context) @@ -91,6 +91,33 @@ static PlatformData platform = { 0 }; // Platform specific data //---------------------------------------------------------------------------------- // Module Internal Functions Declaration //---------------------------------------------------------------------------------- +static int map_point_id(UITouch *touch){ + static UITouch* touchs[MAX_TOUCH_POINTS] = { 0 }; + for(int i = 0; i < MAX_TOUCH_POINTS; i++){ + if(touchs[i] == touch) return i + 1; + } + // clear unused touch pairs before insert + for(int i = 0; i < MAX_TOUCH_POINTS; i++){ + if(touchs[i] == NULL) continue; + bool found = false; + for(int j = 0; j < MAX_TOUCH_POINTS; j++){ + if(CORE.Input.Touch.pointId[j] == i + 1){ + found = true; + break; + } + } + if(!found) touchs[i] = NULL; + } + for(int i = 0; i < MAX_TOUCH_POINTS; i++){ + if(touchs[i] == NULL){ + touchs[i] = touch; + return i + 1; + } + } + TRACELOG(LOG_ERROR, "Touch point id overflow. This may be a bug!"); + return 0; +} + int InitPlatform(void); // Initialize platform (graphics, inputs and more) //---------------------------------------------------------------------------------- @@ -644,15 +671,6 @@ 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;