Skip to content

Commit

Permalink
Update rcore_ios.c
Browse files Browse the repository at this point in the history
  • Loading branch information
blueloveTH committed Mar 27, 2024
1 parent 4a7b666 commit bc34ea6
Showing 1 changed file with 28 additions and 10 deletions.
38 changes: 28 additions & 10 deletions src/platforms/rcore_ios.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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)

//----------------------------------------------------------------------------------
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit bc34ea6

Please sign in to comment.