Skip to content

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

C++

Check a shipped recipe's requirements against the kit

Leonardo Lobatob01a183588c1
diff --git a/docs/community-recipes.md b/docs/community-recipes.md
index 54bfebf..189bfe1 100644
--- a/docs/community-recipes.md
+++ b/docs/community-recipes.md
@@ -66,6 +66,7 @@ Recipe fields:
| `graphics` | `auto`, `gdi`, `dxvk` or `opengl`. |
| `defaults` | Game settings by setting id (`SettingsCatalogue()`), only values that differ from Playden's default. |
| `locked` | Setting ids the player must choose "Change anyway" to change. |
+| `requirements` | What the runtime kit's template bottle must provide: `{"audio": "ps5"}` (Wine's PS5 audio driver) is the only one so far. On a kit without it, Playden refuses to prepare the game and names what is missing. |
| `registry` | Values the bottle gets under `HKEY_CURRENT_USER` when the game's files are prepared, as a Steam install script's would be: `{"Software\\Wine\\AppDefaults\\game.exe\\Direct3D": {"VideoMemorySize": "4096"}}`. Strings only. The Windows version and text scale values belong to Game settings and are refused here. |
Community fields:
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index 7063f0f..1803423 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -58,6 +58,15 @@ constexpr std::int64_t kPreflightFreshMs = 5000;
std::string InstallId(std::uint32_t app_id) { return "steam-" + std::to_string(app_id); }
+// Why the kit cannot run a recipe Playden ships (its requirements), for the player; empty when it
+// can. The kit's own recipe is skipped: the kit's packager checked its template against it.
+std::string KitLacksForRecipe(const rt::GameRecipe& recipe, const rt::VerifiedKitView& kit) {
+ if (recipe.id == kit.recipe.id) return {};
+ const auto unmet = rt::UnmetRecipeRequirements(recipe.requirements, kit);
+ return unmet.empty() ? std::string()
+ : "The installed compatibility kit lacks what this game needs (" + unmet + "); install a newer kit.";
+}
+
// Staged, its registration submitted, and only waiting for ShadowMountPlus, which
// registers titles once no title runs: the game is ready to play from Home. A
// registration the console refused (a stale hook, a failed submission) is not.
@@ -769,6 +778,11 @@ std::string RuntimeHost::RepublishSettings(Composition& c, const rt::RuntimeInst
if (published) *published = false;
const auto saved = config_.settings_record ? config_.settings_record(record.app_id).value_or(rt::GameSettingsRecord{})
: rt::GameSettingsRecord{};
+ // A recipe this kit cannot run is refused before the game's files or bottle change.
+ if (c.kit)
+ for (const auto& candidate : c.recipes)
+ if (candidate.app_id == record.app_id && candidate.id == record.recipe_id)
+ if (const auto lacks = KitLacksForRecipe(candidate, c.kit->view); !lacks.empty()) return lacks;
// "Steam features" only swaps the game's own files, so it follows the saved value at once.
if (saved.revision <= record.settings_revision) return ApplySteamworks(c, record);
if (!c.kit) return "No verified compatibility kit is installed.";
@@ -1478,6 +1492,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
// only that one must agree with the kit, as the kit's shell was packaged for it.
if (recipe->id == c.kit->view.recipe.id && std::to_string(recipe->version) != c.kit->view.recipe.version)
return "The installed compatibility kit was built for another version of this game's setup.";
+ if (const auto lacks = KitLacksForRecipe(*recipe, c.kit->view); !lacks.empty()) return lacks;
if (recipe->launch_entries.empty()) return "Steam lists no Windows program this console can start for this game.";
const auto settings = config_.settings_record ? config_.settings_record(request.app_id) : std::nullopt;
// The title is made for the launch option the player chose, so its publication matches.
@@ -2170,10 +2185,14 @@ void RuntimeHost::Run() {
operations.progress = [this](std::uint64_t done, std::uint64_t total) { ReportWork(done, total); };
operations.log = [this](const std::string& line) { Log(line); };
auto installer = std::make_unique<rt::FilesystemPackageInstaller>(c.kit->view, config_.package_paths, operations);
- // Records prepared with a recipe Playden ships resolve whatever recipe the kit carries.
+ // Records prepared with a recipe Playden ships resolve whatever recipe the kit carries,
+ // as long as the kit's template provides what the recipe requires.
std::vector<std::string> shipped;
- for (const auto& recipe : c.recipes)
- if (!rt::IsGeneratedRecipeId(recipe.id)) shipped.push_back(recipe.id);
+ for (const auto& recipe : c.recipes) {
+ if (rt::IsGeneratedRecipeId(recipe.id)) continue;
+ if (const auto lacks = KitLacksForRecipe(recipe, c.kit->view); lacks.empty()) shipped.push_back(recipe.id);
+ else Log("recipe " + recipe.id + " refused kit=" + c.kit->view.kit_id + " " + lacks);
+ }
installer->AcceptShippedRecipes(std::move(shipped));
c.installer = std::move(installer);
} else {
diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cpp
index 299c624..3137f9c 100644
--- a/src/runtime/game_settings.cpp
+++ b/src/runtime/game_settings.cpp
@@ -1013,6 +1013,7 @@ bool ParseGameRecipe(std::string_view text, GameRecipe* recipe, std::string* rea
out.launch_entries.push_back(std::move(entry));
}
if (!StringMap(root->get("defaults"), &out.defaults)) return fail("defaults must map setting ids to strings");
+ if (!StringMap(root->get("requirements"), &out.requirements)) return fail("requirements must map names to strings");
if (const auto* locked = root->get("locked")) {
if (!locked->array()) return fail("locked must be a list");
for (const auto& item : *locked->array()) {
@@ -1162,6 +1163,16 @@ std::string SerializeGameRecipe(const GameRecipe& recipe) {
text += quoted(id);
}
text += "]";
+ if (!recipe.requirements.empty()) {
+ text += ",\"requirements\":{";
+ first = true;
+ for (const auto& [name, value] : recipe.requirements) {
+ if (!first) text += ",";
+ first = false;
+ text += quoted(name) + ":" + quoted(value);
+ }
+ text += "}";
+ }
if (!recipe.registry.empty()) {
// Grouped by key as the file has it; data holds the quoted string.
std::map<std::string, std::vector<const RegistryValue*>> keys;
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index e2235ca..ac3f871 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -115,6 +115,8 @@ struct GameRecipe {
// Values the bottle's user.reg gets when the game's files are prepared, as a Steam install
// script's would be (docs/community-recipes.md): strings under HKEY_CURRENT_USER.
std::vector<RegistryValue> registry;
+ // What the kit's template bottle must provide ("audio": "ps5"); see UnmetRecipeRequirements.
+ std::map<std::string, std::string> requirements;
};
struct SettingsPreset {
diff --git a/src/runtime/kit_manifest.cpp b/src/runtime/kit_manifest.cpp
index 129e464..4e47b97 100644
--- a/src/runtime/kit_manifest.cpp
+++ b/src/runtime/kit_manifest.cpp
@@ -499,6 +499,9 @@ class Verifier {
}
view_.template_path = template_path->text();
view_.template_drive_table = template_path->text() + "/dosdevices/.pw-symlinks";
+ // Whether the template has PS5 audio even when its own recipe does not ask for it: other
+ // recipes Playden ships may (UnmetRecipeRequirements).
+ view_.template_audio_ps5 = audio || ValidateRegistry(template_root, true);
view_.recipe = {id->text(), version->text(), recipe_path->text(), sha->text()};
view_artifacts_.push_back({"recipe", id->text() + "-" + version->text(), sha->text(),
ImmutableArtifactLocation::kKit, recipe_path->text()});
diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cpp
index 35e721f..e2bc480 100644
--- a/src/runtime/package_installer.cpp
+++ b/src/runtime/package_installer.cpp
@@ -469,6 +469,15 @@ std::vector<std::string> KitTitleCandidates(const VerifiedKitView& kit) {
return titles;
}
+std::string UnmetRecipeRequirements(const std::map<std::string, std::string>& requirements, const VerifiedKitView& kit) {
+ std::string unmet;
+ for (const auto& [name, value] : requirements) {
+ if (name == "audio" && value == "ps5" && kit.template_audio_ps5) continue;
+ unmet += (unmet.empty() ? "" : ", ") + (name == "audio" && value == "ps5" ? std::string("PS5 audio") : name + " " + value);
+ }
+ return unmet;
+}
+
FilesystemPackageInstaller::FilesystemPackageInstaller(
VerifiedKitView kit, PackageInstallPaths paths,
PackageInstallerOperations operations)
diff --git a/src/runtime/package_installer.h b/src/runtime/package_installer.h
index 2bbf774..2475eb5 100644
--- a/src/runtime/package_installer.h
+++ b/src/runtime/package_installer.h
@@ -5,6 +5,7 @@
#include <cstdint>
#include <filesystem>
#include <functional>
+#include <map>
#include <optional>
#include <string>
#include <string_view>
@@ -65,6 +66,7 @@ struct VerifiedKitView {
std::string template_path;
std::string template_drive_table;
KitRecipe recipe;
+ bool template_audio_ps5 = false; // the template's user.reg selects Wine's ps5 audio driver
std::vector<KitTitleVariant> variants;
std::vector<KitFile> files;
std::vector<KitArtifact> artifacts;
@@ -75,6 +77,11 @@ const KitTitleVariant* KitVariantFor(const VerifiedKitView& kit, const std::stri
// The titles a new game may get, in order: the fixed variants' titles, then, with an any-title
// variant, every other FAKE78001-FAKE78999 (the lowest free one is taken).
std::vector<std::string> KitTitleCandidates(const VerifiedKitView& kit);
+// What a recipe's requirements ask of the kit's template bottle that it does not provide, in a
+// few words for the player ("PS5 audio"); empty when the kit provides all of it. The kit's
+// packager checks its own recipe this way; Playden checks the other recipes it ships. A
+// requirement this build does not know is never met.
+std::string UnmetRecipeRequirements(const std::map<std::string, std::string>& requirements, const VerifiedKitView& kit);
// Canonical paths remain /data/... in RuntimeInstall and descriptors. Tests map
// that namespace beneath host_data_root without weakening canonical validation.
diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cpp
index 5cd0547..a0f1d8f 100644
--- a/tests/game_settings_test.cpp
+++ b/tests/game_settings_test.cpp
@@ -53,6 +53,13 @@ int main(int argc, char** argv) {
GameRecipe hl2;
CHECK(ParseGameRecipe(ReadText(source / "runtime/recipes/steam-220-hl2-v1.json"), &hl2, &reason));
+ // What the kit's template must provide is read and written back (UnmetRecipeRequirements checks it).
+ CHECK(hl2.requirements == (std::map<std::string, std::string>{{"audio", "ps5"}}));
+ {
+ GameRecipe reread;
+ CHECK(ParseGameRecipe(SerializeGameRecipe(hl2), &reread, &reason) && reread.requirements == hl2.requirements);
+ CHECK(!ParseGameRecipe(R"({"recipe_id":"x","recipe_version":1,"app_id":1,"launch_entries":[{"id":"a","label":"A","executable":"a.exe"}],"requirements":{"audio":1}})", &reread, &reason));
+ }
std::vector<SettingsPreset> presets;
CHECK(ParseSettingsPresets(ReadText(source / "runtime/presets.json"), &presets, &reason));
CHECK(presets.size() == 4 && presets.front().id == "playden-default");
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index b090a6f..717bccc 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -1746,6 +1746,73 @@ void ShippedRecipePreparesWithAnotherKitsRecipe() {
restarted.Shutdown();
}
+// A shipped recipe's requirements are checked against the kit's template, as the kit's packager
+// checks the kit's own recipe: without PS5 audio in the template, a recipe that needs it is refused.
+void ShippedRecipeRequirementsFollowTheKit(bool template_audio_ps5) {
+ Fixture fixture;
+ auto config = fixture.Config();
+ const auto runtime = fixture.root / "runtime";
+ Write(runtime / "presets.json", Read(fs::path(g_runtime_dir) / "presets.json"), 0644);
+ Write(runtime / "recipes/recipes.lst", Read(fs::path(g_runtime_dir) / "recipes/recipes.lst"), 0644);
+ Write(runtime / "recipes/steam-220-hl2-v1.json", Read(fs::path(g_runtime_dir) / "recipes/steam-220-hl2-v1.json"), 0644);
+ auto ffxiii = Read(fs::path(g_runtime_dir) / "recipes/steam-292120-ffxiii-v1.json");
+ ffxiii.replace(ffxiii.find("\"locked\""), 0, "\"requirements\": {\"audio\": \"ps5\"},\n ");
+ Write(runtime / "recipes/steam-292120-ffxiii-v1.json", ffxiii, 0644);
+ config.runtime_dir = runtime.string();
+ config.steamworks_dir = (fs::path(g_runtime_dir) / "steamworks").string();
+ config.host_namespace_prefix = fixture.root;
+ config.package_paths.console_data_root = "/data";
+ config.package_paths.host_data_root = fixture.root / "data";
+ config.package_operations.hash_file = HashArtifactFile;
+ config.package_operations.hash_bytes = HashArtifactBytes;
+ config.package_operations.free_space_unverifiable = true;
+ config.package_operations.validate_bottle = [](const fs::path& bottle) {
+ return fs::is_regular_file(bottle / "system.reg") && fs::is_regular_file(bottle / "user.reg");
+ };
+ auto kit = SyntheticKit(fixture.root / "kit");
+ kit.view.template_audio_ps5 = template_audio_ps5;
+ config.admit_kit = [&kit](std::string*) { return std::optional<RuntimeKit>(kit); };
+ unsigned uuids = 0;
+ config.uuid = [&uuids]() -> std::optional<std::string> {
+ ++uuids; return std::string("00000000-0000-4000-8000-00000000000") + std::to_string(uuids);
+ };
+ config.unix_time = [] { return std::int64_t{1760000000}; };
+ Write(fixture.root / "data/homebrew/FAKE77031/games/292120/white_data/prog/win/bin/ffxiiiimg.exe", "existing-game", 0644);
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ host.Prepare({292120, "/data/homebrew/FAKE77031/games/292120", "internal", "Final Fantasy XIII"});
+ const auto done = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && (s.refusals.count(292120) || (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));
+ }, 60);
+ if (template_audio_ps5) {
+ if (done.refusals.count(292120)) std::fprintf(stderr, "Prepare refused: %s\n", done.refusals.at(292120).c_str());
+ CHECK(!done.refusals.count(292120) && done.installs.size() == 1);
+ // Swapped for a kit without PS5 audio, Play is refused before the bottle or the game's files change.
+ host.Shutdown();
+ const auto user_reg = fixture.root / "data/playden/games/steam-292120/library/prefixes/game/user.reg";
+ auto marked = Read(user_reg);
+ marked.replace(marked.find("\"VideoMemorySize\"=\"4096\""), 24, "\"VideoMemorySize\"=\"1234\"");
+ Write(user_reg, marked, 0600);
+ kit.view.template_audio_ps5 = false;
+ RuntimeHost swapped(config);
+ CHECK(swapped.Start());
+ CHECK(WaitFor(swapped, Started).kit_available);
+ swapped.Play(292120);
+ const auto played = WaitFor(swapped, [](const RuntimeSnapshot& s) { return s.plays_handled > 0; }, 30);
+ if (played.play_refusals.count(292120)) std::fprintf(stderr, "Play refused: %s\n", played.play_refusals.at(292120).c_str());
+ CHECK(played.play_refusals.count(292120) &&
+ played.play_refusals.at(292120).find("lacks what this game needs (PS5 audio)") != std::string::npos);
+ CHECK(Read(user_reg).find("\"VideoMemorySize\"=\"1234\"") != std::string::npos);
+ swapped.Shutdown();
+ return;
+ } else {
+ CHECK(done.refusals.count(292120) && done.installs.empty());
+ CHECK(done.refusals.at(292120).find("lacks what this game needs (PS5 audio)") != std::string::npos);
+ }
+ host.Shutdown();
+}
+
int main(int argc, char** argv) {
CHECK(argc == 2);
g_runtime_dir = argv[1];
@@ -1770,6 +1837,8 @@ int main(int argc, char** argv) {
KitRespinKeepsWaitingSettingsUpdate();
RemovesTitleKeepingSaves();
ShippedRecipePreparesWithAnotherKitsRecipe();
+ ShippedRecipeRequirementsFollowTheKit(false);
+ ShippedRecipeRequirementsFollowTheKit(true);
std::puts("runtime host tests passed");
return 0;
}
diff --git a/tests/runtime_kit_manifest_test.cpp b/tests/runtime_kit_manifest_test.cpp
index 5743963..e10afd0 100644
--- a/tests/runtime_kit_manifest_test.cpp
+++ b/tests/runtime_kit_manifest_test.cpp
@@ -436,7 +436,7 @@ int main() {
if (result.status != KitManifestStatus::kVerified)
std::fprintf(stderr, "valid fixture rejected: %s\n", result.reason.c_str());
assert(result.status == KitManifestStatus::kVerified);
- assert(result.view && result.view->kit_id == "kit-1");
+ assert(result.view && result.view->kit_id == "kit-1" && result.view->template_audio_ps5);
assert(result.available_variant_ids == std::vector<std::string>{"variant"});
assert(result.capabilities == std::vector<std::string>({"ps5-audio", "wine-wow64"}));
assert(result.artifacts.size() >= 2);
@@ -507,6 +507,20 @@ int main() {
fixture.RewriteManifest();
CheckRejected(fixture.Verify(), KitManifestStatus::kIntegrityFailure);
}
+ {
+ // The kit says whether its template has PS5 audio even when its own recipe does not ask for it,
+ // so Playden can check the other recipes it ships.
+ Fixture fixture;
+ Write(fixture.root / "recipes/steam-220-hl2-v1.json", "{\"id\":\"steam-220-hl2-v1\",\"version\":\"1\"}");
+ fixture.RewriteManifest();
+ auto result = fixture.Verify();
+ assert(result.status == KitManifestStatus::kVerified && result.view->template_audio_ps5);
+ Write(fixture.root / "template/bottle/user.reg",
+ "[Volatile Environment]\n\"USERNAME\"=\"prospero\"\n\"USERPROFILE\"=\"C:\\\\users\\\\prospero\"\n");
+ fixture.RewriteManifest();
+ result = fixture.Verify();
+ assert(result.status == KitManifestStatus::kVerified && !result.view->template_audio_ps5);
+ }
{
Fixture fixture; Write(fixture.root / "unexpected.bin", "extra");
CheckRejected(fixture.Verify(), KitManifestStatus::kIntegrityFailure);
diff --git a/tests/runtime_package_installer_test.cpp b/tests/runtime_package_installer_test.cpp
index 51c0f1c..ff5084b 100644
--- a/tests/runtime_package_installer_test.cpp
+++ b/tests/runtime_package_installer_test.cpp
@@ -974,11 +974,24 @@ void ShippedRecipeResolvesWithAnyKit() {
CHECK(!installer.Inspect(generated).title_source_path.empty());
}
+// A shipped recipe's requirements against what the kit's template provides.
+void RecipeRequirementsNameWhatTheKitLacks() {
+ VerifiedKitView kit;
+ CHECK(UnmetRecipeRequirements({}, kit).empty());
+ CHECK(UnmetRecipeRequirements({{"audio", "ps5"}}, kit) == "PS5 audio");
+ kit.template_audio_ps5 = true;
+ CHECK(UnmetRecipeRequirements({{"audio", "ps5"}}, kit).empty());
+ // A requirement this build does not know is never met.
+ CHECK(UnmetRecipeRequirements({{"audio", "ps5"}, {"gpu", "rdna9"}}, kit) == "gpu rdna9");
+ CHECK(UnmetRecipeRequirements({{"audio", "pulse"}}, kit) == "audio pulse");
+}
+
} // namespace
int main() {
TemplateCopyReportsProgress();
ShippedRecipeResolvesWithAnyKit();
+ RecipeRequirementsNameWhatTheKitLacks();
{
Fixture fixture;
const auto game = fixture.host_data / "playden/games/install-hl2";