Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

Separate the Game Pass catalog from the account's own games

Rafael Abud Ferreira3bad2b131b36
diff --git a/src/app/cli_main.cpp b/src/app/cli_main.cpp
index 8214711..3bdbd26 100644
--- a/src/app/cli_main.cpp
+++ b/src/app/cli_main.cpp
@@ -91,7 +91,7 @@ int cmdTitles(auth::AuthManager& am, bool recent) {
std::string market = gssv.session().market.empty() ? "US" : gssv.session().market;
if (!gssv.hydrateTitles(titles, market, "en-us", err)) XC_LOGW("%s", err.c_str());
for (const auto& t : titles)
- std::printf("%-28s %-14s %s\n", t.titleId.c_str(), t.productId.c_str(),
+ std::printf("%-28s %-14s %s %s\n", t.titleId.c_str(), t.productId.c_str(), t.hasEntitlement ? "owned" : "- ",
t.name.empty() ? "?" : t.name.c_str());
std::printf("%zu titles\n", titles.size());
return 0;
@@ -306,6 +306,7 @@ int cmdUiPreview(auth::AuthManager& am, const std::string& dir) {
XC_LOGE("%s", err.c_str());
return 1;
}
+ library.loadOwned(gssv, onRows);
library.hydrate(onRows);
app.showHome();
save("home", 4000);
@@ -320,6 +321,20 @@ int cmdUiPreview(auth::AuthManager& am, const std::string& dir) {
accept.accept = true;
app.handle(accept);
save("details", 2000);
+ {
+ // A game the account can't stream: dimmed card with a lock, no Play.
+ auto rows = library.rows();
+ if (!rows.empty()) {
+ for (auto& row : rows)
+ for (size_t i = 0; i < row.tiles.size(); i += 2) row.tiles[i].playable = false;
+ app.setRows(rows);
+ app.showHome();
+ save("home_locked", 3000);
+ app.handle(accept);
+ save("details_locked", 1000);
+ app.setRows(library.rows());
+ }
+ }
ui::GameTile game;
game.name = "Balatro";
app.showLaunching(game, ui::trf(ui::Str::InQueue, "1 min"));
diff --git a/src/app/library.cpp b/src/app/library.cpp
index 0c75d26..387fbec 100644
--- a/src/app/library.cpp
+++ b/src/app/library.cpp
@@ -43,7 +43,10 @@ std::vector<ui::GameRow> Library::rows() const {
auto it = products_.find(pid);
if (it == products_.end()) continue;
if (tid.empty() && it->second.xcloudTitleId.empty()) continue;
- row.tiles.push_back(toTile(it->second, tid));
+ ui::GameTile tile = toTile(it->second, tid);
+ if (ownershipKnown_)
+ tile.playable = ownedTitles_.count(tile.titleId) || ownedProducts_.count(tile.productId);
+ row.tiles.push_back(std::move(tile));
}
if (!row.tiles.empty()) rows.push_back(std::move(row));
}
@@ -73,18 +76,39 @@ bool Library::load(xcloud::GssvClient& gssv, const std::string& language, const
}
}
+ // The Game Pass catalog first: it decides what the other lists may show.
+ xcloud::ProductList all;
+ std::string e;
+ if (xcloud::fetchList(xcloud::sigl::kAllGames, market_, language_, all, e)) {
+ gamePass_.insert(all.productIds.begin(), all.productIds.end());
+ } else {
+ XC_LOGW("%s", e.c_str());
+ lastErr = e;
+ }
+
const ListSpec lists[] = {{xcloud::sigl::kRecentlyAdded, 40},
{xcloud::sigl::kMostPopular, 40},
{xcloud::sigl::kLeavingSoon, 40},
{xcloud::sigl::kAllGames, 120}};
for (const auto& spec : lists) {
xcloud::ProductList list;
- std::string e;
- if (!xcloud::fetchList(spec.sigl, market_, language_, list, e)) {
+ if (spec.sigl == xcloud::sigl::kAllGames && !all.productIds.empty()) {
+ list = all;
+ } else if (!xcloud::fetchList(spec.sigl, market_, language_, list, e)) {
XC_LOGW("%s", e.c_str());
lastErr = e;
continue;
}
+ // "Most popular on cloud" also lists games to buy first (Cuphead...).
+ if (!gamePass_.empty()) {
+ size_t before = list.productIds.size();
+ list.productIds.erase(std::remove_if(list.productIds.begin(), list.productIds.end(),
+ [&](const std::string& id) { return !gamePass_.count(id); }),
+ list.productIds.end());
+ if (list.productIds.size() != before)
+ XC_LOGI("library: %s: %zu of %zu not in Game Pass, left out", list.title.c_str(),
+ before - list.productIds.size(), before);
+ }
if (list.productIds.size() > spec.limit) list.productIds.resize(spec.limit);
std::vector<std::string> missing;
for (const auto& id : list.productIds)
@@ -106,6 +130,44 @@ bool Library::load(xcloud::GssvClient& gssv, const std::string& language, const
return true;
}
+void Library::loadOwned(xcloud::GssvClient gssv, const RowsCallback& onRows, const std::atomic<bool>* stop) {
+ std::vector<xcloud::Title> titles;
+ std::string err;
+ if (!gssv.listTitles(titles, err, false)) {
+ XC_LOGW("%s", err.c_str()); // rows stay as they are, all playable
+ return;
+ }
+ if (stop && *stop) return;
+ std::vector<std::pair<std::string, std::string>> mine; // productId, titleId
+ for (const auto& t : titles) {
+ if (!t.hasEntitlement) continue;
+ ownedTitles_.insert(t.titleId);
+ if (t.productId.empty()) continue;
+ ownedProducts_.insert(t.productId);
+ if (!gamePass_.count(t.productId)) mine.emplace_back(t.productId, t.titleId);
+ }
+ std::vector<std::string> missing;
+ for (const auto& m : mine)
+ if (!products_.count(m.first)) missing.push_back(m.first);
+ if (!missing.empty() && !xcloud::fetchProducts(missing, market_, language_, products_, err, false))
+ XC_LOGW("%s", err.c_str());
+ if (stop && *stop) return;
+ // Alphabetical; products the catalog doesn't know have no name or art.
+ mine.erase(std::remove_if(mine.begin(), mine.end(), [&](const auto& m) { return !products_.count(m.first); }),
+ mine.end());
+ std::sort(mine.begin(), mine.end(), [&](const auto& a, const auto& b) {
+ return products_[a.first].title < products_[b.first].title;
+ });
+ RowIds row{ui::tr(ui::Str::YourGames), false, std::move(mine)};
+ size_t at = 0; // after "Jump back in"
+ if (!layout_.empty() && !layout_.front().badges) at = 1;
+ size_t count = row.items.size();
+ layout_.insert(layout_.begin() + static_cast<long>(at), std::move(row));
+ ownershipKnown_ = true;
+ XC_LOGI("library: account can stream %zu titles; %zu outside Game Pass", ownedTitles_.size(), count);
+ onRows(rows());
+}
+
void Library::hydrate(const RowsCallback& onRows, const std::atomic<bool>* stop) {
// Row order, so what is on screen first gets its art first.
std::vector<std::string> order;
diff --git a/src/app/library.h b/src/app/library.h
index a01400f..dfe24f8 100644
--- a/src/app/library.h
+++ b/src/app/library.h
@@ -1,11 +1,18 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 RafaelNGP
// Builds the home screen rows: "Jump back in" (the account's recently played
-// cloud titles) followed by the Game Pass lists xbox.com/play shows.
+// cloud titles), "Your games" (what the account owns outside Game Pass:
+// purchases, free-to-play) and the Game Pass lists xbox.com/play shows.
//
-// Two phases: load() fetches every row with the light catalog payload (the
-// home screen can show right away); hydrate() then adds hero art and
-// descriptions in the background and can run on its own thread.
+// The Game Pass rows only hold Game Pass games: xbox.com's "popular" list
+// mixes in "stream your own game" titles that must be bought first, and
+// those would fail to start.
+//
+// Three phases: load() fetches the catalog rows with the light payload (the
+// home screen can show right away); loadOwned() then reads the account's
+// titles (~12 s for ~2700) and adds "Your games" and the playable flags;
+// hydrate() adds hero art and descriptions. The last two can run on their
+// own thread, one after the other.
#pragma once
#include "ui/app_ui.h"
@@ -15,6 +22,7 @@
#include <atomic>
#include <functional>
#include <map>
+#include <set>
#include <string>
#include <vector>
@@ -26,6 +34,9 @@ public:
// Calls `onRows` after each row arrives; false only when nothing loaded.
bool load(xcloud::GssvClient& gssv, const std::string& language, const RowsCallback& onRows, std::string& err);
+ // The account's titles: which games it can play, and the "Your games"
+ // row. Takes its own GssvClient (a copy) so it can run on another thread.
+ void loadOwned(xcloud::GssvClient gssv, const RowsCallback& onRows, const std::atomic<bool>* stop = nullptr);
// Hero art and descriptions, in batches; stops early when `stop` is set.
void hydrate(const RowsCallback& onRows, const std::atomic<bool>* stop = nullptr);
@@ -40,6 +51,10 @@ private:
std::string market_, language_;
std::vector<RowIds> layout_;
std::map<std::string, xcloud::Product> products_;
+ std::set<std::string> gamePass_; // product ids of the Game Pass catalog
+ // Filled by loadOwned(): what the account can stream.
+ bool ownershipKnown_ = false;
+ std::set<std::string> ownedTitles_, ownedProducts_;
};
} // namespace xc::app
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cpp
index 3e2208f..5e6741e 100644
--- a/src/app/ps5_main.cpp
+++ b/src/app/ps5_main.cpp
@@ -328,10 +328,13 @@ void loadLibrary(xcloud::GssvClient& gssv) {
return;
}
std::vector<ui::GameRow> rows = library->rows();
- // Hero art and descriptions keep arriving while the user browses/plays.
+ // The account's own games, then hero art and descriptions, keep arriving
+ // while the user browses/plays. The thread gets its own GssvClient copy.
g_stopHydration = false;
- platform::startThread(g_hydrationThread, [library] {
- library->hydrate([](const std::vector<ui::GameRow>& r) { g_ui->setRows(r); }, &g_stopHydration);
+ platform::startThread(g_hydrationThread, [library, owned = gssv] {
+ auto onRows = [](const std::vector<ui::GameRow>& r) { g_ui->setRows(r); };
+ library->loadOwned(owned, onRows, &g_stopHydration);
+ library->hydrate(onRows, &g_stopHydration);
});
if (!g_autoplayTitle.empty() && g_autoplayTitle != "BENCH") {
platform::sleepMs(6000); // leave the home screen up for ui.ppm
diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cpp
index e901462..0bf2200 100644
--- a/src/ui/app_ui.cpp
+++ b/src/ui/app_ui.cpp
@@ -16,6 +16,15 @@ namespace xc::ui {
namespace {
+// A padlock centred on (cx, cy), about 24x30 px: a game the account can't play.
+void drawLock(Canvas& c, int cx, int cy) {
+ const Color white = rgba(255, 255, 255, 230);
+ c.strokeArc(static_cast<float>(cx), static_cast<float>(cy - 4), 8, 3.5f, 3.1416f, 3.1416f, white);
+ c.line(cx - 8.0f, cy - 4.0f, cx - 8.0f, cy + 1.0f, 3.5f, white);
+ c.line(cx + 8.0f, cy - 4.0f, cx + 8.0f, cy + 1.0f, 3.5f, white);
+ c.fillRect({cx - 12, cy, 24, 18}, white, 4);
+}
+
constexpr int kW = 1920, kH = 1080;
constexpr int kMargin = 96;
constexpr int kCard = 240;
@@ -292,7 +301,7 @@ UiEvent AppUi::handle(const NavInput& in) {
}
break;
case Screen::Details:
- if (in.accept && focusedTile()) {
+ if (in.accept && focusedTile() && focusedTile()->playable) {
ev.action = Action::Play;
ev.game = *focusedTile();
}
@@ -552,7 +561,10 @@ void AppUi::drawHome(Canvas& c, uint64_t nowMs) {
for (size_t i = 0; i < lines.size(); ++i)
fonts_.semibold.draw(c, lines[i], x + 16, cardY + 16 + static_cast<int>(i) * 30, 22, kGray);
}
- if (row.gamePassBadges) {
+ if (!t.playable) { // dimmed, with a lock: can't be streamed on this account
+ c.fillRect({x, cardY, kCard, kCard}, rgba(0, 0, 0, 150), 10);
+ drawLock(c, x + kCard - 34, cardY + 30);
+ } else if (row.gamePassBadges) {
Rect badge{x + 10, cardY + kCard - 34, 96, 24};
c.fillRect(badge, rgba(0, 0, 0, 210), 4);
fonts_.bold.draw(c, "GAME PASS", badge.x + 9, badge.y + 4, 13, kWhite);
@@ -594,6 +606,15 @@ void AppUi::drawDetails(Canvas& c, uint64_t nowMs) {
fonts_.regular.draw(c, line, kMargin, y, 24, kGray);
y += 34;
}
+ if (!g->playable) {
+ // Bought separately or outside the subscription: no Play button.
+ Rect note{kMargin, std::max(y + 48, 620), 560, 76};
+ c.fillRect(note, rgba(255, 255, 255, 40), 38);
+ drawLock(c, note.x + 52, note.y + note.h / 2);
+ fonts_.semibold.draw(c, tr(Str::NotPlayable), note.x + 90, note.y + 22, 28, kGray);
+ drawHints(c, {{kIconCircle, tr(Str::Back)}});
+ return;
+ }
// Play button (focused).
Rect play{kMargin, std::max(y + 48, 620), 300, 76};
c.strokeRect({play.x - 7, play.y - 7, play.w + 14, play.h + 14}, kWhite, 4, 45);
diff --git a/src/ui/app_ui.h b/src/ui/app_ui.h
index 2645e2c..2392fad 100644
--- a/src/ui/app_ui.h
+++ b/src/ui/app_ui.h
@@ -28,6 +28,9 @@ struct GameTile {
std::string tileUrl;
std::string heroUrl;
std::vector<std::string> categories;
+ // False once the account's titles are known and this one isn't among
+ // them (bought separately, or not in the subscription).
+ bool playable = true;
};
struct GameRow {
diff --git a/src/ui/strings.cpp b/src/ui/strings.cpp
index 47f4e3c..a875d97 100644
--- a/src/ui/strings.cpp
+++ b/src/ui/strings.cpp
@@ -76,6 +76,8 @@ constexpr Column kEnglish = {
"Could not load the game list: %s", // LibraryFailed
"Could not start the stream: %s", // StreamFailed
"No input for a while: you will be disconnected in %s seconds", // IdleWarning
+ "Your games", // YourGames
+ "Not available on your account", // NotPlayable
};
constexpr Column kPortugueseBR = {
@@ -122,6 +124,8 @@ constexpr Column kPortugueseBR = {
"Não foi possível carregar a lista de jogos: %s",
"Não foi possível iniciar o streaming: %s",
"Sem atividade: você será desconectado em %s segundos",
+ "Seus jogos",
+ "Indisponível na sua conta",
};
constexpr Column kSpanish = {
@@ -168,6 +172,8 @@ constexpr Column kSpanish = {
"No se pudo cargar la lista de juegos: %s",
"No se pudo iniciar el streaming: %s",
"Sin actividad: se te desconectará en %s segundos",
+ "Tus juegos",
+ "No disponible en tu cuenta",
};
constexpr Column kFrench = {
@@ -214,6 +220,8 @@ constexpr Column kFrench = {
"Impossible de charger la liste des jeux : %s",
"Impossible de démarrer le streaming : %s",
"Aucune activité : vous serez déconnecté dans %s secondes",
+ "Vos jeux",
+ "Indisponible sur votre compte",
};
constexpr Column kGerman = {
@@ -260,6 +268,8 @@ constexpr Column kGerman = {
"Die Spieleliste konnte nicht geladen werden: %s",
"Das Streaming konnte nicht gestartet werden: %s",
"Keine Aktivität: Die Verbindung wird in %s Sekunden getrennt",
+ "Deine Spiele",
+ "Für dein Konto nicht verfügbar",
};
constexpr Column kItalian = {
@@ -306,6 +316,8 @@ constexpr Column kItalian = {
"Impossibile caricare l'elenco dei giochi: %s",
"Impossibile avviare lo streaming: %s",
"Nessuna attività: verrai disconnesso tra %s secondi",
+ "I tuoi giochi",
+ "Non disponibile sul tuo account",
};
constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,
diff --git a/src/ui/strings.h b/src/ui/strings.h
index db0f7cc..8d9ef69 100644
--- a/src/ui/strings.h
+++ b/src/ui/strings.h
@@ -53,6 +53,8 @@ enum class Str {
LibraryFailed, // "%s" = technical detail
StreamFailed, // "%s" = technical detail
IdleWarning, // "%s" = seconds until the server disconnects
+ YourGames, // row of the account's own (non-Game Pass) games
+ NotPlayable, // the account can't stream this game
Count
};
diff --git a/src/xcloud/gssv.cpp b/src/xcloud/gssv.cpp
index 171da6d..29ae51b 100644
--- a/src/xcloud/gssv.cpp
+++ b/src/xcloud/gssv.cpp
@@ -5,6 +5,7 @@
#include "auth/msa.h"
#include "net/http.h"
#include "util/json.h"
+#include "platform/platform.h"
#include "util/log.h"
#include <cstdlib>
@@ -213,6 +214,7 @@ bool GssvClient::login(const auth::XblToken& gssvXsts, std::string& err) {
bool GssvClient::listTitles(std::vector<Title>& out, std::string& err, bool recentOnly) {
out.clear();
+ uint64_t started = platform::nowMs();
std::string continuation;
do {
std::string path = recentOnly ? "/v2/titles/mru?mr=25" : "/v2/titles?mr=200";
@@ -231,7 +233,9 @@ bool GssvClient::listTitles(std::vector<Title>& out, std::string& err, bool rece
if (!title.titleId.empty()) out.push_back(std::move(title));
}
continuation = recentOnly ? std::string() : (*j)["continuationToken"].str();
- } while (!continuation.empty() && out.size() < 2000);
+ } while (!continuation.empty() && out.size() < 5000);
+ XC_LOGI("title list%s: %zu titles in %llu ms", recentOnly ? " (recent)" : "", out.size(),
+ static_cast<unsigned long long>(platform::nowMs() - started));
return true;
}