Replace forEach() with for()

This commit is contained in:
redphx
2024-10-22 10:42:09 +07:00
parent 01502363ab
commit 6cfff0274d
7 changed files with 25 additions and 16 deletions

View File

@@ -73,7 +73,8 @@ export class ControllerShortcut {
const pressed: boolean[] = [];
let otherButtonPressed = false;
gamepad.buttons.forEach((button, index) => {
const entries = gamepad.buttons.entries();
for (const [index, button] of entries) {
// Only add the newly pressed button to the array (holding doesn't count)
if (button.pressed && index !== GamepadKey.HOME) {
otherButtonPressed = true;
@@ -84,7 +85,7 @@ export class ControllerShortcut {
setTimeout(() => ControllerShortcut.runAction(actions[index]!), 0);
}
}
});
};
ControllerShortcut.buttonsStatus[gamepadIndex] = pressed;
return otherButtonPressed;