aboutsummaryrefslogtreecommitdiff
path: root/src/yuzu_cmd
diff options
context:
space:
mode:
authorTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-28 07:47:45 -0400
committerTakoroka <137927095+Takoroka@users.noreply.github.com>2026-10-28 07:47:45 -0400
commit32d876ded1aefc52f839d65570e3e3c43ec04415 (patch)
tree9030b5090a857d943b5b0341c499af7184abb192 /src/yuzu_cmd
parent598bb7750c71ea1378724ddfe9418f27330fa279 (diff)
nx2: read debug switches once; key scripts from a file
Several debug switches were read with std::getenv on every macro call, QMD, semaphore write or draw. The UCRT getenv locks and scans the environment, thousands of times a frame; a long EDEN_NX2_KEY_SCRIPT made title 4 crawl at 2 fps. Each is now read once. EDEN_NX2_KEY_SCRIPT=@<file> reads the script from a file. gdbrsp.py gains 'hits' (log registers, frame chain and object words at breakpoints, following the stopped thread).
Diffstat (limited to 'src/yuzu_cmd')
-rw-r--r--src/yuzu_cmd/yuzu.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/yuzu_cmd/yuzu.cpp b/src/yuzu_cmd/yuzu.cpp
index 96146abec3..f55da5fd61 100644
--- a/src/yuzu_cmd/yuzu.cpp
+++ b/src/yuzu_cmd/yuzu.cpp
@@ -4,6 +4,8 @@
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
+#include <iterator>
+#include <fstream>
#include <vector>
#include <cstdlib>
#include <chrono>
@@ -331,7 +333,7 @@ extern "C" SDL_AppResult SDL_AppInit(void **appstate, int argc, char **argv) {
state->system.InitializeDebugger();
return SDL_APP_CONTINUE;
}
-// EDEN_NX2_KEY_SCRIPT="seconds:code,seconds:-code,...": press (code) or release (-code) keyboard
+// EDEN_NX2_KEY_SCRIPT="seconds:code,seconds:-code,..." (or "@<file>"): 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
@@ -344,7 +346,13 @@ static void RunKeyScript(InputCommon::InputSubsystem& input_subsystem) {
static const std::vector<KeyEvent> script = [] {
std::vector<KeyEvent> events;
if (const char* text = std::getenv("EDEN_NX2_KEY_SCRIPT")) {
+ // "@<file>" reads the list from a file: long scripts in the environment slow down
+ // every getenv in the process.
std::string list{text};
+ if (!list.empty() && list[0] == '@') {
+ std::ifstream file{list.substr(1)};
+ list.assign(std::istreambuf_iterator<char>{file}, {});
+ }
size_t start = 0;
while (start < list.size()) {
const size_t end = std::min(list.find(',', start), list.size());