Skip to content

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

C++

Wait for a running preparation before quitting to Home

Leonardo Lobatof701bdcea480
diff --git a/src/homebrew/controller.cpp b/src/homebrew/controller.cpp
index bd4648a..584e449 100644
--- a/src/homebrew/controller.cpp
+++ b/src/homebrew/controller.cpp
@@ -755,7 +755,8 @@ void Controller::TickRuntime() {
if (prepared.status != RuntimeHostStatus::kStarting)
for (auto it = auto_prepare_.begin(); it != auto_prepare_.end();) {
if (!usable || !game_roots_.count(*it) || record_of(*it)) { it = auto_prepare_.erase(it); continue; }
- if (prepared.preparing_app) break;
+ // A quit to Home waits for the running preparation; the next one would be cut off.
+ if (prepared.preparing_app || model_.state().quit_waiting) break;
play_after_prepare_.erase(*it);
model_.RequestRuntimePrepare(*it);
auto_prepare_.erase(it);
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index d888875..7e4eced 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -1191,6 +1191,18 @@ void Simulation::UpdateRuntime(RuntimeState runtime, const std::vector<LiveRunti
}
}
state_.runtime_games = std::move(next);
+ // A quit to Home waiting for a preparation goes once nothing is prepared; Cancel drops it.
+ if (state_.quit_waiting) {
+ const bool waiting = !state_.navigation.modals.empty() && state_.navigation.modals.back().title == quit_wait_title_;
+ if (!waiting) {
+ state_.quit_waiting = false;
+ } else if (std::none_of(state_.runtime_games.begin(), state_.runtime_games.end(),
+ [](const auto& entry) { return entry.second.status == "Preparing"; })) {
+ state_.quit_waiting = false;
+ state_.navigation.modals.clear();
+ state_.quit_requested = true;
+ }
+ }
for (auto& installation : state_.installations) {
const auto found = state_.runtime_games.find(installation.game_id);
installation.runtime_ready = found != state_.runtime_games.end() && found->second.ready;
@@ -3569,6 +3581,18 @@ void Simulation::rebuild_view() {
play.subtitle = "Play quits to the PS5 Home screen, where the game appears";
}
play.enabled = enabled && value.uninstall_status.empty();
+ // The runtime prepares one game at a time: a Play or Resume held behind another game's
+ // preparation says so, instead of a greyed button with this game's old status.
+ if (!play.enabled && value.uninstall_status.empty() && value.status != "Preparing") {
+ const auto other = std::find_if(state_.runtime_games.begin(), state_.runtime_games.end(),
+ [&](const auto& entry) { return entry.first != game->id && entry.second.status == "Preparing"; });
+ if (other != state_.runtime_games.end()) {
+ const auto* busy = find_game(state_, other->first);
+ play.value = "Waiting";
+ play.subtitle = "Waits for " + (busy ? busy->title : std::string("another game")) +
+ " to finish preparing";
+ }
+ }
// A copy or deletion with a known fraction shows a bar and its percentage; other steps
// only their words.
if (value.progress) {
@@ -4688,6 +4712,24 @@ void Simulation::UpdateSaveSizes(std::map<GameId, std::uint64_t> sizes) {
rebuild_view();
}
+// Quitting stops the game runtime, so a preparation still running would be cut off and its half-made
+// title left on the Home screen, where it fails to start. The quit waits for it in a dialog instead.
+void Simulation::quit_to_home() {
+ const auto preparing = std::find_if(state_.runtime_games.begin(), state_.runtime_games.end(),
+ [](const auto& entry) { return entry.second.status == "Preparing"; });
+ if (preparing == state_.runtime_games.end()) {
+ state_.quit_requested = true;
+ return;
+ }
+ const auto* game = find_game(state_, preparing->first);
+ const std::string name = game ? game->title : std::string("A game");
+ quit_wait_title_ = "Waiting for " + name;
+ state_.quit_waiting = true;
+ ModalEntry wait{"confirmation", quit_wait_title_, state_.navigation.focus_key, {"cancel"}, 0, false};
+ wait.body = name + " is being prepared. Playden quits to the PS5 Home screen once it is done, so it is not left half-made.";
+ open_modal(std::move(wait));
+}
+
// Play on a game waiting for the PS5 quits to Home; first its saves sync. Quits once they are in
// step; a choice, a failure or a refusal lets the player play without syncing.
void Simulation::settle_quit_sync(GameId id, std::optional<CloudStatus> status) {
@@ -4699,7 +4741,7 @@ void Simulation::settle_quit_sync(GameId id, std::optional<CloudStatus> status)
if (!waiting) return; // the player cancelled
if (status && (*status == CloudStatus::Synced || *status == CloudStatus::UpToDate || *status == CloudStatus::Unsupported)) {
state_.navigation.modals.clear();
- state_.quit_requested = true;
+ quit_to_home();
return;
}
auto& modal = state_.navigation.modals.back();
@@ -5070,7 +5112,7 @@ void Simulation::activate() {
} else if (live() && action_name == "saves-quit-anyway") {
quit_sync_game_ = 0;
state_.navigation.modals.clear();
- state_.quit_requested = true;
+ quit_to_home();
} else if (live() && action_name == "cloud-sync") {
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
if (id != 0) pending_cloud_requests_.push_back({CloudRequestKind::Sync, id});
@@ -5317,7 +5359,7 @@ void Simulation::activate() {
state_.navigation.modals.clear();
ready_prompt_game_ = 0;
if (!syncs) {
- state_.quit_requested = true;
+ quit_to_home();
} else {
quit_sync_game_ = id;
pending_cloud_requests_.push_back({CloudRequestKind::Sync, id});
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index 1405cf8..654de99 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -493,6 +493,7 @@ struct State {
bool library_offline = false;
bool screenshot_mode = false;
bool quit_requested = false;
+ bool quit_waiting = false; // a quit to Home waits for a preparation; no new one starts meanwhile
bool simulation_mode = true;
std::int64_t clock_ticks = 0;
};
@@ -796,6 +797,7 @@ private:
std::map<GameId, CloudStatus> settled_cloud_; // each game's last settled Cloud state, for notices
GameId ready_prompt_game_ = 0; // the game the "ready to play" dialog is about
GameId quit_sync_game_ = 0; // Play quits to Home once this game's saves are in step
+ std::string quit_wait_title_; // the dialog a quit to Home waits in while a game is prepared
std::string live_log_topic_;
GameId live_log_game_ = 0;
bool details_primary_pending_ = false; // live Details: move focus to the first action once known
@@ -855,6 +857,7 @@ private:
void ask_upload_all();
void open_saves();
void settle_quit_sync(GameId id, std::optional<CloudStatus> status);
+ void quit_to_home();
void change_route(int delta);
void open_modal(ModalEntry modal);
void close_modal();
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index 15bb5aa..03ffb06 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -1500,6 +1500,48 @@ void live_ready_to_play_quits_to_home() {
check(requests.size() == 1 && requests[0].game_id == 43, "Play in the prompt syncs the announced game");
prompted.NotifyCloudAnswered(43, CloudStatus::Synced);
check(prompted.state().quit_requested, "Play in the prompt quits to Home");
+ // Quitting would cut off another game's preparation: the quit waits for it in a dialog.
+ auto busy = make_live();
+ busy.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(busy.UpdateLibrary({{game(42, "Synthetic"), game(43, "Other")}, false, {}, false, false, {}}), "library loaded");
+ busy.UpdateInstalls({}, {{42, 600'000'000}, {43, 100}});
+ LiveRuntimeGame preparing; preparing.game_id = 43; preparing.status = "Preparing";
+ busy.UpdateRuntime(RuntimeState::Ready, {waiting, preparing});
+ busy.UpdateCloud({{42, CloudStatus::Unsupported, "This game does not use Steam Cloud."}});
+ check(busy.action("details:42"), "details open");
+ activate(busy, "details-play");
+ check(!busy.state().quit_requested && busy.state().quit_waiting &&
+ busy.state().navigation.modals.back().title == "Waiting for Other",
+ "Play waits for the other game's preparation");
+ LiveRuntimeGame prepared = preparing; prepared.status = "Ready"; prepared.ready = true;
+ busy.UpdateRuntime(RuntimeState::Ready, {waiting, preparing});
+ check(!busy.state().quit_requested, "still waiting while it prepares");
+ busy.UpdateRuntime(RuntimeState::Ready, {waiting, prepared});
+ check(busy.state().quit_requested && !busy.state().quit_waiting && busy.state().navigation.modals.empty(),
+ "Playden quits once the preparation is done");
+ auto cancelled = make_live();
+ cancelled.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(cancelled.UpdateLibrary({{game(42, "Synthetic"), game(43, "Other")}, false, {}, false, false, {}}), "library loaded");
+ cancelled.UpdateInstalls({}, {{42, 600'000'000}, {43, 100}});
+ cancelled.UpdateRuntime(RuntimeState::Ready, {waiting, preparing});
+ cancelled.UpdateCloud({{42, CloudStatus::Unsupported, "This game does not use Steam Cloud."}});
+ check(cancelled.action("details:42"), "details open");
+ activate(cancelled, "details-play");
+ activate(cancelled, "cancel");
+ cancelled.UpdateRuntime(RuntimeState::Ready, {waiting, prepared});
+ check(!cancelled.state().quit_requested && !cancelled.state().quit_waiting, "Cancel keeps Playden open");
+ // A game held behind another game's preparation says what it waits for.
+ auto held = make_live();
+ held.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
+ check(held.UpdateLibrary({{game(42, "Synthetic"), game(43, "Other")}, false, {}, false, false, {}}), "library loaded");
+ held.UpdateInstalls({}, {{42, 600'000'000}, {43, 100}});
+ LiveRuntimeGame recovering; recovering.game_id = 42; recovering.status = "Needs recovery"; recovering.has_title = true;
+ held.UpdateRuntime(RuntimeState::Ready, {recovering, preparing});
+ check(held.action("details:42"), "details open");
+ const auto* held_play = find_row(held, "details-play");
+ check(held_play && !held_play->enabled && held_play->value == "Waiting" &&
+ held_play->subtitle == "Waits for Other to finish preparing",
+ "a held Resume names the game it waits for");
auto dropped = make_live();
dropped.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});
check(dropped.UpdateLibrary({{game(42, "Synthetic")}, false, {}, false, false, {}}), "library loaded");