summaryrefslogtreecommitdiff
path: root/frontend/src/steamfixes
diff options
context:
space:
mode:
authorAAGaming <aa@mail.catvibers.me>2023-01-07 20:33:28 -0500
committerGitHub <noreply@github.com>2023-01-07 17:33:28 -0800
commitb72b32761058767d143e9ff08dc238c5ac9b777c (patch)
treeab3cb1d855a20c37355f1b0c650647cd733a1d5d /frontend/src/steamfixes
parentb8fdff80933b0164096c94358ab8123722906e0d (diff)
downloaddecky-loader-b72b32761058767d143e9ff08dc238c5ac9b777c.tar.gz
decky-loader-b72b32761058767d143e9ff08dc238c5ac9b777c.zip
Fix reloading UI on updates and restarting steam (#303)v2.4.9-pre1
Diffstat (limited to 'frontend/src/steamfixes')
-rw-r--r--frontend/src/steamfixes/README.md13
-rw-r--r--frontend/src/steamfixes/index.ts12
-rw-r--r--frontend/src/steamfixes/reload.ts14
-rw-r--r--frontend/src/steamfixes/restart.ts60
4 files changed, 99 insertions, 0 deletions
diff --git a/frontend/src/steamfixes/README.md b/frontend/src/steamfixes/README.md
new file mode 100644
index 00000000..97098889
--- /dev/null
+++ b/frontend/src/steamfixes/README.md
@@ -0,0 +1,13 @@
+## What's this?
+
+`steamfixes` contains various fixes and workaround for things Valve has broken that cause Decky issues.
+
+## Current fixes:
+
+- StartRestart() -> StartShutdown(false) override:
+
+ StartRestart() breaks CEF debugging, StartShutdown(false) doesn't. We can safely replace StartRestart() with StartShutdown(false) as gamescope-session will automatically restart the steam client anyway if it shuts down, bypassing the broken restart codepath. Added 12/29/2022
+
+- ExecuteSteamURL UI reload fix:
+
+ Starting sometime in November 2022, Valve broke reloading the Steam UI pages via location.reload, as it won't properly start the UI. We can manually trigger UI startup if we detect no active input contexts by calling `SteamClient.URL.ExecuteSteamURL("steam://open/settings/")` Added 12/29/2022
diff --git a/frontend/src/steamfixes/index.ts b/frontend/src/steamfixes/index.ts
new file mode 100644
index 00000000..988f3bd7
--- /dev/null
+++ b/frontend/src/steamfixes/index.ts
@@ -0,0 +1,12 @@
+import reloadFix from './reload';
+import restartFix from './restart';
+let fixes: Function[] = [];
+
+export function deinitSteamFixes() {
+ fixes.forEach((deinit) => deinit());
+}
+
+export async function initSteamFixes() {
+ fixes.push(reloadFix());
+ fixes.push(await restartFix());
+}
diff --git a/frontend/src/steamfixes/reload.ts b/frontend/src/steamfixes/reload.ts
new file mode 100644
index 00000000..e31f78fc
--- /dev/null
+++ b/frontend/src/steamfixes/reload.ts
@@ -0,0 +1,14 @@
+import Logger from '../logger';
+
+const logger = new Logger('ReloadSteamFix');
+
+export default function reloadFix() {
+ // Hack to unbreak the ui when reloading it
+ if (window.FocusNavController?.m_rgAllContexts?.length == 0) {
+ SteamClient.URL.ExecuteSteamURL('steam://open/settings');
+ logger.log('Applied UI reload fix.');
+ }
+
+ // This steamfix does not need to deinit.
+ return () => {};
+}
diff --git a/frontend/src/steamfixes/restart.ts b/frontend/src/steamfixes/restart.ts
new file mode 100644
index 00000000..467efd6a
--- /dev/null
+++ b/frontend/src/steamfixes/restart.ts
@@ -0,0 +1,60 @@
+import { Patch, findModuleChild, replacePatch, sleep } from 'decky-frontend-lib';
+
+import Logger from '../logger';
+
+const logger = new Logger('RestartSteamFix');
+
+declare global {
+ interface Window {
+ SteamClient: any;
+ appDetailsStore: any;
+ }
+}
+
+let patch: Patch;
+
+function rePatch() {
+ // If you patch anything on SteamClient within the first few seconds of the client having loaded it will get redefined for some reason, so repatch any of these changes that occur with History.listen or an interval
+ patch = replacePatch(window.SteamClient.User, 'StartRestart', () => SteamClient.User.StartShutdown(false));
+}
+
+export default async function restartFix() {
+ try {
+ rePatch();
+ // TODO type and add to frontend-lib
+ let History: any;
+
+ while (!History) {
+ History = findModuleChild((m) => {
+ if (typeof m !== 'object') return undefined;
+ for (let prop in m) {
+ if (m[prop]?.m_history) return m[prop].m_history;
+ }
+ });
+ if (!History) {
+ logger.debug('Waiting 5s for history to become available.');
+ await sleep(5000);
+ }
+ }
+
+ function repatchIfNeeded() {
+ if (window.SteamClient.User.StartRestart !== patch.patchedFunction) {
+ rePatch();
+ }
+ }
+
+ const unlisten = History.listen(repatchIfNeeded);
+
+ // Just in case
+ setTimeout(repatchIfNeeded, 5000);
+ setTimeout(repatchIfNeeded, 10000);
+
+ return () => {
+ unlisten();
+ patch.unpatch();
+ };
+ } catch (e) {
+ logger.error('Error patching StartRestart', e);
+ }
+ return () => {};
+}