From 1becabd8f6e44af6e9cabbd7435cc21ad2e6ded8 Mon Sep 17 00:00:00 2001 From: Louis Justice Date: Tue, 10 Nov 2026 16:27:03 -0500 Subject: [PATCH 01/10] The left mouse button presses A on the Purah Pad's map instead of its binding (map_click, game 1.4.3). Co-Authored-By: Claude Opus 5.5 --- docs/controls.md | 4 ++++ runtime/cfg.c | 5 +++-- runtime/input.c | 8 ++++++++ runtime/menu_cursor.c | 3 +++ runtime/ui/menu.cpp | 1 + runtime/ui_text.c | 8 ++++++++ runtime/ui_text.h | 1 + totk.ini.example | 4 ++++ 8 files changed, 32 insertions(+), 2 deletions(-) diff --git a/docs/controls.md b/docs/controls.md index 0263fbf4..cb33dad1 100644 --- a/docs/controls.md +++ b/docs/controls.md @@ -203,6 +203,10 @@ On game 1.4.3, while one of the game's menus has its focus box (the frame the d- `runtime/menu_cursor.c` reads eui's screens at each pad read and moves the focus with the writes `eui::BoxCursorMgr::moveBoxCursor` makes, so no game code is called. `menu_cursor = 0` (`TOTK_MENU_CURSOR=0`, live; the *Mouse in the game's menus* row of the Controls tab) turns it off; `TOTK_MENU_CURSOR_LOG=1` logs every screen it reads (by default the first six), with the layout size, the node count and the hit panes it uses. +### Left click on the map + +On game 1.4.3, while the Purah Pad's map is open (found as above; the Scope is not the map), the left mouse button presses A at the map's cursor instead of the button it is bound to (Y by default). A press is A or the binding from the moment the button goes down until it is released, so a button held as the map opens or closes keeps what it pressed (`poll_merged` in `runtime/input.c`). `map_click = 0` (`TOTK_MAP_CLICK=0`, live; the *Left click on the map* row of the Controls tab) leaves the left button on its binding there. The map is found only while `menu_cursor` is on. + ## Nintendo Switch 2 controllers Windows does not present the Switch 2 Pro Controller as a gamepad SDL can open (the log says `input: no gamepad`), so it needs a bridge program that wakes it and creates a virtual gamepad. The DS4Windows fork by hbashton ([github.com/hbashton/DS4Windows](https://github.com/hbashton/DS4Windows), tested with release VIIPERRC4.5.1, a pre-release) with the output set to an emulated DualSense gives buttons, rumble, gyro and accelerometer, and reads the sticks through the controller's calibration (they rest at 0 to 2%). The game reads its virtual DualSense directly; the log then shows `input: gamepad "DualSense Wireless Controller" (rumble, gyro and accelerometer, ...)` and `input: motion sensors on`. Its release notes also list Joy-Con 2 support, which is untested here. diff --git a/runtime/cfg.c b/runtime/cfg.c index dbb73f7d..06878bcc 100644 --- a/runtime/cfg.c +++ b/runtime/cfg.c @@ -46,7 +46,7 @@ static const char *const known[] = { "FREEZE_IDLE", "FREE_CORES", "FULLSCREEN", "FXAA", "GPL", "GPL_DRAW_BUILD", "GPU", "GPU_INDEX", "GPU_NAME", "HDR", "HDR_GAME_NITS", "HDR_HUE", "HDR_PEAK_NITS", "HDR_UI_NITS", "HIGHFPS_FIX", "INPUT", "INPUT_RECORD", "INPUT_SCRIPT", "KSPIN_US", "LANG", "LIB_PREBUILD", - "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MENU_LANG", "MENU_TEST", + "LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MAP_CLICK", "MEMORY", "MENU_LANG", "MENU_TEST", "MEM_RESERVE_MIB", "MENU_CURSOR", "MENU_CURSOR_LOG", "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MOTION", "MOUSE_AIM_SCALE", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "MOVIE_ASPECT", "MOVIE_HOST", "MOVIE_PACE", "MVOBJ_ALL", "MVOBJ_BANKS", "MVOBJ_EQUAL", "MVOBJ_EXACT", "MVOBJ_EXEC", "MVOBJ_NOC4", "MVOBJ_ONLY", "MVOBJ_TIMES", "MVPREV_CHECK", "MVPREV_GROW", "MVPREV_SKIP", "MVPREV_TRUST", "MV_CHECK", "MV_SURVEY", @@ -89,7 +89,7 @@ static const struct { const char *key, *section; } sections[] = { {"MOTION", "input"}, {"RUMBLE_STRENGTH", "input"}, {"RUMBLE_CURVE", "input"}, {"RUMBLE_TRIGGERS", "input"}, {"PAD_LAYOUT", "input"}, {"PROMPTS", "input"}, {"STICK_DEADZONE", "input"}, {"LSTICK_DEADZONE", "input"}, {"RSTICK_DEADZONE", "input"}, {"STICK_SENS", "input"}, - {"MENU_CURSOR", "input"}, {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "input"}, {"MOUSE_AIM_SCALE", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "input"}, {"INPUT_RECORD", "input"}, + {"MENU_CURSOR", "input"}, {"MAP_CLICK", "input"}, {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "input"}, {"MOUSE_AIM_SCALE", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "input"}, {"INPUT_RECORD", "input"}, {"BIND_A", "input"}, {"BIND_B", "input"}, {"BIND_X", "input"}, {"BIND_Y", "input"}, {"BIND_LCLICK", "input"}, {"BIND_RCLICK", "input"}, {"BIND_L", "input"}, {"BIND_R", "input"}, {"BIND_ZL", "input"}, {"BIND_ZR", "input"}, {"BIND_PLUS", "input"}, {"BIND_MINUS", "input"}, {"BIND_LEFT", "input"}, {"BIND_UP", "input"}, @@ -156,6 +156,7 @@ static const CfgMeta metas[] = { {"LSTICK_DEADZONE", "", "0..50", LIVE}, {"RSTICK_DEADZONE", "", "0..50", LIVE}, {"MOUSE_MODE", "direct", "stick|direct", LIVE}, {"MOUSE_SENS", "1", "0..10", LIVE}, {"MOUSE_AIM_SCALE", "1", "0.1..3", LIVE}, {"MENU_CURSOR", "1", "0|1", LIVE}, + {"MAP_CLICK", "1", "0|1", LIVE}, // input.c: the left mouse button is A on the Purah Pad's map {"WALK_KEY", "none", NULL, LIVE}, {"WALK_SCALE", "0.51", "0.2..0.9", LIVE}, {"MENU_LANG", "", "en|ru|pt-BR|zh-Hans", LIVE}, {"AMIIBO_DIR", "", NULL, LIVE}, diff --git a/runtime/input.c b/runtime/input.c index 6cfca650..ccf61452 100644 --- a/runtime/input.c +++ b/runtime/input.c @@ -641,6 +641,14 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx if (!counts || mouse_ignore[k]) down[k] = 0; } was_captured = cap; + // On the Purah Pad's map (menu_cursor.c finds it, TOTK_MAP_CLICK) the left mouse button presses A at the + // map's cursor, which the mouse moves there, instead of its binding (Y by default). A press is one or the + // other from the moment it goes down until it is released, so a button held as the map opens or closes + // keeps what it pressed. + static int click_held, click_a; + if (!down[KEY_MOUSE_L]) click_held = click_a = 0; + else if (!click_held) click_held = 1, click_a = menu_cursor_map() && cfg_bool("TOTK_MAP_CLICK"); + if (click_a) down[KEY_MOUSE_L] = 0, b |= 1ull << B_A; b |= input_map_buttons(down); int32_t k[2]; walk_get(); diff --git a/runtime/menu_cursor.c b/runtime/menu_cursor.c index a2d8e093..25bd0afc 100644 --- a/runtime/menu_cursor.c +++ b/runtime/menu_cursor.c @@ -20,6 +20,9 @@ // // Only while keyboard and mouse are the device used last (input_kbm_last): a gamepad player sees the menus unchanged. // TOTK_MENU_CURSOR (live, default 1): 0 leaves the menus to the keys and the pad. +// +// On the map input.c makes the left mouse button A (menu_cursor_map; TOTK_MAP_CLICK, live, default 1), so a click +// acts at the map's cursor. The map is found only while TOTK_MENU_CURSOR is on. #include #include #include diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp index 2bed97ed..5ecfa5d3 100644 --- a/runtime/ui/menu.cpp +++ b/runtime/ui/menu.cpp @@ -867,6 +867,7 @@ static void tab_controls(float scale) { opt_choice("TOTK_MOUSE_MODE", UI_MENU_MOUSE_MODE, mouse_modes, 2, UI_MENU_MOUSE_MODE_DESC); opt_slider("TOTK_MOUSE_SENS", UI_MENU_MOUSE_SENS, 0, 10, UI_MENU_MOUSE_SENS_DESC, 0.1f, "%.1f"); opt_toggle("TOTK_MENU_CURSOR", UI_MENU_MENU_CURSOR, UI_MENU_MENU_CURSOR_DESC); + opt_toggle("TOTK_MAP_CLICK", UI_MENU_MAP_CLICK, UI_MENU_MAP_CLICK_DESC); row_walk_key(); opt_slider("TOTK_WALK_SCALE", UI_MENU_WALK_SCALE, 0.2f, 0.9f, UI_MENU_WALK_SCALE_DESC, 0.01f, "%.2f"); // Analog sticks: one dead zone row per stick, falling back to TOTK_STICK_DEADZONE (both sticks) while unset. With diff --git a/runtime/ui_text.c b/runtime/ui_text.c index 690383b7..ad1c55a9 100644 --- a/runtime/ui_text.c +++ b/runtime/ui_text.c @@ -283,6 +283,8 @@ static const char *const text_en[UI_TEXT_COUNT] = { [UI_MENU_MOUSE_DIRECT] = "Direct", [UI_MENU_MENU_CURSOR] = "Mouse in the game's menus", [UI_MENU_MENU_CURSOR_DESC] = "In the game's own menus (title, inventory, shops, dialogue choices) the pointer shows: the item under it is selected, left click confirms, right click goes back. Only after the mouse or a key was used last, so a gamepad sees the menus unchanged (game 1.4.3).", + [UI_MENU_MAP_CLICK] = "Left click on the map", + [UI_MENU_MAP_CLICK_DESC] = "On the Purah Pad's map, the left mouse button presses A at the map's cursor instead of the button it is bound to (Y by default). Needs Mouse in the game's menus (game 1.4.3).", [UI_MENU_MOUSE_SENS] = "Mouse camera sensitivity", [UI_MENU_MOUSE_SENS_DESC] = "How fast the mouse turns the camera.", [UI_MENU_WALK_KEY] = "Walk key", @@ -763,6 +765,8 @@ static const char *const text_ru[UI_TEXT_COUNT] = { [UI_MENU_MOUSE_DIRECT] = "Прямое", [UI_MENU_MENU_CURSOR] = "Мышь в меню игры", [UI_MENU_MENU_CURSOR_DESC] = "В меню самой игры (заставка, инвентарь, магазины, варианты ответа) появляется указатель: пункт под ним выбирается, левый щелчок подтверждает, правый возвращает назад. Только если последними использовались мышь или клавиатура, поэтому с геймпадом меню не меняются (версия игры 1.4.3).", + [UI_MENU_MAP_CLICK] = "Левый щелчок на карте", + [UI_MENU_MAP_CLICK_DESC] = "На карте игры левая кнопка мыши нажимает A у курсора карты, а не назначенную ей кнопку (по умолчанию Y). Нужна «Мышь в меню игры» (версия игры 1.4.3).", [UI_MENU_MOUSE_SENS] = "Чувствительность мыши", [UI_MENU_MOUSE_SENS_DESC] = "Как быстро мышь поворачивает камеру.", [UI_MENU_WALK_KEY] = "Клавиша шага", @@ -1416,6 +1420,8 @@ static const char *const text_pt_br[UI_TEXT_COUNT] = { [UI_MENU_MOUSE_DIRECT] = "Direta", [UI_MENU_MENU_CURSOR] = "Mouse nos menus do jogo", [UI_MENU_MENU_CURSOR_DESC] = "Nos menus do próprio jogo (título, inventário, lojas, escolhas de diálogo) o ponteiro aparece: o item sob ele fica selecionado, o clique esquerdo confirma e o direito volta. Só depois de usar o mouse ou uma tecla por último, então com um controle os menus ficam como antes (jogo 1.4.3).", + [UI_MENU_MAP_CLICK] = "Clique esquerdo no mapa", + [UI_MENU_MAP_CLICK_DESC] = "No mapa do jogo, o botão esquerdo do mouse aperta A no cursor do mapa, em vez do botão ao qual está atribuído (Y por padrão). Requer Mouse nos menus do jogo (jogo 1.4.3).", [UI_MENU_PROMPTS_MISSING] = "faltam os arquivos dos ícones: execute a instalação de novo", [UI_MENU_PROMPTS_FAILED] = "arquivos dos ícones danificados: execute a instalação de novo", [UI_MENU_PROMPTS_RESTART] = "os ícones mudam após reiniciar", @@ -2045,6 +2051,8 @@ static const char *const text_zh_hans[UI_TEXT_COUNT] = { [UI_MENU_MOUSE_DIRECT] = "直接", [UI_MENU_MENU_CURSOR] = "在游戏菜单中使用鼠标", [UI_MENU_MENU_CURSOR_DESC] = "在游戏自身的菜单中(标题、背包、商店、对话选项)显示指针:指针下的项目被选中,左键确认,右键返回。仅在最后使用的是鼠标或键盘时生效,因此使用手柄时菜单保持不变(游戏 1.4.3)。", + [UI_MENU_MAP_CLICK] = "在地图上左键单击", + [UI_MENU_MAP_CLICK_DESC] = "在游戏地图上,鼠标左键在地图光标处按下 A 键,而不是按下它所绑定的按键(默认为 Y)。需要开启“在游戏菜单中使用鼠标”(游戏 1.4.3)。", [UI_MENU_PROMPTS_MISSING] = "缺少按键提示文件:请重新运行安装程序", [UI_MENU_PROMPTS_FAILED] = "按键提示文件已损坏:请重新运行安装程序", [UI_MENU_PROMPTS_RESTART] = "按键提示重启后生效", diff --git a/runtime/ui_text.h b/runtime/ui_text.h index 3bed8949..c077c608 100644 --- a/runtime/ui_text.h +++ b/runtime/ui_text.h @@ -116,6 +116,7 @@ typedef enum { UI_MENU_STICK_DEADZONE_NOW, UI_MENU_STICK_SENS, UI_MENU_STICK_SENS_DESC, UI_MENU_MOUSE_MODE, UI_MENU_MOUSE_MODE_DESC, UI_MENU_MOUSE_STICK, UI_MENU_MOUSE_DIRECT, UI_MENU_MENU_CURSOR, UI_MENU_MENU_CURSOR_DESC, + UI_MENU_MAP_CLICK, UI_MENU_MAP_CLICK_DESC, UI_MENU_MOUSE_SENS, UI_MENU_MOUSE_SENS_DESC, UI_MENU_WALK_KEY, UI_MENU_WALK_KEY_DESC, UI_MENU_WALK_KEY_TAKEN, UI_MENU_WALK_SCALE, UI_MENU_WALK_SCALE_DESC, diff --git a/totk.ini.example b/totk.ini.example index c45a74b2..1aca43cf 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -348,6 +348,10 @@ # right click is B. On the map the mouse moves the map's cursor and the scroll wheel zooms. 0 leaves the menus and # the map to the keys and the pad. Changes while the game runs. # menu_cursor = 1 +# The left mouse button on the Purah Pad's map, 1.4.3 only: it presses A at the map's cursor instead of the button it +# is bound to (Y by default). Needs menu_cursor = 1, which finds the map. 0 leaves the left button on its binding +# there. Changes while the game runs. +# map_click = 1 # Mouse camera sensitivity (0 to 10; 0 = no mouse camera and no cursor capture). With mouse_mode = direct, 1 turns the # camera 0.08 degrees per count, the same in every camera mode (about 14.3 cm a turn at 800 DPI). # mouse_sens = 1 From c2716d2e7c305c1c812f09a7bda6222750646e57 Mon Sep 17 00:00:00 2001 From: Louis Justice Date: Tue, 10 Nov 2026 18:11:38 -0500 Subject: [PATCH 02/10] The keyboard and mouse text prompts show Y as T, and the setup draws the PC prompts from totk.ini's bindings. Y has two default keys: the left mouse button, which is a menu's A while the pointer is shown, and T, which presses Y everywhere. The button font (menu guides, the dialogue log) now shows Y as its first bound key that is not a mouse button; the button guide in play and the action prompt keep the left button. The PC prompts are a setup step of their own, keyed by the bind_ lines of the install's totk.ini, so running the setup again after rebinding redraws them without preparing the shaders again. Co-Authored-By: Claude Opus 5.5 --- docs/controls.md | 5 +-- installer/gui.py | 2 +- installer/guilogic.py | 2 +- installer/steps.py | 67 ++++++++++++++++++++++++++++++++++--- installer/text/en.json | 2 ++ installer/text/pt-BR.json | 2 ++ installer/text/ru.json | 2 ++ installer/text/zh-Hans.json | 2 ++ tests/installer_test.py | 2 +- tests/romfs_prompts_test.py | 15 +++++++++ tools/button_icons.py | 23 +++++++++---- tools/make_romfs_patches.py | 15 ++++++--- 12 files changed, 118 insertions(+), 21 deletions(-) diff --git a/docs/controls.md b/docs/controls.md index 0263fbf4..0c58515e 100644 --- a/docs/controls.md +++ b/docs/controls.md @@ -65,7 +65,7 @@ At a game resolution of another shape than 16:9 the game loads `romfs-patches-xb | Switch | Prompt | |---|---| -| A, B, X, Y | E, Shift, Space, left click | +| A, B, X, Y | E, Shift, Space, left click (T in text prompts) | | L, R, ZL, ZR | Q, R, right click, F | | Plus, Minus | Tab, M | | D-pad | 1 (left), 2 (up), 3 (right), 4 (down), as a cross or the keys of the directions meant | @@ -74,7 +74,8 @@ At a game resolution of another shape than 16:9 the game loads `romfs-patches-xb - The glyphs keep the width of the game's own, so the right-aligned guides do not run into their text. A key is a rounded square with its label cut out in the game's own text fonts (Shift: an arrow over its name); a mouse button is a mouse with that button filled and the others hollow. - The button guide in play draws every button from images of the Common archive (`Nt_KeyTexA/B/X/Y/L/ZL_00`, `Nt_KeyTexLSt_00` and `_01`, the stick tilted and pressed): all of them are painted with the same icons. The letters of the action prompt's diamond are one character of the Normal font each: E, an arrow for Shift, a bar for Space, L and R for the mouse buttons. -- Like the Xbox prompts they follow the defaults and not the bindings. `--binds ` draws the first key of each `bind_` line of that file instead, for a folder made by hand. +- Y has two keys, the left mouse button and T. The button guide in play and the action prompt show the left button, which attacks there; the prompts in text (the menus' guides such as *Sort*, the dialogue log's) show T, because while a menu has the pointer the left button is that menu's A, and T presses Y everywhere (`PC_TEXT_KEYS` in `tools/button_icons.py`). With a `bind_y` line, the text prompts take its first key that is not a mouse button (its only key when all are mouse buttons). +- They follow the bindings of the install's `totk.ini` as the setup found them: its *Drawing the keyboard and mouse prompts* step passes the file as `--binds` (the first key of each `bind_` line), and the keyboard defaults without one. After a change on the Controls tab run the setup again: that step alone runs, since it is keyed by the `bind_` lines (`PcPrompts` in `installer/steps.py`). The Xbox prompts follow the defaults. - At a game resolution of another shape than 16:9 the game loads `romfs-patches-pc-x` in place of `romfs-patches-x`: the same prompts with that shape's UI layout, `make_romfs_patches.py --prompts pc --aspect x --reuse \romfs-patches-pc --out \romfs-patches-pc-x`. The setup writes one for each of the fifteen sizes it lays the UI out for, so on a display of one of those shapes the game resolution follows the display with these prompts too. At another size, without that folder, the Switch prompts stay (*off at this game resolution*). ## Window keys diff --git a/installer/gui.py b/installer/gui.py index 9c0dc1fd..cddc6530 100644 --- a/installer/gui.py +++ b/installer/gui.py @@ -619,7 +619,7 @@ class App: # ---- self test --------------------------------------------------------------------------------------------------- SAMPLE_START = {'type': 'start', 'release': 'selftest', 'mode': 'install', 'dest': 'Z:/selftest/TotK', 'log': 'D:\\log.txt', - 'steps': ['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'dlss', 'cleanup']} + 'steps': ['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'dlss', 'cleanup']} SAMPLE_RUN = [ SAMPLE_START, {'type': 'plan', 'run': ['check', 'fonts', 'extract'], 'skip': {}}, diff --git a/installer/guilogic.py b/installer/guilogic.py index f17a2dc4..e46b1025 100644 --- a/installer/guilogic.py +++ b/installer/guilogic.py @@ -27,7 +27,7 @@ TEXT = Path(__file__).resolve().parent / 'text' UI_LANGUAGES = ('en', 'ru', 'pt-BR', 'zh-Hans') # what the language switch in the window's corner shows for each UI_LANGUAGE_LABELS = {'en': 'English', 'ru': 'Русский', 'pt-BR': 'Português (Brasil)', 'zh-Hans': '简体中文'} -STEP_ORDER = ('check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'dlss', 'cleanup') +STEP_ORDER = ('check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'dlss', 'cleanup') # message parameter -> catalog id prefix of the names that replace its raw values PARAM_NAMES = {'lang': 'lang.', 'known': 'lang.', 'step': 'step.', 'input': 'param.input.'} LANG_RU = 0x19 # primary language id of Russian in a Windows LANGID diff --git a/installer/steps.py b/installer/steps.py index 49ce815d..69dcefa0 100644 --- a/installer/steps.py +++ b/installer/steps.py @@ -1098,10 +1098,10 @@ class Prepare(Step): # romfs-patches-xbox for the Nintendo pad layout, romfs-patches-xbox-label for xbox and auto (runtime/input_map.c # input_prompts_folder). Both are written on every install, so the menu choices work without another run of # the setup. Optional: when one fails, the game keeps the Switch prompts with that layout and the menu says the - # files are missing, so the setup warns once and goes on. romfs-patches-pc likewise, with keyboard and mouse - # prompts for prompts = pc. + # files are missing, so the setup warns once and goes on. The keyboard and mouse prompts are the PcPrompts + # step's: they follow totk.ini's bindings. failed = None - for style in ('xbox', 'xbox-label', 'pc'): + for style in ('xbox', 'xbox-label'): out = dest / f'romfs-patches-{style}' remove(out) code, log = run_tool(ctx, f'prepare-{style}', layout.tools / 'make_romfs_patches.py', @@ -1116,7 +1116,7 @@ class Prepare(Step): # the prompts and the screen's shape. Only the Common archive differs from romfs-patches-