Skip to content

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

C++

Hold an imported game's files while it runs

Leonardo Lobatob4ea5d6888a5
diff --git a/README.md b/README.md
index c265a4a..0c2e36e 100644
--- a/README.md
+++ b/README.md
@@ -262,7 +262,7 @@ The drive must be exFAT. The PS5 can't read NTFS, and FAT32 can't hold files ove
4. Choose where the game files live:
- **Play from the USB drive** (or the M.2 SSD, or the drop folder): nothing is copied. The drive must stay plugged
in.
- - **Import into Playden:** then choose the storage it goes to. Playden copies the game there; the console copies
+ - **Copy to storage** (**Move to storage** for the drop folder): then choose the storage it goes to. Playden copies the game there; the console copies
about 11 MB/s, so a large game takes a while. A drive without room for the game, and the drive the game is on,
can't be chosen.
5. For a game in the drop folder, **Console storage** moves the folder into Playden at once. Another drive gets a
diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cpp
index d7e97b5..63cd263 100644
--- a/src/homebrew/simulation.cpp
+++ b/src/homebrew/simulation.cpp
@@ -357,13 +357,18 @@ void reconcile_library_selection(State& state) {
std::string game_key(GameId id) { return "game-" + ToKey(id); }
-// A game's setup is under way: it's being set up or waiting for that, its bottle is being changed, or Play is installing
-// something first. Its files stay where they are until that ends.
-bool setup_under_way(const State& state, GameId id) {
+// Why an imported game's files can't be copied or removed now, empty when they can. They stay where they are while its
+// setup is under way (it's being set up or waiting for that, its bottle is being changed, or Play is installing something
+// first) and while it runs. A game not known to run doesn't wait: an imported game may have no PS5 title to ask about.
+std::string import_files_wait(const State& state, GameId id) {
const auto found = state.runtime_games.find(id);
- if (found == state.runtime_games.end()) return false;
+ if (found == state.runtime_games.end()) return {};
const auto& game = found->second;
- return game.status == "Preparing" || game.queued || game.maintenance_running || !game.play_work.empty();
+ if (game.activity == TitleActivity::Running || game.play_status == "Playing" || game.play_status == "Starting…")
+ return "Quit the game first";
+ if (game.status == "Preparing" || game.queued || game.maintenance_running || !game.play_work.empty())
+ return "Waits for setup to finish";
+ return {};
}
std::vector<std::string> context_actions(bool live) {
@@ -1235,7 +1240,7 @@ void Simulation::open_import_choice(std::size_t program) {
const auto* candidate = import_candidate(import_programs_key_);
if (!candidate || program >= candidate->programs.size()) return;
// Play from the folder (disabled, with why, when the PS5 can't start a game from it), then
- // Import into Playden (step 2 picks the drive), then Back. Import has the focus.
+ // Copy to storage (step 2 picks the drive), then Back. Copy has the focus.
open_modal({"import-choice", kImportChoiceTitle, state_.navigation.focus_key,
{"import-play-in-place", "import-copy", "cancel"}, 1, false});
}
@@ -1300,7 +1305,7 @@ void Simulation::start_import_transfer(GameId id, ImportRequestKind kind, const
}
void Simulation::choose_import(const std::string& action) {
- // Step 1: Import into Playden goes on to the drive choice.
+ // Step 1: Copy to storage goes on to the drive choice.
if (action == "import-copy") { open_import_storage(); return; }
if (action != "import-play-in-place") return;
const auto* candidate = import_candidate(import_programs_key_);
@@ -5533,6 +5538,7 @@ void Simulation::rebuild_view() {
if (state_.navigation.route != Route::Downloads && !queue_details) queue_shown_ = false;
if (state_.navigation.route != Route::Downloads && !queue_details) queue_return_focus_.clear();
view_.surface = route_name(state_.navigation.route);
+ if (state_.navigation.route != Route::Details) import_page_asked_ = {};
view_.show_simulation_label = state_.simulation_mode;
if (state_.editor.active) view_.surface = "keyboard";
else if (!state_.navigation.modals.empty()) view_.surface = state_.navigation.modals.back().id;
@@ -6312,7 +6318,7 @@ void Simulation::rebuild_view() {
item.enabled = import_wizard_subject.ascii_ok;
}
else if (modal.id == "import-choice" && action_key == "import-copy") {
- item.title = "Import into Playden…";
+ item.title = import_from_drop ? "Move to storage…" : "Copy to storage…";
item.value = format_bytes(import_wizard_subject.bytes);
item.subtitle = import_from_drop ? "Takes the game out of the drop folder. You pick the storage next."
: "Copies the game. You pick the storage next.";
@@ -6438,9 +6444,9 @@ void Simulation::rebuild_view() {
runtime_game != state_.runtime_games.end() && runtime_game->second.maintenance_running)
item.value = "Working…";
}
- else if (action_key == "import-remove" && setup_under_way(state_, state_.navigation.selected_game_id)) {
+ else if (action_key == "import-remove" && !import_files_wait(state_, state_.navigation.selected_game_id).empty()) {
item.enabled = false;
- item.subtitle = "Waits for setup to finish";
+ item.subtitle = import_files_wait(state_, state_.navigation.selected_game_id);
}
else if (action_key == "verify" || action_key == "uninstall") {
if (!is_installed(state_, state_.navigation.selected_game_id)) { item.enabled = false; item.subtitle = "Game is not installed"; }
@@ -6936,8 +6942,13 @@ void Simulation::rebuild_view() {
}
if (imported) {
// An imported game: Copy to storage while it plays from its folder (the copy's progress
- // while it runs), then Remove from library; a copy in Playden uninstalls. Both wait for setup.
- const bool setup_busy = setup_under_way(state_, game->id);
+ // while it runs), then Remove from library; a copy in Playden uninstalls. Both wait for setup and
+ // for the game to close, so the page asks whether it runs each time it opens.
+ const bool files_wait = !import_files_wait(state_, game->id).empty();
+ if (in_place && live() && import_page_asked_ != game->id) {
+ import_page_asked_ = game->id;
+ pending_activity_requests_.push_back(game->id);
+ }
const auto starting = copying || !in_place ? import_transfers_starting_.end()
: import_transfers_starting_.find(game->id);
if (starting != import_transfers_starting_.end()) {
@@ -6957,11 +6968,11 @@ void Simulation::rebuild_view() {
// Its drive is there: a folder the PS5 can't play from (its name) can still be copied.
// The drop folder's game leaves it; a drive keeps its copy.
row("details-copy", RowKind::Action, external->volume_id == kImportDropVolume ? "Move to storage…" : "Copy to storage…",
- "import-copy-game").enabled = !setup_busy;
+ "import-copy-game").enabled = !files_wait;
}
if (in_place) {
row("details-remove", RowKind::Action, "Remove from library…", "import-remove").enabled =
- !copying && starting == import_transfers_starting_.end() && !setup_busy;
+ !copying && starting == import_transfers_starting_.end() && !files_wait;
// Where it plays from, under the buttons.
for (const auto& candidate : state_.import_candidates)
if (candidate.imported == game->id && installation->available) {
@@ -9553,7 +9564,7 @@ void Simulation::activate() {
} else if (action_name == "import-copy-game") {
// An imported game playing from its folder: Copy to storage opens the drive choice.
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
- if (setup_under_way(state_, id)) return;
+ if (!import_files_wait(state_, id).empty()) return;
if (const auto* external = external_game(id); external && external->available && !import_copy_job(id)) open_import_storage(id);
} else if (action_name == "import-cancel-copy") {
// The same cancel as Queue's, from the game's page.
@@ -9572,7 +9583,7 @@ void Simulation::activate() {
// Out of the library; the folder stays where it is.
const auto id = state_.navigation.detail_id.value_or(state_.navigation.selected_game_id);
const auto* game = find_game(state_, id);
- if (!game || !external_game(id) || setup_under_way(state_, id)) return;
+ if (!game || !external_game(id) || !import_files_wait(state_, id).empty()) return;
pending_destructive_action_ = action_name;
destructive_target_ = id;
ModalEntry confirmation{"confirmation", "Remove " + game->title + " from the library?", state_.navigation.focus_key,
diff --git a/src/homebrew/simulation.hpp b/src/homebrew/simulation.hpp
index baba424..bfc76c3 100644
--- a/src/homebrew/simulation.hpp
+++ b/src/homebrew/simulation.hpp
@@ -1417,6 +1417,7 @@ private:
void load_fixtures();
void load_profile();
bool save_profile();
+ GameId import_page_asked_; // the imported game whose open page has asked whether it runs
void reset_default_state();
void rebuild_view();
void activate();
@@ -1463,7 +1464,7 @@ private:
void look_for_games();
std::string import_programs_key_; // the candidate whose program list is open
// The import wizard. Step 1 (surface import-choice), for the program picked in the open program
- // list: play the game from its folder, or Import into Playden. Step 2 (surface import-storage):
+ // list: play the game from its folder, or Copy to storage. Step 2 (surface import-storage):
// the drive the game goes to, for that program's folder or for a game already added
// (import_choice_game_ valid: its page's Copy to storage opens step 2 directly).
void open_import_choice(std::size_t program);
diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cpp
index 8c707b8..c1660c9 100644
--- a/tests/homebrew_library_model_test.cpp
+++ b/tests/homebrew_library_model_test.cpp
@@ -3824,7 +3824,7 @@ void live_import_sheet_sends_requests() {
model.view().subtitle.rfind("Starts with Delores.exe, which you can change in Game settings.", 0) == 0,
"one program besides an installer skips the program list");
check(model.view().surface == "import-choice" && find_row(model, "import-play-in-place")->title == "Play from the drop folder" &&
- find_row(model, "import-copy")->title == "Import into Playden…" && !has_row(model, "import-move"),
+ find_row(model, "import-copy")->title == "Move to storage…" && !has_row(model, "import-move"),
"a drop-folder game plays from there or is imported into Playden");
activate(model, "import-play-in-place");
requests = model.TakeImportRequests();
@@ -3888,7 +3888,7 @@ void live_import_choice_and_details() {
check(model.view().surface == "import-choice" && model.TakeImportRequests().empty(), "its Play from the drive does nothing");
model.action("circle");
- // A drive folder: play in place, or Import into Playden with its size (no estimate), then the drive.
+ // A drive folder: play in place, or Copy to storage with its size (no estimate), then the drive.
activate(model, "import-candidate-usb0:playden/import/Rally");
check(find_row(model, "import-play-in-place")->title == "Play from the USB drive" &&
find_row(model, "import-play-in-place")->value.empty() &&
@@ -3945,7 +3945,9 @@ void live_import_choice_and_details() {
find_row(model, "details-remove") && !has_row(model, "details-cloud") && !has_row(model, "details-uninstall"),
"an imported game on a drive offers Copy to storage and Remove from library");
{
- // Both wait while the game is set up, and so does Remove in its actions.
+ // Both wait while the game is set up or runs, and so does Remove in its actions. The page asks whether it runs.
+ const auto asked = model.TakeActivityRequests();
+ check(std::count(asked.begin(), asked.end(), id) == 1, "an imported game's page asks whether it runs");
using playden::homebrew::LiveRuntimeGame;
using playden::homebrew::RuntimeState;
check(find_row(model, "details-copy")->enabled && find_row(model, "details-remove")->enabled, "both work when nothing runs");
@@ -3960,8 +3962,29 @@ void live_import_choice_and_details() {
check(model.state().navigation.modals.empty(), "Remove can't be pressed during setup");
}
activate(model, "details-more");
- check(find_row(model, "import-remove") && !find_row(model, "import-remove")->enabled, "Game actions' Remove waits too");
+ check(find_row(model, "import-remove") && !find_row(model, "import-remove")->enabled &&
+ find_row(model, "import-remove")->subtitle == "Waits for setup to finish",
+ "Game actions' Remove waits too");
model.action("circle");
+ for (int state = 0; state < 3; ++state) {
+ LiveRuntimeGame running; running.game_id = id; running.status = "Ready"; running.ready = true;
+ if (state == 0) running.activity = playden::homebrew::TitleActivity::Running;
+ if (state == 1) running.play_status = "Playing";
+ if (state == 2) running.play_status = "Starting…";
+ model.UpdateRuntime(RuntimeState::Ready, {running});
+ check(!find_row(model, "details-copy")->enabled && !find_row(model, "details-remove")->enabled, "both wait for the game to close");
+ if (model.action("focus:details-remove")) model.action("cross");
+ check(model.state().navigation.modals.empty(), "Remove can't be pressed while the game runs");
+ }
+ activate(model, "details-more");
+ check(find_row(model, "import-remove")->subtitle == "Quit the game first", "Game actions says to quit the game");
+ model.action("circle");
+ // Not known to run, or known to be closed: nothing waits.
+ for (const auto activity : {playden::homebrew::TitleActivity::Unknown, playden::homebrew::TitleActivity::Stopped}) {
+ LiveRuntimeGame closed; closed.game_id = id; closed.status = "Ready"; closed.ready = true; closed.activity = activity;
+ model.UpdateRuntime(RuntimeState::Ready, {closed});
+ check(find_row(model, "details-copy")->enabled && find_row(model, "details-remove")->enabled, "a game not known to run doesn't wait");
+ }
LiveRuntimeGame done; done.game_id = id; done.status = "Ready"; done.ready = done.can_play = true;
model.UpdateRuntime(RuntimeState::Ready, {done});
check(find_row(model, "details-copy")->enabled && find_row(model, "details-remove")->enabled, "both are back after setup");
diff --git a/tests/homebrew_simulation_test.cpp b/tests/homebrew_simulation_test.cpp
index 060230e..49c1e99 100644
--- a/tests/homebrew_simulation_test.cpp
+++ b/tests/homebrew_simulation_test.cpp
@@ -1311,7 +1311,7 @@ static void t17_import_sheet(const std::filesystem::path& fixtures, const std::f
simulation.view().subtitle == "You can import it into Playden later from the game's page." &&
row("import-play-in-place")->title == "Play from the USB drive" &&
row("import-play-in-place")->subtitle == "Nothing is copied. Keep the drive plugged in." &&
- row("import-copy")->title == "Import into Playden…" && row("import-copy")->value == "938 MB" &&
+ row("import-copy")->title == "Copy to storage…" && row("import-copy")->value == "938 MB" &&
row("import-copy")->subtitle == "Copies the game. You pick the storage next." &&
simulation.state().navigation.focus_key == "import-copy",
"T17 choosing the program asks where the game files live, Import focused");
@@ -1399,7 +1399,7 @@ static void t18_imported_game_page(const std::filesystem::path& fixtures, const
press("import-candidate-internal:playden-import/Hollow Knight");
check(row("import-play-in-place")->title == "Play from the drop folder" &&
row("import-play-in-place")->subtitle == "Nothing moves. The files stay in /data/playden-import." &&
- row("import-copy")->title == "Import into Playden…" && row("import-copy")->value == "8.9 GB" &&
+ row("import-copy")->title == "Move to storage…" && row("import-copy")->value == "8.9 GB" &&
row("import-copy")->subtitle == "Takes the game out of the drop folder. You pick the storage next." &&
!row("import-move") && !row("storage-picker"),
"T18 a drop-folder game plays from there or is imported");