Skip to content

Commit 549ed33

Browse files
committed
fix(v2): keep gamepad input with the stream while a session is active
useGamepad gates its pad-to-UI translation on the playing store flag, but the v2 Stream player never set it, so button presses kept navigating the app (and a Back/Start press could tear the session down mid-game). Flag the session while launching or playing and clear it on unmount.
1 parent e0d822e commit 549ed33

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

frontend/src/v2/views/Player/Stream.vue

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ import { useRoute, useRouter } from "vue-router";
2222
import { ROUTES } from "@/plugins/router";
2323
import romApi from "@/services/api/rom";
2424
import streamingApi from "@/services/api/streaming";
25+
import storePlaying from "@/stores/playing";
2526
import storeRoms, { type DetailedRom, type SimpleRom } from "@/stores/roms";
2627
import { useStreamingStore } from "@/stores/streaming";
2728
import GameCover from "@/v2/components/shared/GameCover.vue";
@@ -42,6 +43,7 @@ const setBgArt = useBackgroundArt();
4243
4344
const romsStore = storeRoms();
4445
const galleryRoms = storeGalleryRoms();
46+
const playingStore = storePlaying();
4547
4648
const rom = ref<DetailedRom | null>(null);
4749
const playerState = ref<PlayerState>("idle");
@@ -138,6 +140,14 @@ watch(playerState, (state) =>
138140
setBgArt(state === "playing" ? null : bgCoverUrl.value),
139141
);
140142
143+
// While a session is launching or playing the emulator owns the controller:
144+
// this flag mutes useGamepad's pad->UI translation so button presses reach
145+
// the stream instead of navigating (or closing) the RomM UI.
146+
const sessionActive = computed(
147+
() => playerState.value === "playing" || playerState.value === "loading",
148+
);
149+
watch(sessionActive, (active) => playingStore.setPlaying(active));
150+
141151
// Sync volume slider (0-1) and mute button to the broker in real time.
142152
// Debounced via watch — only fires after the value settles for 150ms.
143153
let volumeDebounce: ReturnType<typeof setTimeout> | null = null;
@@ -175,6 +185,8 @@ onBeforeUnmount(() => {
175185
iframeLoadCleanup = null;
176186
contentWindowCleanup?.();
177187
contentWindowCleanup = null;
188+
// Hand controller input back to the UI regardless of how we leave.
189+
playingStore.setPlaying(false);
178190
if (playerState.value === "exited") {
179191
// handleSaveAndExit already released the session, nothing to do.
180192
return;

0 commit comments

Comments
 (0)