aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author0neGal <mail@0negal.com>2024-06-15 23:41:10 +0200
committer0neGal <mail@0negal.com>2024-06-15 23:41:10 +0200
commita3665ec4b680c64acbd10761fb137cc9ac5d4fd2 (patch)
tree7352e82d16aeaa8e4a8f731c9a7b07702881961e
parentdfa9403efa208e43089828e77962b2a23d3883cd (diff)
downloadViper-a3665ec4b680c64acbd10761fb137cc9ac5d4fd2.tar.gz
Viper-a3665ec4b680c64acbd10761fb137cc9ac5d4fd2.zip
added ability to switch section with bumpers
Either with the top bumper buttons on a gamepad, or with Q/E on a keyboard instead.
-rw-r--r--src/app/js/gamepad.js12
1 files changed, 10 insertions, 2 deletions
diff --git a/src/app/js/gamepad.js b/src/app/js/gamepad.js
index 172c673..fea2ee2 100644
--- a/src/app/js/gamepad.js
+++ b/src/app/js/gamepad.js
@@ -1,4 +1,5 @@
const popups = require("./popups");
+const launcher = require("./launcher");
const navigate = require("./navigate");
window.addEventListener("gamepadconnected", (e) => {
@@ -151,16 +152,20 @@ setInterval(() => {
// interpret `ii` as a specific button/action, using the
// standard IDs: https://w3c.github.io/gamepad/#remapping
switch(ii) {
- case 4: // switch tab (prev)
- case 5: // switch tab (next)
+ // change active section
+ case 4: launcher.relative_section("left"); break;
+ case 5: launcher.relative_section("right"); break;
+ // navigate selection
case 12: navigate.move("up"); break;
case 13: navigate.move("down"); break;
case 14: navigate.move("left"); break;
case 15: navigate.move("right"); break;
+ // click selected element
case buttons.accept: navigate.select(); break;
+ // close last opened popup
case buttons.cancel: popups.hide_last(); break;
}
}
@@ -293,6 +298,9 @@ window.addEventListener("keyup", (e) => {
// perform the relevant action for the key that was pressed
switch(e.code) {
+ case "KeyQ": launcher.relative_section("left"); break;
+ case "KeyE": launcher.relative_section("right"); break;
+
case "Space": return selection_el
.classList.remove("keyboard-selecting");