revert long long change

This commit is contained in:
blueloveTH 2024-03-27 21:17:07 +08:00
parent d1a8b86148
commit faaa6230a1

View File

@ -644,6 +644,15 @@ void ClosePlatform(void)
return false; 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) static void sync_all_touches(UIEvent* event)
{ {
CORE.Input.Touch.pointCount = (int)event.allTouches.count; 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]; CGPoint location = [touch locationInView:platform.viewController.view];
CORE.Input.Touch.position[i] = (Vector2){ location.x, location.y }; 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++; i++;
if(i >= MAX_TOUCH_POINTS) break; if(i >= MAX_TOUCH_POINTS) break;
} }
// TODO: Normalize CORE.Input.Touch.position[i] for CORE.Window.screen.width and CORE.Window.screen.height // 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; for (int i = 0; i < size; i++) if(haystack[i] == needle) return i;
return -1; return -1;
@ -693,7 +702,7 @@ static void send_gesture_event(NSSet<UITouch *> * touches, int action)
{ {
int size = CORE.Input.Touch.pointCount; int size = CORE.Input.Touch.pointCount;
if(size > MAX_TOUCH_POINTS) size = MAX_TOUCH_POINTS; 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){ if(i >= 0){
// remove i-th touch point // remove i-th touch point
for (int j = i; j < size - 1; j++) for (int j = i; j < size - 1; j++)