summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorHongyu Ouyang <[email protected]>2024-01-20 12:05:30 -0800
committerGitHub <[email protected]>2024-01-20 21:05:30 +0100
commit0a8165c0acc85bab1624b94ee28ab67535aedbdd (patch)
treef059fa923dc9151055a7681f8c8ea99655ba1049 /src
parentb600786c525caa667646c5d271c65a8eb007f168 (diff)
downloadraylib-0a8165c0acc85bab1624b94ee28ab67535aedbdd.tar.gz
raylib-0a8165c0acc85bab1624b94ee28ab67535aedbdd.zip
Make raylib/raygui work better on touchscreen (#3728)
* Fix that touch doesn't work for click/drag/raygui * Add comments * comments update
Diffstat (limited to 'src')
-rw-r--r--src/platforms/rcore_web.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/platforms/rcore_web.c b/src/platforms/rcore_web.c
index 8c16ff32..a13f6990 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};