瀏覽代碼

[HTML5] Fix multi-touch input handling.

The code to populate the input data for WebAssembly was incorrectly
overriding values when multiple touches were present due to wrong
indexing.

(cherry picked from commit 470496d8d40e2f476fac4f72c0b69748b5370936)
Fabio Alessandrelli 3 年之前
父節點
當前提交
53ce3f64ad
共有 1 個文件被更改,包括 3 次插入3 次删除
  1. 3 3
      platform/javascript/js/libs/library_godot_input.js

+ 3 - 3
platform/javascript/js/libs/library_godot_input.js

@@ -424,9 +424,9 @@ const GodotInput = {
 			for (let i = 0; i < touches.length; i++) {
 				const touch = touches[i];
 				const pos = GodotInput.computePosition(touch, rect);
-				GodotRuntime.setHeapValue(coords + (i * 2), pos[0], 'double');
-				GodotRuntime.setHeapValue(coords + (i * 2 + 8), pos[1], 'double');
-				GodotRuntime.setHeapValue(ids + i, touch.identifier, 'i32');
+				GodotRuntime.setHeapValue(coords + (i * 2) * 8, pos[0], 'double');
+				GodotRuntime.setHeapValue(coords + (i * 2 + 1) * 8, pos[1], 'double');
+				GodotRuntime.setHeapValue(ids + i * 4, touch.identifier, 'i32');
 			}
 			func(type, touches.length);
 			if (evt.cancelable) {