From e7e5c2b832a98000b3a0fe5b89ee74c3dfddffbc Mon Sep 17 00:00:00 2001 From: Airyzz <36567925+Airyzz@users.noreply.github.com> Date: Sun, 22 Jun 2025 17:02:16 +0930 Subject: [PATCH] [Web] Disregard touch events in pointer callbacks Update library_godot_input.js fix style --- platform/web/js/libs/library_godot_input.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/platform/web/js/libs/library_godot_input.js b/platform/web/js/libs/library_godot_input.js index d569c97b89e..1d1108ba9ad 100644 --- a/platform/web/js/libs/library_godot_input.js +++ b/platform/web/js/libs/library_godot_input.js @@ -507,6 +507,10 @@ const GodotInput = { const func = GodotRuntime.get_func(callback); const canvas = GodotConfig.canvas; function move_cb(evt) { + if (evt.pointerType == 'touch') { + return; + } + const rect = canvas.getBoundingClientRect(); const pos = GodotInput.computePosition(evt, rect); // Scale movement @@ -538,6 +542,10 @@ const GodotInput = { const func = GodotRuntime.get_func(callback); const canvas = GodotConfig.canvas; function button_cb(p_pressed, evt) { + if (evt.pointerType == 'touch') { + return; + } + const rect = canvas.getBoundingClientRect(); const pos = GodotInput.computePosition(evt, rect); const modifiers = GodotInput.getModifiers(evt); @@ -550,8 +558,8 @@ const GodotInput = { evt.preventDefault(); } } - GodotEventListeners.add(canvas, 'mousedown', button_cb.bind(null, 1), false); - GodotEventListeners.add(window, 'mouseup', button_cb.bind(null, 0), false); + GodotEventListeners.add(canvas, 'pointerdown', button_cb.bind(null, 1), false); + GodotEventListeners.add(window, 'pointerup', button_cb.bind(null, 0), false); }, /*