Skip to content

Play your Steam library's Windows games on a jailbroken PS5.

C++

Show a full console storage instead of a stuck sign-in

Leonardo Lobato24597e2224e7
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index 048a8e4..e29d2db 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -54,13 +54,14 @@ void Controller::Shutdown() {
Update(AuthState::SignedOut,{},true);
}
void Controller::Update(AuthState state,const std::string& error,bool clear,const std::string& challenge,
- SignInStep step,const steam::SteamEvent* prompt) {
+ SignInStep step,const steam::SteamEvent* prompt,bool storage_full) {
AccountUpdate update;
update.authentication = state;
update.id = clear ? std::string{} : model_.state().account.id;
update.display_name = clear ? std::string{} : model_.state().account.display_name;
update.error = error; update.challenge_url = challenge; update.clear_library = clear;
update.sign_in = step;
+ update.storage_full = storage_full;
if (prompt) {
update.email_domain = prompt->email_domain;
update.code_allowed = prompt->code_allowed;
@@ -141,10 +142,12 @@ void Controller::Reauthenticate() {
request_ = service_->BeginQrSignIn();
Update(AuthState::Waiting);
}
-void Controller::Restore() {
+void Controller::Restore(bool quiet) {
if(library_) library_->Reset();
phase_=Phase::Restore;request_=service_->RestoreSession();
- Update(AuthState::Restoring);
+ // A retry every few seconds that flipped to Restoring and back would move the screen and close
+ // the focus of a list opened from it (Installed games on a full console storage).
+ if (!quiet) Update(AuthState::Restoring);
}
void Controller::SignOut(bool switch_account) {
if(phase_==Phase::ClearLibrary || phase_==Phase::ClearOrganization || phase_==Phase::SignOut) return;
@@ -240,7 +243,7 @@ void Controller::Tick() {
}
}
if (retry_saved_session_ && phase_ == Phase::Idle &&
- std::chrono::steady_clock::now() >= retry_saved_session_at_) Restore();
+ std::chrono::steady_clock::now() >= retry_saved_session_at_) Restore(true);
auto mark = std::chrono::steady_clock::now();
const auto lap = [&](std::size_t index) {
const auto now = std::chrono::steady_clock::now();
@@ -1395,7 +1398,18 @@ void Controller::Apply(const steam::SteamEvent& event) {
// account state, retry the saved session, and never start QR sign-in.
retry_saved_session_ = true;
retry_saved_session_at_ = std::chrono::steady_clock::now() + std::chrono::seconds(2);
- Update(AuthState::Failed, "Account storage is unavailable. Retrying your saved sign-in…");
+ // A full console storage refuses the refreshed sign-in until games are uninstalled; the query
+ // holds back the space the PS5 keeps, so none left means writes fail.
+ std::optional<steam::VolumeSpace> space;
+ if (installs_) {
+ const auto volumes = installs_->Snapshot().volumes;
+ if (!volumes.empty()) space = steam::QueryVolumeSpace(volumes.front().games_root, steam::kConsoleSystemReserve);
+ }
+ if (space && space->free_bytes == 0)
+ Update(AuthState::Failed, "Playden can't save your sign-in. Uninstall games to free up space; it signs in again on its own.",
+ false, {}, SignInStep::Qr, nullptr, true);
+ else
+ Update(AuthState::Failed, "Account storage is unavailable. Retrying your saved sign-in…");
break;
}
retry_saved_session_ = false;
diff --git a/src/homebrew/controller.hpp b/src/homebrew/controller.hpp
index bcdd4c7..c1293ab 100644
--- a/src/homebrew/controller.hpp
+++ b/src/homebrew/controller.hpp
@@ -50,14 +50,15 @@ class Controller {
void BeginPassword();
void SignOut(bool switch_account);
void Reauthenticate();
- void Restore();
+ // quiet: an automatic retry keeps the failure on screen instead of showing Restoring.
+ void Restore(bool quiet = false);
void AdvanceClear();
void BeginOrganizationClear();
void AdvanceOrganizationClear();
void Apply(const steam::SteamEvent& event);
void Update(AuthState state, const std::string& error = {}, bool clear = false,
const std::string& challenge = {}, SignInStep step = SignInStep::Qr,
- const steam::SteamEvent* prompt = nullptr);
+ const steam::SteamEvent* prompt = nullptr, bool storage_full = false);
void TickAppDetails();
void TickStoreDetails();
steam::StoreDetailsService* store_details_ = nullptr;
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index 7afa221..a3beb2e 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -1536,6 +1536,12 @@ void Simulation::clear_account_specific_state() {
void Simulation::UpdateAccount(AccountUpdate update) {
if (!live()) return;
if (update.clear_library) clear_account_specific_state();
+ // The saved sign-in is retried every few seconds; a repeat of the same failure leaves the
+ // screen, its focus and any open list alone.
+ const bool repeat = update.authentication == AuthState::Failed && state_.account.authentication == AuthState::Failed &&
+ update.sign_in == SignInStep::Qr && state_.sign_in.step == SignInStep::Qr &&
+ update.error == state_.account.error && update.storage_full == state_.account.storage_full;
+ state_.account.storage_full = update.authentication == AuthState::Failed && update.storage_full;
state_.account.authentication = update.authentication;
state_.account.id = std::move(update.id);
state_.account.display_name = std::move(update.display_name);
@@ -1548,7 +1554,9 @@ void Simulation::UpdateAccount(AccountUpdate update) {
state_.sign_in_password = *update.signed_in_with_password;
save_profile();
}
- if (update.authentication == AuthState::Waiting || update.authentication == AuthState::Expired || update.authentication == AuthState::Failed) {
+ if (repeat) {
+ // Nothing changed.
+ } else if (update.authentication == AuthState::Waiting || update.authentication == AuthState::Expired || update.authentication == AuthState::Failed) {
state_.navigation.route = Route::SignIn;
auto& form = state_.sign_in;
if (update.sign_in == SignInStep::Qr) {
@@ -1556,7 +1564,8 @@ void Simulation::UpdateAccount(AccountUpdate update) {
form.step = SignInStep::Qr;
form.error.clear();
set_route_focus(update.authentication == AuthState::Expired ? "qr-refresh"
- : update.authentication == AuthState::Failed ? "qr-retry" : "qr-cancel");
+ : update.authentication != AuthState::Failed ? "qr-cancel"
+ : state_.account.storage_full && !state_.installations.empty() ? "signin-installed" : "qr-retry");
} else if (update.authentication != AuthState::Waiting) {
// A failed password sign-in returns to the form, with the reason and the account name kept.
clear_sign_in_secrets();
@@ -3442,6 +3451,22 @@ void Simulation::rebuild_view() {
}
if (!live() && (form.step == SignInStep::Approval || form.step == SignInStep::Submitting))
row("qr-fixture-controls", RowKind::Action, "QR fixture controls", "qr-fixture-controls");
+ } else if (state_.navigation.route == Route::SignIn && state_.account.authentication == AuthState::Failed &&
+ state_.account.storage_full) {
+ // The saved sign-in keeps being retried; uninstalling games here gives it the room it needs.
+ view_.title = "Console storage is full";
+ view_.subtitle = state_.account.error;
+ auto& installed = row("signin-installed", RowKind::Action, "Installed games", "installed-manage");
+ installed.subtitle = "Uninstall games you no longer play to free up space";
+ if (state_.installations.empty()) {
+ installed.kind = RowKind::Status; installed.action.clear(); installed.enabled = false; installed.value = "None";
+ installed.subtitle = "Free up space in the PS5's Settings > Storage";
+ } else {
+ std::uint64_t bytes = 0;
+ for (const auto& item : state_.installations) bytes += item.installed_bytes;
+ installed.value = kept_count(state_.installations.size()) + " · " + format_bytes(bytes);
+ }
+ row("qr-retry", RowKind::Action, "Retry", "qr-retry");
} else if (state_.navigation.route == Route::SignIn) {
view_.title = "Connect Steam";
view_.subtitle = state_.account.authentication == AuthState::Waiting
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index d8f9165..30801d1 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -240,6 +240,7 @@ struct Account {
std::int64_t last_sync = 0;
bool cache_available = false;
std::string error;
+ bool storage_full = false; // Failed: the sign-in can't be saved until console storage has room
};
struct AccountUpdate {
@@ -257,6 +258,7 @@ struct AccountUpdate {
bool code_rejected = false;
// Authenticated by a sign-in (not a restore): whether it used the password, remembered for next time.
std::optional<bool> signed_in_with_password;
+ bool storage_full = false; // Failed: console storage is full
};
struct LibraryUpdate {
diff --git a/src/homebrew/view.cpp b/src/homebrew/view.cpp
index 839462a..f154e40 100644
--- a/src/homebrew/view.cpp
+++ b/src/homebrew/view.cpp
@@ -1230,7 +1230,8 @@ class Render::Impl
void draw_sign_in(ui::Canvas &, const ViewData &view, const State &state)
{
- section_label("Connect Steam", 96.0F, 78.0F);
+ const bool storage_full = state.account.authentication == AuthState::Failed && state.account.storage_full;
+ section_label(storage_full ? "Console storage" : "Connect Steam", 96.0F, 78.0F);
draw_title(view, 96.0F, 272.0F, 720.0F);
draw_actions(view, 96.0F, 594.0F, 540.0F);
constexpr float qr_x = 1116.0F;
@@ -1253,6 +1254,9 @@ class Render::Impl
} else if (state.account.authentication == AuthState::Expired) {
draw_qr_placeholder(qr_x, qr_y, static_cast<float>(qr_side),
"QR code expired", "Refresh to continue");
+ } else if (storage_full) {
+ draw_qr_placeholder(qr_x, qr_y, static_cast<float>(qr_side),
+ "Storage is full", "Uninstall games to sign in");
} else if (state.account.authentication == AuthState::Failed) {
draw_qr_placeholder(qr_x, qr_y, static_cast<float>(qr_side),
"Connection failed", "Retry the connection");
@@ -1279,6 +1283,11 @@ class Render::Impl
status = "Challenge expired";
color = kAmber;
}
+ else if (storage_full)
+ {
+ status = "Console storage is full · Retrying";
+ color = kRed;
+ }
else if (state.account.authentication == AuthState::Failed)
{
status = state.account.error.empty() ? "Connection failed" : state.account.error.c_str();
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index df9543d..794bc0b 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -2006,6 +2006,37 @@ void live_download_reorder_reaches_service() {
"Move up sends the order change to the download service");
}
+void live_sign_in_on_full_storage_offers_uninstall() {
+ auto model = make_live();
+ constexpr std::uint64_t gb = 1'000'000'000;
+ model.UpdateVolumes({{"internal", "Console storage", true, 800 * gb, 0}}, "internal");
+ model.UpdateInstalls({}, {{12, 5 * gb, "internal"}, {13, 1 * gb, "internal"}});
+ playden::homebrew::AccountUpdate full;
+ full.authentication = AuthState::Failed;
+ full.error = "Playden can't save your sign-in.";
+ full.storage_full = true;
+ model.UpdateAccount(full);
+ check(model.view().title == "Console storage is full", "a sign-in that can't be saved says storage is full");
+ const auto* installed = find_row(model, "signin-installed");
+ check(installed && installed->enabled && installed->value == "2 games · 6.0 GB" && has_row(model, "qr-retry"),
+ "it offers the installed games and Retry");
+ check(model.state().navigation.focus_key == "signin-installed", "the installed games are focused");
+ activate(model, "signin-installed");
+ check(!model.state().navigation.modals.empty() && model.state().navigation.modals.back().title == "Installed games",
+ "the list opens to uninstall from");
+ model.UpdateAccount(full);
+ check(!model.state().navigation.modals.empty() && model.state().navigation.modals.back().title == "Installed games",
+ "the retry every few seconds leaves the open list alone");
+ model.action("circle");
+
+ playden::homebrew::AccountUpdate busy;
+ busy.authentication = AuthState::Failed;
+ busy.error = "Account storage is unavailable. Retrying your saved sign-in…";
+ model.UpdateAccount(busy);
+ check(model.view().title == "Connect Steam" && !has_row(model, "signin-installed"),
+ "other storage trouble keeps the usual screen");
+}
+
int main() {
live_download_reorder_reaches_service();
live_play_does_the_next_useful_thing();
@@ -2014,6 +2045,7 @@ int main() {
live_ready_prompt_matches_the_open_game();
live_details_focus_moves_to_play_once_enabled();
live_settings_focus_stays_near_a_removed_row();
+ live_sign_in_on_full_storage_offers_uninstall();
live_storage_section_and_installed_games();
preparation_steps_read_as_player_words();
live_install_requests_and_projection();