1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-05 12:10:55 +00:00

Merge pull request #107837 from Airyzz/airyzz/web-pen-pressure

[Web] Disregard touch events in pointer callbacks
This commit is contained in:
Thaddeus Crews
2025-06-24 09:58:44 -05:00

View File

@@ -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);
},
/*