Update rcore_ios.c

This commit is contained in:
blueloveTH 2024-03-27 21:55:50 +08:00
parent 4a7b6666c8
commit bc34ea6faa

View File

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