aboutsummaryrefslogtreecommitdiffstats
path: root/javascript/imageviewerGamepad.js
diff options
context:
space:
mode:
authorAUTOMATIC1111 <16777216c@gmail.com>2023-06-27 06:23:15 +0000
committerGitHub <noreply@github.com>2023-06-27 06:23:15 +0000
commit0b97ae2832a89b103be1c062d7778e558732712f (patch)
tree6d0966156f1cfa78aa0e97ed0474afaffc50f2cd /javascript/imageviewerGamepad.js
parent7e2d39a2d158d1426321686b05d31a3ea694a99e (diff)
parent3cd4fd51ef916aba8b978490569a5da82795a839 (diff)
downloadstable-diffusion-webui-gfx803-0b97ae2832a89b103be1c062d7778e558732712f.tar.gz
stable-diffusion-webui-gfx803-0b97ae2832a89b103be1c062d7778e558732712f.tar.bz2
stable-diffusion-webui-gfx803-0b97ae2832a89b103be1c062d7778e558732712f.zip
Merge branch 'dev' into master
Diffstat (limited to 'javascript/imageviewerGamepad.js')
-rw-r--r--javascript/imageviewerGamepad.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/javascript/imageviewerGamepad.js b/javascript/imageviewerGamepad.js
index 31d226de..a22c7e6e 100644
--- a/javascript/imageviewerGamepad.js
+++ b/javascript/imageviewerGamepad.js
@@ -1,7 +1,9 @@
+let gamepads = [];
+
window.addEventListener('gamepadconnected', (e) => {
const index = e.gamepad.index;
let isWaiting = false;
- setInterval(async() => {
+ gamepads[index] = setInterval(async() => {
if (!opts.js_modal_lightbox_gamepad || isWaiting) return;
const gamepad = navigator.getGamepads()[index];
const xValue = gamepad.axes[0];
@@ -24,6 +26,10 @@ window.addEventListener('gamepadconnected', (e) => {
}, 10);
});
+window.addEventListener('gamepaddisconnected', (e) => {
+ clearInterval(gamepads[e.gamepad.index]);
+});
+
/*
Primarily for vr controller type pointer devices.
I use the wheel event because there's currently no way to do it properly with web xr.