Play your Steam library's Windows games on a jailbroken PS5.
C++
Show the PhysX message after setup and after a restart
Leonardo Lobato271e00765cda
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cppindex 66677ec..89f8b56 100644--- a/src/homebrew/runtime_host.cpp+++ b/src/homebrew/runtime_host.cpp@@ -1009,6 +1009,8 @@ std::string RuntimeHost::InstallScriptsStep(const GameFiles& files) {return rt::ProgramUsesPhysx(files.root.string(), program);});if (physx_needed) Log("redist app=" + std::to_string(number) + " physx engine missing version=" + (physx_needed->empty() ? "unknown" : *physx_needed));+ // Kept in the bottle: the game's page says it again after Playden restarts, before the next Play checks.+ if (!rt::RecordPhysxNeeded(files.prefix, physx_needed)) Log("redist app=" + std::to_string(number) + " physx note not saved");Publish([&](RuntimeSnapshot& s) {if (physx_needed) s.physx_needed[number] = *physx_needed;else s.physx_needed.erase(number);@@ -4590,6 +4592,14 @@ bool RuntimeHost::RunServices() {hints[record.runtime_number] = program;}if (!hints.empty()) Publish([&](RuntimeSnapshot& s) { s.launcher_hints = std::move(hints); });+ // What the last check found: a game missing its PhysX engine says so before its next Play.+ std::map<std::uint32_t, std::string> physx;+ for (const auto& record : c.repository.Snapshot()) {+ if (record.state != rt::PreparationState::kReady) continue;+ if (auto needed = rt::RecordedPhysxNeeded((HostPath(record.data_root) / "library/prefixes/game").string()))+ physx[record.runtime_number] = std::move(*needed);+ }+ if (!physx.empty()) Publish([&](RuntimeSnapshot& s) { s.physx_needed = std::move(physx); });}if (config_.title_log)for (const auto& record : c.repository.Snapshot()) {diff --git a/src/homebrew/simulation.cpp b/src/homebrew/simulation.cppindex 441fa5e..9a4a0e4 100644--- a/src/homebrew/simulation.cpp+++ b/src/homebrew/simulation.cpp@@ -6986,6 +6986,8 @@ void Simulation::rebuild_view() {if (const auto* other_game = find_game(state_, other_id)) ahead = other_game->title;}}+ // Once setup has finished, when Play can start the game and adding the installer would help.+ const bool physx_message = runtime && runtime->physx_needed && status == "Ready" && runtime->play_work.empty();auto& setup = row("details-setup", RowKind::Status, "Setup", "");setup.value = waiting ? "Waiting for the PS5" : kit_update ? "Kit update available": status == "Not prepared" ? "Not set up" : status == "Needs recovery" ? "Interrupted"@@ -6996,7 +6998,7 @@ void Simulation::rebuild_view() {if (runtime && !runtime->play_work.empty()) {setup.value = runtime->play_work.substr(0, runtime->play_work.rfind("…"));setup.tone = "busy";- } else if (runtime && runtime->physx_needed && status == "Ready") {+ } else if (physx_message) {setup.value = "Needs PhysX";setup.tone = "attention";}@@ -7018,7 +7020,7 @@ void Simulation::rebuild_view() {else if (status == "Removal incomplete") hint = "Removing " + game->title + " from the PS5 Home screen stopped partway.";else if (status == "Needs repair") hint = "Some of " + game->title + "'s setup files changed.";else if (status == "No kit") hint = "Playden needs its runtime kit to set up games.";- else if (runtime && runtime->physx_needed) {+ else if (physx_message) {const auto& version = *runtime->physx_needed;hint = version.empty() ? "This game needs PhysX. Add its installer to the game's _Redist folder, then press Play.": "This game needs PhysX " + version + ". Add its installer to the game's _Redist folder, then press Play.";@@ -7037,7 +7039,7 @@ void Simulation::rebuild_view() {}if (!hint.empty()) {auto& note = row("details-hint", RowKind::Status, hint, "");- note.tone = runtime && runtime->physx_needed && setup.tone != "busy" ? "attention" : setup.tone;+ note.tone = setup.tone;note.enabled = false;}// Waiting behind other games: move it to the front; the game being set up now finishes first.diff --git a/src/runtime/redist_install.cpp b/src/runtime/redist_install.cppindex 5f38871..a89ef50 100644--- a/src/runtime/redist_install.cpp+++ b/src/runtime/redist_install.cpp@@ -29,6 +29,7 @@ constexpr std::size_t kMaxScripts = 32;constexpr int kMaxDepth = 4;constexpr std::size_t kMaxPhysxPackages = 8;constexpr const char* kStateFile = ".playden-redist";+constexpr const char* kPhysxNeededFile = ".playden-physx-needed";constexpr const char* kMfcScanFile = ".playden-mfc";constexpr const char* kEnvironmentKey = "System\\CurrentControlSet\\Control\\Session Manager\\Environment";@@ -820,6 +821,21 @@ std::optional<std::string> MissingPhysxEngine(const std::string& game_root, consreturn std::nullopt;}+bool RecordPhysxNeeded(const std::string& prefix_dir, const std::optional<std::string>& needed) {+ if (RecordedPhysxNeeded(prefix_dir) == needed) return true;+ auto directory = ManagedDirectory::Open(prefix_dir, DirectoryPolicy::kApprovedTree);+ if (!directory) return false;+ return needed ? WriteFileAt(*directory, kPhysxNeededFile, *needed) : directory->RemoveRegularFile(kPhysxNeededFile);+}++std::optional<std::string> RecordedPhysxNeeded(const std::string& prefix_dir) {+ std::string text;+ if (!ReadFile(std::filesystem::path(prefix_dir) / kPhysxNeededFile, 64, &text)) return std::nullopt;+ if (!std::all_of(text.begin(), text.end(), [](char value) { return value == '.' || (value >= '0' && value <= '9'); }))+ return std::nullopt;+ return text;+}+bool RedistIsPhysx(const std::string& name) { return Lower(name).find("physx") != std::string::npos; }RedistInstallResult InstallRedistributables(const std::string& game_root, const std::string& install_dir,diff --git a/src/runtime/redist_install.h b/src/runtime/redist_install.hindex a48cc8e..9347f9c 100644--- a/src/runtime/redist_install.h+++ b/src/runtime/redist_install.h@@ -59,6 +59,12 @@ std::optional<std::string> MissingPhysxEngine(const std::string& game_root, consconst std::string& prefix_dir,const std::function<bool(const std::string&)>& uses_physx);+// What MissingPhysxEngine last found, kept in the bottle so a later Playden start can say it without reading the game's+// drive (which may not be there). RecordPhysxNeeded replaces it (nullopt: nothing is missing); RecordedPhysxNeeded reads+// it: the version, empty when it isn't known, or nullopt.+bool RecordPhysxNeeded(const std::string& prefix_dir, const std::optional<std::string>& needed);+std::optional<std::string> RecordedPhysxNeeded(const std::string& prefix_dir);+// Whether a redistributable's name (an install script's entry) is PhysX's.bool RedistIsPhysx(const std::string& name);diff --git a/tests/homebrew_library_model_test.cpp b/tests/homebrew_library_model_test.cppindex 40761a8..7459d8a 100644--- a/tests/homebrew_library_model_test.cpp+++ b/tests/homebrew_library_model_test.cpp@@ -2644,6 +2644,18 @@ void live_play_does_the_next_useful_thing() {model.UpdateRuntime(RuntimeState::Ready, {physx});check(find_row(model, "details-hint")->title == "This game needs PhysX. Add its installer to the game's _Redist folder, then press Play.","without a known version the hint still says what to add");+ // Not while setup runs, nor while Play installs something: "press Play" isn't true yet.+ auto preparing_physx = physx;+ preparing_physx.status = "Preparing"; preparing_physx.ready = preparing_physx.can_play = false;+ preparing_physx.detail = "Step 6 of 6 · Waiting for the PS5"; preparing_physx.physx_needed = "2.8.1";+ model.UpdateRuntime(RuntimeState::Ready, {preparing_physx});+ check(!has_row(model, "details-hint") && find_row(model, "details-setup")->value == preparing_physx.detail,+ "no PhysX message during setup");+ auto installing_physx = physx;+ installing_physx.physx_needed = "2.8.1"; installing_physx.play_work = "Installing PhysX…";+ model.UpdateRuntime(RuntimeState::Ready, {installing_physx});+ check(!has_row(model, "details-hint") && find_row(model, "details-setup")->value == "Installing PhysX",+ "no PhysX message while one installs");physx.physx_needed.reset();model.UpdateRuntime(RuntimeState::Ready, {physx});check(!has_row(model, "details-hint"), "with the engine there is no hint");diff --git a/tests/runtime_redist_test.cpp b/tests/runtime_redist_test.cppindex a72877e..00bfacf 100644--- a/tests/runtime_redist_test.cpp+++ b/tests/runtime_redist_test.cpp@@ -514,6 +514,20 @@ void TestFoundPhysx() {CHECK(!MissingPhysxEngine(versioned.string(), {"Tools/Plain.exe", "Binaries/Game.exe", "Local/Game.exe"}, bottle.string(), uses));}+ // What the check found stays in the bottle for the next Playden start.+ {+ const auto note = fresh_prefix("note-prefix");+ CHECK(!RecordedPhysxNeeded(note.string()));+ CHECK(RecordPhysxNeeded(note.string(), std::string("2.8.1")) && RecordedPhysxNeeded(note.string()) == std::optional<std::string>("2.8.1"));+ CHECK(RecordPhysxNeeded(note.string(), std::string()) && RecordedPhysxNeeded(note.string()) == std::optional<std::string>(""));+ CHECK(RecordPhysxNeeded(note.string(), std::nullopt) && !RecordedPhysxNeeded(note.string()));+ CHECK(RecordPhysxNeeded(note.string(), std::nullopt)); // nothing to remove+ WriteText(note / ".playden-physx-needed", "not a version");+ CHECK(!RecordedPhysxNeeded(note.string()));+ const auto missing = base / "no-such-bottle";+ CHECK(!RecordedPhysxNeeded(missing.string()));+ }+// Needed, and nothing to install.const auto bare = base / "bare";std::filesystem::create_directories(bare / "Binaries");