diff options
author | missionfloyd <missionfloyd@users.noreply.github.com> | 2023-05-07 04:47:35 +0000 |
---|---|---|
committer | missionfloyd <missionfloyd@users.noreply.github.com> | 2023-05-07 04:47:35 +0000 |
commit | 85bd9b3d31474c0bb4b209519f3f4179ccda2539 (patch) | |
tree | 04cdb9a1954578b8e2e4cc7d3a0b1dc506efd8c8 /javascript/imageviewerGamepad.js | |
parent | 99f3bf07d2976211eed81a9293a447c7ead2d893 (diff) | |
download | stable-diffusion-webui-gfx803-85bd9b3d31474c0bb4b209519f3f4179ccda2539.tar.gz stable-diffusion-webui-gfx803-85bd9b3d31474c0bb4b209519f3f4179ccda2539.tar.bz2 stable-diffusion-webui-gfx803-85bd9b3d31474c0bb4b209519f3f4179ccda2539.zip |
Work with multiple gamepads
Diffstat (limited to 'javascript/imageviewerGamepad.js')
-rw-r--r-- | javascript/imageviewerGamepad.js | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/javascript/imageviewerGamepad.js b/javascript/imageviewerGamepad.js index d24b7b97..6297a12b 100644 --- a/javascript/imageviewerGamepad.js +++ b/javascript/imageviewerGamepad.js @@ -1,8 +1,9 @@ -let isWaiting = false; window.addEventListener('gamepadconnected', (e) => { + const index = e.gamepad.index; + let isWaiting = false; setInterval(async () => { if (!opts.js_modal_lightbox_gamepad || isWaiting) return; - const gamepad = navigator.getGamepads()[0]; + const gamepad = navigator.getGamepads()[index]; const xValue = gamepad.axes[0]; if (xValue <= -0.3) { modalPrevImage(e); @@ -13,7 +14,7 @@ window.addEventListener('gamepadconnected', (e) => { } if (isWaiting) { await sleepUntil(() => { - const xValue = navigator.getGamepads()[0].axes[0] + const xValue = navigator.getGamepads()[index].axes[0] if (xValue < 0.3 && xValue > -0.3) { return true; } |