From e74ce65fb00c9d8a75a855f1f1de44700ae88a63 Mon Sep 17 00:00:00 2001
From: Sam Lantinga <[EMAIL REDACTED]>
Date: Mon, 15 Dec 2025 16:59:33 -0800
Subject: [PATCH] Added the name for Steam Remote Play Together players
---
game/gameinfo.cpp | 2 ++
game/lobby.cpp | 22 +++++++++++++---------
game/steam.cpp | 31 ++++++++++++++++++++-----------
3 files changed, 35 insertions(+), 20 deletions(-)
diff --git a/game/gameinfo.cpp b/game/gameinfo.cpp
index 282f89ad..bde5aa6f 100644
--- a/game/gameinfo.cpp
+++ b/game/gameinfo.cpp
@@ -562,6 +562,8 @@ GameInfo::UpdateUI(GameInfoPlayer *player)
desc = GetGamepadName(1);
} else if (player->controlMask == CONTROL_JOYSTICK3) {
desc = GetGamepadName(2);
+ } else if (IS_REMOTE_CONTROL(player->controlMask)) {
+ desc = player->name;
}
player->UI.desc->SetText(desc);
}
diff --git a/game/lobby.cpp b/game/lobby.cpp
index e86c2a1e..44ec49f3 100644
--- a/game/lobby.cpp
+++ b/game/lobby.cpp
@@ -58,11 +58,13 @@ class SelectControlCallback : public UIClickCallback
}
// Select the control and hide the dialog
+ const char *name = NULL;
if (IS_LOCAL_CONTROL(m_controlType)) {
- m_game.SetPlayerSlot(m_index, prefs->GetString(PREFERENCES_HANDLE), m_controlType);
- } else {
- m_game.SetPlayerSlot(m_index, NULL, m_controlType);
+ name = prefs->GetString(PREFERENCES_HANDLE);
+ } else if (IS_REMOTE_CONTROL(m_controlType)) {
+ name = GetRemotePlayerName(m_controlType);
}
+ m_game.SetPlayerSlot(m_index, name, m_controlType);
m_dialog->Hide();
}
@@ -420,14 +422,16 @@ LobbyDialogDelegate::SetState(LOBBY_STATE state)
// Set up the controls for this game
for (i = 0; i < MAX_PLAYERS; ++i) {
Uint8 controlType;
- char name[128];
- SDL_snprintf(name, sizeof(name), "Player%d.Controls", i+1);
- controlType = prefs->GetNumber(name, (i == 0 ? CONTROL_LOCAL : CONTROL_NETWORK));
+ char entry[128];
+ SDL_snprintf(entry, sizeof(entry), "Player%d.Controls", i+1);
+ controlType = prefs->GetNumber(entry, (i == 0 ? CONTROL_LOCAL : CONTROL_NETWORK));
+ const char *name = NULL;
if (IS_LOCAL_CONTROL(controlType)) {
- m_game.SetPlayerSlot(i, prefs->GetString(PREFERENCES_HANDLE), controlType);
- } else {
- m_game.SetPlayerSlot(i, NULL, controlType);
+ name = prefs->GetString(PREFERENCES_HANDLE);
+ } else if (IS_REMOTE_CONTROL(controlType)) {
+ name = GetRemotePlayerName(controlType);
}
+ m_game.SetPlayerSlot(i, name, controlType);
}
} else if (state == STATE_LISTING) {
ClearGameList();
diff --git a/game/steam.cpp b/game/steam.cpp
index 0bf600bc..f083d155 100644
--- a/game/steam.cpp
+++ b/game/steam.cpp
@@ -23,6 +23,7 @@
#include <SDL3/SDL.h>
#include "steam.h"
+#include "Localization.h"
#ifdef ENABLE_STEAM
@@ -169,18 +170,9 @@ Uint8 SteamInterface::GetControlForSession(RemotePlaySessionID_t sessionID)
return 0;
}
-// FIXME: We need a Steamworks API for this
bool SteamInterface::IsRemotePlayTogether(RemotePlaySessionID_t sessionID)
{
- RemoteSession_t *session = GetSession(sessionID);
- if (!session) {
- return false;
- }
-
- if (session->steamID == m_steamID) {
- return false;
- }
- return true;
+ return SteamRemotePlay()->BSessionRemotePlayTogether(sessionID);
}
void SteamInterface::UpdatePlayers()
@@ -284,11 +276,28 @@ void SteamInterface::DisableRemoteInput()
void SteamInterface::OnRemotePlaySessionConnected(SteamRemotePlaySessionConnected_t *pParam)
{
RemotePlaySessionID_t sessionID = pParam->m_unSessionID;
+
+ if (!IsRemotePlayTogether(sessionID)) {
+ // Ignore this session, it'll control the local player
+ return;
+ }
+
RemoteSession_t *session = new RemoteSession_t;
session->id = sessionID;
session->steamID = SteamRemotePlay()->GetSessionSteamID(sessionID);
- session->name = SDL_strdup("");
+
+ if (session->steamID.IsValid()) {
+ session->name = SDL_strdup(SteamFriends()->GetFriendPersonaName(session->steamID));
+ } else {
+ uint32 unGuestID = SteamRemotePlay()->GetSessionGuestID(sessionID);
+ if (unGuestID) {
+ SDL_asprintf(&session->name, TEXT("Guest %u"), unGuestID);
+ } else {
+ session->name = NULL;
+ }
+ }
SDL_zeroa(session->keystate);
+
m_sessions.add(session);
UpdatePlayers();