Play your Steam library's Windows games on a jailbroken PS5.
C++
Follow a shipped recipe's Steam features setting
Timothy Slater623fc61a99c5
diff --git a/runtime/recipes/steam-292120-ffxiii-v1.json b/runtime/recipes/steam-292120-ffxiii-v1.jsonindex c2ba1af..1caf1a7 100644--- a/runtime/recipes/steam-292120-ffxiii-v1.json+++ b/runtime/recipes/steam-292120-ffxiii-v1.json@@ -6,14 +6,15 @@"launch_entries": [{"id": "game", "label": "Final Fantasy XIII", "executable": "white_data/prog/win/bin/ffxiiiimg.exe"}],- "arguments": "",- "resolution_arguments": "",- "dll_overrides": "",+ "arguments": "-FullScreenMode=Force {resolution} -Shadow=4096 -MSAA=4",+ "resolution_arguments": "-Width={w} -Height={h}",+ "dll_overrides": "d3d9=n","architecture": "pe32","runtime": "wine-wow64","prefix": "game","graphics": "dxvk","defaults": {+ "resolution": "1920x1080","steam_features": "emulate","controller": "xinput"},diff --git a/src/runtime/game_settings.cpp b/src/runtime/game_settings.cppindex 0b739f0..299c624 100644--- a/src/runtime/game_settings.cpp+++ b/src/runtime/game_settings.cpp@@ -528,9 +528,11 @@ bool BuildEffectiveSettings(const GameRecipe& recipe, const SettingsPreset* pres// Graphics comes from the recipe; only a recipe that locks it (Half-Life 2) keeps players from changing it.if (definition.id == "graphics") value.value = recipe.graphics, value.source = ValueSource::kRecipe;if (definition.id == "architecture") value.value = recipe.architecture, value.source = ValueSource::kRecipe;- // A shipped recipe was proven with the game's own Steam library (Half-Life 2), so that stays.+ // A shipped recipe that says nothing about Steam features was proven with the game's own Steam+ // library (Half-Life 2), so that stays; one that names them (Final Fantasy XIII: emulation) is followed.value.locked = recipe.locked.count(definition.id) > 0;- if (definition.id == "steam_features" && !IsGeneratedRecipeId(recipe.id) && !IsCommunityRecipeId(recipe.id))+ if (definition.id == "steam_features" && !IsGeneratedRecipeId(recipe.id) && !IsCommunityRecipeId(recipe.id) &&+ !recipe.defaults.count("steam_features"))value.value = "game", value.source = ValueSource::kRecipe, value.locked = true;// "Change anyway": the player's value wins over the recipe's lock; the row still says so.value.unlocked = value.locked && overrides.count(kUnlockPrefix + definition.id) > 0;diff --git a/tests/game_probe_test.cpp b/tests/game_probe_test.cppindex 8ab6a1a..e8ade21 100644--- a/tests/game_probe_test.cpp+++ b/tests/game_probe_test.cpp@@ -291,11 +291,23 @@ int main() {CHECK(settings.values.at("steam_features").value == "emulate" && !settings.values.at("steam_features").locked);CHECK(BuildEffectiveSettings(recipe, nullptr, {{"steam_features", "game"}}, KitCapabilities{}, &settings, &error));CHECK(settings.values.at("steam_features").value == "game");- // A shipped recipe keeps the game's own Steam library, whatever the player asks.+ // A shipped recipe that says nothing about Steam features keeps the game's own library, whatever the player asks.auto shipped = recipe;shipped.id = "steam-2062430-shipped-v1";+ shipped.defaults.erase("steam_features");CHECK(BuildEffectiveSettings(shipped, nullptr, {{"steam_features", "emulate"}}, KitCapabilities{}, &settings, &error));CHECK(settings.values.at("steam_features").value == "game" && settings.values.at("steam_features").locked);+ // A shipped recipe that names its Steam features (Final Fantasy XIII: emulation) is followed, and+ // the player may still choose the game's own files unless the recipe locks the row.+ auto emulated = shipped;+ emulated.defaults["steam_features"] = "emulate";+ CHECK(BuildEffectiveSettings(emulated, nullptr, {}, KitCapabilities{}, &settings, &error));+ CHECK(settings.values.at("steam_features").value == "emulate" && !settings.values.at("steam_features").locked);+ CHECK(BuildEffectiveSettings(emulated, nullptr, {{"steam_features", "game"}}, KitCapabilities{}, &settings, &error));+ CHECK(settings.values.at("steam_features").value == "game");+ emulated.locked.insert("steam_features");+ CHECK(BuildEffectiveSettings(emulated, nullptr, {{"steam_features", "game"}}, KitCapabilities{}, &settings, &error));+ CHECK(settings.values.at("steam_features").value == "emulate" && settings.values.at("steam_features").locked);// Every program refused: the first reason is the player's.WritePe(root / "Stub.exe", {false, {"d3d9.dll"}, false, true});GameRecipeDiagnostics diagnostics;diff --git a/tests/game_settings_test.cpp b/tests/game_settings_test.cppindex 6e6be53..c205e87 100644--- a/tests/game_settings_test.cpp+++ b/tests/game_settings_test.cpp@@ -662,12 +662,22 @@ int main(int argc, char** argv) {std::filesystem::remove_all(registry_root);}// Final Fantasy XIII asks DxDiag for its video memory, which Wine answers from wined3d, so the shipped- // recipe sets wined3d's VideoMemorySize for its program.+ // recipe sets wined3d's VideoMemorySize for its program. Its Direct3D 9 goes to DXVK (a shipped recipe+ // names its own overrides), and it wants the Steam emulator, not the game's own files.{GameRecipe ffxiii;CHECK(ParseGameRecipe(ReadText(source / "runtime/recipes/steam-292120-ffxiii-v1.json"), &ffxiii, &reason));CHECK(ffxiii.app_id == 292120 && ffxiii.registry.size() == 1 && ffxiii.registry[0].name == "VideoMemorySize" &&ffxiii.registry[0].key == "Software\\Wine\\AppDefaults\\ffxiiiimg.exe\\Direct3D" && ffxiii.registry[0].data == "\"4096\"");+ EffectiveSettings settings;+ SettingsError error;+ CHECK(BuildEffectiveSettings(ffxiii, nullptr, {}, KitCapabilities{}, &settings, &error));+ CHECK(settings.graphics == "dxvk" && settings.dll_overrides == "d3d9=n");+ CHECK(settings.values.at("steam_features").value == "emulate" && !settings.values.at("steam_features").locked);+ // Its own full-screen, size and quality arguments; the size follows the Resolution row.+ CHECK(settings.arguments == "-FullScreenMode=Force -Width=1920 -Height=1080 -Shadow=4096 -MSAA=4");+ CHECK(BuildEffectiveSettings(ffxiii, nullptr, {{"resolution", "1280x720"}}, KitCapabilities{}, &settings, &error));+ CHECK(settings.arguments == "-FullScreenMode=Force -Width=1280 -Height=720 -Shadow=4096 -MSAA=4");}CHECK(!ParseSettingsPresets(R"({"presets":[{"id":"x","name":"X","settings":{"graphics":"gdi"}}]})", &presets, &reason));CHECK(!ParseSettingsPresets(R"({"presets":[{"id":"x","name":"X","settings":{"extra_arguments":"-a"}}]})", &presets, &reason));