fix(plugin): revert to RegisterForGameStarted/Stopped for runtime compat

This commit is contained in:
2026-06-28 18:54:46 +08:00
parent a49aca93c7
commit 677adc5ad0
2 changed files with 12 additions and 7 deletions
+6 -7
View File
@@ -42,15 +42,14 @@ function Content() {
// ── Register SteamClient game events ────────────────────────── // ── Register SteamClient game events ──────────────────────────
useEffect(() => { useEffect(() => {
try { try {
const startedReg = SteamClient.Apps.RegisterForGameActionStart( // Use RegisterForGameStarted/Stopped — these are the most widely used
(_gameActionId: number, appId: string, _action: string, _source: number) => { // APIs in Decky plugins despite TypeScript type warnings.
const appIdNum = parseInt(appId, 10) const startedReg = SteamClient.Apps.RegisterForGameStarted((appId: number) => {
onGameStart(appIdNum, `App ${appId}`) onGameStart(appId, `App ${appId}`)
}, })
)
gameStartedUnregRef.current = startedReg gameStartedUnregRef.current = startedReg
const stoppedReg = SteamClient.Apps.RegisterForGameActionEnd((_gameActionId: number) => { const stoppedReg = SteamClient.Apps.RegisterForGameStopped((_appId: number) => {
onGameStop() onGameStop()
}) })
gameStoppedUnregRef.current = stoppedReg gameStoppedUnregRef.current = stoppedReg
+6
View File
@@ -5,6 +5,12 @@
declare global { declare global {
const SteamClient: { const SteamClient: {
Apps: { Apps: {
RegisterForGameStarted: (
callback: (appId: number) => void,
) => { unregister: () => void }
RegisterForGameStopped: (
callback: (appId: number) => void,
) => { unregister: () => void }
RegisterForGameActionStart: ( RegisterForGameActionStart: (
callback: (gameActionId: number, appId: string, action: string, source: number) => void, callback: (gameActionId: number, appId: string, action: string, source: number) => void,
) => { unregister: () => void } ) => { unregister: () => void }