From 0a8165c0acc85bab1624b94ee28ab67535aedbdd Mon Sep 17 00:00:00 2001 From: Hongyu Ouyang <96765450+casavaca@users.noreply.github.com> Date: Sat, 20 Jan 2024 12:05:30 -0800 Subject: [PATCH] Make raylib/raygui work better on touchscreen (#3728) * Fix that touch doesn't work for click/drag/raygui * Add comments * comments update --- src/platforms/rcore_web.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c index 8c16ff320..a13f69908 100644 --- a/src/platforms/rcore_web.c +++ b/src/platforms/rcore_web.c @@ -1646,6 +1646,13 @@ static EM_BOOL EmscriptenTouchCallback(int eventType, const EmscriptenTouchEvent else if (eventType == EMSCRIPTEN_EVENT_TOUCHEND) CORE.Input.Touch.currentTouchState[i] = 0; } + // Update mouse position if we detect a single touch. + if (CORE.Input.Touch.pointCount == 1) + { + CORE.Input.Mouse.currentPosition.x = CORE.Input.Touch.position[0].x; + CORE.Input.Mouse.currentPosition.y = CORE.Input.Touch.position[0].y; + } + #if defined(SUPPORT_GESTURES_SYSTEM) GestureEvent gestureEvent = {0};