Skip to content

Commit

Permalink
Made a few small navigation improvements (#9686)
Browse files Browse the repository at this point in the history
  • Loading branch information
eanders-ms committed Oct 24, 2023
1 parent 03ea84b commit 32748bf
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 3 deletions.
3 changes: 2 additions & 1 deletion kiosk/src/Components/AddingGame.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const AddingGame: React.FC<IProps> = ({ kiosk }) => {
}
playSoundEffect("switch");
}
if (menuButtonSelected && kiosk.gamepadManager.isAButtonPressed()) {
if ((menuButtonSelected && kiosk.gamepadManager.isAButtonPressed()) || kiosk.gamepadManager.isBButtonPressed()) {
tickEvent("kiosk.toMainMenu");
kiosk.showMainMenu();
playSoundEffect("select");
Expand All @@ -61,6 +61,7 @@ const AddingGame: React.FC<IProps> = ({ kiosk }) => {
if (qrCodeButtonSelected && kiosk.gamepadManager.isAButtonPressed()) {
tickEvent("kiosk.newKioskCode");
setRenderQRCode(true);
playSoundEffect("select");
}
};

Expand Down
15 changes: 13 additions & 2 deletions kiosk/src/Components/GameOver.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import AddGameButton from "./AddGameButton";
import configData from "../config.json";
import { KioskState } from "../Models/KioskState";
import { tickEvent } from "../browserUtils";
import { playSoundEffect } from "../Services/SoundEffectService";

interface IProps {
kiosk: Kiosk;
Expand All @@ -15,21 +16,25 @@ const GameOver: React.FC<IProps> = ({ kiosk }) => {
const gameId = kiosk.launchedGame;

const updateLoop = () => {
if (kiosk.gamepadManager.isLeftPressed()) {
if (!retryButtonSelected && kiosk.gamepadManager.isLeftPressed()) {
setRetryButtonState(true);
setHomeButtonState(false);
playSoundEffect("switch");
}
if (kiosk.gamepadManager.isRightPressed()) {
if (!homeButtonSelected && kiosk.gamepadManager.isRightPressed()) {
setHomeButtonState(true);
setRetryButtonState(false);
playSoundEffect("switch");
}
if (homeButtonSelected && kiosk.gamepadManager.isAButtonPressed()) {
tickEvent("kiosk.gameOver.mainMenu");
playSoundEffect("select");
kiosk.navigate(KioskState.MainMenu);
}

if (retryButtonSelected && kiosk.gamepadManager.isAButtonPressed()) {
tickEvent("kiosk.gameOver.retry");
playSoundEffect("select");
kiosk.launchGame(gameId);
}
};
Expand All @@ -48,6 +53,12 @@ const GameOver: React.FC<IProps> = ({ kiosk }) => {
};
});

useEffect(() => {
// When returning from another screen, block the A button until it is released to avoid launching the selected game.
kiosk.gamepadManager.clear();
kiosk.gamepadManager.blockAPressUntilRelease();
}, []);

return (
<div className="gameOverPage">
<h1>GAME OVER</h1>
Expand Down
1 change: 1 addition & 0 deletions kiosk/src/Components/MainMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ const MainMenu: React.FC<IProps> = ({ kiosk }) => {

useEffect(() => {
// When returning from another screen, block the A button until it is released to avoid launching the selected game.
kiosk.gamepadManager.clear();
kiosk.gamepadManager.blockAPressUntilRelease();
}, []);

Expand Down
5 changes: 5 additions & 0 deletions kiosk/src/Models/GamepadManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,9 @@ export class GamepadManager {
blockAPressUntilRelease() {
this.blockingAPressed = true;
}

clear() {
this.keyboardManager.clear();
// Not possible to clear gamepad state at the moment
}
}

0 comments on commit 32748bf

Please sign in to comment.