瀏覽代碼

Fix Touch pointCount reduction (#4661)

pull/4663/head
Maicon Santana 1 周之前
committed by GitHub
父節點
當前提交
fc29bc27fd
沒有發現已知的金鑰在資料庫的簽署中 GPG 金鑰 ID: B5690EEEBB952194
共有 1 個檔案被更改,包括 17 行新增1 行删除
  1. +17
    -1
      src/platforms/rcore_web.c

+ 17
- 1
src/platforms/rcore_web.c 查看文件

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

Loading…
取消
儲存