diff options
| author | Takoroka <137927095+Takoroka@users.noreply.github.com> | 2026-10-28 04:56:14 -0400 |
|---|---|---|
| committer | Takoroka <137927095+Takoroka@users.noreply.github.com> | 2026-10-28 04:56:14 -0400 |
| commit | 64c91974f4455a63a025149a4ba8e2c46894bdc7 (patch) | |
| tree | 3712d1c121e020e6a0eabb883f47745bbb8cd89a /src/yuzu_cmd/yuzu.cpp | |
| parent | 1517ba02d3247a8deaad9ac493b9ad4a3deb7506 (diff) | |
nx2: frame-locked input replay and quieter logs
EDEN_NX2_KEY_RECORD records keyboard transitions as "f<frame>:code" against a
global count of guest presents; EDEN_NX2_KEY_SCRIPT replays them on the same
frames (or by seconds, as before), so a played session reproduces exactly.
Debug aids: the PC/LR/SP of the first unmapped reads, NSO load addresses,
EDEN_NX2_IPC_SUMMARY (request counts every 5 s), EDEN_NX2_FORCE_LOD0.
Unmapped-access logging is rate limited and the per-draw/semaphore spam is
demoted, so long sessions stay under the log size cap.
Diffstat (limited to 'src/yuzu_cmd/yuzu.cpp')
| -rw-r--r-- | src/yuzu_cmd/yuzu.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp index b46534ec9d..96146abec3 100644 --- a/src/yuzu_cmd/yuzu.cpp +++ b/src/yuzu_cmd/yuzu.cpp @@ -333,9 +333,12 @@ extern "C" SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) { } // EDEN_NX2_KEY_SCRIPT="seconds:code,seconds:-code,...": press (code) or release (-code) keyboard // keys, by SDL scancode, that many seconds after start. Lets hidden test runs drive menus. +double Nx2KeyClockSeconds(); // emu_window_sdl3.cpp + static void RunKeyScript(InputCommon::InputSubsystem& input_subsystem) { struct KeyEvent { - double seconds; + double seconds; // when frame is 0 + u64 frame; // "f<frame>:code": after that many presents int code; }; static const std::vector<KeyEvent> script = [] { @@ -347,22 +350,27 @@ static void RunKeyScript(InputCommon::InputSubsystem& input_subsystem) { const size_t end = std::min(list.find(',', start), list.size()); const std::string item = list.substr(start, end - start); if (const size_t colon = item.find(':'); colon != std::string::npos) { - events.push_back({std::stod(item.substr(0, colon)), - std::stoi(item.substr(colon + 1))}); + const std::string when = item.substr(0, colon); + const int code = std::stoi(item.substr(colon + 1)); + if (!when.empty() && when[0] == 'f') { + events.push_back({0.0, std::stoull(when.substr(1)), code}); + } else { + events.push_back({std::stod(when), 0, code}); + } } start = end + 1; } } return events; }(); - static const auto begin = std::chrono::steady_clock::now(); static size_t next = 0; - const double elapsed = - std::chrono::duration<double>(std::chrono::steady_clock::now() - begin).count(); - while (next < script.size() && script[next].seconds <= elapsed) { + const double elapsed = Nx2KeyClockSeconds(); + const u64 frame = Core::g_nx2_present_count.load(); + while (next < script.size() && (script[next].frame != 0 ? script[next].frame <= frame + : script[next].seconds <= elapsed)) { const int code = script[next].code; - LOG_INFO(Frontend, "Key script: {} key {} at {:.1f} s", code < 0 ? "release" : "press", - code < 0 ? -code : code, elapsed); + LOG_INFO(Frontend, "Key script: {} key {} at {:.1f} s (frame {})", + code < 0 ? "release" : "press", code < 0 ? -code : code, elapsed, frame); if (code < 0) { input_subsystem.GetKeyboard()->ReleaseKey(static_cast<std::size_t>(-code)); } else { |
