From 8691f6d7249ab5570a7b9720a99e96eb04daa12d Mon Sep 17 00:00:00 2001 From: Valiantsin Dzerakh Date: Thu, 29 Oct 2026 17:53:57 +0300 Subject: [PATCH] Remap keys, mouse buttons and controller buttons from the Controls tab Every Switch button and the eight stick directions the keys drive get two key cells and a controller cell under the button layout. A cell takes the next key, mouse button or controller button pressed; a key in use moves over, a controller button swaps. The tab writes bind_ lines (new: bind_LSTICK_* / bind_RSTICK_*, key:default, pad:default) and input_win.c builds the tables again when one changes, so remapping applies while the game runs. More keys can be bound: Enter, Backspace, right Shift and Ctrl, Alt, the numpad, punctuation, F2-F7, F9, F12, mouse buttons 4 and 5. Alt alone no longer enters the window menu loop. Co-Authored-By: Claude Opus 5.5 --- docs/controls.md | 11 +- runtime/cfg.c | 12 +- runtime/cfg_probe.c | 49 +++++++ runtime/input.h | 15 ++ runtime/input_map.c | 280 ++++++++++++++++++++++++++++--------- runtime/input_map.h | 73 +++++++--- runtime/input_win.c | 142 ++++++++++++++++++- runtime/ui/binds_page.cpp | 246 ++++++++++++++++++++++++++++++++ runtime/ui/binds_page.h | 10 ++ runtime/ui/menu.cpp | 7 +- runtime/ui/menu_win.cpp | 1 + runtime/ui/option_rows.cpp | 100 +++++++++++++ runtime/ui/option_rows.h | 9 ++ runtime/ui_text.c | 92 ++++++++++++ runtime/ui_text.h | 30 ++++ totk.ini.example | 12 +- 16 files changed, 990 insertions(+), 99 deletions(-) create mode 100644 runtime/ui/binds_page.cpp create mode 100644 runtime/ui/binds_page.h diff --git a/docs/controls.md b/docs/controls.md index 658436a5..00f5a5d1 100644 --- a/docs/controls.md +++ b/docs/controls.md @@ -28,7 +28,7 @@ The log names the layout in effect (`input: gamepad layout ...`); the menu shows | Plus | Start | Tab | menu, inventory | | Minus | Back | M | map | -Esc is unbound in the game; it opens the settings menu and releases the mouse cursor (see Mouse camera). Z and X duplicate ZL and ZR so menu pages turn with two neighbouring keys; the menu tabs (L, R) are Q and R. The mouse wheel is unbound. The bindings are two tables in `runtime/input_map.c`, `input_bindings` (platform-neutral key ids) and `input_pad_bindings` (gamepad inputs by position); `runtime/input_win.c` translates Win32 virtual keys and SDL buttons, so a remapping page can edit both later. +Esc is unbound in the game; it opens the settings menu and releases the mouse cursor (see Mouse camera). Z and X duplicate ZL and ZR so menu pages turn with two neighbouring keys; the menu tabs (L, R) are Q and R. The mouse wheel is unbound. The bindings are the tables of `input_map` in `runtime/input_map.c`: the keys (platform-neutral key ids) and one gamepad table per layout (gamepad inputs by position); `runtime/input_win.c` translates Win32 virtual keys and SDL buttons. ## Window keys @@ -42,13 +42,16 @@ The Minus+Plus combo never reaches the game. In the menu the arrow keys, the D-p ## Remapping -`totk.ini` rebinds the buttons, one line per Switch button: `bind_