Skip to content

Commit

Permalink
revert long long change
Browse files Browse the repository at this point in the history
  • Loading branch information
blueloveTH committed Mar 27, 2024
1 parent d1a8b86 commit faaa623
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/platforms/rcore_ios.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -693,7 +702,7 @@ static void send_gesture_event(NSSet<UITouch *> * 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++)
Expand Down

0 comments on commit faaa623

Please sign in to comment.