Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

Settings screen with six languages, stream resolution and server region; PS5 Home art

Rafael Abud Ferreira102eb36770f2
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 8a8375c..e3d207f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -60,6 +60,7 @@ add_library(xcloud_ui STATIC
src/ui/app_ui.cpp
src/ui/brand.cpp
src/app/library.cpp
+ src/app/settings.cpp
extern/qrcodegen/qrcodegen.c
)
target_include_directories(xcloud_ui PUBLIC extern/stb extern/qrcodegen)
@@ -85,6 +86,6 @@ else()
enable_testing()
add_executable(xcloud-tests tests/test_main.cpp)
- target_link_libraries(xcloud-tests PRIVATE xcloud_stream)
+ target_link_libraries(xcloud-tests PRIVATE xcloud_stream xcloud_ui)
add_test(NAME unit COMMAND xcloud-tests)
endif()
diff --git a/README.md b/README.md
index 4155cfc..679ec92 100644
--- a/README.md
+++ b/README.md
@@ -25,7 +25,11 @@ an Xbox controller.
added, Most popular on cloud, Leaving soon and All games.
- WebRTC streaming (libdatachannel on Mbed TLS) with H.264 and Opus decoded by
FFmpeg on the CPU.
-- English UI; text is centralized in `src/ui/strings.cpp` for translation.
+- Settings (Triangle on the home screen): language (English, Português
+ (Brasil), Español, Français, Deutsch, Italiano), stream resolution (1080p or
+ 720p for slower connections) and server region.
+- Custom PS5 Home art (selection and launch backgrounds), generated from the
+ same code as the icon by `tools/ps5/home-art.sh`.
Requires a homebrew-enabled PS5 that can run directory-style apps (for
example through ShadowMountPlus) and a subscription that includes cloud
@@ -71,7 +75,7 @@ cmake -S . -B build-host -G Ninja -DCMAKE_BUILD_TYPE=RelWithDebInfo
ninja -C build-host
build-host/xcloud-tests # unit tests
build-host/xcloud-cli login # sign in
-build-host/xcloud-cli stream BALATRO 30 # stream a title for 30 s
+build-host/xcloud-cli stream BALATRO 30 # stream a title for 30 s (--720p, --region=EASTUS)
build-host/xcloud-cli ui-preview /tmp/ui # render every screen to PNG
```
diff --git a/ps5/release/README.txt b/ps5/release/README.txt
index 68e3fc3..37fe202 100644
--- a/ps5/release/README.txt
+++ b/ps5/release/README.txt
@@ -47,13 +47,21 @@ deletes it.
Controls
--------
Menus: D-pad or left stick to move, Cross to select, Circle to go back,
- OPTIONS to sign out.
+ Triangle for Settings, OPTIONS to sign out.
In game: the DualSense acts as an Xbox controller
(Cross = A, Circle = B, Square = X, Triangle = Y,
OPTIONS = Menu, TOUCHPAD = View).
Hold OPTIONS + TOUCHPAD for one second to leave the game.
+Settings
+--------
+Triangle on the home screen: language (English, Portugues (Brasil),
+Espanol, Francais, Deutsch, Italiano), stream resolution (1080p, or 720p
+for slower connections) and server region (Automatic, or a specific
+Azure region). Saved in /data/homebrew/@TITLE_ID@/settings.json.
+
+
Problems
--------
The app writes a log to /data/homebrew/@TITLE_ID@/xcloud.log (no
diff --git a/ps5/sce_sys/pic0.dds b/ps5/sce_sys/pic0.dds
new file mode 100644
index 0000000..275b17d
Binary files /dev/null and b/ps5/sce_sys/pic0.dds differ
diff --git a/ps5/sce_sys/pic1.dds b/ps5/sce_sys/pic1.dds
new file mode 100644
index 0000000..026413f
Binary files /dev/null and b/ps5/sce_sys/pic1.dds differ
diff --git a/src/app/cli_main.cpp b/src/app/cli_main.cpp
index 12ad013..522245e 100644
--- a/src/app/cli_main.cpp
+++ b/src/app/cli_main.cpp
@@ -36,6 +36,7 @@
#include <cstdio>
#include <cstdlib>
#include <cstring>
+#include <strings.h>
#include <string>
#include <vector>
@@ -144,9 +145,18 @@ int cmdProvision(auth::AuthManager& am, const std::string& titleId) {
return ok ? 0 : 1;
}
-int cmdStream(auth::AuthManager& am, const std::string& titleId, int seconds, const char* outPath) {
+int cmdStream(auth::AuthManager& am, const std::string& titleId, int seconds, const char* outPath,
+ xcloud::Resolution res, const stream::StreamOptions& opts, const std::string& region = {}) {
xcloud::GssvClient gssv;
+ gssv.setResolution(res);
if (!signIn(am, gssv)) return 1;
+ for (const auto& r : gssv.session().regions) {
+ XC_LOGD("region %s%s", r.name.c_str(), r.isDefault ? " (default)" : "");
+ if (!region.empty() && strcasecmp(r.name.c_str(), region.c_str()) == 0) {
+ gssv.setRegion(r);
+ XC_LOGI("using region %s (%s)", r.name.c_str(), r.baseUri.c_str());
+ }
+ }
if (!provision(am, gssv, titleId)) {
gssv.stopSession();
return 1;
@@ -183,7 +193,7 @@ int cmdStream(auth::AuthManager& am, const std::string& titleId, int seconds, co
int rc = 1;
{
- stream::StreamSession session(gssv, cb);
+ stream::StreamSession session(gssv, cb, opts);
std::string err;
if (!session.start(err)) {
XC_LOGE("stream: %s", err.c_str());
@@ -307,6 +317,35 @@ int cmdUiPreview(auth::AuthManager& am, const std::string& dir) {
save("launching");
app.showError("Could not connect to the stream: the server did not answer in time.");
save("error");
+
+ // Settings, then the same screens in Portuguese.
+ std::vector<std::string> regions;
+ for (const auto& r : gssv.session().regions) regions.push_back(r.name);
+ app.setRegions(regions, gssv.region().name);
+ app.showHome();
+ ui::NavInput tri;
+ tri.triangle = true;
+ app.handle(tri);
+ save("settings");
+ ui::NavInput down2;
+ down2.down = true;
+ app.handle(down2);
+ app.handle(down2);
+ ui::NavInput rightOne;
+ rightOne.right = true;
+ app.handle(rightOne); // pick the first non-automatic region
+ ui::NavInput up2;
+ up2.up = true;
+ app.handle(up2);
+ app.handle(up2);
+ app.handle(rightOne); // English -> Portugues (Brasil)
+ save("settings_pt");
+ app.handle(tri); // back to home
+ if (!library.load(gssv, ui::catalogLanguage(), onRows, err)) XC_LOGE("%s", err.c_str());
+ library.hydrate(onRows);
+ app.showHome();
+ save("home_pt", 3000);
+ ui::setLanguage(ui::Language::English);
return 0;
}
@@ -336,6 +375,23 @@ int main(int argc, char** argv) {
}
return stbi_write_png(argv[argi], size, size, 3, rgb.data(), size * 3) ? 0 : 1;
}
+ if ((cmd == "render-pic0" || cmd == "render-pic1") && argi < argc) {
+ // PS5 home-screen backgrounds (PNG; tools/ps5/home-art.sh makes DDS).
+ int w = argi + 1 < argc ? std::atoi(argv[argi + 1]) : 3840;
+ int h = w * 9 / 16;
+ ui::Fonts fonts;
+ if (!fonts.load("assets/fonts")) return 1;
+ ui::Canvas art(w, h);
+ ui::drawHomeArt(art, fonts, cmd == "render-pic1");
+ std::vector<uint8_t> rgb(static_cast<size_t>(w) * h * 3);
+ for (size_t i = 0; i < static_cast<size_t>(w) * h; ++i) {
+ uint32_t p = art.data()[i];
+ rgb[i * 3] = p & 0xFF;
+ rgb[i * 3 + 1] = (p >> 8) & 0xFF;
+ rgb[i * 3 + 2] = (p >> 16) & 0xFF;
+ }
+ return stbi_write_png(argv[argi], w, h, 3, rgb.data(), w * 3) ? 0 : 1;
+ }
if (cmd == "bench-decode" && argi < argc)
return cmdBenchDecode(argv[argi], argi + 1 < argc ? std::atoi(argv[argi + 1]) : 1);
@@ -352,9 +408,19 @@ int main(int argc, char** argv) {
} else if (cmd == "provision" && argi < argc) {
rc = cmdProvision(am, argv[argi]);
} else if (cmd == "stream" && argi < argc) {
- const char* id = argv[argi++];
- int seconds = argi < argc ? std::atoi(argv[argi++]) : 30;
- rc = cmdStream(am, id, seconds > 0 ? seconds : 30, argi < argc ? argv[argi] : nullptr);
+ // stream <id> [seconds] [out.h264] [--720p] [--region=NAME]
+ std::vector<const char*> pos;
+ xcloud::Resolution res = xcloud::Resolution::P1080;
+ stream::StreamOptions opts;
+ std::string region;
+ for (; argi < argc; ++argi) {
+ std::string a = argv[argi];
+ if (a.rfind("--region=", 0) == 0) region = a.substr(9);
+ else if (a == "--720p") res = xcloud::Resolution::P720;
+ else pos.push_back(argv[argi]);
+ }
+ int seconds = pos.size() > 1 ? std::atoi(pos[1]) : 30;
+ rc = cmdStream(am, pos[0], seconds > 0 ? seconds : 30, pos.size() > 2 ? pos[2] : nullptr, res, opts, region);
} else if (cmd == "ui-preview" && argi < argc) {
rc = cmdUiPreview(am, argv[argi]);
} else if (cmd == "logout") {
diff --git a/src/app/ps5_main.cpp b/src/app/ps5_main.cpp
index a66cc23..6d4fdde 100644
--- a/src/app/ps5_main.cpp
+++ b/src/app/ps5_main.cpp
@@ -6,6 +6,7 @@
// One worker thread owns AuthManager/GssvClient and does all network work;
// the main thread reads the pad, drives the UI and draws it.
#include "app/library.h"
+#include "app/settings.h"
#include "app/stream_player.h"
#include "auth/auth_manager.h"
#include "display/display.h"
@@ -39,7 +40,12 @@ std::unique_ptr<ui::AppUi> g_ui;
// --- Worker commands ---------------------------------------------------------
-enum Command { kNone, kSignIn, kPlay, kSignOut };
+enum Command { kNone, kSignIn, kPlay, kSignOut, kReloadLibrary };
+
+// User settings (settings.json); read by the worker, changed by the UI thread.
+std::mutex g_settingsMutex;
+app::Settings g_settings;
+std::string settingsPath() { return platform::dataDir() + "/settings.json"; }
std::atomic<int> g_command{kSignIn};
std::atomic<bool> g_cancel{false};
@@ -134,7 +140,7 @@ std::string stream(xcloud::GssvClient& gssv) {
app::StreamPlayer player(gssv);
if (g_autoplayDump) player.dumpVideo(platform::dataDir() + "/stream.aus", 20);
std::string err;
- if (!player.start(err)) return "ERROR: could not connect the stream: " + err;
+ if (!player.start(err)) return "ERROR: " + ui::trf(ui::Str::StreamFailed, err);
{
std::lock_guard<std::mutex> lock(g_playerMutex);
g_player = &player;
@@ -194,7 +200,17 @@ std::string play(auth::AuthManager& am, xcloud::GssvClient& gssv, const ui::Game
XC_LOGI("starting %s (%s)", game.name.c_str(), game.titleId.c_str());
g_ui->showLaunching(game, ui::tr(ui::Str::Connecting));
std::string err;
- if (!gssv.startSession(game.titleId, "en-US", err)) return err;
+ {
+ std::lock_guard<std::mutex> lock(g_settingsMutex);
+ gssv.setResolution(g_settings.resolution == "720p" ? xcloud::Resolution::P720 : xcloud::Resolution::P1080);
+ const xcloud::Region* region = gssv.session().defaultRegion();
+ for (const auto& r : gssv.session().regions)
+ if (r.name == g_settings.region) region = &r;
+ if (region) gssv.setRegion(*region);
+ XC_LOGI("stream settings: %s, region %s, locale %s", g_settings.resolution.c_str(),
+ region ? region->name.c_str() : "?", ui::gameLocale());
+ }
+ if (!gssv.startSession(game.titleId, ui::gameLocale(), err)) return err;
if (game.heroUrl.empty() && !game.productId.empty()) {
// Picked before the background hydration reached it: fetch the hero
// art for the loading screen while the session queues.
@@ -248,19 +264,29 @@ std::string play(auth::AuthManager& am, xcloud::GssvClient& gssv, const ui::Game
return result;
}
+void loadLibrary(xcloud::GssvClient& gssv);
+
void signInAndLoad(auth::AuthManager& am, xcloud::GssvClient& gssv) {
g_ui->showSplash(ui::tr(am.hasStoredAccount() ? ui::Str::SigningIn : ui::Str::RequestingCode));
std::string err;
auto onCode = [](const auth::DeviceCode& dc) { g_ui->showSignIn(dc.userCode, dc.verificationUri); };
if (!am.signIn(gssv, onCode, err, &g_cancel)) {
XC_LOGE("sign-in failed: %s", err.c_str());
- g_ui->showError("Sign-in failed: " + err);
+ g_ui->showError(ui::trf(ui::Str::SignInFailed, err));
if (!g_autoplayTitle.empty()) XC_LOGI("AUTOPLAY END: sign-in failed");
return;
}
g_ui->setProfile(am.profile().gamertag, am.profile().gamerpicUrl);
platform::notify(ui::trf(ui::Str::SignedInAs, am.profile().gamertag));
+ std::vector<std::string> regions;
+ for (const auto& r : gssv.session().regions) regions.push_back(r.name);
+ const xcloud::Region* def = gssv.session().defaultRegion();
+ g_ui->setRegions(regions, def ? def->name : std::string());
+ loadLibrary(gssv);
+}
+void loadLibrary(xcloud::GssvClient& gssv) {
+ std::string err;
g_ui->showSplash(ui::tr(ui::Str::LoadingGames));
stopHydration();
auto library = std::make_shared<app::Library>();
@@ -275,7 +301,7 @@ void signInAndLoad(auth::AuthManager& am, xcloud::GssvClient& gssv) {
},
err);
if (!ok) {
- g_ui->showError("Could not load the game list: " + err);
+ g_ui->showError(ui::trf(ui::Str::LibraryFailed, err));
return;
}
std::vector<ui::GameRow> rows = library->rows();
@@ -312,6 +338,7 @@ void worker() {
g_cancel = false;
switch (cmd) {
case kSignIn: signInAndLoad(am, gssv); break;
+ case kReloadLibrary: loadLibrary(gssv); break; // e.g. after a language change
case kSignOut:
am.signOut();
g_ui->setProfile({}, {});
@@ -327,7 +354,7 @@ void worker() {
std::string result = play(am, gssv, tile, failed);
XC_LOGI("%s", result.c_str());
if (failed)
- g_ui->showError(result);
+ g_ui->showError(result.rfind("ERROR: ", 0) == 0 ? result.substr(7) : result);
else
g_ui->showHome(ui::tr(ui::Str::StreamEnded));
autoplayFinished(result);
@@ -375,6 +402,10 @@ int main(int argc, char** argv) {
log::setFile((platform::dataDir() + "/xcloud.log").c_str());
XC_LOGI("=== PSBox Cloud Gaming starting ===");
loadAutoplay();
+ g_settings.load(settingsPath());
+ ui::setLanguage(ui::languageFromCode(g_settings.language));
+ XC_LOGI("settings: language %s, %s, region %s", g_settings.language.c_str(), g_settings.resolution.c_str(),
+ g_settings.region.empty() ? "auto" : g_settings.region.c_str());
sceSystemServiceHideSplashScreen();
bool haveDisplay = display::init();
@@ -386,6 +417,13 @@ int main(int argc, char** argv) {
if (g_ui) g_ui->invalidate();
});
g_ui = std::make_unique<ui::AppUi>(fonts, *g_images);
+ {
+ ui::SettingsChoice choice;
+ choice.language = static_cast<int>(ui::language());
+ choice.hd = g_settings.resolution != "720p";
+ choice.region = g_settings.region;
+ g_ui->setSettings(choice);
+ }
ui::Canvas canvas(display::kWidth, display::kHeight);
if (!net::initTls(platform::caBundlePath())) {
@@ -436,6 +474,7 @@ int main(int argc, char** argv) {
nav.accept = pad.btnA && !prev.btnA;
nav.back = pad.btnB && !prev.btnB;
nav.options = pad.btnOptions && !prev.btnOptions;
+ nav.triangle = pad.btnY && !prev.btnY;
prev = pad;
ui::UiEvent ev = g_ui->handle(nav);
@@ -452,6 +491,24 @@ int main(int argc, char** argv) {
break;
case ui::Action::Retry: g_command = kSignIn; break;
case ui::Action::CancelLaunch: g_cancel = true; break;
+ case ui::Action::SettingsChanged: {
+ bool languageChanged;
+ {
+ std::lock_guard<std::mutex> lock(g_settingsMutex);
+ std::string code = ui::languageCode(static_cast<ui::Language>(ev.settings.language));
+ languageChanged = code != g_settings.language;
+ g_settings.language = code;
+ g_settings.resolution = ev.settings.hd ? "1080p" : "720p";
+ g_settings.region = ev.settings.region;
+ if (!g_settings.save(settingsPath())) XC_LOGW("could not save settings");
+ XC_LOGI("settings saved: language %s, %s, region %s", code.c_str(), g_settings.resolution.c_str(),
+ g_settings.region.empty() ? "auto" : g_settings.region.c_str());
+ }
+ // Row titles and game details come from the catalog in the
+ // chosen language.
+ if (languageChanged) g_command = kReloadLibrary;
+ break;
+ }
case ui::Action::None: break;
}
diff --git a/src/app/settings.cpp b/src/app/settings.cpp
new file mode 100644
index 0000000..717dd10
--- /dev/null
+++ b/src/app/settings.cpp
@@ -0,0 +1,30 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+#include "app/settings.h"
+
+#include "platform/platform.h"
+#include "util/json.h"
+
+namespace xc::app {
+
+bool Settings::load(const std::string& path) {
+ std::string text;
+ if (!platform::readFile(path, text)) return false;
+ auto j = json::parse(text);
+ if (!j) return false;
+ language = (*j)["language"].str(language);
+ resolution = (*j)["resolution"].str(resolution);
+ region = (*j)["region"].str(region);
+ if (resolution != "720p") resolution = "1080p";
+ return true;
+}
+
+bool Settings::save(const std::string& path) const {
+ json::Value v = json::Value::object();
+ v.set("language", language);
+ v.set("resolution", resolution);
+ v.set("region", region);
+ return platform::writeFileAtomic(path, v.dump());
+}
+
+} // namespace xc::app
diff --git a/src/app/settings.h b/src/app/settings.h
new file mode 100644
index 0000000..c5b76ae
--- /dev/null
+++ b/src/app/settings.h
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 RafaelNGP
+// User settings, kept in <dataDir>/settings.json.
+#pragma once
+
+#include <string>
+
+namespace xc::app {
+
+struct Settings {
+ std::string language = "en"; // ui::languageCode()
+ std::string resolution = "1080p"; // "1080p" or "720p"
+ std::string region; // gssv region name; empty = automatic
+
+ bool load(const std::string& path);
+ bool save(const std::string& path) const;
+};
+
+} // namespace xc::app
diff --git a/src/stream/stream_session.cpp b/src/stream/stream_session.cpp
index dbd7b49..c12fa05 100644
--- a/src/stream/stream_session.cpp
+++ b/src/stream/stream_session.cpp
@@ -255,6 +255,7 @@ struct StreamSession::Impl {
std::string id = (*j)["id"].str();
XC_LOGI("message %s %s", type.c_str(), target.c_str());
if (target == "/streaming/sessionLifetimeManagement/serverInitiatedDisconnect") {
+ XC_LOGW("server disconnect: %s", (*j)["content"].str().substr(0, 300).c_str());
completeTransaction(id, json::Value(""));
fail("the server ended the session");
} else if (target == "/streaming/systemUi/messages/ShowMessageDialog") {
diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cpp
index 3f00209..2f17f67 100644
--- a/src/ui/app_ui.cpp
+++ b/src/ui/app_ui.cpp
@@ -8,6 +8,7 @@
#include "qrcodegen.h"
#include <algorithm>
+#include <cctype>
#include <cmath>
#include <map>
@@ -36,6 +37,35 @@ enum Icon { kIconCross, kIconCircle, kIconOptions, kIconTriangle };
} // namespace
+std::string prettyRegion(const std::string& name) {
+ static const char* kWords[] = {"SOUTHEAST", "NORTHEAST", "CENTRAL", "AUSTRALIA", "GERMANY", "EUROPE", "BRAZIL",
+ "CANADA", "FRANCE", "MEXICO", "SWEDEN", "JAPAN", "KOREA", "INDIA", "NORTH",
+ "SOUTH", "EAST", "WEST", "ASIA", "UK", "US"};
+ std::string out;
+ size_t i = 0;
+ while (i < name.size()) {
+ bool matched = false;
+ for (const char* w : kWords) {
+ size_t n = std::char_traits<char>::length(w);
+ if (name.compare(i, n, w) == 0) {
+ std::string word = n <= 2 ? std::string(w) : std::string(1, w[0]);
+ if (n > 2)
+ for (size_t k = 1; k < n; ++k) word += static_cast<char>(w[k] - 'A' + 'a');
+ out += (out.empty() ? "" : " ") + word;
+ i += n;
+ matched = true;
+ break;
+ }
+ }
+ if (!matched) {
+ if (std::isdigit(static_cast<unsigned char>(name[i])) && !out.empty() && !std::isdigit(static_cast<unsigned char>(out.back())))
+ out += ' ';
+ out += name[i++];
+ }
+ }
+ return out;
+}
+
bool AppUi::Anim::step(float dt) {
float d = target - value;
if (std::fabs(d) < 0.5f) {
@@ -148,6 +178,39 @@ void AppUi::showError(const std::string& message) {
dirty_ = true;
}
+void AppUi::setSettings(const SettingsChoice& choice) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ settings_ = choice;
+ dirty_ = true;
+}
+
+void AppUi::setRegions(std::vector<std::string> regions, const std::string& defaultRegion) {
+ std::lock_guard<std::mutex> lock(mutex_);
+ regions_ = std::move(regions);
+ defaultRegion_ = defaultRegion;
+ dirty_ = true;
+}
+
+void AppUi::changeSetting(int delta) {
+ // Caller holds mutex_.
+ if (settingsRow_ == 0) {
+ int n = static_cast<int>(Language::Count);
+ settings_.language = (settings_.language + delta + n) % n;
+ setLanguage(static_cast<Language>(settings_.language)); // the UI switches right away
+ } else if (settingsRow_ == 1) {
+ settings_.hd = !settings_.hd;
+ } else {
+ // Index 0 is automatic, then the regions in the login's order.
+ int n = static_cast<int>(regions_.size()) + 1;
+ int cur = 0;
+ for (size_t i = 0; i < regions_.size(); ++i)
+ if (regions_[i] == settings_.region) cur = static_cast<int>(i) + 1;
+ cur = (cur + delta + n) % n;
+ settings_.region = cur == 0 ? std::string() : regions_[static_cast<size_t>(cur - 1)];
+ }
+ dirty_ = true;
+}
+
Screen AppUi::screen() const {
std::lock_guard<std::mutex> lock(mutex_);
return screen_;
@@ -186,6 +249,11 @@ UiEvent AppUi::handle(const NavInput& in) {
case Screen::Home: {
if (rows_.empty()) {
if (in.options) ev.action = Action::SignOut;
+ if (in.triangle) {
+ screen_ = Screen::Settings;
+ settingsRow_ = 0;
+ dirty_ = true;
+ }
break;
}
int rows = static_cast<int>(rows_.size());
@@ -204,8 +272,25 @@ UiEvent AppUi::handle(const NavInput& in) {
dirty_ = true;
}
if (in.options) ev.action = Action::SignOut;
+ if (in.triangle) {
+ screen_ = Screen::Settings;
+ settingsRow_ = 0;
+ dirty_ = true;
+ }
break;
}
+ case Screen::Settings:
+ if (in.down && settingsRow_ < 2) ++settingsRow_, dirty_ = true;
+ if (in.up && settingsRow_ > 0) --settingsRow_, dirty_ = true;
+ if (in.right || in.accept) changeSetting(+1);
+ if (in.left) changeSetting(-1);
+ if (in.back || in.triangle) {
+ screen_ = Screen::Home;
+ dirty_ = true;
+ ev.action = Action::SettingsChanged;
+ ev.settings = settings_;
+ }
+ break;
case Screen::Details:
if (in.accept && focusedTile()) {
ev.action = Action::Play;
@@ -459,7 +544,7 @@ void AppUi::drawHome(Canvas& c, uint64_t nowMs) {
// Fade the rows out under the button hints.
c.gradientV({0, kH - 190, kW, 110}, withAlpha(kBg, 0), withAlpha(kBg, 245));
c.fillRect({0, kH - 80, kW, 80}, withAlpha(kBg, 245));
- drawHints(c, {{kIconCross, tr(Str::Select)}, {kIconOptions, tr(Str::SignOut)}});
+ drawHints(c, {{kIconCross, tr(Str::Select)}, {kIconTriangle, tr(Str::Settings)}, {kIconOptions, tr(Str::SignOut)}});
drawToast(c, nowMs);
}
@@ -529,6 +614,40 @@ void AppUi::drawError(Canvas& c) {
drawHints(c, {{kIconCross, tr(Str::TryAgain)}, {kIconOptions, tr(Str::SignOut)}});
}
+void AppUi::drawSettings(Canvas& c) {
+ drawBackground(c);
+ drawTopBar(c);
+ fonts_.bold.draw(c, tr(Str::Settings), kMargin, 170, 60, kWhite);
+ struct Row {
+ const char* label;
+ std::string value;
+ };
+ std::string region = settings_.region.empty()
+ ? trf(Str::RegionAuto, defaultRegion_.empty() ? "-" : prettyRegion(defaultRegion_))
+ : prettyRegion(settings_.region);
+ const Row rows[] = {{tr(Str::Language), languageName(static_cast<Language>(settings_.language))},
+ {tr(Str::Resolution), tr(settings_.hd ? Str::Res1080 : Str::Res720)},
+ {tr(Str::Region), region}};
+ constexpr int kRowW = 1200, kRowH = 92;
+ int y = 290;
+ for (int i = 0; i < 3; ++i) {
+ Rect r{kMargin, y, kRowW, kRowH};
+ bool focused = i == settingsRow_;
+ c.fillRect(r, focused ? rgba(255, 255, 255, 36) : rgba(255, 255, 255, 14), 16);
+ if (focused) c.strokeRect({r.x - 5, r.y - 5, r.w + 10, r.h + 10}, kWhite, 3, 20);
+ fonts_.semibold.draw(c, rows[i].label, r.x + 36, r.y + 28, 30, kWhite);
+ std::string value = focused ? "\xE2\x80\xB9 " + rows[i].value + " \xE2\x80\xBA" : rows[i].value;
+ int w = fonts_.regular.measure(value, 30);
+ fonts_.regular.draw(c, value, r.x + r.w - 36 - w, r.y + 28, 30, focused ? kWhite : kGray);
+ y += kRowH + 22;
+ }
+ for (const auto& line : fonts_.regular.wrap(tr(Str::SettingsNote), 24, kRowW, 2)) {
+ fonts_.regular.draw(c, line, kMargin, y + 20, 24, kDim);
+ y += 34;
+ }
+ drawHints(c, {{kIconCross, tr(Str::Change)}, {kIconCircle, tr(Str::Back)}});
+}
+
void AppUi::render(Canvas& c, uint64_t nowMs) {
std::lock_guard<std::mutex> lock(mutex_);
float dt = lastRender_ ? std::min(0.1f, (nowMs - lastRender_) / 1000.0f) : 0.0f;
@@ -543,6 +662,7 @@ void AppUi::render(Canvas& c, uint64_t nowMs) {
case Screen::Details: drawDetails(c, nowMs); break;
case Screen::Launching: drawLaunching(c, nowMs); break;
case Screen::Error: drawError(c); break;
+ case Screen::Settings: drawSettings(c); break;
case Screen::Streaming: break;
}
if (!toast_.empty()) animating_ = true; // to expire it
diff --git a/src/ui/app_ui.h b/src/ui/app_ui.h
index e40b357..49512d9 100644
--- a/src/ui/app_ui.h
+++ b/src/ui/app_ui.h
@@ -36,20 +36,31 @@ struct GameRow {
bool gamePassBadges = true;
};
-enum class Screen { Splash, SignIn, Home, Details, Launching, Streaming, Error };
+enum class Screen { Splash, SignIn, Home, Details, Launching, Streaming, Error, Settings };
struct NavInput {
bool up = false, down = false, left = false, right = false;
- bool accept = false, back = false, options = false;
+ bool accept = false, back = false, options = false, triangle = false;
};
-enum class Action { None, Play, SignOut, Retry, CancelLaunch };
+// What the Settings screen edits.
+struct SettingsChoice {
+ int language = 0; // ui::Language
+ bool hd = true; // 1080p (else 720p)
+ std::string region; // gssv region name; empty = automatic
+};
+
+enum class Action { None, Play, SignOut, Retry, CancelLaunch, SettingsChanged };
struct UiEvent {
Action action = Action::None;
GameTile game;
+ SettingsChoice settings; // SettingsChanged
};
+// "SOUTHCENTRALUS" -> "South Central US".
+std::string prettyRegion(const std::string& name);
+
class AppUi {
public:
AppUi(const Fonts& fonts, ImageCache& images);
@@ -65,6 +76,10 @@ public:
void setLaunchStatus(const std::string& status);
void showStreaming();
void showError(const std::string& message);
+ void setSettings(const SettingsChoice& choice);
+ // Regions offered by the account's xCloud login; `defaultRegion` is the
+ // one "Automatic" picks.
+ void setRegions(std::vector<std::string> regions, const std::string& defaultRegion);
Screen screen() const;
void invalidate();
@@ -94,6 +109,8 @@ private:
void drawDetails(Canvas& c, uint64_t nowMs);
void drawLaunching(Canvas& c, uint64_t nowMs);
void drawError(Canvas& c);
+ void drawSettings(Canvas& c);
+ void changeSetting(int delta);
void drawCentered(Canvas& c, const Font& f, const std::string& text, int y, int px, Color color);
const Fonts& fonts_;
@@ -112,6 +129,10 @@ private:
Anim rowY_;
GameTile launching_;
std::string error_;
+ SettingsChoice settings_;
+ std::vector<std::string> regions_;
+ std::string defaultRegion_;
+ int settingsRow_ = 0;
std::string toast_;
uint64_t toastUntil_ = 0;
std::string heroUrl_, prevHeroUrl_;
diff --git a/src/ui/brand.cpp b/src/ui/brand.cpp
index 5dde5f0..a8b7dd9 100644
--- a/src/ui/brand.cpp
+++ b/src/ui/brand.cpp
@@ -60,4 +60,37 @@ void drawAppIcon(Canvas& c, const Fonts& fonts) {
fonts.bold.draw(c, word, (s - w) / 2, static_cast<int>(s * 0.74f), px, rgba(255, 255, 255));
}
+void drawHomeArt(Canvas& c, const Fonts& fonts, bool launch) {
+ const float w = static_cast<float>(c.width()), h = static_cast<float>(c.height());
+ const float cx = launch ? w * 0.5f : w * 0.70f;
+ const float cy = launch ? h * 0.42f : h * 0.47f;
+ const float r = h * (launch ? 0.17f : 0.22f);
+
+ // Near-black on the left (the Shell draws text there) to deep green.
+ c.gradientH({0, 0, c.width(), c.height()}, rgba(5, 9, 6), rgba(10, 64, 12));
+ // Soft green glow behind the mark: stacked translucent discs.
+ for (int i = 40; i > 0; --i) c.fillCircle(cx, cy, r * (1.0f + i * 0.09f), rgba(40, 200, 60, 4));
+ for (int i = 12; i > 0; --i) c.fillCircle(cx, cy, r * (1.0f + i * 0.03f), rgba(70, 230, 90, 5));
+ // Light streaks, as if moving fast through a tunnel of light.
+ for (int i = 0; i < 9; ++i) {
+ float y0 = h * (0.08f + 0.11f * i);
+ float tilt = h * 0.22f;
+ c.line(cx - w * 0.55f, y0 + tilt, cx + w * 0.55f, y0 - tilt, h * (0.002f + 0.0015f * (i % 3)),
+ rgba(150, 255, 160, static_cast<uint8_t>(10 + 6 * (i % 3))));
+ }
+ // Darken the edges so the Shell's overlays stay readable.
+ c.gradientV({0, 0, c.width(), static_cast<int>(h * 0.25f)}, rgba(0, 0, 0, 120), rgba(0, 0, 0, 0));
+ c.gradientV({0, static_cast<int>(h * 0.7f), c.width(), static_cast<int>(h * 0.3f) + 1}, rgba(0, 0, 0, 0),
+ rgba(0, 0, 0, 150));
+ if (!launch) c.gradientH({0, 0, static_cast<int>(w * 0.45f), c.height()}, rgba(0, 0, 0, 140), rgba(0, 0, 0, 0));
+
+ drawBrandMark(c, cx, cy, r);
+ if (launch) {
+ const char* name = "PSBox Cloud Gaming";
+ int px = static_cast<int>(h * 0.065f);
+ int tw = fonts.bold.measure(name, px);
+ fonts.bold.draw(c, name, (c.width() - tw) / 2, static_cast<int>(cy + r * 1.45f), px, rgba(255, 255, 255));
+ }
+}
+
} // namespace xc::ui
diff --git a/src/ui/brand.h b/src/ui/brand.h
index 1d0e8ab..798b200 100644
--- a/src/ui/brand.h
+++ b/src/ui/brand.h
@@ -20,4 +20,10 @@ void drawBrandMark(Canvas& c, float cx, float cy, float r, Color color = rgba(25
// The square app icon (green field, mark, "PSBox" wordmark).
void drawAppIcon(Canvas& c, const Fonts& fonts);
+// PS5 home-screen artwork, any 16:9 size (3840x2160 for sce_sys):
+// `launch` false: pic0, the selected-app background (mark on the right, the
+// left kept dark for the Shell's title and Play button);
+// `launch` true: pic1, the launch transition (mark and name centred).
+void drawHomeArt(Canvas& c, const Fonts& fonts, bool launch);
+
} // namespace xc::ui
diff --git a/src/ui/strings.cpp b/src/ui/strings.cpp
index f03aee2..36cdc5b 100644
--- a/src/ui/strings.cpp
+++ b/src/ui/strings.cpp
@@ -3,14 +3,36 @@
#include "ui/strings.h"
#include <array>
+#include <atomic>
namespace xc::ui {
namespace {
-Language g_language = Language::English;
+constexpr size_t kLangs = static_cast<size_t>(Language::Count);
+constexpr size_t kStrs = static_cast<size_t>(Str::Count);
-constexpr std::array<const char*, static_cast<size_t>(Str::Count)> kEnglish = {
+std::atomic<int> g_language{0};
+
+struct LangInfo {
+ const char* name;
+ const char* code;
+ const char* catalog;
+ const char* locale;
+};
+
+constexpr std::array<LangInfo, kLangs> kInfo = {{
+ {"English", "en", "en-us", "en-US"},
+ {"Português (Brasil)", "pt-BR", "pt-br", "pt-BR"},
+ {"Español", "es", "es-es", "es-ES"},
+ {"Français", "fr", "fr-fr", "fr-FR"},
+ {"Deutsch", "de", "de-de", "de-DE"},
+ {"Italiano", "it", "it-it", "it-IT"},
+}};
+
+using Column = std::array<const char*, kStrs>;
+
+constexpr Column kEnglish = {
"PSBox Cloud Gaming", // AppName
"PSBOX CLOUD GAMING", // CloudGaming
"Signing in...", // SigningIn
@@ -38,23 +60,267 @@ constexpr std::array<const char*, static_cast<size_t>(Str::Count)> kEnglish = {
"Signed in as %s", // SignedInAs
"No games to show yet", // NoGames
"By %s", // PublisherBy
+ "Settings", // Settings
+ "Language", // Language
+ "Stream resolution", // Resolution
+ "Server region", // Region
+ "Automatic (%s)", // RegionAuto
+ "1080p (Full HD)", // Res1080
+ "720p (uses less data)", // Res720
+ "Resolution and region apply to the next game you start.", // SettingsNote
+ "Change", // Change
+ "Sign-in failed: %s", // SignInFailed
+ "Could not load the game list: %s", // LibraryFailed
+ "Could not start the stream: %s", // StreamFailed
+};
+
+constexpr Column kPortugueseBR = {
+ "PSBox Cloud Gaming",
+ "PSBOX CLOUD GAMING",
+ "Entrando...",
+ "Gerando um código de login...",
+ "Carregando seus jogos...",
+ "Entre para jogar",
+ "No celular ou computador, acesse",
+ "e digite este código",
+ "Escaneie para abrir a página e digite o código",
+ "Aguardando você entrar...",
+ "Continue jogando",
+ "Jogar",
+ "Voltar",
+ "Selecionar",
+ "Sair da conta",
+ "Cancelar",
+ "Tentar de novo",
+ "Preparando seu jogo",
+ "Você está na fila. Espera estimada: %s",
+ "Conectando...",
+ "Iniciando o streaming...",
+ "Segure OPTIONS + TOUCHPAD para sair do jogo",
+ "Streaming encerrado",
+ "Algo deu errado",
+ "Conectado como %s",
+ "Nenhum jogo para mostrar ainda",
+ "Por %s",
+ "Configurações",
+ "Idioma",
+ "Resolução do streaming",
+ "Região do servidor",
+ "Automática (%s)",
+ "1080p (Full HD)",
+ "720p (usa menos dados)",
+ "A resolução e a região valem a partir do próximo jogo.",
+ "Alterar",
+ "Falha ao entrar: %s",
+ "Não foi possível carregar a lista de jogos: %s",
+ "Não foi possível iniciar o streaming: %s",
+};
+
+constexpr Column kSpanish = {
+ "PSBox Cloud Gaming",
+ "PSBOX CLOUD GAMING",
+ "Iniciando sesión...",
+ "Obteniendo un código de inicio de sesión...",
+ "Cargando tus juegos...",
+ "Inicia sesión para jugar",
+ "En tu teléfono u ordenador, ve a",
+ "e introduce este código",
+ "Escanea para abrir la página e introduce el código",
+ "Esperando a que inicies sesión...",
+ "Seguir jugando",
+ "Jugar",
+ "Atrás",
+ "Seleccionar",
+ "Cerrar sesión",
+ "Cancelar",
+ "Reintentar",
+ "Preparando tu juego",
+ "Estás en la cola. Espera estimada: %s",
+ "Conectando...",
+ "Iniciando el streaming...",
+ "Mantén OPTIONS + TOUCHPAD para salir del juego",
+ "Streaming finalizado",
+ "Algo salió mal",
+ "Sesión iniciada como %s",
+ "Todavía no hay juegos para mostrar",
+ "De %s",
+ "Ajustes",
+ "Idioma",
+ "Resolución del streaming",
+ "Región del servidor",
+ "Automática (%s)",
+ "1080p (Full HD)",
+ "720p (usa menos datos)",
+ "La resolución y la región se aplican al próximo juego que inicies.",
+ "Cambiar",
+ "Error al iniciar sesión: %s",
+ "No se pudo cargar la lista de juegos: %s",
+ "No se pudo iniciar el streaming: %s",
+};
+
+constexpr Column kFrench = {
+ "PSBox Cloud Gaming",
+ "PSBOX CLOUD GAMING",
+ "Connexion...",
+ "Obtention d'un code de connexion...",
+ "Chargement de vos jeux...",
+ "Connectez-vous pour jouer",
+ "Sur votre téléphone ou ordinateur, allez sur",
+ "et saisissez ce code",
+ "Scannez pour ouvrir la page, puis saisissez le code",
+ "En attente de votre connexion...",
+ "Reprendre",
+ "Jouer",
+ "Retour",
+ "Sélectionner",
+ "Se déconnecter",
+ "Annuler",
+ "Réessayer",
+ "Préparation de votre jeu",
+ "Vous êtes dans la file d'attente. Attente estimée : %s",
+ "Connexion...",
+ "Démarrage du streaming...",
+ "Maintenez OPTIONS + PAVÉ TACTILE pour quitter le jeu",
+ "Streaming terminé",
+ "Un problème est survenu",
+ "Connecté en tant que %s",
+ "Aucun jeu à afficher pour le moment",
+ "Par %s",
+ "Paramètres",
+ "Langue",
+ "Résolution du streaming",
+ "Région du serveur",
+ "Automatique (%s)",
+ "1080p (Full HD)",
+ "720p (consomme moins de données)",
+ "La résolution et la région s'appliquent au prochain jeu lancé.",
+ "Modifier",
+ "Échec de la connexion : %s",
+ "Impossible de charger la liste des jeux : %s",
+ "Impossible de démarrer le streaming : %s",
+};
+
+constexpr Column kGerman = {
+ "PSBox Cloud Gaming",
+ "PSBOX CLOUD GAMING",
+ "Anmeldung läuft...",
+ "Anmeldecode wird abgerufen...",
+ "Deine Spiele werden geladen...",
+ "Zum Spielen anmelden",
+ "Rufe auf deinem Handy oder Computer",
+ "auf und gib diesen Code ein",
+ "Scannen, um die Seite zu öffnen, dann den Code eingeben",
+ "Warte auf deine Anmeldung...",
+ "Weiterspielen",
+ "Spielen",
+ "Zurück",
+ "Auswählen",
+ "Abmelden",
+ "Abbrechen",
+ "Erneut versuchen",
+ "Dein Spiel wird vorbereitet",
+ "Du bist in der Warteschlange. Geschätzte Wartezeit: %s",
+ "Verbindung wird hergestellt...",
+ "Streaming wird gestartet...",
+ "OPTIONS + TOUCHPAD gedrückt halten, um das Spiel zu verlassen",
+ "Streaming beendet",
+ "Etwas ist schiefgelaufen",
+ "Angemeldet als %s",
+ "Noch keine Spiele vorhanden",
+ "Von %s",
+ "Einstellungen",
+ "Sprache",
+ "Streaming-Auflösung",
+ "Serverregion",
+ "Automatisch (%s)",
+ "1080p (Full HD)",
+ "720p (verbraucht weniger Daten)",
+ "Auflösung und Region gelten ab dem nächsten gestarteten Spiel.",
+ "Ändern",
+ "Anmeldung fehlgeschlagen: %s",
+ "Die Spieleliste konnte nicht geladen werden: %s",
+ "Das Streaming konnte nicht gestartet werden: %s",
+};
+
+constexpr Column kItalian = {
+ "PSBox Cloud Gaming",
+ "PSBOX CLOUD GAMING",
+ "Accesso in corso...",
+ "Richiesta di un codice di accesso...",
+ "Caricamento dei tuoi giochi...",
+ "Accedi per giocare",
+ "Sul telefono o sul computer, vai su",
+ "e inserisci questo codice",
+ "Scansiona per aprire la pagina, poi inserisci il codice",
+ "In attesa del tuo accesso...",
+ "Riprendi a giocare",
+ "Gioca",
+ "Indietro",
+ "Seleziona",
+ "Esci",
+ "Annulla",
+ "Riprova",
+ "Preparazione del gioco",
+ "Sei in coda. Attesa stimata: %s",
+ "Connessione...",
+ "Avvio dello streaming...",
+ "Tieni premuti OPTIONS + TOUCHPAD per uscire dal gioco",
+ "Streaming terminato",
+ "Si è verificato un problema",
+ "Accesso effettuato come %s",
+ "Ancora nessun gioco da mostrare",
+ "Di %s",
+ "Impostazioni",
+ "Lingua",
+ "Risoluzione dello streaming",
+ "Regione del server",
+ "Automatica (%s)",
+ "1080p (Full HD)",
+ "720p (usa meno dati)",
+ "Risoluzione e regione valgono dal prossimo gioco avviato.",
+ "Cambia",
+ "Accesso non riuscito: %s",
+ "Impossibile caricare l'elenco dei giochi: %s",
+ "Impossibile avviare lo streaming: %s",
};
+constexpr std::array<const Column*, kLangs> kTable = {&kEnglish, &kPortugueseBR, &kSpanish,
+ &kFrench, &kGerman, &kItalian};
+
+const LangInfo& info() { return kInfo[static_cast<size_t>(g_language.load())]; }
+
} // namespace
-void setLanguage(Language lang) { g_language = lang; }
-Language language() { return g_language; }
+void setLanguage(Language lang) {
+ if (static_cast<size_t>(lang) < kLangs) g_language = static_cast<int>(lang);
+}
+
+Language language() { return static_cast<Language>(g_language.load()); }
+
+const char* languageName(Language lang) {
+ auto i = static_cast<size_t>(lang);
+ return i < kLangs ? kInfo[i].name : "";
+}
+
+const char* languageCode(Language lang) {
+ auto i = static_cast<size_t>(lang);
+ return i < kLangs ? kInfo[i].code : "en";
+}
-const char* catalogLanguage() {
- switch (g_language) {
- case Language::English: break;
- }
- return "en-us";
+Language languageFromCode(const std::string& code) {
+ for (size_t i = 0; i < kLangs; ++i)
+ if (code == kInfo[i].code) return static_cast<Language>(i);
+ return Language::English;
}
+const char* catalogLanguage() { return info().catalog; }
+const char* gameLocale() { return info().locale; }
+
const char* tr(Str id) {
auto i = static_cast<size_t>(id);
- return i < kEnglish.size() ? kEnglish[i] : "";
+ if (i >= kStrs) return "";
+ const char* s = (*kTable[static_cast<size_t>(g_language.load())])[i];
+ return s && *s ? s : kEnglish[i];
}
std::string trf(Str id, const std::string& arg) {
diff --git a/src/ui/strings.h b/src/ui/strings.h
index 8ab520a..12c1751 100644
--- a/src/ui/strings.h
+++ b/src/ui/strings.h
@@ -1,7 +1,8 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (C) 2026 RafaelNGP
-// User-facing text. English is the default; other languages add a column to
-// the table in strings.cpp and are picked with setLanguage().
+// User-facing text in every supported language. English is the default; the
+// user picks another in Settings. To add a language: a Language value, its
+// codes in strings.cpp, and a column in the table there.
#pragma once
#include <string>
@@ -36,15 +37,34 @@ enum class Str {
SignedInAs, // "%s" = gamertag
NoGames,
PublisherBy, // "%s" = publisher
+ Settings,
+ Language,
+ Resolution,
+ Region,
+ RegionAuto, // "%s" = the account's default region
+ Res1080,
+ Res720,
+ SettingsNote,
+ Change,
+ SignInFailed, // "%s" = technical detail
+ LibraryFailed, // "%s" = technical detail
+ StreamFailed, // "%s" = technical detail
Count
};
-enum class Language { English };
+enum class Language { English, PortugueseBR, Spanish, French, German, Italian, Count };
void setLanguage(Language lang);
Language language();
-// Catalog language tag for the current language, e.g. "en-us".
+// The language's own name ("Português (Brasil)").
+const char* languageName(Language lang);
+// Stable code saved in settings.json ("pt-BR"); fromCode() falls back to English.
+const char* languageCode(Language lang);
+Language languageFromCode(const std::string& code);
+// Catalog language tag for the current language, e.g. "pt-br".
const char* catalogLanguage();
+// Locale asked of the cloud game, e.g. "pt-BR".
+const char* gameLocale();
const char* tr(Str id);
// tr() with one "%s" substituted.
diff --git a/src/xcloud/gssv.cpp b/src/xcloud/gssv.cpp
index 1410539..229b41c 100644
--- a/src/xcloud/gssv.cpp
+++ b/src/xcloud/gssv.cpp
@@ -16,9 +16,9 @@ namespace {
constexpr const char* kClientHeader = "XboxComBrowser";
// Sent like the Windows Xbox app does: "Windows" plus a 1080p display is what
-// gets a 1080p stream instead of 720p.
-const std::string& deviceInfo() {
- static const std::string info = [] {
+// gets a 1080p stream; an Android device with a 720p display gets 720p.
+const std::string& deviceInfo(Resolution res) {
+ auto build = [](bool hd) {
json::Value env = json::Value::object();
env.set("clientAppId", "Microsoft.GamingApp");
env.set("clientAppType", "native");
@@ -29,16 +29,16 @@ const std::string& deviceInfo() {
json::Value app = json::Value::object();
app.set("env", env);
json::Value hw = json::Value::object();
- hw.set("make", "Microsoft");
- hw.set("model", "Surface Pro");
+ hw.set("make", hd ? "Microsoft" : "Google");
+ hw.set("model", hd ? "Surface Pro" : "Pixel");
hw.set("sdktype", "native");
json::Value os = json::Value::object();
- os.set("name", "Windows 11");
- os.set("ver", "22631.2715");
- os.set("platform", "desktop");
+ os.set("name", hd ? "Windows 11" : "Android");
+ os.set("ver", hd ? "22631.2715" : "14");
+ os.set("platform", hd ? "desktop" : "phone");
json::Value dims = json::Value::object();
- dims.set("widthInPixels", 1920);
- dims.set("heightInPixels", 1080);
+ dims.set("widthInPixels", hd ? 1920 : 1280);
+ dims.set("heightInPixels", hd ? 1080 : 720);
json::Value dpi = json::Value::object();
dpi.set("dpiX", 1);
dpi.set("dpiY", 1);
@@ -53,8 +53,9 @@ const std::string& deviceInfo() {
v.set("appInfo", app);
v.set("dev", dev);
return v.dump();
- }();
- return info;
+ };
+ static const std::string hd = build(true), sd = build(false);
+ return res == Resolution::P720 ? sd : hd;
}
std::string describe(const net::Response& r) {
@@ -108,14 +109,15 @@ std::string GssvClient::sessionUrl(const std::string& suffix) const {
return region_.baseUri + p + suffix;
}
-static net::Request authed(const GssvLogin& l, std::string method, std::string url, std::string body = {}) {
+static net::Request authed(Resolution res, const GssvLogin& l, std::string method, std::string url,
+ std::string body = {}) {
net::Request req;
req.method = std::move(method);
req.url = std::move(url);
req.body = std::move(body);
req.headers = {{"Authorization", "Bearer " + l.gsToken},
{"x-gssv-client", kClientHeader},
- {"X-MS-Device-Info", deviceInfo()}};
+ {"X-MS-Device-Info", deviceInfo(res)}};
if (!req.body.empty() || req.method == "POST") req.headers.emplace_back("Content-Type", "application/json");
return req;
}
@@ -165,7 +167,7 @@ bool GssvClient::listTitles(std::vector<Title>& out, std::string& err, bool rece
do {
std::string path = recentOnly ? "/v2/titles/mru?mr=25" : "/v2/titles?mr=200";
if (!continuation.empty()) path += "&ct=" + net::urlEncode(continuation);
- auto r = net::perform(authed(login_, "GET", url(path)));
+ auto r = net::perform(authed(resolution_, login_, "GET", url(path)));
auto j = json::parse(r.body);
if (!r.ok() || !j) {
err = "title list failed: " + describe(r);
@@ -242,7 +244,7 @@ bool GssvClient::startSession(const std::string& titleId, const std::string& loc
settings.set("useIceConnection", false);
settings.set("timezoneOffsetMinutes", 0);
settings.set("sdkType", "web");
- settings.set("osName", "windows");
+ settings.set("osName", resolution_ == Resolution::P720 ? "android" : "windows");
json::Value body = json::Value::object();
body.set("clientSessionId", "");
@@ -253,7 +255,7 @@ bool GssvClient::startSession(const std::string& titleId, const std::string& loc
body.set("fallbackRegionNames", json::Value::array());
std::string kind = offering_ == "xhome" ? "home" : "cloud";
- auto r = net::perform(authed(login_, "POST", url("/v5/sessions/" + kind + "/play"), body.dump()));
+ auto r = net::perform(authed(resolution_, login_, "POST", url("/v5/sessions/" + kind + "/play"), body.dump()));
auto j = json::parse(r.body);
if (!r.ok() || !j || !(*j)["sessionPath"].isString()) {
err = "session start failed: " + describe(r);
@@ -265,7 +267,7 @@ bool GssvClient::startSession(const std::string& titleId, const std::string& loc
}
bool GssvClient::sessionState(SessionStatus& out, std::string& err) {
- auto r = net::perform(authed(login_, "GET", sessionUrl("/state")));
+ auto r = net::perform(authed(resolution_, login_, "GET", sessionUrl("/state")));
auto j = json::parse(r.body);
if (!r.ok() || !j) {
err = "session state failed: " + describe(r);
@@ -279,7 +281,7 @@ bool GssvClient::sessionState(SessionStatus& out, std::string& err) {
}
int GssvClient::waitTimeSeconds() {
- auto r = net::perform(authed(login_, "GET", sessionUrl("/waittime")));
+ auto r = net::perform(authed(resolution_, login_, "GET", sessionUrl("/waittime")));
auto j = json::parse(r.body);
if (!r.ok() || !j) return -1;
return static_cast<int>((*j)["estimatedTotalWaitTimeInSeconds"].asInt(-1));
@@ -288,7 +290,7 @@ int GssvClient::waitTimeSeconds() {
bool GssvClient::connect(const std::string& msaTransferToken, std::string& err) {
json::Value body = json::Value::object();
body.set("userToken", msaTransferToken);
- auto r = net::perform(authed(login_, "POST", sessionUrl("/connect"), body.dump()));
+ auto r = net::perform(authed(resolution_, login_, "POST", sessionUrl("/connect"), body.dump()));
if (!r.ok()) {
err = "session connect failed: " + describe(r);
return false;
@@ -325,7 +327,7 @@ bool GssvClient::sendSdpOffer(const std::string& sdp, std::string& err) {
body.set("sdp", sdp);
body.set("requestId", "1");
body.set("configuration", cfg);
- auto r = net::perform(authed(login_, "POST", sessionUrl("/sdp"), body.dump()));
+ auto r = net::perform(authed(resolution_, login_, "POST", sessionUrl("/sdp"), body.dump()));
if (!r.ok()) {
err = "SDP offer failed: " + describe(r);
return false;
@@ -335,7 +337,7 @@ bool GssvClient::sendSdpOffer(const std::string& sdp, std::string& err) {
bool GssvClient::pollSdpAnswer(std::string& answer, std::string& err) {
answer.clear();
- auto r = net::perform(authed(login_, "GET", sessionUrl("/sdp")));
+ auto r = net::perform(authed(resolution_, login_, "GET", sessionUrl("/sdp")));
if (r.status == 204) return true; // not ready yet
auto j = json::parse(r.body);
if (!r.ok() || !j) {
@@ -364,7 +366,7 @@ bool GssvClient::sendIceCandidates(const std::vector<IceCandidate>& candidates,
json::Value body = json::Value::object();
body.set("messageType", "iceCandidate");
body.set("candidate", list);
- auto r = net::perform(authed(login_, "POST", sessionUrl("/ice"), body.dump()));
+ auto r = net::perform(authed(resolution_, login_, "POST", sessionUrl("/ice"), body.dump()));
if (!r.ok()) {
err = "ICE upload failed: " + describe(r);
return false;
@@ -374,7 +376,7 @@ bool GssvClient::sendIceCandidates(const std::vector<IceCandidate>& candidates,
bool GssvClient::pollIceCandidates(std::vector<IceCandidate>& out, std::string& err) {
out.clear();
- auto r = net::perform(authed(login_, "GET", sessionUrl("/ice")));
+ auto r = net::perform(authed(resolution_, login_, "GET", sessionUrl("/ice")));
if (r.status == 204) return true;
auto j = json::parse(r.body);
if (!r.ok() || !j) {
@@ -394,7 +396,7 @@ bool GssvClient::pollIceCandidates(std::vector<IceCandidate>& out, std::string&
}
bool GssvClient::keepalive(std::string& err) {
- auto r = net::perform(authed(login_, "POST", sessionUrl("/keepalive")));
+ auto r = net::perform(authed(resolution_, login_, "POST", sessionUrl("/keepalive")));
if (!r.ok()) {
err = "keepalive failed: " + describe(r);
return false;
@@ -404,7 +406,7 @@ bool GssvClient::keepalive(std::string& err) {
void GssvClient::stopSession() {
if (sessionPath_.empty()) return;
- net::perform(authed(login_, "DELETE", sessionUrl("")));
+ net::perform(authed(resolution_, login_, "DELETE", sessionUrl("")));
XC_LOGI("session stopped: %s", sessionPath_.c_str());
sessionPath_.clear();
}
diff --git a/src/xcloud/gssv.h b/src/xcloud/gssv.h
index d8a6116..5496090 100644
--- a/src/xcloud/gssv.h
+++ b/src/xcloud/gssv.h
@@ -53,6 +53,10 @@ struct IceCandidate {
int sdpMLineIndex = 0;
};
+// Stream resolution the service is asked for. It decides from the device the
+// client claims to be: a Windows desktop gets 1080p, other devices 720p.
+enum class Resolution { P1080, P720 };
+
class GssvClient {
public:
// `offering` is "xgpuweb" (Game Pass cloud) or "xhome" (own console).
@@ -61,6 +65,8 @@ public:
bool login(const auth::XblToken& gssvXsts, std::string& err);
const GssvLogin& session() const { return login_; }
void setRegion(const Region& r) { region_ = r; }
+ void setResolution(Resolution r) { resolution_ = r; }
+ Resolution resolution() const { return resolution_; }
const Region& region() const { return region_; }
// Titles available to stream (entitled + Game Pass) and recently played.
@@ -91,6 +97,7 @@ private:
std::string sessionUrl(const std::string& suffix) const;
std::string offering_;
+ Resolution resolution_ = Resolution::P1080;
GssvLogin login_;
Region region_;
std::string sessionPath_;
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index a0f0896..fdd2a4a 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -4,6 +4,8 @@
#include "net/http.h"
#include "stream/input_packet.h"
#include "stream/stream_session.h"
+#include "ui/app_ui.h"
+#include "ui/strings.h"
#include "util/json.h"
#include <cstdio>
@@ -107,7 +109,34 @@ static void testTeredo() {
CHECK(!stream::decodeTeredo("10.0.0.1", ip, port));
}
+static void testStrings() {
+ using namespace ui;
+ auto placeholders = [](const std::string& t) {
+ int n = 0;
+ for (size_t at = t.find("%s"); at != std::string::npos; at = t.find("%s", at + 2)) ++n;
+ return n;
+ };
+ for (int l = 0; l < static_cast<int>(Language::Count); ++l) {
+ setLanguage(Language::English);
+ std::vector<std::string> english;
+ for (int i = 0; i < static_cast<int>(Str::Count); ++i) english.push_back(tr(static_cast<Str>(i)));
+ setLanguage(static_cast<Language>(l));
+ CHECK(languageFromCode(languageCode(static_cast<Language>(l))) == static_cast<Language>(l));
+ for (int i = 0; i < static_cast<int>(Str::Count); ++i) {
+ std::string t = tr(static_cast<Str>(i));
+ CHECK(!t.empty());
+ CHECK(placeholders(t) == placeholders(english[static_cast<size_t>(i)]));
+ }
+ }
+ setLanguage(Language::English);
+ CHECK(languageFromCode("xx") == Language::English);
+ CHECK(prettyRegion("SOUTHCENTRALUS") == "South Central US");
+ CHECK(prettyRegion("EASTUS2") == "East US 2");
+ CHECK(prettyRegion("BRAZILSOUTH") == "Brazil South");
+}
+
int main() {
+ testStrings();
testJson();
testUrl();
testInputPacket();
diff --git a/tools/ps5/home-art.sh b/tools/ps5/home-art.sh
new file mode 100755
index 0000000..84307cc
--- /dev/null
+++ b/tools/ps5/home-art.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+# SPDX-License-Identifier: GPL-3.0-or-later
+# Copyright (C) 2026 RafaelNGP
+# Regenerates the PS5 home-screen art from src/ui/brand.cpp:
+# sce_sys/icon0.png (512x512), pic0.dds (selected-app background) and
+# pic1.dds (launch transition), 3840x2160 BC7 DDS via PS5_Vulkan's
+# tools/prepare-assets.sh (bc7enc: run its tools/setup-asset-dependencies.sh once).
+#
+# tools/ps5/home-art.sh [build-host-dir]
+set -euo pipefail
+
+root=$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)
+vk=${PS5_VULKAN:-$(cd "$root/../../WoW-PS5/deps/PS5_Vulkan" && pwd)}
+cli=${1:-$root/build-host}/xcloud-cli
+tmp=$(mktemp -d)
+trap 'rm -rf "$tmp"' EXIT
+
+cd "$root"
+"$cli" render-icon ps5/sce_sys/icon0.png 512
+"$cli" render-pic0 "$tmp/pic0.png" 3840
+"$cli" render-pic1 "$tmp/pic1.png" 3840
+mkdir -p "$tmp/out" && cp ps5/sce_sys/icon0.png "$tmp/out/" # validated alongside
+bash "$vk/tools/prepare-assets.sh" --selection-background "$tmp/pic0.png" \
+ --launch-background "$tmp/pic1.png" --output-directory "$tmp/out"
+cp "$tmp/out/pic0.dds" "$tmp/out/pic1.dds" ps5/sce_sys/
+echo "home art updated in ps5/sce_sys"
diff --git a/tools/ps5/package.sh b/tools/ps5/package.sh
index f3b4daf..482a1c5 100755
--- a/tools/ps5/package.sh
+++ b/tools/ps5/package.sh
@@ -22,6 +22,10 @@ mkdir -p "$app/sce_sys" "$app/sce_module" "$app/assets"
cp "$build/eboot.bin" "$app/eboot.bin"
cp "$param" "$app/sce_sys/param.json"
cp "$root/ps5/sce_sys/icon0.png" "$app/sce_sys/icon0.png"
+# Home-screen backgrounds (tools/ps5/home-art.sh).
+for f in pic0.dds pic1.dds; do
+ [[ -f "$root/ps5/sce_sys/$f" ]] && cp "$root/ps5/sce_sys/$f" "$app/sce_sys/$f"
+done
cp "$vk/runtime/libc.prx" "$app/sce_module/libc.prx"
cp -r "$root/assets/." "$app/assets/"