From 611a8c26d61152decb6b0522786338d8eda2ef7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=B5=B5=E5=BD=A4=E5=88=9A?= <2585649532@qq.com> Date: Sun, 14 Jul 2024 13:13:11 +0800 Subject: [PATCH] Update gamepad.js (#855) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The objects traversed by the “foreach” method should be arrays, and the “Array.from()” method should be used to convert the traversal objects to arrays, ensuring that they run in some more restrictive browsers. --- data/gamepad.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/gamepad.js b/data/gamepad.js index e43eb03..6c13644 100644 --- a/data/gamepad.js +++ b/data/gamepad.js @@ -37,7 +37,7 @@ class GamepadHandler { this.timeout = setTimeout(this.loop.bind(this), 10); } updateGamepadState() { - const gamepads = this.getGamepads(); + const gamepads = Array.from(this.getGamepads()); gamepads.forEach((gamepad, index) => { if (!gamepad) return; let hasGamepad = false;