Skip to content

Commit

Permalink
Fix Touch pointCount reduction (#4661)
Browse files Browse the repository at this point in the history
  • Loading branch information
maiconpintoabreu authored Jan 6, 2025
1 parent ad035ed commit fc29bc2
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion src/platforms/rcore_web.c
Original file line number Diff line number Diff line change
Expand Up @@ -1812,7 +1812,23 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent

if (eventType == EMSCRIPTEN_EVENT_TOUCHEND)
{
CORE.Input.Touch.pointCount--;
// Identify the EMSCRIPTEN_EVENT_TOUCHEND and remove it from the list
for (int i = 0; i < CORE.Input.Touch.pointCount; i++)
{
if (touchEvent->touches[i].isChanged)
{
// Move all touch points one position up
for (int j = i; j < CORE.Input.Touch.pointCount - 1; j++)
{
CORE.Input.Touch.pointId[j] = CORE.Input.Touch.pointId[j + 1];
CORE.Input.Touch.position[j] = CORE.Input.Touch.position[j + 1];
}
// Decrease touch points count to remove the last one
CORE.Input.Touch.pointCount--;
break;
}
}
// Clamp pointCount to avoid negative values
if (CORE.Input.Touch.pointCount < 0) CORE.Input.Touch.pointCount = 0;
}

Expand Down

0 comments on commit fc29bc2

Please sign in to comment.