mirror of
https://github.com/valentderah/totk-pc-recomp.git
synced 2026-11-20 04:35:57 +00:00
Merge task/kbmwave: T in the PC text prompts, opt-in mouse clicks on the map and in dialogue, the mouse wheel in menus, strips and the camera (#1098, #1096, #1097, #1092, #356, #62, #147)
Pull requests by lwj10case (#1098, #1096, #1097) and itaskaev2 (#1092); #1092's pointer image left out. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
11c3ce1319
23 files changed
+419
-69
No files matched your search
+17
-5
@@ -29,7 +29,7 @@ The log names the layout in effect (`input: gamepad layout ...`); the menu shows
|
||||
| Minus | Back | M | map |
|
||||
| Right stick shaken left and right | shake the right stick | G | detach a fused part from what Ultrahand holds |
|
||||
|
||||
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. T duplicates Y for the game's menus, where the left mouse button is A while the pointer is shown (sort the inventory with T). The mouse wheel zooms the Purah Pad's map and is unbound elsewhere. 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.
|
||||
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. T duplicates Y for the game's menus, where the left mouse button is A while the pointer is shown (sort the inventory with T). The mouse wheel zooms the Purah Pad's map and its camera, steps the game's menus and the d-pad strips (see Mouse in the game's menus), and is unbound elsewhere. 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.
|
||||
|
||||
## Xbox button prompts
|
||||
|
||||
@@ -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 <totk.ini>` 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-<w>x<h>` in place of `romfs-patches-<w>x<h>`: the same prompts with that shape's UI layout, `make_romfs_patches.py --prompts pc --aspect <w>x<h> --reuse <install>\romfs-patches-pc --out <install>\romfs-patches-pc-<w>x<h>`. 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
|
||||
@@ -174,7 +175,8 @@ The horizontal quick lists (D-pad up/left/right: materials, shields and weapons)
|
||||
with at least 32 ms of neutral between them. At sensitivity 1, 32 horizontal counts request a step; a large flick
|
||||
cannot queue continued scrolling after the mouse stops. Vertical movement is ignored in these lists. Switching or
|
||||
releasing a selector resets its cursor/step state without sending the last movement to the camera. Selector input is
|
||||
not consumed by the direct camera or Ultrahand hooks.
|
||||
not consumed by the direct camera or Ultrahand hooks. The scroll wheel steps these lists too: each notch is one step,
|
||||
away from you to the left, towards you to the right.
|
||||
To detach a fused part from what Ultrahand holds, shake the mouse left and right, or press G (`bind_SHAKE`). A press
|
||||
swings the right stick left and right for 0.8 s, holding the key keeps it swinging. With `mouse_mode = direct` a shake
|
||||
of the mouse while Ultrahand holds an object swings the right stick with it: once the swings (10 degrees of camera turn
|
||||
@@ -199,10 +201,18 @@ The stick direction bits (`StickLLeft` to `StickRDown`) are derived from the sti
|
||||
|
||||
## Mouse in the game's menus
|
||||
|
||||
On game 1.4.3, while one of the game's menus has its focus box (the frame the d-pad moves: the title, the save list, the inventory and its System tab, Options, shops, dialogue choices), the cursor is released from the mouse camera and shown in the middle of the window. A focus gap of up to 300 ms (a tab switch, a popup opening: the game drops the focus box for a frame or two) keeps the pointer where it is instead of capturing and centring it again. The item under the pointer takes the focus as if the d-pad had moved there, with the game's highlight, sound and description; a left click is A on it, a right click is B. The middle and side mouse buttons keep their bindings (bound to L and R they turn the tabs), and T presses Y (sort). The keys and the pad keep working, and the focus moves only when the pointer moves. This happens only while the keyboard and mouse are the device used last: after a gamepad button press or a stick pushed past half way the menus are as on the console, with no pointer, until the mouse moves or a key is pressed (`input_kbm_last` in `runtime/input.c`). The ability wheel, the d-pad strips, Autobuild and the Purah Pad's camera stay gameplay: the mouse keeps the camera there. The map has no focus box; it is found in `eui::ScreenMgr`'s list of open screens (every 100 ms: the Purah Pad's frame `AppMenuOverlay_00` with `AppMap_00` and the menu background `AppMenuBG_00`), and there the mouse moves the map's cursor as the left stick does, with the cursor still captured, and the scroll wheel zooms: each notch is a full-tilt push of the right stick (the map's zoom) for 100 ms with 50 ms of neutral after it, up (in) for a turn away from you; a fast scroll's notches wait their turn (at most four), a turn the other way drops them. The Scope opens the same map screen without the menu background and keeps the mouse camera. When the menu closes the cursor is captured again.
|
||||
On game 1.4.3, while one of the game's menus has its focus box (the frame the d-pad moves: the title, the save list, the inventory and its System tab, Options, shops, dialogue choices), the cursor is released from the mouse camera and shown in the middle of the window. A focus gap of up to 300 ms (a tab switch, a popup opening: the game drops the focus box for a frame or two) keeps the pointer where it is instead of capturing and centring it again. The item under the pointer takes the focus as if the d-pad had moved there, with the game's highlight, sound and description; a left click is A on it, a right click is B. The middle and side mouse buttons keep their bindings (bound to L and R they turn the tabs), and T presses Y (sort). The scroll wheel moves the focus up and down, one step a notch (a full-tilt push of the left stick for 70 ms with 50 ms of neutral after it, up for a turn away from you), so a long list of items scrolls without moving the pointer; `menu_cursor = 0` turns this off with the pointer. The keys and the pad keep working, and the focus moves with the pointer only when the pointer moves: after the wheel, a key or the pad moved the focus off the pointer's item, the pointer takes it back once it has moved 6 layout units (the menus' 1280 x 720: about 9 window pixels at 1080p, 18 at 4K) from where it was then (`DEAD_ZONE` in `runtime/menu_cursor.c`), so a hand resting on the mouse does not undo a scroll; a click acts at once. This happens only while the keyboard and mouse are the device used last: after a gamepad button press or a stick pushed past half way the menus are as on the console, with no pointer, until the mouse moves or a key is pressed (`input_kbm_last` in `runtime/input.c`). The ability wheel, the d-pad strips, Autobuild and the Purah Pad's camera stay gameplay: the mouse keeps the camera there. The map has no focus box; it is found in `eui::ScreenMgr`'s list of open screens (every 100 ms: the Purah Pad's frame `AppMenuOverlay_00` with `AppMap_00` and the menu background `AppMenuBG_00`), and there the mouse moves the map's cursor as the left stick does, with the cursor still captured, and the scroll wheel zooms: each notch is a full-tilt push of the right stick (the map's zoom) for 100 ms with 50 ms of neutral after it, up (in) for a turn away from you; a fast scroll's notches wait their turn (at most four), a turn the other way drops them. The Scope opens the same map screen without the menu background and keeps the mouse camera. The Purah Pad's camera (the ability wheel's camera) opens the frame and its pointer `CameraPointer_00` without `AppMap_00` (the Scope has it); there the scroll wheel zooms as the camera's guide shows: each notch is a press of the d-pad's up (in, for a turn away from you) or down for 100 ms with 50 ms of release after it (`menu_cursor_camera`). The Scope itself has no zoom; the wheel does nothing there. When the menu closes the cursor is captured again.
|
||||
|
||||
`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
|
||||
|
||||
With `map_click = 1` (off by default, so each key presses one controller button as everywhere else), 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 = 1` (`TOTK_MAP_CLICK=1`, live; the *Left click on the map* row of the Controls tab) turns it on and `0`, the default, leaves the left button on its binding there. The map is found only while `menu_cursor` is on.
|
||||
|
||||
### Clicks in dialogue
|
||||
|
||||
With `dialogue_click = 1` (off by default, so each key presses one controller button as everywhere else), on game 1.4.3, while a dialogue box is open (the layout `MessageDialog_00`: a character's lines and the game's own messages), the left mouse button presses B and the right one A, instead of the buttons they are bound to. B continues the text as A does and also shows the rest of a line that is still scrolling in; the left button's default, Y, would open the dialogue log there, and the log stays in the way until B closes it. Dialogue choices are a menu with the focus box, so the pointer above takes their clicks and a left click is A on the choice under it: clicking through a conversation fast does not pick the choice the focus starts on. A press is the dialogue's button or the binding from the moment the button goes down until it is released: the click that closes the last box does not become an attack while it is still held, and a button held when the box opens does not skip its first line. Between two lines of a conversation the game closes the box and opens it again, so both buttons stay B and A for 500 ms after the box was last open (`DIALOGUE_GAP_MS`); the first clicks after a conversation fall in that time too, as they do for a player who taps the button through the last line. `TOTK_MENU_CURSOR_LOG=1` logs how long each such gap was. The dialogue window has no focus box of its own: the scan of `eui::ScreenMgr`'s open screens (every 100 ms) finds its screen, and from then on that screen's state is read at every pad read (`dialogue_shown` in `runtime/menu_cursor.c`), so the first click after a box opens is already the dialogue's. `dialogue_click = 1` (`TOTK_DIALOGUE_CLICK=1`, live; the *Clicks in dialogue* row of the Controls tab) turns it on and `0`, the default, leaves both buttons on their bindings; the setting does not depend on `menu_cursor`. The log names the first box it sees (`menu_cursor: a dialogue box is open ...`).
|
||||
|
||||
## 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.
|
||||
@@ -220,6 +230,8 @@ Bridges that output a ViGEm DualShock 4 (ProCon2Windows, connectyourpro as teste
|
||||
@<ms> <button> [hold_ms] # timed on the world clock
|
||||
@<ms> LSTICK|RSTICK <x> <y> [hold_ms]
|
||||
@<ms> MOUSE <dx> <dy>
|
||||
<frame> WHEEL <notches> # scroll wheel notches, once; + away from the player
|
||||
@<ms> WHEEL <notches>
|
||||
```
|
||||
|
||||
`<frame>` counts 60 Hz ticks of game time since the first frame (presented frames at 60 fps), so the title menus get the presses at the same game time at any frame limit. `@<ms>` counts milliseconds of the world clock: game time stepped since the end of the first save load (the player leaves the title screen's origin), so a timed event lands at the same game time at any frame rate and load length. A later load, such as fast travel, still shifts what follows. In a script with timed lines the untimed ones stop when the world clock starts, as the load ends at another tick in each run. Each event logs once (`input: script frame N tick T: A`). `tools/input/load_save.txt` loads the first save from the title screen.
|
||||
|
||||
+1
-1
@@ -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': {}},
|
||||
|
||||
@@ -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
|
||||
|
||||
+62
-5
@@ -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-<style>; --reuse links
|
||||
# the fonts, messages and size table from there instead of compressing them again, so each folder takes
|
||||
# seconds and a few MiB. Optional like romfs-patches-<style>, and skipped without it.
|
||||
for style in ('xbox', 'xbox-label', 'pc'):
|
||||
for style in ('xbox', 'xbox-label'):
|
||||
plain = dest / f'romfs-patches-{style}'
|
||||
for size in ASPECT_SIZES:
|
||||
out = dest / f'romfs-patches-{style}-{size}'
|
||||
@@ -1167,6 +1167,63 @@ class Prepare(Step):
|
||||
return {'xlate_sha256': file_sha256(xlate)}
|
||||
|
||||
|
||||
# ---- 6b. Keyboard and mouse prompts
|
||||
|
||||
def bind_lines(dest):
|
||||
"""The bind_ lines of the install's totk.ini (the Controls tab writes them), '' without the file."""
|
||||
try:
|
||||
text = (dest / 'totk.ini').read_text(encoding='utf-8', errors='replace')
|
||||
except OSError:
|
||||
return ''
|
||||
return '\n'.join(s for s in (line.split('#')[0].split(';')[0].strip() for line in text.splitlines())
|
||||
if s.lower().startswith('bind_'))
|
||||
|
||||
|
||||
class PcPrompts(Step):
|
||||
"""romfs-patches-pc and romfs-patches-pc-<w>x<h>, for prompts = pc: the prompts drawn as the keys and mouse buttons
|
||||
of totk.ini's bind_ lines (make_romfs_patches.py --prompts pc --binds), the keyboard defaults without them. Its own
|
||||
step, keyed by those lines, so running the setup again after a change of the bindings draws the prompts again and
|
||||
leaves the shaders alone. Optional like the Xbox prompts: a failure warns, and the game keeps the Switch prompts."""
|
||||
id = 'pc_prompts'
|
||||
|
||||
def key(self, ctx):
|
||||
layout = ctx.layout
|
||||
tools = [layout.tools / n for n in ('make_romfs_patches.py', 'ultrawide_layout.py', 'button_icons.py')]
|
||||
return fingerprint('pc-prompts-1', ctx.keys['extract'], *tools, bind_lines(ctx.dest))
|
||||
|
||||
def current(self, ctx, record):
|
||||
return record.get('failed') or (ctx.dest / 'romfs-patches-pc' / 'manifest.tsv').is_file()
|
||||
|
||||
def run(self, ctx):
|
||||
layout, rep, dest = ctx.layout, ctx.reporter, ctx.dest
|
||||
rep.progress('pc_prompts', 'draw', force=True)
|
||||
binds = []
|
||||
if bind_lines(dest):
|
||||
binds = ['--binds', dest / 'totk.ini']
|
||||
version = ['--version', version_tag(game_version(ctx)), '--romfs', dest / 'romfs']
|
||||
plain = dest / 'romfs-patches-pc'
|
||||
for out in [plain] + [dest / f'romfs-patches-pc-{size}' for size in ASPECT_SIZES]:
|
||||
remove(out)
|
||||
code, log = run_tool(ctx, 'prepare-pc', layout.tools / 'make_romfs_patches.py',
|
||||
version + ['--out', plain, '--prompts', 'pc', *binds])
|
||||
failed = (code, log) if code else None
|
||||
# Each shape of ASPECT_SIZES once more, as for the Xbox prompts (Prepare): --reuse links all but the Common
|
||||
# archive from romfs-patches-pc.
|
||||
for size in ASPECT_SIZES if not failed else ():
|
||||
out = dest / f'romfs-patches-pc-{size}'
|
||||
code, log = run_tool(ctx, f'prepare-pc-{size}', layout.tools / 'make_romfs_patches.py',
|
||||
version + ['--out', out, '--prompts', 'pc', '--aspect', size, '--reuse', plain, *binds])
|
||||
if code:
|
||||
remove(out)
|
||||
failed = failed or (code, log)
|
||||
if failed:
|
||||
if not (plain / 'manifest.tsv').is_file():
|
||||
remove(plain)
|
||||
rep.warning('warn.xbox_prompts_failed', code=failed[0], log=str(failed[1]))
|
||||
return {'failed': True}
|
||||
return {}
|
||||
|
||||
|
||||
# ---- 7. NVIDIA DLSS
|
||||
|
||||
# NVIDIA's DLSS library, which NGX loads from the folder of totk.exe (runtime/vk_dlaa.c). The setup does not ship it:
|
||||
@@ -1310,4 +1367,4 @@ def romfs_problem(romfs, expected):
|
||||
|
||||
|
||||
def all_steps():
|
||||
return [Check(), Fonts(), Extract(), Lift(), Compile(), Prepare(), Dlss(), Cleanup()]
|
||||
return [Check(), Fonts(), Extract(), Lift(), Compile(), Prepare(), PcPrompts(), Dlss(), Cleanup()]
|
||||
@@ -5,6 +5,7 @@
|
||||
"step.lift": "Translating the game code to C",
|
||||
"step.compile": "Compiling {game_exe}",
|
||||
"step.prepare": "Preparing the shaders",
|
||||
"step.pc_prompts": "Drawing the keyboard and mouse prompts",
|
||||
"step.dlss": "Downloading NVIDIA DLSS",
|
||||
"step.cleanup": "Cleaning up",
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
"phase.compile.compile": "Compiling",
|
||||
"phase.compile.link": "Linking {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Writing the 60 fps game data patches",
|
||||
"phase.pc_prompts.draw": "Drawing the keyboard and mouse button prompts from totk.ini's bindings",
|
||||
"phase.prepare.seed": "Reading the shaders from the game data",
|
||||
"phase.prepare.translate": "Translating the shaders",
|
||||
"phase.prepare.libraries": "Building the shaders for the graphics driver",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"step.lift": "Traduzindo o código do jogo para C",
|
||||
"step.compile": "Compilando o {game_exe}",
|
||||
"step.prepare": "Preparando os shaders",
|
||||
"step.pc_prompts": "Desenhando os ícones de teclado e mouse",
|
||||
"step.dlss": "Baixando o NVIDIA DLSS",
|
||||
"step.cleanup": "Finalizando",
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
"phase.compile.compile": "Compilando",
|
||||
"phase.compile.link": "Ligando o {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Gravando os patches de 60 fps nos dados do jogo",
|
||||
"phase.pc_prompts.draw": "Desenhando os ícones de teclas e botões do mouse a partir das atribuições do totk.ini",
|
||||
"phase.prepare.seed": "Lendo os shaders dos dados do jogo",
|
||||
"phase.prepare.translate": "Traduzindo os shaders",
|
||||
"phase.prepare.libraries": "Montando os shaders para o driver de vídeo",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"step.lift": "Перевод кода игры в C",
|
||||
"step.compile": "Сборка {game_exe}",
|
||||
"step.prepare": "Подготовка шейдеров",
|
||||
"step.pc_prompts": "Рисование подсказок клавиатуры и мыши",
|
||||
"step.dlss": "Загрузка NVIDIA DLSS",
|
||||
"step.cleanup": "Уборка",
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
"phase.compile.compile": "Компиляция",
|
||||
"phase.compile.link": "Компоновка {game_exe}",
|
||||
"phase.prepare.romfs_patches": "Запись патчей данных игры для 60 кадров/с",
|
||||
"phase.pc_prompts.draw": "Рисование подсказок клавиш и кнопок мыши по назначениям из totk.ini",
|
||||
"phase.prepare.seed": "Чтение шейдеров из данных игры",
|
||||
"phase.prepare.translate": "Трансляция шейдеров",
|
||||
"phase.prepare.libraries": "Сборка шейдеров для драйвера видеокарты",
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
"step.lift": "将游戏代码转换为 C 代码",
|
||||
"step.compile": "编译 {game_exe}",
|
||||
"step.prepare": "准备着色器",
|
||||
"step.pc_prompts": "绘制键盘和鼠标按键提示",
|
||||
"step.dlss": "下载 NVIDIA DLSS",
|
||||
"step.cleanup": "清理",
|
||||
|
||||
@@ -29,6 +30,7 @@
|
||||
"phase.compile.compile": "编译",
|
||||
"phase.compile.link": "链接 {game_exe}",
|
||||
"phase.prepare.romfs_patches": "写入 60 帧游戏数据补丁",
|
||||
"phase.pc_prompts.draw": "根据 totk.ini 中的按键绑定绘制键盘和鼠标按键提示",
|
||||
"phase.prepare.seed": "从游戏数据中读取着色器",
|
||||
"phase.prepare.translate": "转译着色器",
|
||||
"phase.prepare.libraries": "为显卡驱动构建着色器",
|
||||
|
||||
+5
-3
@@ -40,13 +40,13 @@ static const char *const known[] = {
|
||||
"BIND_SKIP", "BIND_STATS", "BIND_UP", "BIND_X", "BIND_Y",
|
||||
"BIND_ZL", "BIND_ZR", "BLOCK_VIEWS_3D", "CLIMB_FIX", "CLOTH_REALTIME", "COLOR_BRIGHTNESS", "COLOR_CONTRAST", "COLOR_GAMMA",
|
||||
"COLOR_PRESET", "COLOR_SATURATION", "CONTACT_DEBUG", "CONTACT_SHADOWS", "CORE_DIAG", "CRIT", "CRIT_OUT",
|
||||
"DESC_TEMPLATE", "DESWIZZLE", "DEVICE_PROFILE", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
|
||||
"DESC_TEMPLATE", "DESWIZZLE", "DEVICE_PROFILE", "DIALOGUE_CLICK", "DISCORD_APP_ID", "DISCORD_IMAGE", "DISCORD_RPC", "DLAA", "DLAA_JITTER", "DLAA_MV", "DLAA_MASKDEBUG", "DLAA_MVDEBUG", "DLAA_OBJMV", "DLAA_SURVEY", "DLAA_TIMES", "DLSS", "DLSS_CHAR_MASK", "DLSS_PRESET", "DLSS_REACTIVE", "DUMP", "DUMP_BUF", "DUMP_DIR",
|
||||
"DUMP_LOG", "DYNAMIC_RES", "DYN_DELTA", "EXEFS", "FEEDBACK", "FIXED_RES_PATCH", "FIX_C0", "FIX_ZERO", "FLIGHT", "FLIGHT_AT", "FLIGHT_DIR", "FLIGHT_FRAMES",
|
||||
"FLIGHT_SPIKE_MS", "FLIGHT_THUMBS", "FLUSH_SPAN", "FOV", "FOV_PATCH", "FPS60", "FPS_LIMIT", "FRAME_QUEUE",
|
||||
"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"}, {"DIALOGUE_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,8 @@ 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", "0", "0|1", LIVE}, // input.c: the left mouse button is A on the Purah Pad's map
|
||||
{"DIALOGUE_CLICK", "0", "0|1", LIVE}, // menu_cursor.c: in a dialogue box left click is B, right click A
|
||||
{"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},
|
||||
|
||||
+113
-24
@@ -57,7 +57,8 @@ static const SDL_GamepadButton pad_sdl[PAD_COUNT] = {
|
||||
[PAD_LPADDLE2] = SDL_GAMEPAD_BUTTON_LEFT_PADDLE2, [PAD_RPADDLE2] = SDL_GAMEPAD_BUTTON_RIGHT_PADDLE2,
|
||||
};
|
||||
|
||||
// TOTK_INPUT_SCRIPT=<file>: lines "<frame> <button> [hold]" or "<frame> LSTICK|RSTICK <x> <y> [hold]", ORed into the real input.
|
||||
// TOTK_INPUT_SCRIPT=<file>: lines "<frame> <button> [hold]", "<frame> LSTICK|RSTICK <x> <y> [hold]", "<frame> MOUSE
|
||||
// <dx> <dy>" or "<frame> WHEEL <notches>" (+ away from the player), ORed into the real input.
|
||||
// <frame> and its hold are 60 Hz ticks of game time since the first present (frame_step_ticks: presents at 60 fps), so
|
||||
// the title menus get the presses at the same game time at any frame limit. A line "@<ms> ..." is timed instead: <ms>
|
||||
// and its hold are milliseconds of the world clock (frame_step_world_us, game time since the loaded save's first
|
||||
@@ -74,6 +75,7 @@ static ScriptEv *script_ev;
|
||||
static int script_n, script_state; // 0 not loaded, 1 loaded
|
||||
static int script_mixed; // the script has timed lines: its untimed ones end where the world clock starts
|
||||
static int32_t script_mouse[2]; // one-shot raw counts, consumed by the camera hook; under lock
|
||||
static int32_t script_wheel; // one-shot wheel notches, taken with the real ones (wheel_stick); under lock
|
||||
|
||||
static void script_load(void) {
|
||||
script_state = 1;
|
||||
@@ -96,7 +98,11 @@ static void script_load(void) {
|
||||
ScriptEv e = {.at = (uint64_t)(at * unit + 0.5), .hold = timed ? 66667 : 4, .bit = -1, .timed = timed};
|
||||
long a, b;
|
||||
double c;
|
||||
if (!strcmp(name, "MOUSE") || !strcmp(name, "LSTICK") || !strcmp(name, "RSTICK")) {
|
||||
if (!strcmp(name, "WHEEL")) {
|
||||
if (sscanf(line + off, "%ld", &a) != 1) { rt_log("input: script line %d: WHEEL needs notches", ln); continue; }
|
||||
e.stick = 4, e.x = (int32_t)a, e.hold = 1; // one turn, never held
|
||||
snprintf(e.text, sizeof e.text, "WHEEL %d", e.x);
|
||||
} else if (!strcmp(name, "MOUSE") || !strcmp(name, "LSTICK") || !strcmp(name, "RSTICK")) {
|
||||
int n = sscanf(line + off, "%ld %ld %lf", &a, &b, &c);
|
||||
if (n < 2) { rt_log("input: script line %d: %s needs x y [hold]", ln, name); continue; }
|
||||
e.stick = name[0] == 'M' ? 3 : name[0] == 'L' ? 1 : 2; e.x = (int32_t)a; e.y = (int32_t)b;
|
||||
@@ -131,14 +137,17 @@ static void script_apply(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
|
||||
ScriptEv *e = &script_ev[i];
|
||||
if (e->timed ? w < 0 : script_mixed && w >= 0) continue;
|
||||
uint64_t now = e->timed ? (uint64_t)w : tick;
|
||||
if (now < e->at || (now >= e->at + e->hold && (e->logged || !e->timed))) continue;
|
||||
if (e->stick == 3 && e->logged) continue;
|
||||
// A one-shot (MOUSE, WHEEL) goes in at the first poll at or after its time: a poll that skips a tick (the
|
||||
// game below 60 fps) would otherwise lose it
|
||||
if (e->stick >= 3 ? e->logged || now < e->at
|
||||
: now < e->at || (now >= e->at + e->hold && (e->logged || !e->timed))) continue;
|
||||
if (!e->logged) {
|
||||
e->logged = 1;
|
||||
if (e->timed) rt_log("input: script frame %llu at %.1f ms: %s", (unsigned long long)fr, w / 1000.0, e->text);
|
||||
else rt_log("input: script frame %llu tick %llu: %s", (unsigned long long)fr, (unsigned long long)tick, e->text);
|
||||
}
|
||||
if (e->stick == 3) {
|
||||
if (e->stick == 4) script_wheel += e->x;
|
||||
else if (e->stick == 3) {
|
||||
int64_t x = (int64_t)script_mouse[0] + e->x, y = (int64_t)script_mouse[1] + e->y;
|
||||
script_mouse[0] = (int32_t)(x < INT32_MIN ? INT32_MIN : x > INT32_MAX ? INT32_MAX : x);
|
||||
script_mouse[1] = (int32_t)(y < INT32_MIN ? INT32_MIN : y > INT32_MAX ? INT32_MAX : y);
|
||||
@@ -261,6 +270,17 @@ void input_direct_mouse_sample(int enabled, int32_t *dx, int32_t *dy) {
|
||||
plat_mutex_unlock(&lock);
|
||||
}
|
||||
|
||||
// A turn of the real wheel as a WHEEL line of the recording (one-shot, as a MOUSE line). Under lock.
|
||||
static void rec_wheel(int32_t notches) {
|
||||
if (rec_state != 1) return;
|
||||
char what[32];
|
||||
snprintf(what, sizeof what, "WHEEL %d", notches);
|
||||
int64_t w = frame_step_world_us();
|
||||
uint64_t tick = frame_step_ticks();
|
||||
rec_line(tick, w, tick + 1, w, what);
|
||||
fflush(rec);
|
||||
}
|
||||
|
||||
static float mouse_sens = -1; // TOTK_MOUSE_SENS, 0 = mouse camera off; live (cfg_version)
|
||||
static unsigned mouse_sens_seen;
|
||||
|
||||
@@ -541,35 +561,84 @@ static int32_t shake_stick(int held) {
|
||||
return (now - from) / SHAKE_SIDE_NS % 2 ? STICK_MAX : -STICK_MAX;
|
||||
}
|
||||
|
||||
// The scroll wheel on the Purah Pad's map, which zooms with the right stick's y (up: in): each notch is a full-tilt
|
||||
// pulse of MAP_ZOOM_PULSE_NS on that stick with MAP_ZOOM_GAP_NS of neutral after it, so a step of the zoom and a
|
||||
// held zoom both see one notch as one push. A fast scroll's notches wait their turn (at most MAP_ZOOM_QUEUE), a turn the
|
||||
// other way drops them. Returns the stick y for this poll, 0 between pulses and off the map. Under lock.
|
||||
#define MAP_ZOOM_PULSE_NS 100000000ull
|
||||
#define MAP_ZOOM_GAP_NS 50000000ull
|
||||
#define MAP_ZOOM_QUEUE 4
|
||||
static int32_t map_zoom_stick(int32_t notches, int on_map) {
|
||||
// The scroll wheel (ikb_wheel_take, and an input script's WHEEL lines) as the stick a gamepad player would move:
|
||||
// - on the Purah Pad's map it zooms: the right stick's y, away from the player zooming in;
|
||||
// - while a D-pad strip (weapons, shields, bows, materials) is held open it steps the choice: the right stick's x, away
|
||||
// from the player to the left, towards the player to the right;
|
||||
// - in a menu with the game's focus box (the inventory, shops, Options, the save list; menu_cursor_menu) it steps the
|
||||
// focus: the left stick's y, away from the player up;
|
||||
// - in the Purah Pad's camera (menu_cursor_camera) it zooms: the D-pad's up (away from the player, in) or down, the
|
||||
// buttons its guide shows for the zoom.
|
||||
// Each notch is a full-tilt pulse with neutral after it (wheel_timing), so the game sees one notch as one step, and a
|
||||
// fast scroll's notches wait their turn (at most WHEEL_QUEUE); a turn the other way drops them. A strip's pulse is the
|
||||
// mouse's (input_direct_mouse_row: 32 ms each way); a menu takes the stick on its own update, a frame of the game's
|
||||
// 30 Hz or less, so its pulse covers two. Elsewhere, and while the settings menu is open, the notches are dropped.
|
||||
enum { WHEEL_NONE, WHEEL_MAP, WHEEL_STRIP, WHEEL_MENU, WHEEL_CAMERA };
|
||||
static const struct { uint64_t pulse_ns, gap_ns; } wheel_timing[] = {
|
||||
[WHEEL_MAP] = {100000000ull, 50000000ull}, [WHEEL_STRIP] = {32000000ull, 32000000ull},
|
||||
[WHEEL_MENU] = {70000000ull, 50000000ull}, [WHEEL_CAMERA] = {100000000ull, 50000000ull}};
|
||||
#define WHEEL_QUEUE 4
|
||||
#define WHEEL_GAP_NS 300000000ull // a menu's focus gap (a tab switch): queued notches wait this long for its next screen
|
||||
|
||||
// The stick value for this poll at the place `where` (WHEEL_*): -STICK_MAX, 0 or STICK_MAX. Under lock.
|
||||
static int32_t wheel_stick(int32_t notches, int where) {
|
||||
static int32_t queued, dir;
|
||||
static uint64_t until; // the end of the pulse (dir != 0) or of the neutral after it
|
||||
static int place;
|
||||
static uint64_t until, none_since; // until: the end of the pulse (dir != 0) or of the neutral after it
|
||||
uint64_t now = plat_now_ns();
|
||||
if (!on_map) { queued = dir = 0, until = 0; return 0; }
|
||||
if (where == WHEEL_NONE) {
|
||||
if (!none_since) none_since = now;
|
||||
if (now - none_since > WHEEL_GAP_NS) queued = 0, place = WHEEL_NONE;
|
||||
dir = 0;
|
||||
return 0;
|
||||
}
|
||||
none_since = 0;
|
||||
if (where != place) queued = dir = 0, until = 0, place = where;
|
||||
if (notches) {
|
||||
if (queued && (notches > 0) != (queued > 0)) queued = 0;
|
||||
queued += notches;
|
||||
queued = queued > MAP_ZOOM_QUEUE ? MAP_ZOOM_QUEUE : queued < -MAP_ZOOM_QUEUE ? -MAP_ZOOM_QUEUE : queued;
|
||||
queued = queued > WHEEL_QUEUE ? WHEEL_QUEUE : queued < -WHEEL_QUEUE ? -WHEEL_QUEUE : queued;
|
||||
}
|
||||
if (dir) {
|
||||
if (now < until) return dir * STICK_MAX;
|
||||
dir = 0, until = now + MAP_ZOOM_GAP_NS;
|
||||
dir = 0, until = now + wheel_timing[where].gap_ns;
|
||||
return 0;
|
||||
}
|
||||
if (now < until || !queued) return 0;
|
||||
dir = queued > 0 ? 1 : -1;
|
||||
queued -= dir;
|
||||
until = now + MAP_ZOOM_PULSE_NS;
|
||||
until = now + wheel_timing[where].pulse_ns;
|
||||
return dir * STICK_MAX;
|
||||
}
|
||||
|
||||
// After the keys, the gamepad and the script: where the wheel goes this poll (b holds the script's D-pad too, so a
|
||||
// scripted strip takes scripted notches). Under lock.
|
||||
static void wheel_route(uint64_t *bp, int32_t sl[2], int32_t sr[2]) {
|
||||
uint64_t b = *bp;
|
||||
int32_t real = state > 0 ? ikb_wheel_take() : 0, notches = real + script_wheel; // the script's under TOTK_INPUT=none too
|
||||
script_wheel = 0;
|
||||
if (menu_is_open()) notches = 0;
|
||||
if (real && notches) {
|
||||
__atomic_store_n(&g_kbm_last, 1, __ATOMIC_RELAXED); // the pointer comes to a menu the wheel turns in
|
||||
rec_wheel(real);
|
||||
}
|
||||
// A strip is its D-pad direction held with its screen open; with the menu cursor off (the screens not read,
|
||||
// menu_cursor_shortcut -1) the buttons alone decide, as for the mouse's selectors
|
||||
int sc = b & (1ull << B_UP | 1ull << B_LEFT | 1ull << B_RIGHT) && !(b & 1ull << B_L) ? menu_cursor_shortcut() : 0;
|
||||
int strip = sc == -1 || sc == 1 || (sc == 0 && menu_cursor_strip());
|
||||
int where = menu_cursor_map() ? WHEEL_MAP
|
||||
: strip ? WHEEL_STRIP
|
||||
: menu_cursor_camera() ? WHEEL_CAMERA
|
||||
: menu_cursor_menu() ? WHEEL_MENU
|
||||
: WHEEL_NONE;
|
||||
int32_t v = wheel_stick(notches, where);
|
||||
if (!v) return;
|
||||
if (where == WHEEL_CAMERA) *bp |= 1ull << (v > 0 ? B_UP : B_DOWN);
|
||||
else if (where == WHEEL_MAP) pick(&sr[0], &sr[1], 0, v);
|
||||
else if (where == WHEEL_STRIP) pick(&sr[0], &sr[1], -v, 0);
|
||||
else pick(&sl[0], &sl[1], 0, v);
|
||||
}
|
||||
|
||||
// Under lock, state 1: the open gamepad's inputs by position (pd[PAD_*] != 0 held); 0 without a connected gamepad.
|
||||
static int pad_physical(uint8_t pd[PAD_COUNT]) {
|
||||
if ((!pad || !SDL_GamepadConnected(pad)) && plat_now_ns() / 1000000u >= next_scan) { next_scan = plat_now_ns() / 1000000u + RESCAN_MS; scan_pads(); }
|
||||
@@ -641,6 +710,28 @@ 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 map_held, map_a;
|
||||
if (!down[KEY_MOUSE_L]) map_held = map_a = 0;
|
||||
else if (!map_held) map_held = 1, map_a = menu_cursor_map() && cfg_bool("TOTK_MAP_CLICK");
|
||||
if (map_a) down[KEY_MOUSE_L] = 0, b |= 1ull << B_A;
|
||||
// While a dialogue box is on screen (menu_cursor.c, TOTK_DIALOGUE_CLICK) the left mouse button presses B,
|
||||
// which advances the text and also shows the rest of a line at once, and the right one presses A, instead
|
||||
// of their bindings: Y by default, which opens the dialogue log there, and ZL. A press is one or the other
|
||||
// from the moment it goes down until it is released, so a click that closes the last box does not turn
|
||||
// into an attack while it is still held, and a button held as the box opens does not skip its first line.
|
||||
// Dialogue choices have the pointer, and their clicks are menu_cursor.c's: a left click there is A.
|
||||
static const uint8_t click_key[2] = {KEY_MOUSE_L, KEY_MOUSE_R}, click_btn[2] = {B_B, B_A};
|
||||
static int click_held[2], click_talk[2];
|
||||
for (int i = 0; i < 2; i++) {
|
||||
int key = click_key[i];
|
||||
if (!down[key]) click_held[i] = click_talk[i] = 0;
|
||||
else if (!click_held[i]) click_held[i] = 1, click_talk[i] = menu_cursor_dialogue();
|
||||
if (click_talk[i]) down[key] = 0, b |= 1ull << click_btn[i];
|
||||
}
|
||||
b |= input_map_buttons(down);
|
||||
int32_t k[2];
|
||||
walk_get();
|
||||
@@ -658,13 +749,10 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
// Before the screens were read (the menu cursor off) the buttons alone decide, as before.
|
||||
if (selector && menu_cursor_shortcut() == 0) selector = 0;
|
||||
mouse_camera(k, selector);
|
||||
// On the map the left stick moves the cursor and the right one zooms: the mouse moves the cursor there,
|
||||
// the scroll wheel zooms (map_zoom_stick). Elsewhere the wheel is unbound; its notches are dropped.
|
||||
int map = menu_cursor_map();
|
||||
if (map) pick(&sl[0], &sl[1], k[0], k[1]);
|
||||
// On the map the left stick moves the cursor and the right one zooms: the mouse moves the cursor there
|
||||
// (the scroll wheel zooms, wheel_route)
|
||||
if (menu_cursor_map()) pick(&sl[0], &sl[1], k[0], k[1]);
|
||||
else pick(&sr[0], &sr[1], k[0], k[1]);
|
||||
int32_t zoom = map_zoom_stick(ikb_wheel_take(), map);
|
||||
if (zoom) pick(&sr[0], &sr[1], 0, zoom);
|
||||
int32_t shake = shake_stick(input_map_held(down, B_SHAKE));
|
||||
if (shake) sr[0] = shake, sr[1] = 0;
|
||||
// A mouse shake (mouse_direct.c) moves the stick with the mouse, side by side, and lets go when it rests
|
||||
@@ -679,6 +767,7 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
|
||||
else if (kbm_used) __atomic_store_n(&g_kbm_last, 1, __ATOMIC_RELAXED);
|
||||
}
|
||||
script_apply(&b, sl, sr);
|
||||
wheel_route(&b, sl, sr);
|
||||
rec_apply(b, sl, sr);
|
||||
// Minus and Plus held together (gamepad or keys) open or close the menu and never reach the game
|
||||
static int combo_held;
|
||||
|
||||
@@ -35,6 +35,15 @@ int menu_cursor_shortcut(void);
|
||||
void menu_cursor_poll(uint64_t *buttons);
|
||||
int menu_cursor_pointer(void);
|
||||
int menu_cursor_map(void); // the Purah Pad's map is open: the mouse's stick is the left one (its cursor)
|
||||
// a dialogue box is on screen and TOTK_DIALOGUE_CLICK is on: left click is B, right click A (input.c poll_merged)
|
||||
int menu_cursor_dialogue(void);
|
||||
// A menu screen (not the ability wheel, a D-pad strip or the map) has the game's focus box, whichever device was used
|
||||
// last: input.c turns the scroll wheel into steps of its focus. 0 with the menu cursor off.
|
||||
int menu_cursor_menu(void);
|
||||
// A D-pad strip's screen (ShortCut_00) is open; it has no focus box while held. 0 with the menu cursor off.
|
||||
int menu_cursor_strip(void);
|
||||
// The Purah Pad's camera is open: its frame and pointer without the map the Scope has. 0 with the menu cursor off.
|
||||
int menu_cursor_camera(void);
|
||||
// The same for host UI (the text entry): never blocked. input_block(1) while a text entry is open: input_poll then
|
||||
// reports nothing; input_block(0) when it closes: nothing until all buttons and stick directions are released.
|
||||
void input_poll_ui(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
|
||||
|
||||
+4
-2
@@ -23,7 +23,8 @@ static SDL_Window *win;
|
||||
static volatile uint8_t key_held[KEY_COUNT];
|
||||
static volatile int32_t esc_held, f8_held, focused;
|
||||
static volatile int32_t mouse_dx, mouse_dy; // relative motion since the last ikb_mouse_take, whole counts
|
||||
static volatile int32_t mouse_wheel; // wheel turned while captured, in 1/120 notches (ikb_wheel_take)
|
||||
static volatile int32_t mouse_wheel; // wheel turned while captured or over the window, in 1/120 notches
|
||||
// (ikb_wheel_take)
|
||||
static float rem_x, rem_y; // window thread: the fractions SDL reported beyond them
|
||||
static volatile int32_t mouse_travel; // raw counts moved in total, captured or not (ikb_mouse_travel)
|
||||
static float travel_rem; // window thread: the fraction of a count beyond mouse_travel
|
||||
@@ -266,7 +267,8 @@ void input_sdl_event(const SDL_Event *e) {
|
||||
__atomic_store_n(&ptr_have, 0, __ATOMIC_RELEASE);
|
||||
break;
|
||||
case SDL_EVENT_MOUSE_WHEEL: // notches, + away from the player (a flipped wheel reports the other sign)
|
||||
if (captured) {
|
||||
// Captured, or released over the focused window: a game menu with the pointer takes it (input.c)
|
||||
if (captured || (focused && __atomic_load_n(&ptr_have, __ATOMIC_ACQUIRE))) {
|
||||
float y = e->wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? -e->wheel.y : e->wheel.y;
|
||||
plat_add32(&mouse_wheel, (int32_t)(y * 120));
|
||||
}
|
||||
|
||||
+8
-3
@@ -84,7 +84,8 @@ uint32_t input_key_char(int key) {
|
||||
// ---- mouse camera: raw motion accumulated by the window thread, one stick sample per presented frame
|
||||
static volatile LONG mouse_dx, mouse_dy; // raw counts since the last frame sample
|
||||
static volatile LONG mouse_travel; // raw counts moved in total, captured or not (ikb_mouse_travel)
|
||||
static volatile LONG mouse_wheel; // wheel turned while captured, in WHEEL_DELTA units (ikb_wheel_take)
|
||||
static volatile LONG mouse_wheel; // wheel turned while captured or over the window, in WHEEL_DELTA units
|
||||
// (ikb_wheel_take)
|
||||
static volatile LONG cur_captured; // cursor hidden and confined to the client area
|
||||
static volatile LONG cur_active; // WM_ACTIVATEAPP: the window's application is active
|
||||
// Bits: CUR_REL, Esc or activation by a click on the title bar or border: until a client click; CUR_ESC, set with CUR_REL
|
||||
@@ -148,8 +149,12 @@ int input_window_msg(HWND h, UINT m, WPARAM w, LPARAM l, LRESULT *res) {
|
||||
InterlockedAdd(&mouse_dy, y);
|
||||
}
|
||||
}
|
||||
// The wheel comes in the same message (usButtonData, signed, + away from the player)
|
||||
if (cur_captured && ri.header.dwType == RIM_TYPEMOUSE && (ri.data.mouse.usButtonFlags & RI_MOUSE_WHEEL))
|
||||
// The wheel comes in the same message (usButtonData, signed, + away from the player). It counts while the
|
||||
// cursor is captured, or released over the client area: a game menu with the pointer (menu_cursor.c) takes it
|
||||
// as steps of its focus. input.c drops the notches where nothing takes them.
|
||||
float px, py;
|
||||
if (ri.header.dwType == RIM_TYPEMOUSE && (ri.data.mouse.usButtonFlags & RI_MOUSE_WHEEL) &&
|
||||
(cur_captured || ikb_pointer(&px, &py)))
|
||||
InterlockedAdd(&mouse_wheel, (SHORT)ri.data.mouse.usButtonData);
|
||||
break; // DefWindowProc must see WM_INPUT for cleanup
|
||||
}
|
||||
|
||||
@@ -13,8 +13,9 @@ void ikb_pointer_set(float nx, float ny); // moves the pointer there (the wind
|
||||
int ikb_captured(void); // the cursor is captured for the mouse camera
|
||||
void ikb_mouse_take(int32_t *dx, int32_t *dy); // raw mouse motion since the last call, in counts
|
||||
uint32_t ikb_mouse_travel(void); // raw counts the mouse moved in total (|dx| + |dy|), captured or not
|
||||
int32_t ikb_wheel_take(void); // whole wheel notches turned while captured since the last call (+ away
|
||||
// from the player); a high-resolution wheel's part of a notch is kept
|
||||
int32_t ikb_wheel_take(void); // whole wheel notches turned since the last call while the cursor was
|
||||
// captured or over the focused window (+ away from the player); a
|
||||
// high-resolution wheel's part of a notch is kept
|
||||
void ikb_cursor_update(void); // what input_cursor_allowed says may have changed
|
||||
void ikb_menu_closed(void); // the menu closed: a capture that Esc gave up comes back
|
||||
|
||||
|
||||
+114
-11
@@ -20,6 +20,14 @@
|
||||
//
|
||||
// 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.
|
||||
//
|
||||
// With TOTK_MAP_CLICK=1 (live, default 0: one key per controller button) input.c makes the left mouse button A on the
|
||||
// map (menu_cursor_map), so a click acts at the map's cursor. The map is found only while TOTK_MENU_CURSOR is on.
|
||||
//
|
||||
// The same read of the open screens tells input.c when a dialogue box is on screen (menu_cursor_dialogue), where the
|
||||
// left mouse button presses B (it advances the text and skips its scroll) and the right one A, instead of their
|
||||
// bindings (Y by default, which opens the dialogue log, and ZL). TOTK_DIALOGUE_CLICK (live, default 0: one key per
|
||||
// controller button) switches that on its own: it does not need the pointer.
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <stdio.h>
|
||||
@@ -50,6 +58,10 @@ enum { DI_PROJ = 0x10, DI_VIEW = 0x50, LYT_ROOT = 0x18, LYT_SIZE = 0x28, LYT_NAM
|
||||
// nn::ui2d::Pane
|
||||
enum { PANE_PARENT = 0x18, PANE_SIZE = 0x50, PANE_FLAG = 0x58, PANE_ALPHA = 0x59, PANE_BASE = 0x5b, PANE_MTX = 0x70 };
|
||||
|
||||
// How far the pointer moves, in layout units (1280 x 720 across the picture: 1.5 window pixels at 1080p, 3 at 4K),
|
||||
// before it takes back a focus that the wheel, the keys or the pad moved away from it (menu_cursor_poll)
|
||||
#define DEAD_ZONE 6.0f
|
||||
|
||||
static uint64_t main_lo, main_hi;
|
||||
|
||||
static int ok_at(uint64_t p, uint64_t n) {
|
||||
@@ -166,16 +178,24 @@ static void layout_name(uint64_t scr, char *out, size_t n) {
|
||||
// 1.4.3 constructor keeps). The map has no focus box, so it is found here: the Purah Pad's frame (AppMenuOverlay_00)
|
||||
// with AppMap_00 and the menu's background AppMenuBG_00 open. The Scope opens the frame over AppMap_00 without that
|
||||
// background (Weeping of the Empire's engine/runtime/totk_menu_cursor.cpp census tells them apart the same way).
|
||||
// The dialogue window (DIALOGUE_SCREEN) has no focus box either: the scan remembers its screen for dialogue_shown.
|
||||
// A D-pad strip has no focus box either while it is held open: *strip is ShortCut_00 being open. *camera is the
|
||||
// Purah Pad's camera (the ability wheel's camera): the frame and its pointer CameraPointer_00 open without AppMap_00,
|
||||
// which the Scope has with them.
|
||||
// TOTK_MENU_CURSOR_LOG=1 logs the open screens whenever the set changes.
|
||||
enum { SM_COUNT = 0x8, SM_SCREENS = 0x10 };
|
||||
static int map_open(void) {
|
||||
#define DIALOGUE_SCREEN "MessageDialog_00" // the box a character's lines and the game's messages are shown in
|
||||
#define DIALOGUE_GAP_MS 500 // how long after the box closed a click is still the dialogue's
|
||||
static uint64_t dialogue_scr; // game thread only
|
||||
static int map_open(int *strip, int *camera) {
|
||||
uint64_t sm = screen_mgr();
|
||||
if (!sm) return 0;
|
||||
int32_t n = (int32_t)rd32(sm + SM_COUNT);
|
||||
uint64_t arr = rd64(sm + SM_SCREENS);
|
||||
*strip = *camera = 0;
|
||||
if (n <= 0 || n > 1024 || !ok_at(arr, 8ull * (uint64_t)n)) return 0;
|
||||
const char *e = cfg_get("TOTK_MENU_CURSOR_LOG");
|
||||
int verbose = e && !strcmp(e, "1"), pad = 0, map = 0, bg = 0;
|
||||
int verbose = e && !strcmp(e, "1"), pad = 0, map = 0, bg = 0, pointer = 0;
|
||||
char list[1024];
|
||||
size_t len = 0;
|
||||
uint64_t h = 1469598103934665603ull;
|
||||
@@ -187,6 +207,9 @@ static int map_open(void) {
|
||||
pad |= !strcmp(nm, "AppMenuOverlay_00");
|
||||
map |= !strcmp(nm, "AppMap_00");
|
||||
bg |= !strcmp(nm, "AppMenuBG_00");
|
||||
if (!strcmp(nm, DIALOGUE_SCREEN)) dialogue_scr = scr;
|
||||
pointer |= !strcmp(nm, "CameraPointer_00");
|
||||
*strip |= !strcmp(nm, "ShortCut_00");
|
||||
if (!verbose) continue;
|
||||
for (const char *c = nm; *c; c++) h = (h ^ (uint8_t)*c) * 1099511628211ull;
|
||||
if (len < sizeof list - 64) len += (size_t)snprintf(list + len, sizeof list - len, "%s%s", len ? " " : "", nm);
|
||||
@@ -194,8 +217,22 @@ static int map_open(void) {
|
||||
static uint64_t last;
|
||||
static int lines;
|
||||
if (verbose && h != last && lines < 200) last = h, lines++, rt_log("menu_cursor: open screens: %s", list);
|
||||
*camera = pad && pointer && !map && !bg;
|
||||
return pad && map && bg;
|
||||
}
|
||||
// The dialogue window is open. Read at every pad read from the screen the last scan found open, so a click follows the
|
||||
// box without the scan's 100 ms: the game keeps its screens, so the one found once is the one that opens the next time.
|
||||
// A screen that is no longer that layout (a reload built the screens again) is forgotten until a scan finds it.
|
||||
static int dialogue_shown(void) {
|
||||
uint64_t scr = dialogue_scr;
|
||||
if (!scr) return 0;
|
||||
if (!game_object(scr, SCR_REQUEST + 1)) { dialogue_scr = 0; return 0; }
|
||||
if (rd8(scr + SCR_STATE) != SCR_OPENED) return 0;
|
||||
char nm[48];
|
||||
layout_name(scr, nm, sizeof nm);
|
||||
if (strcmp(nm, DIALOGUE_SCREEN)) { dialogue_scr = 0; return 0; }
|
||||
return 1;
|
||||
}
|
||||
static void layout_size(uint64_t scr, float *lw, float *lh) {
|
||||
*lw = 1920, *lh = 1080;
|
||||
uint64_t lyt = rd64(scr + SCR_LAYOUT);
|
||||
@@ -280,15 +317,29 @@ static int gameplay_screen(const char *nm) {
|
||||
|
||||
static volatile int32_t g_pointer; // a menu has the pointer: input_cursor_allowed releases the capture
|
||||
static volatile int32_t g_map; // the Purah Pad's map is open (not the Scope): the mouse moves its cursor
|
||||
static volatile int32_t g_dialogue; // a dialogue box is on screen and TOTK_DIALOGUE_CLICK is on: left B, right A
|
||||
static volatile int32_t g_menu; // a menu screen has the focus box, from either device (the scroll wheel's steps)
|
||||
static volatile int32_t g_strip; // a D-pad strip's screen is open (the scroll wheel's steps along it)
|
||||
static volatile int32_t g_camera; // the Purah Pad's camera is open (the scroll wheel zooms it)
|
||||
|
||||
int menu_cursor_pointer(void) { return __atomic_load_n(&g_pointer, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_map(void) { return __atomic_load_n(&g_map, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_dialogue(void) { return __atomic_load_n(&g_dialogue, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_menu(void) { return __atomic_load_n(&g_menu, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_strip(void) { return __atomic_load_n(&g_strip, __ATOMIC_RELAXED); }
|
||||
int menu_cursor_camera(void) { return __atomic_load_n(&g_camera, __ATOMIC_RELAXED); }
|
||||
|
||||
static int enabled(void) {
|
||||
if (!RT_V143) return 0;
|
||||
const char *v = cfg_get("TOTK_MENU_CURSOR"), *in = cfg_get("TOTK_INPUT");
|
||||
return !(v && !strcmp(v, "0")) && !(in && !strcmp(in, "none"));
|
||||
}
|
||||
// The left click in dialogue: its own setting, on with the menu cursor off too
|
||||
static int dialogue_enabled(void) {
|
||||
if (!RT_V143) return 0;
|
||||
const char *in = cfg_get("TOTK_INPUT");
|
||||
return cfg_bool("TOTK_DIALOGUE_CLICK") && !(in && !strcmp(in, "none"));
|
||||
}
|
||||
|
||||
static void set_pointer(int on) {
|
||||
if (plat_xchg32(&g_pointer, on) == on) return;
|
||||
@@ -317,27 +368,68 @@ static void log_screen(const Focus *f, const char *nm, int n, float lw, float lh
|
||||
|
||||
// Once per pad read on the game thread: the pointer's hover and clicks, as pad buttons (A, B) for this read
|
||||
void menu_cursor_poll(uint64_t *buttons) {
|
||||
static int inited, pending_a, held_l, held_r;
|
||||
static int inited, pending_a, held_l, held_r, anchored;
|
||||
static uint64_t pending_node, pending_until, hold_until, hold_bit, menu_seen;
|
||||
static float last_px = -1, last_py = -1;
|
||||
static uint64_t ptr_node, last_focus; // the item the pointer last pointed at, the focus at the last read
|
||||
static float last_px = -1, last_py = -1, anchor_px, anchor_py;
|
||||
if (!inited) {
|
||||
inited = 1;
|
||||
main_lo = MOD_MAIN_BASE, main_hi = MOD_MAIN_BASE + MAIN_SIZE;
|
||||
if (RT_V143) rt_log("menu_cursor: on for 1.4.3 (TOTK_MENU_CURSOR=0 turns it off)");
|
||||
}
|
||||
if (!enabled()) { set_pointer(0); __atomic_store_n(&g_map, 0, __ATOMIC_RELAXED); return; }
|
||||
Focus f = focus_now();
|
||||
char nm[48] = "";
|
||||
if (f.screen) layout_name(f.screen, nm, sizeof nm);
|
||||
int cursor = enabled(), talk = dialogue_enabled();
|
||||
if (!cursor && !talk) {
|
||||
set_pointer(0);
|
||||
__atomic_store_n(&g_map, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_dialogue, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_menu, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_strip, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_camera, 0, __ATOMIC_RELAXED);
|
||||
return;
|
||||
}
|
||||
// The open screens are scanned every 100 ms, not at every pad read: each screen costs memory queries
|
||||
uint64_t now = plat_now_ms();
|
||||
static uint64_t map_at;
|
||||
static int map, map_logged;
|
||||
if (!map_at || now - map_at >= 100) map_at = now, map = map_open();
|
||||
static int map, map_logged, dialogue_logged, strip, camera;
|
||||
if (!map_at || now - map_at >= 100) map_at = now, map = map_open(&strip, &camera);
|
||||
// Between two lines of a conversation the game closes the box and opens it again, so a click made in that gap still
|
||||
// counts as dialogue for DIALOGUE_GAP_MS after the box was last open. The first clicks after a conversation fall
|
||||
// in it too and are B or A, as they are for a player who taps the button through the last line.
|
||||
// TOTK_MENU_CURSOR_LOG=1 logs how long each gap was.
|
||||
static uint64_t dialogue_seen;
|
||||
int box = talk && dialogue_shown();
|
||||
if (!talk) dialogue_seen = 0;
|
||||
if (box) {
|
||||
static int gap_lines;
|
||||
const char *e = cfg_get("TOTK_MENU_CURSOR_LOG");
|
||||
uint64_t gap = dialogue_seen ? now - dialogue_seen : 0;
|
||||
if (gap > 30 && gap < 5000 && gap_lines < 100 && e && !strcmp(e, "1"))
|
||||
gap_lines++, rt_log("menu_cursor: the dialogue box was closed for %llu ms", (unsigned long long)gap);
|
||||
dialogue_seen = now;
|
||||
}
|
||||
int dialogue = box || (dialogue_seen && now - dialogue_seen < DIALOGUE_GAP_MS);
|
||||
if (dialogue && !dialogue_logged)
|
||||
dialogue_logged = 1, rt_log("menu_cursor: a dialogue box is open (" DIALOGUE_SCREEN "): left click is B, "
|
||||
"right click A (TOTK_DIALOGUE_CLICK=1)");
|
||||
__atomic_store_n(&g_dialogue, dialogue, __ATOMIC_RELAXED);
|
||||
if (!cursor) {
|
||||
set_pointer(0);
|
||||
__atomic_store_n(&g_map, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_menu, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_strip, 0, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_camera, 0, __ATOMIC_RELAXED);
|
||||
return;
|
||||
}
|
||||
__atomic_store_n(&g_strip, strip, __ATOMIC_RELAXED);
|
||||
__atomic_store_n(&g_camera, camera, __ATOMIC_RELAXED);
|
||||
Focus f = focus_now();
|
||||
char nm[48] = "";
|
||||
if (f.screen) layout_name(f.screen, nm, sizeof nm);
|
||||
if (map && !map_logged) map_logged = 1, rt_log("menu_cursor: the map is open: the mouse moves its cursor");
|
||||
__atomic_store_n(&g_map, map, __ATOMIC_RELAXED);
|
||||
// With the gamepad as the last device the menus stay as they are on the console: no pointer, the capture kept.
|
||||
// Moving the mouse (or a key) makes keyboard and mouse the last device and the pointer comes.
|
||||
__atomic_store_n(&g_menu, f.screen && !gameplay_screen(nm) && !map, __ATOMIC_RELAXED);
|
||||
int menu = f.screen && !gameplay_screen(nm) && ikb_foreground() && input_kbm_last();
|
||||
if (menu) menu_seen = now;
|
||||
// A menu's focus gap (a tab switch, a popup opening: no focus box for a frame or two) keeps the pointer where it
|
||||
@@ -352,7 +444,7 @@ void menu_cursor_poll(uint64_t *buttons) {
|
||||
return;
|
||||
}
|
||||
if (gap) return; // a click's focus request waits for the next screen
|
||||
if (!menu) { pending_a = 0; last_px = last_py = -1; return; }
|
||||
if (!menu) { pending_a = 0, anchored = 0, ptr_node = last_focus = 0; last_px = last_py = -1; return; }
|
||||
if (pending_a) { // the focus asked for by a click: A once it is there
|
||||
if (rd64(f.control + CTL_ACTIVE) == pending_node) {
|
||||
pending_a = 0, hold_until = now + 60, hold_bit = 1ull << B_A;
|
||||
@@ -366,11 +458,21 @@ void menu_cursor_poll(uint64_t *buttons) {
|
||||
if (click_r) { hold_until = now + 60, hold_bit = 1ull << B_B; *buttons |= hold_bit; return; }
|
||||
float px, py;
|
||||
if (!picture_pos(&px, &py)) return;
|
||||
// The focus moved to another item than the pointer's (the scroll wheel, the keys, the pad): the pointer takes it
|
||||
// back only after it has left a dead zone of DEAD_ZONE layout units around where it was then, so a hand resting on
|
||||
// the mouse does not undo a scroll. A click still acts at once.
|
||||
if (f.node != last_focus) {
|
||||
if (f.node != ptr_node) anchored = 1, anchor_px = px, anchor_py = py;
|
||||
last_focus = f.node;
|
||||
}
|
||||
int moved = fabsf(px - last_px) > 0.001f || fabsf(py - last_py) > 0.001f;
|
||||
if (!moved && !click_l) return;
|
||||
last_px = px, last_py = py;
|
||||
float lw, lh;
|
||||
layout_size(f.screen, &lw, &lh);
|
||||
if (anchored && !click_l && fabsf(px - anchor_px) * lw < DEAD_ZONE && fabsf(py - anchor_py) * lh < DEAD_ZONE)
|
||||
return;
|
||||
anchored = 0;
|
||||
Xf xf = screen_xf(f.screen);
|
||||
Pt p = {(px - 0.5f) * lw, (0.5f - py) * lh, px * 2 - 1, 1 - py * 2, NULL};
|
||||
if (xf.ok && !xf_plain(&xf, lw, lh)) p.t = &xf;
|
||||
@@ -379,6 +481,7 @@ void menu_cursor_poll(uint64_t *buttons) {
|
||||
log_screen(&f, nm, n, lw, lh, p.t, n && stale_hit_panes(n, btn, lw, lh, p.t));
|
||||
uint64_t at = n ? node_at(n, node, btn, &p, lw, lh) : 0;
|
||||
if (!at) return;
|
||||
ptr_node = at;
|
||||
if (at != f.node) move_focus(&f, at);
|
||||
if (click_l) {
|
||||
if (at == f.node) { hold_until = now + 60, hold_bit = 1ull << B_A; *buttons |= hold_bit; }
|
||||
|
||||
@@ -869,6 +869,8 @@ 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);
|
||||
opt_toggle("TOTK_DIALOGUE_CLICK", UI_MENU_DIALOGUE_CLICK, UI_MENU_DIALOGUE_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
|
||||
|
||||
@@ -289,6 +289,10 @@ 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_DIALOGUE_CLICK] = "Clicks in dialogue",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "While a dialogue box is open, left click presses B (it continues the text and skips its scroll) and right click presses A, instead of the buttons they are bound to (Y by default, which opens the dialogue log, and ZL). Dialogue choices keep the pointer: left click picks (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",
|
||||
@@ -775,6 +779,10 @@ 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_DIALOGUE_CLICK] = "Щелчки в диалоге",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "Пока открыто окно диалога, левый щелчок нажимает B (продолжает текст и пропускает его прокрутку), а правый — A, вместо назначенных им кнопок (по умолчанию Y, она открывает журнал диалога, и ZL). В вариантах ответа по-прежнему работает указатель: левый щелчок выбирает (версия игры 1.4.3).",
|
||||
[UI_MENU_MOUSE_SENS] = "Чувствительность мыши",
|
||||
[UI_MENU_MOUSE_SENS_DESC] = "Как быстро мышь поворачивает камеру.",
|
||||
[UI_MENU_WALK_KEY] = "Клавиша шага",
|
||||
@@ -1429,6 +1437,10 @@ 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_DIALOGUE_CLICK] = "Cliques no diálogo",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "Enquanto uma caixa de diálogo está aberta, o clique esquerdo aperta B (continua o texto e pula a rolagem) e o direito aperta A, em vez dos botões aos quais estão atribuídos (Y por padrão, que abre o registro do diálogo, e ZL). As escolhas de diálogo continuam com o ponteiro: o clique esquerdo escolhe (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",
|
||||
@@ -2064,6 +2076,10 @@ 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_DIALOGUE_CLICK] = "对话中的鼠标点击",
|
||||
[UI_MENU_DIALOGUE_CLICK_DESC] = "对话框打开时,鼠标左键按下 B 键(继续对话并跳过文字滚动),右键按下 A 键,而不是它们所绑定的按键(默认为 Y,会打开对话记录;以及 ZL)。对话选项仍使用指针:左键选择(游戏 1.4.3)。",
|
||||
[UI_MENU_PROMPTS_MISSING] = "缺少按键提示文件:请重新运行安装程序",
|
||||
[UI_MENU_PROMPTS_FAILED] = "按键提示文件已损坏:请重新运行安装程序",
|
||||
[UI_MENU_PROMPTS_RESTART] = "按键提示重启后生效",
|
||||
|
||||
@@ -117,6 +117,8 @@ 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_DIALOGUE_CLICK, UI_MENU_DIALOGUE_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,
|
||||
|
||||
|
||||
@@ -575,7 +575,7 @@ class FontsTest(unittest.TestCase):
|
||||
|
||||
def test_all_steps_order(self):
|
||||
self.assertEqual([s.id for s in steps.all_steps()],
|
||||
['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'dlss', 'cleanup'])
|
||||
['check', 'fonts', 'extract', 'lift', 'compile', 'prepare', 'pc_prompts', 'dlss', 'cleanup'])
|
||||
|
||||
def test_extracts_into_the_install_folder(self):
|
||||
self.fake_tool()
|
||||
|
||||
@@ -528,7 +528,12 @@ class PromptsTest(unittest.TestCase):
|
||||
drawn = font(sarc_files(romfs.read(out, DEFAULT_FONT))['scft/External.bfotf'])
|
||||
advances = icons.font_advances(sarc_files(romfs.contents[DEFAULT_FONT])['scft/External.bfotf'])
|
||||
pc = icons.pc_icons(icons.text_glyphs(romfs.text_fonts), advances)
|
||||
text = icons.pc_icons(icons.text_glyphs(romfs.text_fonts), advances, icons.pc_binds(text=True))
|
||||
self.assertIn(0xE05E, pc) # the left stick's W A S D
|
||||
# In the font Y is T (PC_TEXT_KEYS); the button guide's Y image below stays the left mouse button
|
||||
otf = unbfotf(sarc_files(romfs.contents[DEFAULT_FONT])['scft/External.bfotf'])
|
||||
t = TTFont(io.BytesIO(icons.redraw_font(otf, {0xE043: text[0xE043]})))
|
||||
self.assertEqual(glyph(drawn, 0xE043)[0], glyph(t, 0xE043)[0])
|
||||
for cp in range(0xE040, 0xE069):
|
||||
outline, advance = glyph(drawn, cp)
|
||||
if cp in pc:
|
||||
@@ -565,6 +570,16 @@ class PromptsTest(unittest.TestCase):
|
||||
self.assertEqual({b: panes[f'T_{b}_00'] for b in PC_PANES}, {**PC_PANES, 'A': 'F'})
|
||||
self.assertEqual(icons.pc_binds(ini.read_text(encoding='utf-8')), {**icons.PC_BINDS, 'A': 'f'})
|
||||
|
||||
def test_pc_text_prompts_show_y_as_its_first_key_that_is_not_a_mouse_button(self):
|
||||
def y(line=None, text=True):
|
||||
return icons.pc_binds(f'[input]\n{line}\n' if line else None, text=text)['Y']
|
||||
self.assertEqual((y(), y(text=False)), ('t', 'mouse_l'))
|
||||
self.assertEqual(y('bind_Y = pad:north, key:mouse_l, key:h'), 'h')
|
||||
self.assertEqual(y('bind_Y = key:g, key:mouse_l'), 'g')
|
||||
self.assertEqual(y('bind_Y = key:mouse_l'), 'mouse_l') # no key besides the mouse: the mouse button
|
||||
self.assertEqual(y('bind_Y = key:default'), 't')
|
||||
self.assertEqual(y('bind_Y = key:h, key:mouse_l', text=False), 'h')
|
||||
|
||||
def test_same_input_same_output_and_the_older_flag(self):
|
||||
romfs = self.romfs['v121']
|
||||
for flags in (('--prompts', 'xbox'), ('--xbox-prompts',)):
|
||||
|
||||
+17
-6
@@ -18,7 +18,9 @@ start, MacNativeGames found).
|
||||
The button guide in play (bottom right) draws its buttons, L and ZL among them, from images of the common layout
|
||||
archive instead (timg/__Combined.bntx, Nt_KeyTexL_00 and Nt_KeyTexZL_00): bntx_redraw paints the same icons into them,
|
||||
the size unchanged. The Xbox prompts redraw L and ZL, the keyboard and mouse ones every image (PC_HUD_TEXTURES: A, B, X,
|
||||
Y, L, ZL and the stick's two). Prompts drawn as fixed images (some tutorial animations) keep the Switch icons.
|
||||
Y, L, ZL and the stick's two) with the keys of pc_binds. The font's glyphs use pc_binds(text=True): a text prompt shows
|
||||
Y as T, the button guide the left mouse button. Prompts drawn as fixed images (some tutorial animations) keep the
|
||||
Switch icons.
|
||||
|
||||
Needs fontTools (tools/requirements-installer.txt, tools/requirements-py314.txt).
|
||||
"""
|
||||
@@ -212,12 +214,18 @@ PC_HUD_TEXTURES = {'Nt_KeyTexA_00': 0xE040, 'Nt_KeyTexB_00': 0xE041, 'Nt_KeyTexX
|
||||
'Nt_KeyTexL_00': 0xE044, 'Nt_KeyTexZL_00': 0xE046, 'Nt_KeyTexLSt_00': 0xE052,
|
||||
'Nt_KeyTexLSt_01': 0xE05E}
|
||||
PC_MOUSE = ('mouse_l', 'mouse_r', 'mouse_m')
|
||||
# The text prompts (the button font: the menus' guides, the dialogue log's) show Y as T, the key runtime/input_map.c
|
||||
# binds next to the left mouse button: while a game menu has the pointer the left button is that menu's A
|
||||
# (runtime/menu_cursor.c), and T presses Y everywhere. The button guide in play and the action prompt keep the left
|
||||
# button (PC_BINDS), which attacks there.
|
||||
PC_TEXT_KEYS = {'Y': 't'}
|
||||
|
||||
|
||||
def pc_binds(ini_text=None):
|
||||
def pc_binds(ini_text=None, text=False):
|
||||
"""PC_BINDS with the first key of each bind_<action> line of a totk.ini text over it (a line without a key entry,
|
||||
or with key:default, keeps the default)."""
|
||||
binds = dict(PC_BINDS)
|
||||
or with key:default, keeps the default). text: the binds the button font is drawn with, where a button of
|
||||
PC_TEXT_KEYS shows its first key that is not a mouse button (PC_TEXT_KEYS's without a line)."""
|
||||
binds = dict(PC_BINDS, **(PC_TEXT_KEYS if text else {}))
|
||||
for line in (ini_text or '').splitlines():
|
||||
line = line.split('#')[0].split(';')[0].strip()
|
||||
if not line.lower().startswith('bind_') or '=' not in line:
|
||||
@@ -225,8 +233,11 @@ def pc_binds(ini_text=None):
|
||||
action, value = (s.strip() for s in line.split('=', 1))
|
||||
keys = [e.strip()[4:].strip().lower() for e in value.split(',') if e.strip().lower().startswith('key:')]
|
||||
keys = [k for k in keys if k != 'default']
|
||||
if keys and action[5:].upper() in binds:
|
||||
binds[action[5:].upper()] = keys[0]
|
||||
button = action[5:].upper()
|
||||
if text and button in PC_TEXT_KEYS:
|
||||
keys = [k for k in keys if not k.startswith('mouse_')] or keys
|
||||
if keys and button in binds:
|
||||
binds[button] = keys[0]
|
||||
return binds
|
||||
|
||||
|
||||
|
||||
@@ -43,8 +43,10 @@ romfs-patches-xbox-label-<w>x<h>: the same prompts with that shape's UI layout.
|
||||
--prompts pc: keyboard and mouse prompts, for prompts = pc (romfs-patches-pc, or romfs-patches-pc-<w>x<h> with
|
||||
--aspect): every button of the button font is drawn as the key or mouse button the keyboard defaults put on it
|
||||
(button_icons.pc_icons; --binds <totk.ini> takes the first key of its bind_ lines instead), and so are the button
|
||||
guide's images (A, B, X, Y, L, ZL and the stick's two). The one-letter panes around the action prompt name the keys
|
||||
with one character of the Normal font (E, an arrow for Shift, a bar for Space, L and R for the mouse buttons).
|
||||
guide's images (A, B, X, Y, L, ZL and the stick's two). In the font Y is T, the key that presses it next to the left
|
||||
mouse button, which is A in the game's menus (button_icons.PC_TEXT_KEYS); the button guide keeps the left button. The
|
||||
one-letter panes around the action prompt name the keys with one character of the Normal font (E, an arrow for Shift,
|
||||
a bar for Space, L and R for the mouse buttons).
|
||||
|
||||
--reuse <folder>: an overlay made before, such as romfs-patches-pc for romfs-patches-pc-<w>x<h>. Each file of it whose
|
||||
contents match the new one is hard-linked (copied where links fail) instead of compressed again; the summary's reused
|
||||
@@ -403,12 +405,15 @@ if args.prompts:
|
||||
assert not missing, f'no {", ".join(missing)} in {icons.TEXT_ARCHIVE}'
|
||||
glyphs = icons.text_glyphs(archives[icons.TEXT_ARCHIVE][slice(*text[name])] for name in icons.TEXT_FONTS)
|
||||
if pc:
|
||||
binds = icons.pc_binds(args.binds.read_text(encoding='utf-8', errors='replace') if args.binds else None)
|
||||
ini = args.binds.read_text(encoding='utf-8', errors='replace') if args.binds else None
|
||||
binds = icons.pc_binds(ini)
|
||||
advances = icons.font_advances(archives[icons.TEXT_ARCHIVE][slice(*text[icons.FONT])])
|
||||
drawn = icons.pc_icons(glyphs, advances, binds)
|
||||
# The text prompts show Y as T (button_icons.PC_TEXT_KEYS); the button guide's images keep the left click
|
||||
font_drawn = icons.pc_icons(glyphs, advances, icons.pc_binds(ini, text=True))
|
||||
pane_letters = {letter: icons.pc_letter(binds[letter]) for letter in 'ABXY'}
|
||||
else:
|
||||
drawn = icons.xbox_icons(glyphs)
|
||||
drawn = font_drawn = icons.xbox_icons(glyphs)
|
||||
pane_letters = KEY_LETTERS
|
||||
bntx = members['timg/__Combined.bntx'][0]
|
||||
letters = {}
|
||||
@@ -431,7 +436,7 @@ if args.prompts:
|
||||
lo, hi = sarc_members(bfarc)[icons.FONT]
|
||||
otf, key = icons.bfotf_decode(bfarc[lo:hi])
|
||||
if otf not in fonts:
|
||||
fonts[otf] = icons.redraw_font(otf, drawn, KEY_GLYPHS if by_position else ())
|
||||
fonts[otf] = icons.redraw_font(otf, font_drawn, KEY_GLYPHS if by_position else ())
|
||||
outputs[path] = sarc_replace(bfarc, {icons.FONT: icons.bfotf_encode(fonts[otf], key, bfarc[lo:hi])})
|
||||
messages = {}
|
||||
for path in MALS if letter_panes else []:
|
||||
|
||||
@@ -353,6 +353,17 @@
|
||||
# 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. 1: 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 (the default) leaves the left button on
|
||||
# its binding there, one key per controller button. Changes while the game runs.
|
||||
# map_click = 0
|
||||
# The mouse buttons in dialogue, 1.4.3 only. 1: while a dialogue box is open left click presses B (it continues the
|
||||
# text and skips its scroll) and right click presses A, instead of their bindings (Y by default, which opens the
|
||||
# dialogue log, and ZL). Dialogue choices keep the pointer, where left click picks. Works with menu_cursor = 0 too. The
|
||||
# clicks stay B and A for half a second after a box closes, as the game closes the box between two lines of a
|
||||
# conversation. 0 (the default) leaves both buttons on their bindings there, one key per controller button. Changes
|
||||
# while the game runs.
|
||||
# dialogue_click = 0
|
||||
# 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
|
||||
|
||||
Reference in new issue
Block a user