Play your Steam library's Windows games on a jailbroken PS5.
C++
Hold queued preparations when quitting to Home
Leonardo Lobatod9f1548e6667
diff --git a/README.md b/README.mdindex 78912f0..5053880 100644--- a/README.md+++ b/README.md@@ -23,7 +23,8 @@ private Windows environment and its own tile on the PS5 Home screen.the method you used last.- **Your whole Steam library.** Search, sort, favorites, collections, ratings and notes, with cover art and storedetails. The library works offline from a cache.-- **Downloads from Steam.** Queue games and watch progress.+- **Downloads from Steam.** Queue games and watch progress. The Queue screen also lists the games being prepared, in+ the order they start; Prepare next moves a waiting game to the front.- **Storage at a glance.** Settings › Storage shows how much space is used and lists installed games by size orlast played. Select several games and uninstall them together; saves are kept unless you choose otherwise.- **Each game is its own PS5 app.** It gets a tile on the Home screen, so you can start it without Playden.@@ -146,7 +147,7 @@ Since 0.3.0, Playden updates itself from this repository's GitHub releases:- **Check:** at startup, and with Settings › About › Playden updates › Check now. When a newer release is out,Playden offers it once, with its notes, its download size, and a QR code for its release page on GitHub.- **Download:** Download and install fetches the new app and, when the release has a new one, the runtime kit. You- can follow the download on the Downloads screen and keep using Playden meanwhile.+ can follow the download on the Queue screen and keep using Playden meanwhile.- **Restart:** when the update is ready, Restart Playden closes Playden, puts the new version and kit in place, andopens Playden again. If it doesn't open by itself (the payload loader on port 9021 isn't running), open it fromthe Home screen. On that first start Playden shows what's new in the version; Settings › About › Release notesdiff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex 5bbae90..0866bd2 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -532,7 +532,10 @@ void RuntimeHost::HoldPreparations(bool hold) {std::lock_guard<std::mutex> lock(mutex_);if (prepares_held_ == hold) return;prepares_held_ = hold;+ // A new revision: a quit waiting for the queue to hold checks again whether anything still runs.+ ++snapshot_.revision;}+ published_.notify_all();wake_.notify_all();}diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex cec13aa..ccc85e5 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -826,7 +826,7 @@ std::string Simulation::installed_blocker(GameId id) const {if (std::any_of(state_.jobs.begin(), state_.jobs.end(), [id](const Job& job) {return job.game_id == id && job.state != JobState::Downloaded && job.state != JobState::Cancelled;}))- return "In Downloads";+ return "In Queue";if (game && (game->status == "Preparing" || game->maintenance_running)) return "Busy";return {};}@@ -2951,6 +2951,7 @@ void Simulation::rebuild_view() {state_.navigation.selected_game_id = selected_game_id;}view_ = {};+ if (state_.navigation.route != Route::Downloads) queue_shown_ = false;view_.surface = route_name(state_.navigation.route);view_.show_simulation_label = state_.simulation_mode;if (state_.editor.active) view_.surface = "keyboard";@@ -3924,8 +3925,14 @@ void Simulation::rebuild_view() {// Queue: Downloads, then Preparation, one expanded at a time, then the drives. Rows come in screen// order (heading, card, the expanded section's rows), so Up and Down follow what is on screen.view_.title = "Queue";+ // Each visit starts from the automatic choice (or the focused row's section); then the open section+ // stays open while focus moves and the queues change, until the player opens the other one.+ if (!queue_shown_) state_.queue_expanded.clear();+ queue_shown_ = true;const auto layout = BuildQueueLayout(state_);view_.subtitle = layout.summary;+ if (layout.downloads.expanded) state_.queue_expanded = kQueueDownloads;+ else if (layout.preparation.expanded) state_.queue_expanded = kQueuePreparation;const auto entry_row = [&](const QueueEntry& entry, bool card) {if (entry.job) {const auto& job = *entry.job;@@ -5010,16 +5017,20 @@ void Simulation::UpdateSaveSizes(std::map<GameId, std::uint64_t> sizes) {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()) {+ // Games waiting in the queue hold too: between two preparations the next one may be about to start.+ const auto& waiting = state_.preparation_queue.waiting;+ if (preparing == state_.runtime_games.end() && waiting.empty()) {state_.quit_requested = true;return;}- const auto* game = find_game(state_, preparing->first);+ const auto* game = find_game(state_, preparing != state_.runtime_games.end() ? preparing->first : waiting.front());const std::string name = game ? game->title : std::string("A game");- quit_wait_title_ = "Waiting for " + name;+ quit_wait_title_ = preparing != state_.runtime_games.end() ? "Waiting for " + name : std::string("Waiting for the queue");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.";+ wait.body = preparing != state_.runtime_games.end()+ ? name + " is being prepared. Playden quits to the PS5 Home screen once it is done, so it is not left half-made."+ : "Playden quits to the PS5 Home screen once the queued games are held, so none is left half-made.";open_modal(std::move(wait));}diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hppindex f478969..abd99c5 100644--- a/src/homebrew/simulation.hpp+++ b/src/homebrew/simulation.hpp@@ -856,6 +856,7 @@ private:// Settings: the last focused row, so focus stays nearby when that row goes away.int settings_focus_index_ = 0;int queue_focus_index_ = 0; // Queue: the focused row's place, for when that row goes away+ bool queue_shown_ = false; // Queue was on screen at the last rebuildstd::string settings_focus_section_;struct OrganizationJournalEntry {diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cppindex 2d22475..8e977f5 100644--- a/tests/homebrew_library_model_test.cpp+++ b/tests/homebrew_library_model_test.cpp@@ -1204,7 +1204,7 @@ void live_storage_section_and_installed_games() {const auto* foxtrot = find_row(model, "installed-toggle-15");const auto* golf = find_row(model, "installed-toggle-16");check(echo && !echo->enabled && echo->subtitle == "Playing", "a running game is blocked");- check(foxtrot && !foxtrot->enabled && foxtrot->subtitle == "In Downloads", "a game with a download is blocked");+ check(foxtrot && !foxtrot->enabled && foxtrot->subtitle == "In Queue", "a game with a download is blocked");check(golf && !golf->enabled && golf->subtitle == "Busy", "a game being prepared is blocked");activate(model, "installed-toggle-14");check(!find_row(model, "installed-toggle-14")->selected, "a blocked game can't be checked");@@ -1627,6 +1627,22 @@ void live_ready_to_play_quits_to_home() {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");+ // Games queued while none is being prepared (between two): the quit waits until the queue is held.+ auto queued = make_live();+ queued.UpdateAccount({AuthState::SignedIn, "123", "Synthetic", {}, {}, true});+ check(queued.UpdateLibrary({{game(42, "Synthetic"), game(43, "Other")}, false, {}, false, false, {}}), "library loaded");+ queued.UpdateInstalls({}, {{42, 600'000'000}, {43, 100}});+ LiveRuntimeGame next; next.game_id = 43; next.status = "Not prepared"; next.queued = true;+ queued.UpdateRuntime(RuntimeState::Ready, {waiting, next});+ queued.UpdatePreparationQueue({std::nullopt, {43}, {}, {}});+ queued.UpdateCloud({{42, CloudStatus::Unsupported, "This game does not use Steam Cloud."}});+ check(queued.action("details:42"), "details open");+ activate(queued, "details-play");+ check(!queued.state().quit_requested && queued.state().quit_waiting &&+ queued.state().navigation.modals.back().title == "Waiting for the queue",+ "a queued game holds the quit");+ queued.UpdateRuntime(RuntimeState::Ready, {waiting, next});+ check(queued.state().quit_requested, "with the queue held and nothing preparing, Playden quits");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");@@ -2270,6 +2286,9 @@ void live_queue_shows_downloads_and_preparations() {{13, 1, "internal", true}, {14, 1, "internal", true}, {23, 1, "internal", true}},{{23, 1, "internal", 1'000}});check(has_row(model, "job-21") && !has_row(model, "prep-11"), "progress keeps the player's choice");+ check(model.action("focus:job-23") && model.action("down") && model.state().navigation.focus_key == "queue-preparation",+ "Down from the last download reaches the Preparation heading");+ check(has_row(model, "job-21") && !has_row(model, "prep-11"), "moving onto the other heading doesn't open it");activate(model, "queue-preparation");activate(model, "prep-11");