1. scan_pads took a controller Steam hid when the virtual pad was not up yet and kept it for the session, so Steam's
remapping was lost. While the open pad is a hidden one, pad_physical looks again every RESCAN_MS and scan_pads
moves the buttons to the virtual pad; the hidden controller stays open as motion_extra, so motion goes on with
the same bias and orientation.
2. pad_identity marked " (under Steam)" only on motion_extra; a hidden controller that became the pad lost the mark
and could take the bias calibrated with Steam closed. The mark now follows steam_hidden_id.
3. After pull request #1024: sensors_ready logs SDL_GetError when the pad has both sensors but enabling them failed,
instead of "has no gyro and accelerometer".
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
A game Steam starts gets SDL_GAMECONTROLLER_IGNORE_DEVICES with the controllers Steam reads itself and sees Steam's
virtual gamepad, which has no motion sensors. input.c steam_reveal keeps that list and clears the hint before
SDL_Init (only with motion on); scan_pads still takes the virtual pad for buttons and sticks, so Steam's remapping
holds, and motion_source opens the hidden controller for its gyro and accelerometer only. A bias belongs to the pad
as Steam presents it: " (Steam Input)" or " (under Steam)" in gyro_bias_pad. docs/controls.md, "Steam Input and
motion", says the Steam layout must bind the gyro to something or Steam zeroes it on the Steam Controller.
The patch as posted against 6151ac4, with sensors_ready merged with #1274's restart. Tested by the author on Linux
(Steam Controller) and the Steam Deck; not on Windows.
Co-authored-by: St5sz2Jk <St5sz2Jk@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The calibration removes the bias measured once; a bias that moves as the controller warms up, or a controller never
calibrated, still turns the aim slowly. motion_fusion.c drift_track learns it from 256 ms windows in which the gyro
stays within 0.04 rad/s and the acceleration within 0.03 G peak to peak, after half a second of rest, with a time
constant of 0.25 s until the estimate settles and 30 s after. The estimate sits on top of the calibrated bias and is
cleared with a new controller, a new or loaded calibration and a change of gyro_calibration. New setting
gyro_auto_bias (live, default 1).
Taken from #380: the rest window by peak to peak, the two time constants, the per-axis limit. Left out: the
0.006 rad/s dead zone, which ate slow aiming; the one global state shared by every fusion instance; the reset at
every StartSixAxisSensor; the 0.5 G acceleration gate, which let a controller in motion count as still. The first
estimate is limited to 0.1 rad/s from zero instead of 0.15; a larger bias is the calibration's job.
Also: a sample without a reading at a restart (#1274) no longer returns before the calibration's log and save.
--probe-services checks the drift with the switch off and on, after a calibration whose bias then moved, a slow
aim in the hand, and the levelling of #1274 with a bias on every axis.
Co-authored-by: airquark <97342227+airquark@users.noreply.github.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
It acts only with sync_ahead in effect and is on by default there, so a player who turns on sync_ahead gets it; 0 and check stay for comparing. docs/settings.md keeps the row.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The new line is written for wb_eager 0, 1 and check alike, so the stall wb_eager removes can be compared between the settings. It costs a clock read only on the blocking path.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
dlaa_effects_after moves to the Screen tab under the DLSS rows, to [display] in totk.ini and totk.ini.example next
to dlss_char_mask, and vk_dlaa_frame reads it after the dl_active check, so a game without DLSS does no new work
per frame.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
With sync_ahead on, the fence write-back of small GPU-drawn targets that the game reads back still blocked the game thread behind the running frame, about every ninth frame. wb_eager copies those targets into staging at the end of the submission that rendered them, so the write-back at the fence wait needs no GPU wait.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
build_game.py used to reuse build/<ver>'s generated objects only as a whole and only for generated/<ver>, so a private
lift of a patch change (gen.py --out generated/<ver>-prN, build_game.py --gen) compiled all 421 chunks, about 5 min on
12 jobs, for one changed chunk. main_objects now decides per object: same compiler, flags and rule in the main
build.ninja (with the main runtime/ and generated dir in place of ours), main build up to date, and every file the main
compile read according to its Ninja deps log byte-identical on our side and unchanged since the object was written
(NTFS ChangeTime, st_ctime elsewhere), the compiler binaries too. A file new on our side whose name those compiles
included or probed blocks the reuse. Anything unknown compiles. The build prints "reused N of M generated objects",
--verbose lists the rest with the reason; obj/reused.txt lets a later build delete a copied object before compiling it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
recomp/patches-v121.txt gets set fov on the two camera routines the aspect set already patches, at the load of the
camera's vertical view angle (+0x13c): camera update main+0xcb4ad8, camera setup main+0x1252194. The update site matches
1.4.3's instruction for instruction around the load; the setup site copies the camera's fields with other instructions
and registers before it and matches 1.4.3's from the load on. Both call sinf, cosf and tanf in the same order as on
1.4.3. Each version fills sead's perspective projection this way in ten places, each with its counterpart in the other
version: these two camera copies, which are the only places 1.4.3 patches, and eight others (inlined copies, projection
routines and four projections on the stack), none patched. The replacement words are those of the 1.1.0 and 1.4.3 sets
(x10 kept on the stack, s8 overwritten by the next instruction), so no register liveness is assumed. #621 (ipavlin98,
closed by its author) chose the same two sites with x8 and s2 as scratch registers.
The setting's text in totk.ini.example and in the four menu languages names 1.2.1, and the comment of
runtime/resolution.c res_fov_live names the patch files of all three versions.
Co-Authored-By: Claude <noreply@anthropic.com>
The game thread hands its sound commands to the audio thread in lists: 16, of which 4 are always held, so at most 12
wait in the command ring. The game thread submits at most one per update (1.2.1 main+0x9bd144), the audio thread
takes one per 5 ms audio frame (after a list, main+0x883780 goes on past the ring's check). Above about 200 updates a
second the ring stays full. The game's guard (main+0x9bcdc4) counts the updates that find the ring of free lists
empty and exactly 12 lists in the command ring (0x9bce1c cmp w9, #0xc); the count returns to 0 only when a free list
is there. At every multiple of 300 (10 s at 30 fps, 1.25 s at 240) it clears the sound command switch
(main+0x2268bfc) and stops every active voice (main+0x226f29c). Only the switch's constructor sets it to 1
(main+0xf31ce8, from the engine's init main+0xf31530), so the game is silent until it is restarted.
Measured on 1.2.1 (Linux, RX 6750 XT), same save and scripted input, mix dumped without a device: with fps_limit 60,
144, 180, 200 and 201 the mix has sound; with 205, 210, 220, 230, 239 and 240 it goes silent after the boot logo and
stays silent, also at the 130-148 fps of the scene that follows. The guard is read from the code; the switch going
to 0 has not been observed in a run.
The set audiodrain (TOTK_AUDIO_DRAIN_FIX, audio_drain_fix, on by default) sends the audio thread back to the ring's
check after each list, so it takes every queued list in the pass: one site per version (1.2.1 main+0x883780, 1.4.3
main+0x149244), each going to a target the game's own code already branches to in the same way (1.2.1 main+0x883c18,
1.4.3 main+0x149700). The setting is in runtime/cfg.c, totk.ini.example and docs/settings.md.
At fps_limit 240, 120 s runs of one build per game version with the set switched, seconds with sound in the mix: on
1.2.1 5 of 118 with the set off and 108 of 118 with it on; on 1.4.3 2 of 118 off and 110 of 119 on. Not run:
Windows. Not covered: 1.1.0, whose main we do not have, so its table has no site and it keeps the game's code.
Co-Authored-By: Claude <noreply@anthropic.com>
plugin_init.c reads TOTK_PLUGIN_TRACE through cfg_bool, which stops the game when the key is unset and metas[] has no
row. Every test run set the key, so only a plain start hit it. tests/settings_doc_check.py now fails on any
cfg_value/cfg_int/cfg_double/cfg_bool reading without a metas[] row that is not guarded by cfg_get of the same key.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/build_game.py --portable writes build.ninja paths on the tools' drive relative to the kit, also through '..'
(the generated C and objects in build-cache/work), names the compiler, windres and ar the same way (backslashes:
CreateProcess does not find a relative program with forward slashes), and passes clang -resource-dir and --sysroot
relative to the kit, because clang names its own headers by its absolute folder whatever argv[0] says. The Ninja deps
log then holds no absolute path. installer/steps.py build_args passes --portable for the build kit.
Measured on an install moved after a portable build: the rebuild compiled modules.c only, 3.5 s; before, the move cost
a full compile of 430 objects (335 s on 12 cores). Without --portable build.ninja is byte-identical to before.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The rebuild for ExeFS patches, code cheats and mod plugins ran the setup window from the setup folder, whose absolute
path build-cache/rebuild.txt held, with the generated C and objects in that folder's temp/. A moved or deleted setup
folder left code mods without a rebuild.
- A new Kit step after the check copies the release folder without TotK-Setup.exe into <game>/build-kit
(installer/layout.py KIT_ITEMS), and every later step runs its tools from there. A newer setup replaces the kit,
the kit's own rebuild keeps it.
- The release's temp folder is <game>/build-cache/work, so the lift cache and the objects stay with the game.
- rebuild.txt names the kit relative to the game folder; runtime/cheats.c and runtime/romfs.c resolve relative
entries against the exe's folder.
- runtime_key drops the lines of clang --version that name its folder, so a rebuild from the kit or a moved game
folder keeps the compile and prepare steps the setup recorded.
- An update over an install of an older setup moves that setup's temp folder into build-cache/work when both are on
one disk.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Per-plugin service runs (a refused, crashed or hung plugin costs only itself) and four fixes the real setup path
needed: plugin_init.c compiled per install, the service run's DLLs beside its exe, module tables sized for plugins in
the runtime library, and a failed plugin stage rerun after a fixed release. Checked with a release install: The
Second Quest built in and played with 7 hooks on, and removed again.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Removing a plugin mod left its module in the layout: the loader skipped the missing file and the game ran, but the
rebuild that drops the plugin never came. The loader counts layout plugins whose file no longer exists
(ldr_plugins_gone) and rebuild_if_needed treats them like files waiting for the rebuild. A changed file was already
pending through its mod's status line. On the 1.4.3 install: The Second Quest removed, the start asked for the
rebuild, the setup lifted and compiled the no-plugin build in 30.5 s, the game reached gameplay.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
loader.c and memory.c sized their tables by MOD_COUNT of the layout.h make_release.py built libtotkrt.a against (3:
main, subsdk0, sdk). An install whose rebuild adds a plugin has 4, and its service run stopped at once with "loader: 4
modules in the layout"; dev builds compile those files against their own layout and never saw it. RT_MAX_MODULES
(host.h) is the bound now; the loader still refuses a layout above it.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After warn.plugins_skipped the lift key still matched its inputs, so the next setup run (with the fixed release) found
lift and compile current and never built the plugin. installer/steps.py runs that stage, so it joins the key when the
mods hold a plugin.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
On the release path the service run's totk.exe in <temp>/build stopped before main with 0xc0000135 (SDL3.dll not
found): the DLLs are copied next to totk.exe in the install folder only by the compile step, after the lift. Every
plugin was skipped with warn.plugins_skipped. The fake-tool tests did not see it; installer_test now checks the copy.
exefs_plugins_test covers run()'s hang and crash reasons.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
DLSS ran at the bloom, after the volumetric fog composite and the particle pass. Neither has motion vectors or jitter
of its own, and DLSS wiped out the smallest motes. In DLAA mode DLSS now runs right after the deferred lighting: the
light target is the G-buffer's scene colour target, the lighting is the first pass into it after the G-buffer, with
a D16 depth, and the first pass into it with any other depth (the scene's, none, or the D16 of an ability's highlight)
is an effect. The order of the effects changes from frame to frame (the yard's half-size effects pass is in some
frames only; with Ultrahand or Ascend open the highlight comes before or after the fog layer), and rules that waited
for one of them, or took any D16 pass for the lighting, flickered. As a safety net the point is used only after it
held for 60 frames with nothing of the scene drawn after it; otherwise DLSS stays at the bloom.
dlaa_effects_after (Advanced tab, Render fixes, default 1, live) turns it off. The upscaling DLSS modes are unchanged.
plugins_start returned before clearing mem_query_hook and rt_process_memory when no plugin's set was on (the mod off,
removed, or its file changed), so the game ran with the service run's view of memory: host ranges Inaccessible, the
rtld stand-in below main.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
tools/exefs_plugins.py ran every plugin's init in one service run and refused them all when one was refused. Now a run
without inits lists the plugin modules, then each plugin runs in service runs of its own (TOTK_PLUGIN_ONLY, the others
stay loaded): a refused svc, a crash (the FATAL line is the reason), a timeout or a failed check refuses that plugin
alone, with its reason in plugins.status; the rest are built in. 4 plugins take 2.3 s.
At start, plugins_start compares each plugin right after its own init and takes its branches out of main's .text before
the next one, so each init sees the game's bytes, as in its service run. Only that init's aliases are flushed: the
start stays at 113 ms for Full Inventory Expansion + Quick Weapon Durability (107 ms before).
The installer's second lift keeps every plugin of the service runs in the layout when one is built: the records hold
that layout's addresses. A refused plugin stays loaded and never starts. A mod with a built plugin and a refused one,
used without its code, runs the built one (mods.c; --probe-mods case T).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
make_release.py stopped at the runtime library: plugin_init.c includes patches.h, a per-version header, so the library
build refused it. Built per install like patches.c, it sees the RT_PLUGINS and RT_PLUGIN_WRITES of the install's own
rebuild.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>