diff options
author | papuSpartan <30642826+papuSpartan@users.noreply.github.com> | 2023-05-03 07:21:50 +0000 |
---|---|---|
committer | papuSpartan <30642826+papuSpartan@users.noreply.github.com> | 2023-05-03 07:21:50 +0000 |
commit | f08ae961157d33051b5cd09ba5c77b779096ef69 (patch) | |
tree | 038e0f511d51816c0a971d6093da0420b5677ae0 /javascript/imageviewerGamepad.js | |
parent | dff60e2e74964a8b02b75ecd8cf8007ef67a9712 (diff) | |
parent | 335428c2c8139dfe07ba096a6defa75036660244 (diff) | |
download | stable-diffusion-webui-gfx803-f08ae961157d33051b5cd09ba5c77b779096ef69.tar.gz stable-diffusion-webui-gfx803-f08ae961157d33051b5cd09ba5c77b779096ef69.tar.bz2 stable-diffusion-webui-gfx803-f08ae961157d33051b5cd09ba5c77b779096ef69.zip |
resolve merge conflicts and swap to dev branch for now
Diffstat (limited to 'javascript/imageviewerGamepad.js')
-rw-r--r-- | javascript/imageviewerGamepad.js | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/javascript/imageviewerGamepad.js b/javascript/imageviewerGamepad.js new file mode 100644 index 00000000..29bd7140 --- /dev/null +++ b/javascript/imageviewerGamepad.js @@ -0,0 +1,36 @@ + let delay = 350//ms + window.addEventListener('gamepadconnected', (e) => { + console.log("Gamepad connected!") + const gamepad = e.gamepad; + setInterval(() => { + const xValue = gamepad.axes[0].toFixed(2); + if (xValue < -0.3) { + modalPrevImage(e); + } else if (xValue > 0.3) { + modalNextImage(e); + } + + }, delay); + }); + + + /* + 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. + */ + + let isScrolling = false; + window.addEventListener('wheel', (e) => { + if (isScrolling) return; + isScrolling = true; + + if (e.deltaX <= -0.6) { + modalPrevImage(e); + } else if (e.deltaX >= 0.6) { + modalNextImage(e); + } + + setTimeout(() => { + isScrolling = false; + }, delay); + });
\ No newline at end of file |