Fix Touch pointCount reduction (#4661)
Some checks failed
Android / build (arm64) (push) Has been cancelled
Android / build (x86_64) (push) Has been cancelled
CMakeBuilds / Windows Build (push) Has been cancelled
CMakeBuilds / Linux Build (push) Has been cancelled
Linux / build (i386, i386, /user/bin, 32) (push) Has been cancelled
Linux / build (x86_64, amd64, /user/bin, 64) (push) Has been cancelled
Linux Examples / build (push) Has been cancelled
macOS / build (push) Has been cancelled
WebAssembly / build (push) Has been cancelled
Windows / build (i686, pe-i386, 32, mingw-w64) (push) Has been cancelled
Windows / build (x64, x64, 64, msvc16) (push) Has been cancelled
Windows / build (x86, Win32, 32, msvc16) (push) Has been cancelled
Windows / build (x86_64, pe-x86-64, 64, mingw-w64) (push) Has been cancelled
Windows Examples / build (push) Has been cancelled

This commit is contained in:
Maicon Santana 2025-01-06 10:29:24 +00:00 committed by GitHub
parent ad035edfac
commit fc29bc27fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

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