mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-08-06 21:28:27 +02:00
Show touch icon on games with custom layouts
This commit is contained in:
46
src/utils/preload-state.ts
Normal file
46
src/utils/preload-state.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import { STATES } from "@utils/global";
|
||||
import { UserAgent } from "@utils/user-agent";
|
||||
import { BxLogger } from "./bx-logger";
|
||||
import { GALLERY_TOUCH_GAMES, TouchController } from "@modules/touch-controller";
|
||||
|
||||
const LOG_TAG = 'PreloadState';
|
||||
|
||||
export function overridePreloadState() {
|
||||
let _state: any;
|
||||
|
||||
Object.defineProperty(window, '__PRELOADED_STATE__', {
|
||||
configurable: true,
|
||||
get: () => {
|
||||
// @ts-ignore
|
||||
return _state;
|
||||
},
|
||||
set: state => {
|
||||
// Override User-Agent
|
||||
const userAgent = UserAgent.spoof();
|
||||
if (userAgent) {
|
||||
try {
|
||||
// @ts-ignore
|
||||
state.appContext.requestInfo.userAgent = userAgent;
|
||||
} catch (e) {
|
||||
BxLogger.error(LOG_TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
// Add list of games with custom layouts to the official list
|
||||
if (STATES.hasTouchSupport) {
|
||||
TouchController.updateCustomList();
|
||||
const customList = TouchController.getCustomList();
|
||||
|
||||
try {
|
||||
state.xcloud.sigls[GALLERY_TOUCH_GAMES]?.data.products.push(...customList);
|
||||
} catch (e) {
|
||||
BxLogger.error(LOG_TAG, e);
|
||||
}
|
||||
}
|
||||
|
||||
// @ts-ignore
|
||||
_state = state;
|
||||
STATES.appContext = structuredClone(state.appContext);
|
||||
}
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user