Show touch icon on games with custom layouts

This commit is contained in:
redphx
2024-05-07 21:40:12 +07:00
parent fc56d486a7
commit c948b63b8d
6 changed files with 78 additions and 28 deletions

View File

@@ -4,7 +4,7 @@ import { LoadingScreen } from "@modules/loading-screen";
import { PrefKey, getPref } from "@utils/preferences";
import { RemotePlay } from "@modules/remote-play";
import { StreamBadges } from "@modules/stream/stream-badges";
import { TouchController } from "@modules/touch-controller";
import { GALLERY_TOUCH_GAMES, TouchController } from "@modules/touch-controller";
import { STATES } from "@utils/global";
import { getPreferredServerRegion } from "@utils/region";
@@ -549,6 +549,20 @@ export function interceptHttpRequests() {
BxEvent.dispatch(window, BxEvent.STREAM_STARTING);
}
// Add list of games with custom layouts to the official list
if (url.includes('catalog.gamepass.com') && url.includes(GALLERY_TOUCH_GAMES)) {
const response = await NATIVE_FETCH(request, init);
const obj = await response.clone().json();
try {
const customList = TouchController.getCustomList().map(item => ({ id: item }));
obj.push(...customList);
} catch (e) {}
response.json = () => Promise.resolve(obj);
return response;
}
let requestType: RequestType;
if (url.includes('/sessions/home') || url.includes('xhome.') || (STATES.remotePlay.isPlaying && url.endsWith('/inputconfigs'))) {
requestType = RequestType.XHOME;