Skip to content

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

C++

Declare games VRR-supported with a VRR-ready runtime kit

Leonardo Lobato71cd33ce2839
diff --git a/cmake/PlaydenCore.cmake b/cmake/PlaydenCore.cmake
index 4b8c459..c313874 100644
--- a/cmake/PlaydenCore.cmake
+++ b/cmake/PlaydenCore.cmake
@@ -83,7 +83,8 @@ target_include_directories(playden_game_paths PUBLIC "${CMAKE_SOURCE_DIR}/src")
target_compile_features(playden_game_paths PUBLIC cxx_std_17)
add_library(playden_runtime_installs STATIC "${CMAKE_SOURCE_DIR}/src/runtime/game_install.cpp"
- "${CMAKE_SOURCE_DIR}/src/runtime/leftover_titles.cpp")
+ "${CMAKE_SOURCE_DIR}/src/runtime/leftover_titles.cpp"
+ "${CMAKE_SOURCE_DIR}/src/runtime/title_parameters.cpp")
target_include_directories(playden_runtime_installs PUBLIC "${CMAKE_SOURCE_DIR}/src")
target_compile_features(playden_runtime_installs PUBLIC cxx_std_17)
target_link_libraries(playden_runtime_installs PUBLIC playden_library playden_storage playden_steam_protocol playden_game_paths)
@@ -257,6 +258,9 @@ if(BUILD_TESTING AND NOT PLAYDEN_PLATFORM_PS5)
add_executable(runtime_leftover_titles_test "${CMAKE_SOURCE_DIR}/tests/runtime_leftover_titles_test.cpp")
target_link_libraries(runtime_leftover_titles_test PRIVATE playden_runtime_installs)
add_test(NAME runtime_leftover_titles COMMAND runtime_leftover_titles_test)
+ add_executable(runtime_title_parameters_test "${CMAKE_SOURCE_DIR}/tests/runtime_title_parameters_test.cpp")
+ target_link_libraries(runtime_title_parameters_test PRIVATE playden_runtime_installs)
+ add_test(NAME runtime_title_parameters COMMAND runtime_title_parameters_test)
add_executable(runtime_leftover_titles_native_policy_test
"${CMAKE_SOURCE_DIR}/tests/runtime_leftover_titles_test.cpp"
"${CMAKE_SOURCE_DIR}/src/runtime/leftover_titles.cpp")
diff --git a/src/homebrew/runtime_host.cpp b/src/homebrew/runtime_host.cpp
index b499838..4d794cf 100644
--- a/src/homebrew/runtime_host.cpp
+++ b/src/homebrew/runtime_host.cpp
@@ -25,6 +25,7 @@
#include "runtime/steamworks.h"
#include "runtime/self_heal.h"
#include "runtime/writable_folders.h"
+#include "runtime/title_parameters.h"
#include "platform/managed_file_lock.h"
#include "steam/backend/cloud_mapping.h"
#include "steam/backend/json.h"
@@ -1576,7 +1577,8 @@ void RuntimeHost::PublishInstalls(const Composition& composition, const std::str
std::tie(view.title_current, view.runtime_current, view.setup_other_kit) = kept->second;
} else if (record.state == rt::PreparationState::kReady && composition.kit) {
const bool files_current = composition.installer->TitleCurrent(record);
- view.title_current = files_current && composition.installer->TitleMetadataCurrent(record) && TitleNameCurrent(record);
+ view.title_current = files_current && composition.installer->TitleMetadataCurrent(record) && TitleNameCurrent(record) &&
+ TitleVariableRefreshCurrent(composition, record);
view.runtime_current = files_current && ArtifactsBound(composition.kit->view.artifacts, record);
} else if (composition.kit && SetupRestarts(record) && !view.moving) {
view.setup_other_kit = composition.installer->SetupFromOtherKit(record);
@@ -2931,7 +2933,7 @@ std::optional<std::string> TitleNameOf(const std::string& param) {
}
} // namespace
-std::optional<std::string> RuntimeHost::InstalledTitleName(const rt::RuntimeInstall& record) const {
+std::optional<std::string> RuntimeHost::InstalledTitleParameters(const rt::RuntimeInstall& record) const {
if (record.data_root.empty()) return std::nullopt;
const auto root = config_.host_namespace_prefix.empty()
? std::filesystem::path(record.data_root)
@@ -2944,7 +2946,25 @@ std::optional<std::string> RuntimeHost::InstalledTitleName(const rt::RuntimeInst
for (ssize_t count; (count = read(fd, chunk, sizeof(chunk))) > 0 && bytes.size() < 64 * 1024;)
bytes.append(chunk, static_cast<std::size_t>(count));
close(fd);
- return TitleNameOf(bytes);
+ return bytes;
+}
+
+std::optional<std::string> RuntimeHost::InstalledTitleName(const rt::RuntimeInstall& record) const {
+ const auto param = InstalledTitleParameters(record);
+ return param ? TitleNameOf(*param) : std::nullopt;
+}
+
+bool RuntimeHost::KitDeclaresVariableRefresh(const Composition& c) {
+ return c.kit && std::find(c.kit->capabilities.begin(), c.kit->capabilities.end(), rt::kKitDisplayVrr) !=
+ c.kit->capabilities.end();
+}
+
+bool RuntimeHost::TitleVariableRefreshCurrent(const Composition& c, const rt::RuntimeInstall& record) const {
+ const auto param = InstalledTitleParameters(record);
+ const auto attribute3 = param ? rt::TitleAttribute3(*param) : std::nullopt;
+ // Writing again would not change a layout Playden can't edit.
+ if (!attribute3) return true;
+ return ((*attribute3 & rt::kTitleAttribute3VariableRefresh) != 0) == KitDeclaresVariableRefresh(c);
}
bool RuntimeHost::TitleNameCurrent(const rt::RuntimeInstall& record) const {
@@ -3000,6 +3020,10 @@ rt::PackageActionResult RuntimeHost::WriteTitleMetadata(Composition& c, const rt
const std::string name = title_name.empty() ? "Steam game " + std::to_string(record.runtime_number) : title_name;
if (!replace_value("titleName", JsonEscaped(name)))
Log("title metadata app=" + std::to_string(record.runtime_number) + " keeps the kit's name: unexpected layout");
+ // VRR support only with a runtime that keeps 120 Hz under VRR: older ones would cap a VRR display at 60 Hz.
+ const bool variable_refresh = KitDeclaresVariableRefresh(c);
+ if (!rt::SetTitleVariableRefresh(&param, variable_refresh))
+ Log("title metadata app=" + std::to_string(record.runtime_number) + " keeps the kit's attribute3: unexpected layout");
std::filesystem::path program;
if (auto launch = record.launch_path; !launch.empty() && !record.install_path.empty()) {
std::replace(launch.begin(), launch.end(), '\\', '/');
@@ -3007,7 +3031,7 @@ rt::PackageActionResult RuntimeHost::WriteTitleMetadata(Composition& c, const rt
}
const auto icon = config_.title_icon ? config_.title_icon(GameOf(record), program) : std::nullopt;
Log("title metadata app=" + std::to_string(record.runtime_number) + " name=" + name + " icon=" +
- (icon ? std::to_string(icon->size()) + "B" : std::string("kit")));
+ (icon ? std::to_string(icon->size()) + "B" : std::string("kit")) + " vrr=" + (variable_refresh ? "1" : "0"));
return c.installer->WriteTitleMetadata(record, param, icon);
}
@@ -3385,7 +3409,7 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
const auto bound = c.repository.Update(record);
if (!bound.ok()) return "The runtime kit artifacts could not be recorded: " + bound.message();
}
- if (!c.installer->TitleMetadataCurrent(record)) {
+ if (!c.installer->TitleMetadataCurrent(record) || !TitleVariableRefreshCurrent(c, record)) {
const auto written = WriteTitleMetadata(c, record, request.title_name);
if (written.state != rt::PackageActionState::kComplete) return written.message;
}
@@ -3412,7 +3436,8 @@ std::string RuntimeHost::RunPrepare(Composition& c, const RuntimePrepareRequest&
bool changed = false;
// Older titles carry the kit's generic name and icon: give them the game's.
const bool metadata_current = c.installer->TitleMetadataCurrent(*existing) &&
- (request.title_name.empty() || InstalledTitleName(*existing) == request.title_name);
+ (request.title_name.empty() || InstalledTitleName(*existing) == request.title_name) &&
+ TitleVariableRefreshCurrent(c, *existing);
if (!metadata_current) {
const auto written = WriteTitleMetadata(c, *existing, request.title_name);
if (written.state != rt::PackageActionState::kComplete) return written.message;
diff --git a/src/homebrew/runtime_host.hpp b/src/homebrew/runtime_host.hpp
index 7569e55..f0c5ac1 100644
--- a/src/homebrew/runtime_host.hpp
+++ b/src/homebrew/runtime_host.hpp
@@ -745,8 +745,14 @@ class RuntimeHost {
// titles may start; empty on success (or with no such kit), otherwise why not.
std::string SyncTitleAllowList(Composition& composition);
std::filesystem::path HostPath(const std::string& console_path) const;
+ // The param.json Playden wrote for the game's title, or nothing.
+ std::optional<std::string> InstalledTitleParameters(const runtime::RuntimeInstall& record) const;
std::optional<std::string> InstalledTitleName(const runtime::RuntimeInstall& record) const;
bool TitleNameCurrent(const runtime::RuntimeInstall& record) const;
+ // The kit can declare a title VRR-supported (display-vrr).
+ static bool KitDeclaresVariableRefresh(const Composition& composition);
+ // The title's written parameters declare VRR support exactly when the kit can (an unreadable layout counts as current).
+ bool TitleVariableRefreshCurrent(const Composition& composition, const runtime::RuntimeInstall& record) const;
// Writes the game's own title name (and icon) for its PS5 title.
runtime::PackageActionResult WriteTitleMetadata(Composition& composition, const runtime::RuntimeInstall& record,
const std::string& title_name);
diff --git a/src/runtime/game_settings.h b/src/runtime/game_settings.h
index 9a0e823..044aed0 100644
--- a/src/runtime/game_settings.h
+++ b/src/runtime/game_settings.h
@@ -597,6 +597,9 @@ inline constexpr const char* kKitVkd3dProton = "vkd3d-proton";
// system threads do, so a game's TLS callback can't stop its start in Xbox controller mode (NW.js).
inline constexpr const char* kKitDriverThreads = "wine-driver-threads";
inline constexpr const char* kKitGameRootUsbSearch = "game-root-usb-search";
+// The kit's libvulkan.prx keeps 120 Hz output on a display with variable refresh, so Playden may declare a game's PS5
+// title VRR-supported (param.json attribute3 0x40000). Older runtimes fall back to 60 Hz under VRR: they get no such title.
+inline constexpr const char* kKitDisplayVrr = "display-vrr";
// The runtime honors [display] refresh = 60|120 on every graphics path (Wine reports the rate it asked for) and
// [display] frame_rate = 0|120|60|40|30, which the display paces. Runtimes without it refuse a profile with frame_rate.
inline constexpr const char* kKitDisplay120Hz = "display-120hz";
diff --git a/src/runtime/kit_trust.cpp b/src/runtime/kit_trust.cpp
index b95263f..f82cc5f 100644
--- a/src/runtime/kit_trust.cpp
+++ b/src/runtime/kit_trust.cpp
@@ -16,7 +16,8 @@ KitAdmissionConfig DevelopmentKitAdmission() {
kKitInputWheel, kKitEnvironment, kKitWineMono, kKitVkd3dProton,
kKitDisplay120Hz, kKitProfileVersion2, kKitInputRumble,
kKitDisplayFramegen, kKitDisplayFpsCounter, kKitLauncherMode,
- kKitInputPlaystation, kKitDriverThreads, kKitGameRootUsbSearch};
+ kKitInputPlaystation, kKitDriverThreads, kKitGameRootUsbSearch,
+ kKitDisplayVrr};
std::sort(config.known_capabilities.begin(), config.known_capabilities.end());
return config;
}
diff --git a/src/runtime/package_installer.cpp b/src/runtime/package_installer.cpp
index 256b25e..35f3334 100644
--- a/src/runtime/package_installer.cpp
+++ b/src/runtime/package_installer.cpp
@@ -1650,7 +1650,8 @@ PackageActionResult FilesystemPackageInstaller::RefreshTitle(const RuntimeInstal
RespinIdentity(new_title, kit_.kit_id) != RespinIdentity(*title_marker, kit_.kit_id) ||
RespinIdentity(new_bottle, kit_.kit_id) != RespinIdentity(*bottle_marker, kit_.kit_id))
return Failed("refresh-ownership", "installed title and bottle are not this install's from a compatible kit");
- if (title_digest == kit_.files_sha256 && TitleMatches(record, *paths)) return Complete();
+ // TitleMatches checks sizes and modes only: new metadata of the same size (an attribute3 bit) still needs copying.
+ if (title_digest == kit_.files_sha256 && TitleMatches(record, *paths) && TitleMetadataCurrent(record)) return Complete();
std::vector<char> buffer(kCopyBufferBytes); // heap: console worker stacks are small
const auto mappings = TitleMappings(record);
// Progress: the title's bytes, checked or copied; a file already current counts as done.
diff --git a/src/runtime/title_parameters.cpp b/src/runtime/title_parameters.cpp
new file mode 100644
index 0000000..11ad6e5
--- /dev/null
+++ b/src/runtime/title_parameters.cpp
@@ -0,0 +1,56 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#include "runtime/title_parameters.h"
+
+#include <limits>
+#include <string_view>
+
+namespace playden::runtime {
+namespace {
+
+struct Span {
+ std::size_t begin = 0;
+ std::size_t end = 0;
+ std::uint64_t value = 0;
+};
+
+// The digits after the one "attribute3" key; nothing for a second key, a sign, a fraction or an exponent.
+std::optional<Span> Attribute3Span(const std::string& param) {
+ static constexpr std::string_view key = "\"attribute3\"";
+ const auto at = param.find(key);
+ if (at == std::string::npos || param.find(key, at + key.size()) != std::string::npos) return std::nullopt;
+ auto cursor = param.find_first_not_of(" \t\r\n", at + key.size());
+ if (cursor == std::string::npos || param[cursor] != ':') return std::nullopt;
+ cursor = param.find_first_not_of(" \t\r\n", cursor + 1);
+ if (cursor == std::string::npos) return std::nullopt;
+ Span span{cursor, cursor, 0};
+ while (span.end < param.size() && param[span.end] >= '0' && param[span.end] <= '9') {
+ const std::uint64_t digit = static_cast<std::uint64_t>(param[span.end] - '0');
+ if (span.value > (std::numeric_limits<std::uint32_t>::max() - digit) / 10) return std::nullopt;
+ span.value = span.value * 10 + digit;
+ ++span.end;
+ }
+ if (span.end == span.begin || (span.end - span.begin > 1 && param[span.begin] == '0')) return std::nullopt;
+ const auto after = param.find_first_not_of(" \t\r\n", span.end);
+ if (after == std::string::npos || (param[after] != ',' && param[after] != '}')) return std::nullopt;
+ return span;
+}
+
+} // namespace
+
+std::optional<std::uint64_t> TitleAttribute3(const std::string& param_json) {
+ const auto span = Attribute3Span(param_json);
+ if (!span) return std::nullopt;
+ return span->value;
+}
+
+bool SetTitleVariableRefresh(std::string* param_json, bool supported) {
+ if (!param_json) return false;
+ const auto span = Attribute3Span(*param_json);
+ if (!span) return false;
+ const auto value = supported ? span->value | kTitleAttribute3VariableRefresh
+ : span->value & ~kTitleAttribute3VariableRefresh;
+ param_json->replace(span->begin, span->end - span->begin, std::to_string(value));
+ return true;
+}
+
+} // namespace playden::runtime
diff --git a/src/runtime/title_parameters.h b/src/runtime/title_parameters.h
new file mode 100644
index 0000000..7f054d8
--- /dev/null
+++ b/src/runtime/title_parameters.h
@@ -0,0 +1,21 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#pragma once
+
+#include <cstdint>
+#include <optional>
+#include <string>
+
+namespace playden::runtime {
+
+// param.json attribute3 bit of a title that supports variable refresh rate (VRR). With it the system drives a
+// VRR display at the rate the game shows frames, also at 120 Hz, without "Apply to Unsupported Games".
+inline constexpr std::uint64_t kTitleAttribute3VariableRefresh = 0x40000;
+
+// The title's attribute3, or nothing when param.json has no single plain decimal "attribute3".
+std::optional<std::uint64_t> TitleAttribute3(const std::string& param_json);
+
+// Sets or clears the VRR bit in param.json's single plain decimal "attribute3"; the rest of the text is kept as it
+// is. False, with param_json unchanged, for any other layout.
+bool SetTitleVariableRefresh(std::string* param_json, bool supported);
+
+} // namespace playden::runtime
diff --git a/tests/homebrew_runtime_host_test.cpp b/tests/homebrew_runtime_host_test.cpp
index bdd43a6..06e3de2 100644
--- a/tests/homebrew_runtime_host_test.cpp
+++ b/tests/homebrew_runtime_host_test.cpp
@@ -54,11 +54,11 @@ RuntimeKit WithoutUnownedRoots(RuntimeKit kit) {
return kit;
}
// The same kit with one shell for every game: its own param.json names the template title.
-RuntimeKit AnyTitleKit(const fs::path& kit) {
+RuntimeKit AnyTitleKit(const fs::path& kit, const std::string& attribute3 = "64") {
auto admitted = SyntheticKit(kit);
const auto param = kit / "titles/variant/sce_sys/param.json";
Write(param,
- "{\n \"conceptId\": \"78000\",\n \"contentId\": \"UP9000-FAKE78000_00-PROSPEROWIN00001\",\n"
+ "{\n \"attribute3\": " + attribute3 + ",\n \"conceptId\": \"78000\",\n \"contentId\": \"UP9000-FAKE78000_00-PROSPEROWIN00001\",\n"
" \"localizedParameters\": {\n \"en-US\": {\n \"titleName\": \"Prospero Win\"\n }\n },\n"
" \"titleId\": \"FAKE78000\"\n}\n", 0644);
for (auto& file : admitted.view.files)
@@ -72,6 +72,73 @@ RuntimeKit AnyTitleKit(const fs::path& kit) {
}
} // namespace
+// A kit whose libvulkan.prx keeps 120 Hz under VRR (display-vrr) makes the game's title VRR-supported. A title made
+// before it has the kit's attribute3 only: it is out of date until Update writes the bit with the new runtime.
+// first_vrr: the first kit has display-vrr and the second not (a downgrade), else the other way round.
+void TitleAttribute3FollowsTheKit(const std::string& kit_value, bool first_vrr, const std::string& first,
+ const std::string& second) {
+ Fixture fixture;
+ auto config = fixture.Config();
+ 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");
+ };
+ const auto kit = AnyTitleKit(fixture.root / "kit", kit_value);
+ auto vrr = kit;
+ vrr.capabilities.push_back(kKitDisplayVrr);
+ std::sort(vrr.capabilities.begin(), vrr.capabilities.end());
+ const auto& first_kit = first_vrr ? vrr : kit;
+ const auto& second_kit = first_vrr ? kit : vrr;
+ config.admit_kit = [&first_kit](std::string*) { return std::optional<RuntimeKit>(first_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}; };
+ config.write_title_allow_list = [](const std::string&, std::string*) { return true; };
+ Write(fixture.root / "data/homebrew/FAKE77031/games/220/hl2.exe", "existing-game", 0644);
+ const auto param = fixture.root / "data/homebrew/FAKE78001/sce_sys/param.json";
+ {
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ CHECK(WaitFor(host, Started).kit_available);
+ host.Prepare(Hl2());
+ const auto done = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && (s.refusals.count(220) ||
+ (!s.installs.empty() && s.installs[0].state == PreparationState::kReady));
+ }, 60);
+ CHECK(!done.refusals.count(220) && done.installs[0].title_id == "FAKE78001" && done.installs[0].title_current);
+ CHECK(Read(param).find("\"attribute3\": " + first + ",") != std::string::npos);
+ host.Shutdown();
+ }
+ config.admit_kit = [&second_kit](std::string*) { return std::optional<RuntimeKit>(second_kit); };
+ RuntimeHost host(config);
+ CHECK(host.Start());
+ const auto started = WaitFor(host, Started);
+ CHECK(!started.installs[0].title_current);
+ host.Prepare(Hl2());
+ const auto updated = WaitFor(host, [](const RuntimeSnapshot& s) {
+ return !s.preparing_app && !s.installs.empty() && (s.installs[0].title_current || s.refusals.count(220));
+ }, 60);
+ if (updated.refusals.count(220)) std::fprintf(stderr, "Update refused: %s\n", updated.refusals.at(220).c_str());
+ CHECK(!updated.refusals.count(220) && updated.installs[0].title_current);
+ const auto written = Read(param);
+ CHECK(written.find("\"attribute3\": " + second + ",") != std::string::npos);
+ CHECK(written.find(R"("titleName": "Half-Life \"2\"")") != std::string::npos);
+ host.Shutdown();
+}
+
+void DisplayVrrKitDeclaresTheTitleVrrSupported() {
+ TitleAttribute3FollowsTheKit("64", false, "64", "262208");
+ // Without display-vrr the bit goes again. The value keeps its length, so only the title's contents tell it changed.
+ TitleAttribute3FollowsTheKit("1048640", true, "1310784", "1048640");
+}
+
// One shell for every game: the game gets a new title of its own (the lowest free FAKE78xxx),
// stamped with its own title ID, and its helper's allow-list names it before the title exists.
// Without a way to write that list nothing is prepared.
@@ -7075,6 +7142,7 @@ int main(int argc, char** argv) {
PrepareNamesUnfixableFolder();
TitleRefusalNamesTheSourceThatCannotAnswer();
AnyTitleKitMakesTheGameItsOwnTitle();
+ DisplayVrrKitDeclaresTheTitleVrrSupported();
PreparationEndsAwaitingRegistration();
PreparesGameWithoutShippedRecipe();
for (int scenario = 0; scenario <= 3; ++scenario) OlderEngineDefaultsArePublishedOnPlay(scenario);
diff --git a/tests/runtime_title_parameters_test.cpp b/tests/runtime_title_parameters_test.cpp
new file mode 100644
index 0000000..3eae18e
--- /dev/null
+++ b/tests/runtime_title_parameters_test.cpp
@@ -0,0 +1,48 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+#include "runtime/title_parameters.h"
+
+#include <cstdio>
+#include <cstdlib>
+#include <string>
+
+using namespace playden::runtime;
+
+#define CHECK(condition) do { if (!(condition)) { \
+ std::fprintf(stderr, "%s:%d: CHECK failed: %s\n", __FILE__, __LINE__, #condition); \
+ std::exit(1); } } while (false)
+
+int main() {
+ // The any-title shell's layout: 120 Hz allowed (0x40) only.
+ std::string param = "{\n \"attribute\": 0,\n \"attribute3\": 64,\n \"titleId\": \"FAKE78010\"\n}\n";
+ CHECK(TitleAttribute3(param) == 64u);
+ CHECK(SetTitleVariableRefresh(&param, true));
+ CHECK(TitleAttribute3(param) == 0x40040u);
+ CHECK(param == "{\n \"attribute\": 0,\n \"attribute3\": 262208,\n \"titleId\": \"FAKE78010\"\n}\n");
+ // Setting it twice keeps one bit; clearing it gives the kit's value back.
+ CHECK(SetTitleVariableRefresh(&param, true) && TitleAttribute3(param) == 0x40040u);
+ CHECK(SetTitleVariableRefresh(&param, false) && TitleAttribute3(param) == 64u);
+ CHECK(param == "{\n \"attribute\": 0,\n \"attribute3\": 64,\n \"titleId\": \"FAKE78010\"\n}\n");
+ // Last key, no spaces.
+ std::string compact = "{\"titleId\":\"FAKE78010\",\"attribute3\":0}";
+ CHECK(SetTitleVariableRefresh(&compact, true) && compact == "{\"titleId\":\"FAKE78010\",\"attribute3\":262144}");
+
+ // Any other layout is refused and left as it is.
+ for (std::string refused : {std::string("{\"titleId\": \"FAKE78010\"}"),
+ std::string("{\"attribute3\": 64, \"attribute3\": 64}"),
+ std::string("{\"attribute3\": \"64\"}"),
+ std::string("{\"attribute3\": -64}"),
+ std::string("{\"attribute3\": 64.0}"),
+ std::string("{\"attribute3\": 6e1}"),
+ std::string("{\"attribute3\": 064}"),
+ std::string("{\"attribute3\": 4294967296}"),
+ std::string("{\"attribute3\" 64}"),
+ std::string("{\"attribute3\": 64")}) {
+ const auto before = refused;
+ CHECK(!TitleAttribute3(refused));
+ CHECK(!SetTitleVariableRefresh(&refused, true));
+ CHECK(refused == before);
+ }
+ CHECK(!SetTitleVariableRefresh(nullptr, true));
+ std::puts("title parameters ok");
+ return 0;
+}