mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-24 21:55:57 +00:00
Offer the keep-running-out-of-focus switch in the Game tab
The game pauses whenever its window loses focus, as it does on the Switch when Home is pressed, and ASSUME_FOCUS was the only way to change that: a known key with no row in the settings table. The runtime reads it at each focus change rather than once at start, so the row takes effect the next time the window is left, and the build guide says what an unfocused window now does.
This commit is contained in:
1 parent
adf9c768c3
commit
e4eef8ae0c
7 files changed
+24
-12
No files matched your search
+2
-1
@@ -104,7 +104,8 @@ From the repository root, in PowerShell. Every step that depends on the game ver
|
|||||||
The AMD driver keeps its pipeline cache per exe path and holds a limited amount: preparing another build folder can
|
The AMD driver keeps its pipeline cache per exe path and holds a limited amount: preparing another build folder can
|
||||||
evict this one's. `totk.exe --warm-shaders` rebuilds it from the shader cache.
|
evict this one's. `totk.exe --warm-shaders` rebuilds it from the shader cache.
|
||||||
|
|
||||||
7. Run. Keep the window in the foreground; an unfocused window stalls the game.
|
7. Run. The game pauses while its window is out of focus, as it does on the Switch when Home is pressed;
|
||||||
|
`assume_focus = 1` in `totk.ini`, or the Game tab, keeps it running in another window.
|
||||||
|
|
||||||
```powershell
|
```powershell
|
||||||
build\<ver>\totk.exe
|
build\<ver>\totk.exe
|
||||||
|
|||||||
+2
-1
@@ -59,7 +59,7 @@ static const struct { const char *key, *section; } sections[] = {
|
|||||||
{"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"},
|
{"REALTIME", "frame rate"}, {"CLOTH_REALTIME", "frame rate"}, {"HIGHFPS_FIX", "frame rate"},
|
||||||
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
{"FULLSCREEN", "display"}, {"WINDOW_SIZE", "display"}, {"PERF_OVERLAY", "display"}, {"VK_PRESENT", "display"},
|
||||||
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
{"GPU_INDEX", "display"}, {"OUTPUT_RES", "display"}, {"RENDER_SCALE", "display"}, {"UPSCALER", "display"},
|
||||||
{"SHARPNESS", "display"}, {"ASPECT", "display"},
|
{"SHARPNESS", "display"}, {"ASPECT", "display"}, {"ASSUME_FOCUS", "display"},
|
||||||
{"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"},
|
{"MENU_LANG", "language"}, {"LANG", "language"}, {"OPERATION_MODE", "language"},
|
||||||
{"VOLUME", "audio"},
|
{"VOLUME", "audio"},
|
||||||
{"MOTION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"},
|
{"MOTION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"},
|
||||||
@@ -101,6 +101,7 @@ static const CfgMeta metas[] = {
|
|||||||
{"HIGHFPS_FIX", "1", "0|1", RESTART},
|
{"HIGHFPS_FIX", "1", "0|1", RESTART},
|
||||||
{"LANG", "", "ja|en-US|fr|de|it|es|zh-CN|ko|nl|pt|ru|zh-TW|en-GB|fr-CA|es-419|zh-Hans|zh-Hant|pt-BR", RESTART},
|
{"LANG", "", "ja|en-US|fr|de|it|es|zh-CN|ko|nl|pt|ru|zh-TW|en-GB|fr-CA|es-419|zh-Hans|zh-Hant|pt-BR", RESTART},
|
||||||
{"OPERATION_MODE", "docked", "docked|handheld", RESTART},
|
{"OPERATION_MODE", "docked", "docked|handheld", RESTART},
|
||||||
|
{"ASSUME_FOCUS", "0", "0|1", LIVE}, // read on every focus change (ov_system.c)
|
||||||
// Sound, Controls, Menu
|
// Sound, Controls, Menu
|
||||||
{"VOLUME", "100", "0..100", LIVE},
|
{"VOLUME", "100", "0..100", LIVE},
|
||||||
{"MOTION", "1", "0|1", LIVE}, {"RUMBLE_STRENGTH", "130", "0..300", LIVE}, {"RUMBLE_CURVE", "0.6", "0.2..1.5", LIVE},
|
{"MOTION", "1", "0|1", LIVE}, {"RUMBLE_STRENGTH", "130", "0..300", LIVE}, {"RUMBLE_CURVE", "0.6", "0.2..1.5", LIVE},
|
||||||
|
|||||||
+7
-10
@@ -160,18 +160,15 @@ static void ov_focus_mode(Cpu *c) {
|
|||||||
// FocusState GetCurrentFocusState(): 1 in focus, 2 out of focus (nn::oe::FocusState). In focus until the window
|
// FocusState GetCurrentFocusState(): 1 in focus, 2 out of focus (nn::oe::FocusState). In focus until the window
|
||||||
// reports otherwise through oe_set_focus; TOTK_ASSUME_FOCUS=1 (unattended runs) pins it to 1. The caller of
|
// reports otherwise through oe_set_focus; TOTK_ASSUME_FOCUS=1 (unattended runs) pins it to 1. The caller of
|
||||||
// oe_set_focus also pushes OE_MSG_FOCUS_STATE_CHANGED.
|
// oe_set_focus also pushes OE_MSG_FOCUS_STATE_CHANGED.
|
||||||
|
//
|
||||||
|
// The setting is read on every focus change rather than once at start: a focus change is rare, the lookup is a short
|
||||||
|
// walk of the loaded ini entries, and the Game tab's row then takes effect the next time the window is left, without
|
||||||
|
// a restart.
|
||||||
static volatile LONG focus_state = 1;
|
static volatile LONG focus_state = 1;
|
||||||
static int assume_focus(void) {
|
void oe_set_focus(int in_focus) {
|
||||||
static volatile LONG v = -1;
|
const char *e = cfg_get("TOTK_ASSUME_FOCUS");
|
||||||
LONG a = v;
|
InterlockedExchange(&focus_state, in_focus || (e && atoi(e)) ? 1 : 2);
|
||||||
if (a < 0) {
|
|
||||||
const char *e = cfg_get("TOTK_ASSUME_FOCUS");
|
|
||||||
a = e && atoi(e) ? 1 : 0;
|
|
||||||
InterlockedExchange(&v, a);
|
|
||||||
}
|
|
||||||
return (int)a;
|
|
||||||
}
|
}
|
||||||
void oe_set_focus(int in_focus) { InterlockedExchange(&focus_state, in_focus || assume_focus() ? 1 : 2); }
|
|
||||||
static void ov_focus_state(Cpu *c) { ret_x(c, (uint64_t)focus_state); }
|
static void ov_focus_state(Cpu *c) { ret_x(c, (uint64_t)focus_state); }
|
||||||
|
|
||||||
static volatile LONG notify_resume, notify_operation, notify_performance;
|
static volatile LONG notify_resume, notify_operation, notify_performance;
|
||||||
|
|||||||
@@ -553,6 +553,7 @@ static void tab_game(float scale) {
|
|||||||
row_game_lang();
|
row_game_lang();
|
||||||
static const UiTextId mode[] = {UI_MENU_MODE_DOCKED, UI_MENU_MODE_HANDHELD};
|
static const UiTextId mode[] = {UI_MENU_MODE_DOCKED, UI_MENU_MODE_HANDHELD};
|
||||||
opt_choice("TOTK_OPERATION_MODE", UI_MENU_OPERATION_MODE, mode, 2, UI_MENU_OPERATION_MODE_DESC);
|
opt_choice("TOTK_OPERATION_MODE", UI_MENU_OPERATION_MODE, mode, 2, UI_MENU_OPERATION_MODE_DESC);
|
||||||
|
opt_toggle("TOTK_ASSUME_FOCUS", UI_MENU_ASSUME_FOCUS, UI_MENU_ASSUME_FOCUS_DESC);
|
||||||
opt_end();
|
opt_end();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -86,6 +86,10 @@ static const char *const text_en[UI_TEXT_COUNT] = {
|
|||||||
[UI_MENU_OPERATION_MODE] = "Console mode",
|
[UI_MENU_OPERATION_MODE] = "Console mode",
|
||||||
[UI_MENU_OPERATION_MODE_DESC] = "Whether the game thinks it runs docked or handheld.",
|
[UI_MENU_OPERATION_MODE_DESC] = "Whether the game thinks it runs docked or handheld.",
|
||||||
[UI_MENU_MODE_DOCKED] = "Docked", [UI_MENU_MODE_HANDHELD] = "Handheld",
|
[UI_MENU_MODE_DOCKED] = "Docked", [UI_MENU_MODE_HANDHELD] = "Handheld",
|
||||||
|
[UI_MENU_ASSUME_FOCUS] = "Keep running out of focus",
|
||||||
|
[UI_MENU_ASSUME_FOCUS_DESC] = "The game pauses when its window loses focus, as it does on the Switch when Home is "
|
||||||
|
"pressed. On, it keeps running while you are in another window, and the keyboard "
|
||||||
|
"stays quiet until the window is in front again.",
|
||||||
|
|
||||||
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Master volume of the game.",
|
[UI_MENU_VOLUME] = "Volume", [UI_MENU_VOLUME_DESC] = "Master volume of the game.",
|
||||||
|
|
||||||
@@ -320,6 +324,10 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
|
|||||||
[UI_MENU_OPERATION_MODE] = "Режим консоли",
|
[UI_MENU_OPERATION_MODE] = "Режим консоли",
|
||||||
[UI_MENU_OPERATION_MODE_DESC] = "Игра считает, что консоль в док-станции или в портативном режиме.",
|
[UI_MENU_OPERATION_MODE_DESC] = "Игра считает, что консоль в док-станции или в портативном режиме.",
|
||||||
[UI_MENU_MODE_DOCKED] = "В док-станции", [UI_MENU_MODE_HANDHELD] = "Портативный",
|
[UI_MENU_MODE_DOCKED] = "В док-станции", [UI_MENU_MODE_HANDHELD] = "Портативный",
|
||||||
|
[UI_MENU_ASSUME_FOCUS] = "Работать без фокуса",
|
||||||
|
[UI_MENU_ASSUME_FOCUS_DESC] = "Игра встаёт на паузу, когда окно теряет фокус, как на Switch при нажатии Home. "
|
||||||
|
"Включено: игра идёт, пока вы в другом окне, а клавиатура не действует, пока "
|
||||||
|
"окно не вернётся на передний план.",
|
||||||
|
|
||||||
[UI_MENU_VOLUME] = "Громкость", [UI_MENU_VOLUME_DESC] = "Общая громкость игры.",
|
[UI_MENU_VOLUME] = "Громкость", [UI_MENU_VOLUME_DESC] = "Общая громкость игры.",
|
||||||
|
|
||||||
|
|||||||
@@ -47,6 +47,7 @@ typedef enum {
|
|||||||
UI_MENU_HIGHFPS_FIX, UI_MENU_HIGHFPS_FIX_DESC,
|
UI_MENU_HIGHFPS_FIX, UI_MENU_HIGHFPS_FIX_DESC,
|
||||||
UI_MENU_GAME_LANG, UI_MENU_GAME_LANG_DESC, UI_MENU_GAME_LANG_AUTO,
|
UI_MENU_GAME_LANG, UI_MENU_GAME_LANG_DESC, UI_MENU_GAME_LANG_AUTO,
|
||||||
UI_MENU_OPERATION_MODE, UI_MENU_OPERATION_MODE_DESC, UI_MENU_MODE_DOCKED, UI_MENU_MODE_HANDHELD,
|
UI_MENU_OPERATION_MODE, UI_MENU_OPERATION_MODE_DESC, UI_MENU_MODE_DOCKED, UI_MENU_MODE_HANDHELD,
|
||||||
|
UI_MENU_ASSUME_FOCUS, UI_MENU_ASSUME_FOCUS_DESC,
|
||||||
|
|
||||||
// Sound
|
// Sound
|
||||||
UI_MENU_VOLUME, UI_MENU_VOLUME_DESC,
|
UI_MENU_VOLUME, UI_MENU_VOLUME_DESC,
|
||||||
|
|||||||
@@ -102,6 +102,9 @@
|
|||||||
# here. Changes while the game runs take effect at once.
|
# here. Changes while the game runs take effect at once.
|
||||||
# window_size = 1920x1080
|
# window_size = 1920x1080
|
||||||
# fullscreen = 0
|
# fullscreen = 0
|
||||||
|
# The game pauses when its window loses focus, as it does on the Switch when Home is pressed. 1 keeps it running while
|
||||||
|
# you are in another window; the keyboard stays quiet until the window is in front again. Read at each focus change.
|
||||||
|
# assume_focus = 0
|
||||||
# Performance overlay in the top right corner: off, fps, or full (frame rate, mean and longest frame time). F10
|
# Performance overlay in the top right corner: off, fps, or full (frame rate, mean and longest frame time). F10
|
||||||
# cycles the modes in game.
|
# cycles the modes in game.
|
||||||
# perf_overlay = off
|
# perf_overlay = off
|
||||||
|
|||||||
Reference in new issue
Block a user