diff options
Diffstat (limited to 'src/app/js/gamepad.js')
-rw-r--r-- | src/app/js/gamepad.js | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/app/js/gamepad.js b/src/app/js/gamepad.js index fea2ee2..aa9e089 100644 --- a/src/app/js/gamepad.js +++ b/src/app/js/gamepad.js @@ -20,6 +20,8 @@ window.addEventListener("gamepaddisconnected", (e) => { // be pressed again let delay_press = {}; +let held_buttons = {}; + setInterval(() => { let gamepads = navigator.getGamepads(); @@ -87,6 +89,7 @@ setInterval(() => { for (let ii = 0; ii < gamepads[i].buttons.length; ii++) { if (! gamepads[i].buttons[ii].pressed) { + held_buttons[ii] = false; continue; } @@ -149,6 +152,12 @@ setInterval(() => { // immediately again after this delay_press[ii] = 3; + if (held_buttons[ii]) { + continue; + } + + held_buttons[ii] = true; + // interpret `ii` as a specific button/action, using the // standard IDs: https://w3c.github.io/gamepad/#remapping switch(ii) { |