From efec7445fc9ea86b8df87f89ae128c87096745fa Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Tue, 31 Mar 2026 21:59:50 -0700
Subject: [PATCH] Pause the game when the Steam overlay comes up
---
game/controls.cpp | 8 ++++++++
game/gameinfo.h | 1 +
game/steam.cpp | 12 ++++++++++++
game/steam.h | 2 ++
4 files changed, 23 insertions(+)
diff --git a/game/controls.cpp b/game/controls.cpp
index 1ed05ffe..66bf872c 100644
--- a/game/controls.cpp
+++ b/game/controls.cpp
@@ -628,6 +628,14 @@ void HandleEvent(SDL_Event *event)
UpdateControl(player);
break;
+ case SDL_EVENT_OVERLAY_ACTIVATED:
+ gGameInfo.SetPauseReason(PAUSE_OVERLAY, true);
+ break;
+
+ case SDL_EVENT_OVERLAY_DEACTIVATED:
+ gGameInfo.SetPauseReason(PAUSE_OVERLAY, false);
+ break;
+
case SDL_EVENT_WINDOW_MINIMIZED:
gGameInfo.SetPauseReason(PAUSE_MINIMIZED, true);
break;
diff --git a/game/gameinfo.h b/game/gameinfo.h
index f7b0642e..72bd0da8 100644
--- a/game/gameinfo.h
+++ b/game/gameinfo.h
@@ -63,6 +63,7 @@ enum PAUSE_REASON {
PAUSE_REQUEST = 0x01,
PAUSE_MINIMIZED = 0x02,
PAUSE_CONTROLLER = 0x04,
+ PAUSE_OVERLAY = 0x08,
};
enum PING_STATUS {
diff --git a/game/steam.cpp b/game/steam.cpp
index 03f79710..62efa695 100644
--- a/game/steam.cpp
+++ b/game/steam.cpp
@@ -88,6 +88,7 @@ class SteamInterface
array<RemoteSession_t *> m_sessions;
RemoteSession_t *m_players[MAX_PLAYERS - 1] = { };
+ STEAM_CALLBACK(SteamInterface, OnGameOverlayActivated, GameOverlayActivated_t);
STEAM_CALLBACK(SteamInterface, OnRemotePlaySessionConnected, SteamRemotePlaySessionConnected_t);
STEAM_CALLBACK(SteamInterface, OnRemotePlaySessionAvatarLoaded, SteamRemotePlaySessionAvatarLoaded_t);
STEAM_CALLBACK(SteamInterface, OnRemotePlaySessionDisconnected, SteamRemotePlaySessionDisconnected_t);
@@ -475,6 +476,17 @@ void SteamInterface::DisableRemoteInput()
SteamRemotePlay()->DisableRemotePlayTogetherDirectInput();
}
+void SteamInterface::OnGameOverlayActivated(GameOverlayActivated_t *pParam)
+{
+ SDL_Event event;
+ if (pParam->m_bActive) {
+ event.type = SDL_EVENT_OVERLAY_ACTIVATED;
+ } else {
+ event.type = SDL_EVENT_OVERLAY_DEACTIVATED;
+ }
+ SDL_PushEvent(&event);
+}
+
void SteamInterface::OnRemotePlaySessionAvatarLoaded(SteamRemotePlaySessionAvatarLoaded_t *pParam)
{
UpdatePlayers();
diff --git a/game/steam.h b/game/steam.h
index 25e70fb1..355873fc 100644
--- a/game/steam.h
+++ b/game/steam.h
@@ -24,6 +24,8 @@
#define SDL_EVENT_REMOTE_PLAYERS_CHANGED (SDL_EVENT_USER + 0)
#define SDL_EVENT_REMOTE_INPUT (SDL_EVENT_USER + 1)
+#define SDL_EVENT_OVERLAY_ACTIVATED (SDL_EVENT_USER + 2)
+#define SDL_EVENT_OVERLAY_DEACTIVATED (SDL_EVENT_USER + 3)
enum STEAM_TIMELINE_MODE
{