Skip to content

Xbox Cloud Gaming app for PS5 Homebrew

C

fix(startup): restore loading screen and block controller input until account loads

Rafael Abud Ferreira9f1948ca5ed7
diff --git a/src/app/app_core.cpp b/src/app/app_core.cpp
index cc88886..3451e7b 100644
--- a/src/app/app_core.cpp
+++ b/src/app/app_core.cpp
@@ -280,6 +280,7 @@ bool coreStartup() {
},
160u << 20, platform::dataDir() + "/imgcache");
g_ui = std::make_unique<ui::AppUi>(fonts, *g_images);
+ g_ui->showSplash(ui::tr(ui::Str::SigningIn));
startPriceLoop();
{
g_ui->setAllow1440(allow1440Locked());
@@ -589,6 +590,11 @@ bool Core::frame() {
}
streamScreen->idle();
+ if (g_ui->screen() == ui::Screen::Splash) {
+ // Discard controller navigation input while the loading/splash screen is active.
+ nav = ui::NavInput{};
+ }
+
ui::UiEvent ev = g_ui->handle(nav);
int strength, hz, resistance, profile = 0;
bool pulses;
diff --git a/src/app/autoplay.cpp b/src/app/autoplay.cpp
index a48026f..c16d3f8 100644
--- a/src/app/autoplay.cpp
+++ b/src/app/autoplay.cpp
@@ -816,6 +816,15 @@ void autoplayScreens(const ui::Canvas& canvas, uint64_t now) {
saveCanvas("launch.ppm");
}
}
+ static bool splashSaved = false;
+ if (!g_autoplay.title.empty() && !splashSaved && g_ui->screen() == ui::Screen::Splash) {
+ static uint64_t splashSince = 0;
+ if (!splashSince) splashSince = now;
+ if (now - splashSince > 200) {
+ splashSaved = true;
+ saveCanvas("splash.ppm");
+ }
+ }
if (g_autoplay.libraryTest && uiSaved) {
static uint64_t openedAt = 0;
static int saved = 0;
diff --git a/src/app/worker.cpp b/src/app/worker.cpp
index 93a312b..c73a015 100644
--- a/src/app/worker.cpp
+++ b/src/app/worker.cpp
@@ -731,37 +731,6 @@ void loadConsoles(auth::AuthManager& am, xcloud::GssvClient& home) {
namespace {
std::string g_subscription;
-
-void tryInstantCachedBoot(auth::AuthManager& am) {
- if (!am.hasStoredAccount()) return;
- auto library = std::make_shared<app::Library>();
- library->setCachePath(platform::dataDir() + "/library.json");
- {
- std::lock_guard<std::mutex> lock(g_settingsMutex);
- library->setFavorites(g_settings.favorites);
- library->setWishlist(g_settings.wishlist);
- }
- if (library->loadCache(true) && !library->rows().empty()) {
- {
- std::lock_guard<std::mutex> lock(s_libraryMutex);
- s_library = library;
- }
- if (!am.profile().gamertag.empty()) {
- g_ui->setProfile(am.profile().gamertag, am.profile().gamerpicUrl, am.profile().gamerscore);
- }
- if (!library->subscription().empty()) {
- g_subscription = library->subscription();
- g_ui->setSubscription(library->subscription());
- }
- g_ui->setRows(library->rows());
- g_ui->setOwned(library->owned(), library->purchasable(), library->ownedKnown());
- g_ui->setMembership(library->gamePassMember());
- g_ui->setSearchPools(library->gamePassSearchPool(), library->librarySearchPool());
- g_ui->setLoading(true, 0, 0);
- g_ui->showHome();
- XC_LOGI("startup: instant library hydration on frame 1 (<150 ms)");
- }
-}
} // namespace
bool isDnsOrSinkholeError(const std::string& err) {
@@ -777,11 +746,7 @@ void signInAndLoad(auth::AuthManager& am, xcloud::GssvClient& gssv) {
platform::notify(ui::trf(ui::Str::StorageNotWritable, pathAndErr),
"storage not writable (notification)");
}
- if (g_ui->screen() != ui::Screen::Home) {
- g_ui->showSplash(ui::tr(am.hasStoredAccount() ? ui::Str::SigningIn : ui::Str::RequestingCode));
- } else {
- g_ui->setLoading(true, 0, 0);
- }
+ 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); };
std::string country;
@@ -1254,7 +1219,6 @@ void worker() {
return;
}
auth::AuthManager am(platform::dataDir() + "/account.json");
- tryInstantCachedBoot(am);
xcloud::GssvClient gssv, home("xhome");
for (;;) {
int cmd = g_command.exchange(kNone);
diff --git a/src/ui/app_ui.cpp b/src/ui/app_ui.cpp
index 1785053..dbb7c95 100644
--- a/src/ui/app_ui.cpp
+++ b/src/ui/app_ui.cpp
@@ -2601,6 +2601,9 @@ void AppUi::handleGameSettings(const NavInput& in, UiEvent& ev) {
UiEvent AppUi::handle(const NavInput& in) {
std::lock_guard<std::mutex> lock(mutex_);
UiEvent ev;
+ if (screen_ == Screen::Splash) {
+ return ev;
+ }
if (reportOpen_) { // the report's QR code: Circle (or Cross) closes it
if (in.accept && caps_.openUrl) {
// A desktop: Cross opens the form in the browser (the panel stays).
diff --git a/tests/test_main.cpp b/tests/test_main.cpp
index 0fd327d..a384404 100644
--- a/tests/test_main.cpp
+++ b/tests/test_main.cpp
@@ -559,6 +559,31 @@ static void testPlaytimeLimit() {
CHECK(ev.game.titleId == "TEST_TITLE_1");
}
+static void testSplashInputBlocking() {
+ ui::Fonts fonts;
+ ui::ImageCache images([] {});
+ ui::AppUi app(fonts, images);
+ CHECK(app.screen() == ui::Screen::Splash);
+
+ ui::NavInput in;
+ in.accept = true;
+ in.down = true;
+ in.options = true;
+ in.triangle = true;
+ in.r1 = true;
+ ui::UiEvent ev = app.handle(in);
+ CHECK(ev.action == ui::Action::None);
+ CHECK(app.screen() == ui::Screen::Splash);
+
+ app.showSplash("Signing in...");
+ CHECK(app.screen() == ui::Screen::Splash);
+ ev = app.handle(in);
+ CHECK(ev.action == ui::Action::None);
+
+ app.showHome();
+ CHECK(app.screen() == ui::Screen::Home);
+}
+
static void testStreamMenu() {
using xc::ui::MenuAction;
xc::ui::Fonts fonts; // not loaded: handle() never draws
@@ -2619,6 +2644,7 @@ int main() {
testAccentColor();
testVersions();
testStreamMenu();
+ testSplashInputBlocking();
testSettingsMigration();
testSettingsChoiceRoundTrip();
testMicGain();