Skip to content

Commit

Permalink
Update app.js
Browse files Browse the repository at this point in the history
  • Loading branch information
MajesticWafer authored Oct 19, 2023
1 parent 644d549 commit 8b209af
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,18 @@ window.addEventListener("gamepadconnected", function (e) {
showMsg('Gamepad connected.')
currentConnectedGamepad = e.gamepad.index
$id('a-gamepad').innerText = 'Gamepad connected'

function checkGamepadState() {
var gamepad = navigator.getGamepads()[currentConnectedGamepad];
if (gamepad) {
if (gamepad.buttons[6].pressed) { // Replace 6 with the correct button index for "7"
uiSwitchTo('menu');
}
}
requestAnimationFrame(checkGamepadState);
}

checkGamepadState();
});

function processGamepadInput() {
Expand Down

0 comments on commit 8b209af

Please sign in to comment.