diff --git a/docs/controls.md b/docs/controls.md
index 12c4d7c0..ad2de67c 100644
--- a/docs/controls.md
+++ b/docs/controls.md
@@ -90,7 +90,31 @@ bind_Y = pad:north, key:mouse_l
## Mouse camera
-Mouse motion (raw input) becomes right-stick deflection. Each presented frame takes the counts moved since the last frame, divides by the frame time and sets the deflection to `counts per second * TOTK_MOUSE_SENS / 3000` of full, held for that frame, so the turn rate does not depend on the frame rate. This is not mouselook: the game's stick curve and dead zone still apply, so very slow movements do nothing and a fast flick saturates. The mouse deflection competes with the gamepad and arrow keys by the larger-deflection rule.
+`mouse_mode = direct` enables experimental mouse hooks on game 1.4.3. The free-orbit camera receives raw-count
+angular increments at its final spherical-angle output: 0.08 degrees per count on both axes at sensitivity 1, with
+no time multiplier, curve or carry into later frames. The controller's persistent pitch/yaw move with the output.
+Mouse input is removed from its stick path first, so the camera's later vertical signed-square curve and velocity
+filters cannot process it a second time. Other camera modes receive input after the radial dead zone, unit-circle
+clamp and stick response exponent; Ultrahand has a separate hook after its manipulation input's power curves.
+The game's camera inversion and gamepad response remain in effect. `mouse_sens` scales raw counts; its scale
+differs from the stick-emulation mode. Start at 1.
+The Controls tab can switch between *Stick emulation* (the default, `mouse_mode = stick`) and *Direct (experimental)*.
+The orbit camera keeps its desired pitch at the final angular output, including stationary frames, so a later game
+filter cannot recenter it. The persistent filter state accounts for the camera's current vertical offset instead of
+accumulating corrections. A gamepad vertical input or the game's lock-on/override releases that mouse target.
+While L is held, mouse counts move the ability wheel's virtual cursor, which stays where it was when the mouse stops.
+The horizontal quick lists (D-pad up/left/right: materials, shields and weapons) use separate 32 ms right-stick steps,
+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.
+With a held object, three substantial reversals on one mouse axis, with at most 400 ms between strokes, begin a
+short stick-shake gesture for the game's own detach detector. Those gesture pulses are excluded from camera and object movement input.
+The mapping below is still used when the camera-input hook is unavailable or the game disables camera input.
+This hook needs in-game checks of aiming, Ultrahand and menu transitions before it can be considered complete mouse
+support. Games 1.1.0 and 1.2.1 have no hook and keep stick emulation.
+
+In stick-emulation mode, mouse motion (raw input) becomes right-stick deflection. Each presented frame takes the counts moved since the last frame, divides by the frame time and sets the deflection to `counts per second * TOTK_MOUSE_SENS / 3000` of full, held for that frame, so the turn rate does not depend on the frame rate. This is not mouselook: the game's stick curve and dead zone still apply, so very slow movements do nothing and a fast flick saturates. The mouse deflection competes with the gamepad and arrow keys by the larger-deflection rule.
`TOTK_MOUSE_SENS` (0 to 10, default 1; higher turns faster, 0 turns the mouse camera and the cursor capture off). While the window is the foreground window the cursor is hidden and confined to the client area. It is released on focus loss, minimise, while F11 changes the window, during a size or move loop and while a text entry is open. Esc releases it by hand: the cursor shows, the mouse camera and mouse buttons stop, and the window can be moved, minimised or closed. A mouse click inside the client area captures it again; that click does not reach the game. Activating the window by a click on its title bar or border does not capture, so it can be dragged or closed right away; Alt+Tab or a click in the client area captures as before. `TOTK_INPUT=none` disables the capture too.
@@ -111,14 +135,20 @@ Bridges that output a ViGEm DualShock 4 (ProCon2Windows, connectyourpro as teste
```
[hold_frames] # A B X Y L R ZL ZR PLUS MINUS LEFT UP RIGHT DOWN LCLICK RCLICK; hold defaults to 4
LSTICK|RSTICK [hold_frames] # -32767..32767, up is +y
+ MOUSE # direct-mode raw counts, once; down is +dy
@ [hold_ms] # timed on the world clock
@ LSTICK|RSTICK [hold_ms]
+@ MOUSE
```
` ` 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. `@` 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.
`TOTK_INPUT_RECORD=` (`input_record` in `totk.ini`, or Input recording in the menu) writes the merged input in the same format, one line per button press and per stick segment: events before the world clock starts by tick, the rest timed; a button or stick held when the world clock starts is cut there and goes on as a timed event. The file replays as a script, which makes it the repro to attach to a bug report.
+In direct mouse mode the recording also writes one `MOUSE` event per consumed raw displacement. These are one-shot
+displacements rather than held stick segments. They replay without cursor capture, including with `input = none`;
+the game must be accepting camera input when the event reaches its camera update.
+
`TOTK_TEST_PAD=,,,` attaches an SDL virtual gamepad at start whose sticks rest at these raw SDL axis values (-32768 to 32767, down is +y), so a drifting or held stick can be tested without a controller: the values go through the gamepad mapping and `TOTK_STICK_DEADZONE` like a real pad's, and `TOTK_INPUT_RECORD` shows what reached the game.
## RenderDoc capture (blocked)
diff --git a/recomp/patches-v143.txt b/recomp/patches-v143.txt
index 9c85fb7f..c4b3bffd 100644
--- a/recomp/patches-v143.txt
+++ b/recomp/patches-v143.txt
@@ -103,6 +103,16 @@ set fov TOTK_FOV_PATCH 0
site fov main 628c3c bd413e60 f81f0fea @page:x10 bd413e60 bd403d48 1e280800 f84107ea # ldr s0, [x19, #0x13c] (camera update)
site fov main b4342c bd4066c0 f81f0fea @page:x10 bd4066c0 bd403d48 1e280800 f84107ea # ldr s0, [x22, #0x64] (camera setup)
+# The camera input update, after its stick dead zone, unit-radius clamp and StickExponent. The host callback
+# performs the displaced store and adds raw mouse counts to s9/s10 (runtime/mouse_direct.c camera_input).
+# Its address is page +0xfd0; the page is main+0x3adf000 on this verified build.
+set mouse_direct TOTK_MOUSE_DIRECT_PATCH 1
+site mouse_direct main 874cb4 bd042289 94c9acc7
+site mouse_direct main 874d7c 6d40a3e9 94c9ac91
+site mouse_direct main 18e444 f9400408 94e546db
+site mouse_direct main 18f108 bd4047ec 94e543a6
+site mouse_direct main 1d59460 b9004be8 94761acc
+
# The game's zstd decoder (BSD zstd, statically linked into main) through the host's libzstd (runtime/ov_zstd.c):
# every call of ZSTD_decompressMultiFrame (main+0x3a1f0: dctx, dst, capacity, src, size, dict, dict size, ddict) and of
# its wrapper ZSTD_decompress_usingDDict (main+0x3a1e0, which tail-branches to it) goes to a host function on the patch
diff --git a/runtime/cfg.c b/runtime/cfg.c
index de418f3c..d09a2366 100644
--- a/runtime/cfg.c
+++ b/runtime/cfg.c
@@ -43,7 +43,7 @@ static const char *const known[] = {
"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", "LANG", "LIB_PREBUILD",
"LIB_PREBUILD_KEEP", "LIB_PREBUILD_THREADS", "LOCALE", "LOD_GUARD", "LSTICK_DEADZONE", "MEMORY", "MENU_LANG", "MENU_TEST",
- "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MOTION", "MOUSE_SENS", "MOVIE_HOST", "MOVIE_PACE",
+ "MENU_TEST_DIR", "MENU_TEST_SET", "MINIMAL_LAYOUT", "MIRROR_GAP", "MODS_DIR", "MODS_DISABLED", "MODS_ORDER", "MODS_REBUILD", "MOTION", "MOUSE_MODE", "MOUSE_DIRECT_PATCH", "MOUSE_SENS", "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",
"ONE_PER_CORE", "OPERATION_MODE", "OUTPUT_RES", "PAD_LAYOUT", "PASS_CRUMBS", "PATCH_OUTPUT", "PATCH_SCENE", "PCSS", "PCSS_K", "PERF_OVERLAY", "PERF_SLOW_MS", "PIPELINE_CACHE", "PIPE_MEMO", "PIPE_PREBUILD", "PIPE_SKIP", "PIPE_SYNC", "PIPE_WAIT",
@@ -83,7 +83,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"},
- {"MOUSE_SENS", "input"}, {"WALK_KEY", "input"}, {"WALK_SCALE", "input"}, {"INPUT_RECORD", "input"},
+ {"MOUSE_MODE", "input"}, {"MOUSE_SENS", "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"},
@@ -147,6 +147,7 @@ static const CfgMeta metas[] = {
{"PROMPTS", "nintendo", "nintendo|xbox", RESTART},
{"STICK_DEADZONE", "8", "0..50", LIVE}, {"STICK_SENS", "1", "0.1..3", RESTART},
{"LSTICK_DEADZONE", "", "0..50", LIVE}, {"RSTICK_DEADZONE", "", "0..50", LIVE},
+ {"MOUSE_MODE", "stick", "stick|direct", LIVE},
{"MOUSE_SENS", "1", "0..10", LIVE},
{"WALK_KEY", "none", NULL, LIVE}, {"WALK_SCALE", "0.51", "0.2..0.9", LIVE},
{"MENU_LANG", "", "en|ru|pt-BR|zh-Hans", LIVE},
diff --git a/runtime/input.c b/runtime/input.c
index e51a1e54..581054d5 100644
--- a/runtime/input.c
+++ b/runtime/input.c
@@ -26,6 +26,7 @@ enum { STICK_MAX = 32767, STICK_DIR = 16384, TRIGGER_ON = 16384, RESCAN_MS = 100
static PlatMutex lock = PLAT_MUTEX_INIT;
static int state; // 0 not started, 1 running, -1 disabled or SDL failed
+static volatile int32_t g_block, g_menu; // text entry / host menu: 0 off, 1 open, 2 waiting for release
static SDL_Gamepad *pad;
static uint64_t next_scan;
static int pad_rumble; // the open gamepad has rumble motors
@@ -66,6 +67,7 @@ static const struct { const char *name; int bit; } script_buttons[] = {
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 void script_load(void) {
script_state = 1;
@@ -88,10 +90,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, "LSTICK") || !strcmp(name, "RSTICK")) {
+ 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] == 'L' ? 1 : 2; e.x = (int32_t)a; e.y = (int32_t)b;
+ e.stick = name[0] == 'M' ? 3 : name[0] == 'L' ? 1 : 2; e.x = (int32_t)a; e.y = (int32_t)b;
+ if (e.stick == 3) e.hold = 1; // a displacement, never a held speed
if (n >= 3 && c > 0) e.hold = (uint64_t)(c * unit + 0.5);
snprintf(e.text, sizeof e.text, "%s %d %d", name, e.x, e.y);
} else {
@@ -123,12 +126,17 @@ static void script_apply(uint64_t *b, int32_t sl[2], int32_t sr[2]) {
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;
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) { int32_t *s = e->stick == 1 ? sl : sr; s[0] = e->x; s[1] = e->y; }
+ 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);
+ } else if (e->stick) { int32_t *s = e->stick == 1 ? sl : sr; s[0] = e->x; s[1] = e->y; }
else *b |= 1ull << e->bit;
}
}
@@ -223,6 +231,30 @@ static void rec_apply(uint64_t b, const int32_t sl[2], const int32_t sr[2]) {
if (wrote) fflush(rec);
}
+void input_direct_mouse_sample(int enabled, int32_t *dx, int32_t *dy) {
+ plat_mutex_lock(&lock);
+ enabled = enabled && !g_block && !g_menu;
+ *dx = script_mouse[0]; *dy = script_mouse[1];
+ script_mouse[0] = script_mouse[1] = 0;
+ if (!enabled) { *dx = *dy = 0; }
+ else if (ikb_captured() && ikb_foreground() && input_cursor_allowed()) {
+ int32_t x, y;
+ ikb_mouse_take(&x, &y);
+ int64_t sx = (int64_t)*dx + x, sy = (int64_t)*dy + y;
+ *dx = (int32_t)(sx < INT32_MIN ? INT32_MIN : sx > INT32_MAX ? INT32_MAX : sx);
+ *dy = (int32_t)(sy < INT32_MIN ? INT32_MIN : sy > INT32_MAX ? INT32_MAX : sy);
+ }
+ if (enabled && (*dx || *dy) && rec_state == 1) {
+ char what[80];
+ snprintf(what, sizeof what, "MOUSE %d %d", *dx, *dy);
+ int64_t w = frame_step_world_us();
+ uint64_t tick = frame_step_ticks();
+ rec_line(tick, w, tick + 1, w, what);
+ fflush(rec);
+ }
+ plat_mutex_unlock(&lock);
+}
+
static float mouse_sens = -1; // TOTK_MOUSE_SENS, 0 = mouse camera off; live (cfg_version)
static unsigned mouse_sens_seen;
@@ -282,15 +314,41 @@ static void walk_get(void) {
}
}
-// The mouse camera as a right-stick sample, held for the whole presented frame. Under `lock`. The sample is divided by
-// the camera speed factor the game runs with (camera_speed.c, cam_speed_applied), which multiplies every right-stick
-// turn rate, so TOTK_MOUSE_SENS alone sets the mouse's speed; below 1 the sample stays within the stick's range, so the
-// mouse's top speed drops with the factor.
-static void mouse_camera(int32_t out[2]) {
+static int mouse_selector;
+int input_direct_mouse_selector_active(void) { return __atomic_load_n(&mouse_selector, __ATOMIC_RELAXED) != 0; }
+
+// Selector 1 is a radial wheel, 2..4 are distinct horizontal quick lists; only a wheel retains a virtual cursor.
+// Under `lock`.
+static void mouse_camera(int32_t out[2], int selector) {
static uint64_t frame = ~0ull, t0;
static int32_t held[2];
+ static int was_selector;
+ static float cursor[2];
+ static InputMouseRow row;
uint64_t now = plat_now_ns();
int32_t dx, dy;
+ if (!input_direct_mouse_enabled() || !ikb_captured()) selector = 0;
+ __atomic_store_n(&mouse_selector, selector, __ATOMIC_RELAXED);
+ if (selector) {
+ if (was_selector != selector) cursor[0] = cursor[1] = 0, row = (InputMouseRow){0};
+ was_selector = selector;
+ ikb_mouse_take(&dx, &dy);
+ if (selector == 1) input_direct_mouse_radial(dx, dy, mouse_sens_get(), cursor, out);
+ else input_direct_mouse_row(dx, mouse_sens_get(), now, &row, out);
+ held[0] = held[1] = 0; frame = ~0ull;
+ return;
+ }
+ if (was_selector) {
+ was_selector = 0; cursor[0] = cursor[1] = 0; row = (InputMouseRow){0};
+ ikb_mouse_take(&dx, &dy); // release the wheel without sending its last movement to the camera
+ held[0] = held[1] = out[0] = out[1] = 0; frame = ~0ull;
+ return;
+ }
+ if (input_direct_mouse_active()) {
+ held[0] = held[1] = out[0] = out[1] = 0;
+ frame = ~0ull;
+ return; // the camera update takes the raw counts itself, once, outside the HID stick path
+ }
if (!ikb_captured()) {
ikb_mouse_take(&dx, &dy);
held[0] = held[1] = 0;
@@ -530,11 +588,18 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
input_map_stick(down, 1, k);
if (walk) k[0] = (int32_t)(k[0] * walk_scale), k[1] = (int32_t)(k[1] * walk_scale);
pick(&sr[0], &sr[1], k[0], k[1]);
- mouse_camera(k);
+ int selector = b & (1ull << B_L) ? 1 : b & (1ull << B_UP) ? 2 :
+ b & (1ull << B_LEFT) ? 3 : b & (1ull << B_RIGHT) ? 4 : 0;
+ mouse_camera(k, selector);
pick(&sr[0], &sr[1], k[0], k[1]);
}
}
script_apply(&b, sl, sr);
+ int32_t shake[2];
+ int wheel = (b & ((1ull << B_L) | (1ull << B_UP) | (1ull << B_LEFT) | (1ull << B_RIGHT))) != 0;
+ if (input_direct_mouse_shake(!wheel && !sr[0] && !sr[1] && !g_menu && !g_block, shake)) {
+ sr[0] = shake[0]; sr[1] = shake[1];
+ }
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;
@@ -554,8 +619,6 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
// Text entry (swkbd_*.c): while it is open the game reads no input, as behind the keyboard applet; after it closes
// the game reads none until every button and stick direction is released, so the press that closed it stays there.
// g_block: 0 off, 1 text entry open, 2 closed, waiting for the release. The cursor is released while it is open.
-static volatile int32_t g_block;
-static volatile int32_t g_menu; // the in-game menu, the same way (input_menu)
// When g_block and g_menu last went to 2 (plat_now_ns). The wait for the release ends after RELEASE_WAIT_NS even with
// something held: an input that never reads as released (a button another program holds down, a key whose release
// went to another window, a stick that rests outside its dead zone) would otherwise keep the game deaf until restart
diff --git a/runtime/input.h b/runtime/input.h
index 36ca52a0..eea48179 100644
--- a/runtime/input.h
+++ b/runtime/input.h
@@ -6,6 +6,22 @@
// Down=15) and the stick directions (StickLLeft..Down 16-19, StickRLeft..Down 20-23, derived from the sticks).
// Sticks are -32767..32767, up is +y. TOTK_INPUT=none reports no input. Callable from any thread.
void input_poll(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx, int32_t *ry);
+// Direct mouse input is consumed by the game's camera-input update, after its stick response. While that update
+// accepts camera input, the HID right stick contains only the controller and keyboard. Selectors route mouse input
+// separately: a persistent radial cursor for the ability wheel, discrete steps for horizontal quick lists.
+int input_direct_mouse_active(void);
+int input_direct_mouse_enabled(void);
+// A radial selector uses a persistent virtual cursor while its opening button is held.
+void input_direct_mouse_radial(int32_t dx, int32_t dy, float sensitivity, float cursor[2], int32_t out[2]);
+// Horizontal quick selectors receive short, separated steps instead of a latched radial-cursor direction.
+typedef struct { float distance; uint64_t pulse_until, neutral_until; int direction; } InputMouseRow;
+void input_direct_mouse_row(int32_t dx, float sensitivity, uint64_t now, InputMouseRow *row, int32_t out[2]);
+int input_direct_mouse_selector_active(void);
+// A deliberate mouse shake while manipulating an object feeds a short gesture to the game's native shake detector.
+int input_direct_mouse_shake(int allow, int32_t out[2]);
+// Consume direct mouse counts, including one-shot MOUSE events from an input script. enabled=0 discards scripted
+// counts while leaving the real mouse for menu input. Live counts require cursor capture and foreground focus.
+void input_direct_mouse_sample(int enabled, int32_t *dx, int32_t *dy);
// 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);
diff --git a/runtime/mouse_direct.c b/runtime/mouse_direct.c
new file mode 100644
index 00000000..69a6ff1e
--- /dev/null
+++ b/runtime/mouse_direct.c
@@ -0,0 +1,383 @@
+// Direct mouse input for TotK 1.4.3. The camera controller's input update (main+0x874c1c) turns HID stick floats
+// into a radial dead zone, clamps the radius to one and applies StickExponent. The mouse enters after all three,
+// at main+0x874cb4, before the game's X/Y inversion and input-activity flags. It never becomes a HID stick value.
+// Free orbit removes that sample again before the camera's additional vertical square/velocity filters and adds
+// raw-count angular deltas at its spherical-angle output instead. Ultrahand has a separate post-curve hook.
+// The ordinary stick's result stays, so a controller still uses the game's own response.
+//
+// This is deliberately not a render-camera override: the game remains responsible for aiming, camera collision,
+// lock-on and scripted cameras. Which of its other modes consume this camera input needs in-game verification.
+#include
+#include
+#include
+#include
+
+#include "cfg.h"
+#include "host.h"
+#include "input.h"
+#include "input_wsys.h"
+#include "platform/platform.h"
+
+#if __has_include("patches.h")
+#include "patches.h"
+#endif
+
+static int direct_mode(void) {
+ const char *mode = cfg_get("TOTK_MOUSE_MODE");
+ return mode && !strcmp(mode, "direct") && rt_patch_enabled(rt_patch_set("mouse_direct"));
+}
+
+static uint64_t last_update;
+static uint64_t hand_update;
+static uint64_t shake_started, shake_until;
+static int shake_injected;
+static int accepts_mouse;
+
+static int hand_active(uint64_t now) {
+ uint64_t last = __atomic_load_n(&hand_update, __ATOMIC_ACQUIRE);
+ return last && now - last < 150000000ull;
+}
+
+int input_direct_mouse_active(void) {
+ uint64_t last = __atomic_load_n(&last_update, __ATOMIC_ACQUIRE);
+ return direct_mode() && (__atomic_load_n(&accepts_mouse, __ATOMIC_RELAXED) || hand_active(plat_now_ns())) && last &&
+ plat_now_ns() - last < 150000000ull;
+}
+
+int input_direct_mouse_enabled(void) { return direct_mode(); }
+
+void input_direct_mouse_radial(int32_t dx, int32_t dy, float sensitivity, float cursor[2], int32_t out[2]) {
+ if (!(sensitivity > 0)) { cursor[0] = cursor[1] = 0; out[0] = out[1] = 0; return; }
+ cursor[0] += dx * (double)sensitivity / 200;
+ cursor[1] -= dy * (double)sensitivity / 200;
+ double length = hypot(cursor[0], cursor[1]);
+ if (length > 1) { cursor[0] /= length; cursor[1] /= length; }
+ out[0] = (int32_t)lrint(cursor[0] * 32767);
+ out[1] = (int32_t)lrint(cursor[1] * 32767);
+}
+
+void input_direct_mouse_row(int32_t dx, float sensitivity, uint64_t now, InputMouseRow *row, int32_t out[2]) {
+ const float step_counts = 32;
+ out[0] = out[1] = 0;
+ if (!(sensitivity > 0)) { *row = (InputMouseRow){0}; return; }
+ if (dx) {
+ // Reversing direction cancels any remainder from the previous drag. Bound a fast flick to one pending step;
+ // a stopped mouse never starts another pulse, regardless of how often HID is polled.
+ if ((dx < 0 && row->distance > 0) || (dx > 0 && row->distance < 0)) row->distance = 0;
+ row->distance = fmaxf(-2 * step_counts, fminf(2 * step_counts, row->distance + dx * sensitivity));
+ }
+ if (row->direction) {
+ if (now < row->pulse_until && (!dx || (dx > 0 ? 1 : -1) == row->direction)) {
+ out[0] = row->direction * 32767;
+ return;
+ }
+ row->direction = 0;
+ row->neutral_until = now + 32000000ull;
+ return; // publish neutral even when a slow frame skipped the pulse's deadline
+ }
+ if (!dx || now < row->neutral_until || fabsf(row->distance) < step_counts) return;
+ row->direction = row->distance > 0 ? 1 : -1;
+ row->distance = fmodf(row->distance, step_counts);
+ row->pulse_until = now + 32000000ull;
+ out[0] = row->direction * 32767;
+}
+
+int input_direct_mouse_shake(int allow, int32_t out[2]) {
+ uint64_t now = plat_now_ns(), until = __atomic_load_n(&shake_until, __ATOMIC_ACQUIRE);
+ uint64_t start = __atomic_load_n(&shake_started, __ATOMIC_RELAXED);
+ int ready = allow && direct_mode() && hand_active(now) && ikb_captured() && ikb_foreground() && input_cursor_allowed();
+ if (!ready) __atomic_store_n(&shake_until, 0, __ATOMIC_RELEASE);
+ int active = ready && now >= start && now < until;
+ out[0] = active ? ((now - start) / 40000000ull & 1 ? -32767 : 32767) : 0;
+ out[1] = 0;
+ __atomic_store_n(&shake_injected, active, __ATOMIC_RELAXED);
+ return active;
+}
+
+#ifdef RT_PATCH_PAGE
+#define HOST_MOUSE_DIRECT (RT_PATCH_PAGE + 0xfd0)
+#define HOST_MOUSE_ACTIVITY (RT_PATCH_PAGE + 0xfc0)
+#define HOST_MOUSE_ORBIT_BEGIN (RT_PATCH_PAGE + 0xfb0)
+#define HOST_MOUSE_ORBIT_ANGLES (RT_PATCH_PAGE + 0xfa0)
+#define HOST_MOUSE_HAND (RT_PATCH_PAGE + 0xf90)
+static _Thread_local uint64_t mouse_input_object;
+
+typedef struct {
+ uint64_t object, generation, when;
+ float pad[2], motion[2], angle[2]; // post-inversion controller input, mouse input, mouse yaw/pitch in degrees
+ int camera_enabled;
+} MouseSample;
+static MouseSample sample;
+static PlatMutex sample_lock = PLAT_MUTEX_INIT;
+static _Thread_local struct { uint64_t object; MouseSample mouse; } orbit;
+typedef struct {
+ uint64_t object, generation, input;
+ float pitch, original_target;
+ int hold_pitch, target_saved;
+} OrbitTrack;
+static OrbitTrack orbit_seen[16];
+
+// sample_lock held. Camera objects can coexist while the game blends between their outputs.
+static OrbitTrack *orbit_track(uint64_t object) {
+ int oldest = 0;
+ for (int i = 0; i < 16; i++) {
+ if (orbit_seen[i].object == object) return &orbit_seen[i];
+ if (orbit_seen[i].generation < orbit_seen[oldest].generation) oldest = i;
+ }
+ orbit_seen[oldest] = (OrbitTrack){.object = object};
+ return &orbit_seen[oldest];
+}
+
+static int orbit_sample_once(uint64_t object, uint64_t generation) {
+ plat_mutex_lock(&sample_lock);
+ OrbitTrack *track = orbit_track(object);
+ int fresh = track->generation != generation;
+ if (fresh) track->generation = generation;
+ plat_mutex_unlock(&sample_lock);
+ return fresh;
+}
+
+static float guest_float(uint64_t at) { float f; memcpy(&f, (void *)(uintptr_t)at, sizeof f); return f; }
+static void guest_float_store(uint64_t at, float f) { memcpy((void *)(uintptr_t)at, &f, sizeof f); }
+static uint64_t guest_pointer(uint64_t at) { uint64_t p; memcpy(&p, (void *)(uintptr_t)at, sizeof p); return p; }
+static MouseSample sample_read(void) {
+ plat_mutex_lock(&sample_lock);
+ MouseSample m = sample;
+ plat_mutex_unlock(&sample_lock);
+ return m;
+}
+static float wrap_degrees(float a) { return remainderf(a, 360.0f); }
+
+// main+0x191d78 builds the pitch target from +0x15c and +0x11c; the orbit update filters +0x108 toward it and adds
+// (1 - +0x88) * +0x10c at output. Updating only +0x108 makes the camera spring back to the unchanged target.
+static float orbit_pitch_offset(uint64_t object) {
+ return (1 - guest_float(object + 0x88)) * guest_float(object + 0x10c);
+}
+
+static void orbit_pitch_target(uint64_t object, float pitch) {
+ guest_float_store(object + 0x15c, pitch - orbit_pitch_offset(object) - guest_float(object + 0x11c));
+}
+
+static void orbit_pitch_release(OrbitTrack *track) {
+ if (track->target_saved) guest_float_store(track->object + 0x15c, track->original_target);
+ track->hold_pitch = track->target_saved = 0;
+}
+
+static void mouse_shake_feed(int32_t dx, int32_t dy, uint64_t now) {
+ static struct { int sign, confirmed, reversals; double distance; uint64_t last; } stroke[2];
+ static uint64_t cooldown;
+ if (!hand_active(now)) { memset(stroke, 0, sizeof stroke); return; }
+ if (now < cooldown) return;
+ int32_t delta[2] = {dx, dy};
+ for (int i = 0; i < 2; i++) {
+ if (!delta[i]) continue;
+ if (stroke[i].last && now - stroke[i].last > 400000000ull) memset(&stroke[i], 0, sizeof stroke[i]);
+ int sign = delta[i] > 0 ? 1 : -1;
+ if (sign != stroke[i].sign) stroke[i].sign = sign, stroke[i].distance = 0;
+ stroke[i].distance += fabs((double)delta[i]);
+ if (stroke[i].distance < 24) continue;
+ if (stroke[i].confirmed && sign != stroke[i].confirmed) stroke[i].reversals++;
+ stroke[i].confirmed = sign;
+ stroke[i].last = now;
+ stroke[i].distance = 0;
+ if (stroke[i].reversals >= 3) {
+ __atomic_store_n(&shake_started, now, __ATOMIC_RELAXED);
+ __atomic_store_n(&shake_until, now + 320000000ull, __ATOMIC_RELEASE);
+ cooldown = now + 700000000ull;
+ memset(stroke, 0, sizeof stroke);
+ rt_log("mouse: detach shake gesture sent to the game's stick-shake detector");
+ return;
+ }
+ }
+}
+
+// A host call at an instruction site, not an AAPCS64 function replacement. Preserve every guest register except
+// s9/s10, which carry the processed camera input, and perform the displaced store of s9 at [x20 + 0x420].
+static void camera_input(Cpu *c) {
+ mouse_input_object = 0;
+ uint32_t flags = (uint32_t)c->x[21];
+ int accept = !(flags & 1) && !input_direct_mouse_selector_active();
+ __atomic_store_n(&accepts_mouse, accept, __ATOMIC_RELAXED);
+ __atomic_store_n(&last_update, plat_now_ns(), __ATOMIC_RELEASE);
+ if (direct_mode() && __atomic_load_n(&shake_injected, __ATOMIC_RELAXED)) {
+ c->v[9] = c->v[10] = 0; // discrete shake pulses are for the game's gesture detector, not the camera
+ }
+ MouseSample next = {.object = c->x[20], .when = plat_now_ns(), .camera_enabled = accept};
+ memcpy(&next.pad[0], &c->v[9], sizeof(float));
+ memcpy(&next.pad[1], &c->v[10], sizeof(float));
+ if (flags & 2) next.pad[0] = -next.pad[0];
+ if (flags & 4) next.pad[1] = -next.pad[1];
+ if (direct_mode()) {
+ int32_t dx, dy;
+ input_direct_mouse_sample(!input_direct_mouse_selector_active() && (accept || hand_active(plat_now_ns())), &dx, &dy);
+ float sensitivity = (float)cfg_double("TOTK_MOUSE_SENS");
+ sensitivity = fminf(10, fmaxf(0, sensitivity));
+ // The game multiplies camera input by its 30 Hz frame ratio later. Divide by that exact ratio, rather
+ // than wall-clock time: an equal distance of mouse motion then gives equal input at every frame rate.
+ float ratio = 1;
+ if (frame_step_realtime()) memcpy(&ratio, rt_patch_page(), sizeof ratio);
+ else {
+ double hz = frame_step_limit_hz();
+ if (hz > 0) ratio = (float)(30 / hz);
+ }
+ if (isfinite(ratio) && ratio > 0 && sensitivity > 0 && (dx || dy)) {
+ mouse_shake_feed(dx, dy, plat_now_ns());
+ if (accept) mouse_input_object = c->x[20];
+ float x, y;
+ memcpy(&x, &c->v[9], sizeof x);
+ memcpy(&y, &c->v[10], sizeof y);
+ float scale = 0.01f * sensitivity / ratio;
+ next.motion[0] = dx * scale * (flags & 2 ? -1 : 1);
+ next.motion[1] = -dy * scale * (flags & 4 ? -1 : 1);
+ next.angle[0] = -dx * 0.08f * sensitivity * (flags & 2 ? -1 : 1);
+ next.angle[1] = dy * 0.08f * sensitivity * (flags & 4 ? -1 : 1);
+ if (accept) { x += dx * scale; y -= dy * scale; }
+ uint32_t xb, yb;
+ memcpy(&xb, &x, sizeof xb);
+ memcpy(&yb, &y, sizeof yb);
+ c->v[9] = xb;
+ c->v[10] = yb;
+ static int logged;
+ if (!logged) {
+ logged = 1;
+ rt_log("mouse: direct camera input after the stick dead zone, clamp and exponent (experimental)");
+ }
+ }
+ }
+ plat_mutex_lock(&sample_lock);
+ next.generation = sample.generation + 1;
+ sample = next;
+ plat_mutex_unlock(&sample_lock);
+ uint32_t original = (uint32_t)c->v[9];
+ memcpy((void *)(uintptr_t)(c->x[20] + 0x420), &original, sizeof original);
+}
+
+// Free camera has another signed-square curve for its vertical axis, plus mode-dependent velocity filters.
+// Remove only this mouse sample before that controller runs. At its final spherical-angle output, add degrees
+// directly and move its persistent pitch/yaw by the same amounts so the next update starts at the new orientation.
+// The controller still handles its gamepad input, following, collision and focus normally.
+static void orbit_begin(Cpu *c) {
+ orbit.object = 0;
+ uint64_t object = c->x[0];
+ if (direct_mode()) {
+ MouseSample m = sample_read();
+ uint64_t input = guest_pointer(object + 0x20);
+ if (m.object == input && m.camera_enabled) {
+ guest_float_store(input + 0x420, m.pad[0]);
+ guest_float_store(input + 0x424, m.pad[1]);
+ orbit.object = object;
+ orbit.mouse = m;
+ uint64_t held = guest_pointer(input + 0x148);
+ uint8_t override;
+ memcpy(&override, (void *)(uintptr_t)(input + 0x15c), 1);
+ plat_mutex_lock(&sample_lock);
+ OrbitTrack *track = orbit_track(object);
+ if (track->input != input) track->hold_pitch = track->target_saved = 0;
+ if (m.pad[1] != 0 || (held & 0x20) || (override & 0x40)) orbit_pitch_release(track);
+ track->input = input;
+ if (track->hold_pitch) orbit_pitch_target(object, track->pitch);
+ plat_mutex_unlock(&sample_lock);
+ }
+ } else {
+ plat_mutex_lock(&sample_lock);
+ orbit_pitch_release(orbit_track(object));
+ plat_mutex_unlock(&sample_lock);
+ }
+ c->x[8] = guest_pointer(object + 8); // displaced ldr x8, [x0, #8]
+}
+
+static void orbit_angles(Cpu *c) {
+ uint64_t object = c->x[20];
+ if (orbit.object == object) {
+ float yaw_delta = orbit.mouse.angle[0], pitch_delta = orbit.mouse.angle[1];
+ int fresh = plat_now_ns() - orbit.mouse.when < 150000000ull &&
+ orbit_sample_once(object, orbit.mouse.generation);
+ if (!fresh) yaw_delta = pitch_delta = 0;
+ plat_mutex_lock(&sample_lock);
+ OrbitTrack *track = orbit_track(object);
+ if (track->hold_pitch || yaw_delta || pitch_delta) {
+ float pitch = guest_float(c->sp + 0x44), yaw = guest_float(c->sp + 0x48);
+ float low = guest_float(object + 0xf8), high = guest_float(object + 0xfc);
+ if (!isfinite(low) || !isfinite(high) || low >= high) low = -89.9f, high = 89.9f;
+ low = fmaxf(-89.9f, low); high = fminf(89.9f, high);
+ // The game can recalculate its pitch after orbit_begin (following, mode changes and another filter).
+ // Integrate from our last requested angle, then correct the final output even on stationary frames.
+ float base = track->hold_pitch ? track->pitch : pitch;
+ float new_pitch = fminf(high, fmaxf(low, base + pitch_delta));
+ guest_float_store(c->sp + 0x44, new_pitch);
+ guest_float_store(c->sp + 0x48, wrap_degrees(yaw + yaw_delta));
+ guest_float_store(object + 0x108, wrap_degrees(new_pitch - orbit_pitch_offset(object)));
+ guest_float_store(object + 0x120, wrap_degrees(guest_float(object + 0x120) + yaw_delta));
+ if (!track->target_saved) track->original_target = guest_float(object + 0x15c), track->target_saved = 1;
+ track->pitch = new_pitch; track->input = orbit.mouse.object; track->hold_pitch = 1;
+ orbit_pitch_target(object, new_pitch);
+ static int logged;
+ if (!logged) {
+ logged = 1;
+ rt_log("mouse: free-camera angles directly, 0.08 degrees per count at sensitivity 1, equal X/Y");
+ }
+ }
+ plat_mutex_unlock(&sample_lock);
+ orbit.object = 0;
+ }
+ uint32_t bits;
+ memcpy(&bits, (const void *)(uintptr_t)(c->sp + 0x44), sizeof bits);
+ c->v[12] = bits; // displaced ldr s12, [sp, #0x44]
+}
+
+// Ultrahand reads the player's manipulation input rather than the camera's processed stick. Insert the mouse
+// after that controller's per-axis power curves (main+0x1d59460), preserving the keyboard/controller contribution.
+static void hand_input(Cpu *c) {
+ __atomic_store_n(&hand_update, plat_now_ns(), __ATOMIC_RELEASE);
+ static _Thread_local uint64_t object, generation;
+ if (direct_mode()) {
+ MouseSample m = sample_read();
+ if (m.generation != generation || object != c->x[19]) {
+ float x = guest_float(c->sp + 0x60), y;
+ memcpy(&y, &c->v[15], sizeof y);
+ if (__atomic_load_n(&shake_injected, __ATOMIC_RELAXED)) x = y = 0;
+ x += m.motion[0];
+ y += m.motion[1];
+ guest_float_store(c->sp + 0x60, x);
+ uint32_t bits;
+ memcpy(&bits, &y, sizeof bits);
+ c->v[15] = bits;
+ object = c->x[19]; generation = m.generation;
+ static int logged;
+ if (!logged && (m.motion[0] || m.motion[1])) {
+ logged = 1;
+ rt_log("mouse: held-object input after the manipulation controller's power curves (experimental)");
+ }
+ }
+ }
+ uint32_t original = (uint32_t)c->x[8];
+ memcpy((void *)(uintptr_t)(c->sp + 0x48), &original, sizeof original);
+}
+
+// The game also uses a 10% activity threshold after processing the stick. A one-count mouse movement must count
+// as active, even when its displacement is smaller than that threshold. Do this after the game computed the bits,
+// then execute the displaced ldp d9, d8, [sp, #8]. No flag is changed for controller-only input.
+static void camera_activity(Cpu *c) {
+ if (mouse_input_object && mouse_input_object == c->x[20]) {
+ uint32_t flags;
+ void *at = (void *)(uintptr_t)(mouse_input_object + 0x418);
+ memcpy(&flags, at, sizeof flags);
+ flags = (flags | 0x11u) & ~0x28u;
+ memcpy(at, &flags, sizeof flags);
+ mouse_input_object = 0;
+ }
+ uint64_t d9, d8;
+ memcpy(&d9, (const void *)(uintptr_t)(c->sp + 8), sizeof d9);
+ memcpy(&d8, (const void *)(uintptr_t)(c->sp + 16), sizeof d8);
+ c->v[9] = d9;
+ c->v[8] = d8;
+}
+
+__attribute__((constructor)) static void mouse_direct_register(void) {
+ rt_register_host(HOST_MOUSE_DIRECT, camera_input);
+ rt_register_host(HOST_MOUSE_ACTIVITY, camera_activity);
+ rt_register_host(HOST_MOUSE_ORBIT_BEGIN, orbit_begin);
+ rt_register_host(HOST_MOUSE_ORBIT_ANGLES, orbit_angles);
+ rt_register_host(HOST_MOUSE_HAND, hand_input);
+}
+#endif
diff --git a/runtime/ui/menu.cpp b/runtime/ui/menu.cpp
index d76bdde5..036db676 100644
--- a/runtime/ui/menu.cpp
+++ b/runtime/ui/menu.cpp
@@ -836,6 +836,8 @@ static void tab_controls(float scale) {
opt_slider("TOTK_RUMBLE_STRENGTH", UI_MENU_RUMBLE_STRENGTH, 0, 300, UI_MENU_RUMBLE_STRENGTH_DESC, 10, "%.0f %%");
opt_slider("TOTK_RUMBLE_CURVE", UI_MENU_RUMBLE_CURVE, 0.2f, 1.5f, UI_MENU_RUMBLE_CURVE_DESC, 0.05f, "%.2f");
opt_toggle("TOTK_RUMBLE_TRIGGERS", UI_MENU_RUMBLE_TRIGGERS, UI_MENU_RUMBLE_TRIGGERS_DESC);
+ static const UiTextId mouse_modes[] = {UI_MENU_MOUSE_STICK, UI_MENU_MOUSE_DIRECT};
+ 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");
row_walk_key();
opt_slider("TOTK_WALK_SCALE", UI_MENU_WALK_SCALE, 0.2f, 0.9f, UI_MENU_WALK_SCALE_DESC, 0.01f, "%.2f");
diff --git a/runtime/ui_text.c b/runtime/ui_text.c
index 28490bdc..52b0bc1d 100644
--- a/runtime/ui_text.c
+++ b/runtime/ui_text.c
@@ -261,6 +261,10 @@ static const char *const text_en[UI_TEXT_COUNT] = {
[UI_MENU_LSTICK_DEADZONE] = "Left stick dead zone", [UI_MENU_RSTICK_DEADZONE] = "Right stick dead zone",
[UI_MENU_STICK_DEADZONE_DESC] = "How far a gamepad stick moves before the game sees it. Raise it if the character or the camera moves on its own: let go of the stick, read \"stick now\" and set the dead zone a few percent above it.",
[UI_MENU_STICK_DEADZONE_NOW] = "stick now: %.0f %%",
+ [UI_MENU_MOUSE_MODE] = "Mouse camera",
+ [UI_MENU_MOUSE_MODE_DESC] = "Direct input bypasses the game's stick dead zone and response curve (experimental, game 1.4.3).",
+ [UI_MENU_MOUSE_STICK] = "Stick emulation",
+ [UI_MENU_MOUSE_DIRECT] = "Direct (experimental)",
[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",
@@ -712,6 +716,10 @@ static const char *const text_ru[UI_TEXT_COUNT] = {
[UI_MENU_LSTICK_DEADZONE] = "Мёртвая зона левого стика", [UI_MENU_RSTICK_DEADZONE] = "Мёртвая зона правого стика",
[UI_MENU_STICK_DEADZONE_DESC] = "Насколько нужно отклонить стик геймпада, чтобы игра это заметила. Увеличьте, если персонаж или камера двигаются сами: отпустите стик, посмотрите «стик сейчас» и поставьте мёртвую зону на несколько процентов выше.",
[UI_MENU_STICK_DEADZONE_NOW] = "стик сейчас: %.0f %%",
+ [UI_MENU_MOUSE_MODE] = "Управление мышью",
+ [UI_MENU_MOUSE_MODE_DESC] = "Прямой ввод обходит мёртвую зону и кривую стика (экспериментально, версия игры 1.4.3).",
+ [UI_MENU_MOUSE_STICK] = "Эмуляция стика",
+ [UI_MENU_MOUSE_DIRECT] = "Прямое (экспериментально)",
[UI_MENU_MOUSE_SENS] = "Чувствительность мыши",
[UI_MENU_MOUSE_SENS_DESC] = "Как быстро мышь поворачивает камеру.",
[UI_MENU_WALK_KEY] = "Клавиша шага",
diff --git a/runtime/ui_text.h b/runtime/ui_text.h
index edf669fb..7c9c0f2b 100644
--- a/runtime/ui_text.h
+++ b/runtime/ui_text.h
@@ -107,6 +107,7 @@ typedef enum {
UI_MENU_RESTART, UI_MENU_RESTART_DESC, UI_MENU_RESTART_CONFIRM, UI_MENU_RESTART_YES, UI_MENU_RESTART_SAVING,
UI_MENU_GROUP_STICKS, UI_MENU_LSTICK_DEADZONE, UI_MENU_RSTICK_DEADZONE, UI_MENU_STICK_DEADZONE_DESC,
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_MOUSE_SENS, UI_MENU_MOUSE_SENS_DESC,
UI_MENU_WALK_KEY, UI_MENU_WALK_KEY_DESC, UI_MENU_WALK_KEY_TAKEN, UI_MENU_WALK_SCALE, UI_MENU_WALK_SCALE_DESC,
diff --git a/tests/mouse_direct_check.py b/tests/mouse_direct_check.py
new file mode 100644
index 00000000..2c080bbd
--- /dev/null
+++ b/tests/mouse_direct_check.py
@@ -0,0 +1,311 @@
+"""Check the direct camera hook's register contract and raw-count routing without game data.
+
+Usage: python tests/mouse_direct_check.py --cc
+"""
+import argparse
+import os
+from pathlib import Path
+import subprocess
+import tempfile
+
+ROOT = Path(__file__).resolve().parents[1]
+HARNESS = r'''
+#include
+#include
+#include "mouse_direct.c"
+static int raw_x, raw_y, takes, captured=1, foreground=1, allowed=1, mode=1, patched=1, selecting;
+static float ratio=0.5f;
+static uint64_t now=1000000000;
+static GuestFn hook, activity_hook, begin_hook, angles_hook, hand_hook;
+const char *cfg_get(const char *key) { (void)key; return mode ? "direct" : "stick"; }
+double cfg_double(const char *key) { (void)key; return 1; }
+int rt_patch_set(const char *s) { (void)s; return 0; }
+int rt_patch_enabled(int s) { (void)s; return patched; }
+int ikb_captured(void) { return captured; }
+int ikb_foreground(void) { return foreground; }
+int input_cursor_allowed(void) { return allowed; }
+int input_direct_mouse_selector_active(void) { return selecting; }
+void ikb_mouse_take(int32_t *x, int32_t *y) { ++takes; *x=raw_x; *y=raw_y; raw_x=raw_y=0; }
+void input_direct_mouse_sample(int enabled, int32_t *x, int32_t *y) {
+ *x=*y=0;
+ if(enabled && captured && foreground && allowed) ikb_mouse_take(x,y);
+}
+uint64_t plat_now_ns(void) { return now; }
+int frame_step_realtime(void) { return 1; }
+double frame_step_limit_hz(void) { return 60; }
+void *rt_patch_page(void) { return ∶ }
+void rt_register_host(uint64_t addr, GuestFn fn) {
+ if(addr==HOST_MOUSE_DIRECT) hook=fn; else if(addr==HOST_MOUSE_ACTIVITY) activity_hook=fn;
+ else if(addr==HOST_MOUSE_ORBIT_BEGIN) begin_hook=fn; else if(addr==HOST_MOUSE_ORBIT_ANGLES) angles_hook=fn;
+ else if(addr==HOST_MOUSE_HAND) hand_hook=fn; else abort();
+}
+void plat_mutex_lock(PlatMutex *m) { (void)m; }
+void plat_mutex_unlock(PlatMutex *m) { (void)m; }
+void rt_log(const char *fmt, ...) { (void)fmt; }
+static float scalar(__uint128_t v) { float f; memcpy(&f,&v,4); return f; }
+int main(void) {
+ assert(hook && activity_hook);
+ Cpu c, expected;
+ unsigned char target[0x500] = {0};
+ memset(&c, 0x5a, sizeof c);
+ c.x[20]=(uintptr_t)target; c.x[21]=0; c.v[9]=c.v[10]=0;
+ expected=c;
+ raw_x=100; raw_y=-50;
+ hook(&c);
+ assert(fabsf(scalar(c.v[9])-2)<1e-6f);
+ assert(fabsf(scalar(c.v[10])-1)<1e-6f);
+ float stored; memcpy(&stored,target+0x420,4); assert(stored==scalar(c.v[9]));
+ expected.v[9]=c.v[9]; expected.v[10]=c.v[10]; assert(!memcmp(&expected,&c,sizeof c));
+ assert(input_direct_mouse_active());
+ // The next read sees no repeated movement. Gamepad/keyboard input is preserved.
+ expected=c; hook(&c); assert(!memcmp(&expected,&c,sizeof c));
+ // Equal mouse distance produces equal integrated input at 30, 60 and 144 Hz; there is no unit-circle clamp.
+ float rates[]={30,60,144};
+ for(int i=0;i<3;i++) {
+ ratio=30/rates[i]; raw_x=10000; raw_y=10000; c.v[9]=c.v[10]=0; hook(&c);
+ assert(fabsf(scalar(c.v[9])*ratio-100)<0.001f);
+ assert(fabsf(scalar(c.v[10])*ratio+100)<0.001f);
+ }
+ // One count is not discarded by a dead zone.
+ ratio=0.5f; raw_x=1; raw_y=0; c.v[9]=c.v[10]=0; hook(&c); assert(scalar(c.v[9])>0);
+ uint64_t stack[4]={0,0x123456789abcdef0ull,0x456789abcdef0123ull,0}; c.sp=(uintptr_t)stack;
+ uint32_t inactive=0x28; memcpy(target+0x418,&inactive,4);
+ activity_hook(&c);
+ uint32_t active; memcpy(&active,target+0x418,4); assert(active==0x11);
+ assert(c.v[9]==stack[1] && c.v[8]==stack[2]);
+ // A controller-only update keeps the game's activity bits.
+ memcpy(target+0x418,&inactive,4); activity_hook(&c);
+ memcpy(&active,target+0x418,4); assert(active==inactive);
+ // Disabled game camera input leaves raw counts for the menu's legacy mouse-to-stick path.
+ c.x[21]=1; raw_x=42; int before=takes; hook(&c);
+ assert(takes==before && raw_x==42 && !input_direct_mouse_active()); c.x[21]=0;
+ // Focus loss and host menus do not move the camera.
+ captured=0; before=takes; hook(&c); assert(takes==before); captured=1;
+ foreground=0; hook(&c); assert(takes==before); foreground=1;
+ allowed=0; hook(&c); assert(takes==before); allowed=1;
+ mode=0; hook(&c); assert(takes==before && !input_direct_mouse_active()); mode=1;
+ patched=0; hook(&c); assert(takes==before && !input_direct_mouse_active()); patched=1;
+ now+=150000001; assert(!input_direct_mouse_active());
+ // Orbit input removes the mouse from the stick path and writes equal degrees per count at the final angles.
+ unsigned char camera[0x300]={0}, frame[0x100]={0}, hand[0x300]={0};
+ uint64_t input_address=(uintptr_t)target; memcpy(camera+0x20,&input_address,8);
+ for(int rate=0;rate<3;rate++) {
+ memset(orbit_seen,0,sizeof orbit_seen);
+ ratio=30/rates[rate]; c.x[20]=(uintptr_t)target; c.x[21]=0; c.v[9]=c.v[10]=0;
+ raw_x=100; raw_y=-50; hook(&c);
+ guest_float_store((uintptr_t)camera+0x108,30); guest_float_store((uintptr_t)camera+0x120,40);
+ guest_float_store((uintptr_t)frame+0x44,30); guest_float_store((uintptr_t)frame+0x48,40);
+ c.x[0]=(uintptr_t)camera; begin_hook(&c);
+ assert(guest_float((uintptr_t)target+0x420)==0 && guest_float((uintptr_t)target+0x424)==0);
+ c.x[20]=(uintptr_t)camera; c.sp=(uintptr_t)frame; angles_hook(&c);
+ assert(fabsf(guest_float((uintptr_t)frame+0x44)-26)<0.0001f);
+ assert(fabsf(guest_float((uintptr_t)frame+0x48)-32)<0.0001f);
+ assert(fabsf(guest_float((uintptr_t)camera+0x15c)-26)<0.0001f);
+ c.x[0]=(uintptr_t)camera; begin_hook(&c); angles_hook(&c);
+ assert(fabsf(guest_float((uintptr_t)frame+0x48)-32)<0.0001f); // one sample cannot repeat next update
+ // The next input frame is stationary and the game's parameter update rewrites the old default target.
+ // Restoring the mouse's desired target makes the camera filter stay at the new pitch, not spring to zero.
+ c.x[20]=(uintptr_t)target; c.v[9]=c.v[10]=0; raw_x=raw_y=0; hook(&c);
+ guest_float_store((uintptr_t)camera+0x15c,0);
+ c.x[0]=(uintptr_t)camera; begin_hook(&c);
+ float current=guest_float((uintptr_t)camera+0x108), goal=guest_float((uintptr_t)camera+0x15c);
+ assert(fabsf(goal-26)<0.0001f && fabsf((current+goal)*0.5f-26)<0.0001f);
+ // A later game filter overwrites the pitch after the begin hook. Neither a stationary frame nor the next
+ // tiny mouse delta may integrate from that recentered result.
+ guest_float_store((uintptr_t)camera+0x108,0);
+ guest_float_store((uintptr_t)camera+0x11c,5);
+ guest_float_store((uintptr_t)camera+0x10c,20);
+ guest_float_store((uintptr_t)camera+0x88,0.3f);
+ guest_float_store((uintptr_t)frame+0x44,0);
+ c.x[20]=(uintptr_t)camera; angles_hook(&c);
+ assert(fabsf(guest_float((uintptr_t)frame+0x44)-26)<0.0001f);
+ assert(fabsf(guest_float((uintptr_t)camera+0x15c)-7)<0.0001f);
+ assert(fabsf(guest_float((uintptr_t)camera+0x108)-12)<0.0001f);
+ for(int i=0;i<100;i++) {
+ guest_float_store((uintptr_t)frame+0x44,0); angles_hook(&c);
+ assert(fabsf(guest_float((uintptr_t)camera+0x108)-12)<0.0001f);
+ }
+ c.x[20]=(uintptr_t)target; c.v[9]=c.v[10]=0; raw_y=1; hook(&c);
+ c.x[0]=(uintptr_t)camera; begin_hook(&c);
+ guest_float_store((uintptr_t)frame+0x44,0);
+ c.x[20]=(uintptr_t)camera; angles_hook(&c);
+ assert(fabsf(guest_float((uintptr_t)frame+0x44)-26.08f)<0.0001f);
+ // An explicit controller recenter still hands pitch back to the game.
+ uint64_t recenter=0x20; memcpy(target+0x148,&recenter,8);
+ c.x[20]=(uintptr_t)target; c.v[9]=c.v[10]=0; hook(&c);
+ c.x[0]=(uintptr_t)camera; begin_hook(&c);
+ guest_float_store((uintptr_t)frame+0x44,5);
+ c.x[20]=(uintptr_t)camera; angles_hook(&c);
+ assert(guest_float((uintptr_t)frame+0x44)==5);
+ memset(target+0x148,0,8);
+ memset(camera+0x88,0,4); memset(camera+0x10c,0,4); memset(camera+0x11c,0,4);
+ }
+ guest_float_store((uintptr_t)camera+0x108,30); guest_float_store((uintptr_t)camera+0x120,40);
+ for(int count=0;count<100;count++) {
+ c.x[20]=(uintptr_t)target; c.x[21]=0; c.v[9]=c.v[10]=0; raw_x=1; raw_y=0; hook(&c);
+ c.x[0]=(uintptr_t)camera; begin_hook(&c); c.x[20]=(uintptr_t)camera;
+ guest_float_store((uintptr_t)frame+0x44,guest_float((uintptr_t)camera+0x108));
+ guest_float_store((uintptr_t)frame+0x48,guest_float((uintptr_t)camera+0x120));
+ angles_hook(&c);
+ }
+ assert(fabsf(guest_float((uintptr_t)camera+0x120)-32)<0.001f);
+ // A held object receives mouse deltas after its own curves, once per sample, including with camera input off.
+ c.x[20]=(uintptr_t)target; c.v[9]=c.v[10]=0; raw_x=100; raw_y=50; ratio=0.5f; hook(&c);
+ c.x[19]=(uintptr_t)hand; c.x[8]=0x12345678; c.v[15]=0;
+ guest_float_store((uintptr_t)frame+0x60,0); hand_hook(&c);
+ assert(fabsf(guest_float((uintptr_t)frame+0x60)-2)<0.00001f);
+ assert(fabsf(scalar(c.v[15])+1)<0.00001f);
+ hand_hook(&c); assert(fabsf(scalar(c.v[15])+1)<0.00001f);
+ c.x[21]=1; raw_x=5; raw_y=6; hook(&c); assert(raw_x==0 && raw_y==0 && input_direct_mouse_active());
+ // A radial selector retains its virtual cursor between mouse packets, including repeated HID polls.
+ float cursor[2]={0}; int32_t selector[2], held_selector[2];
+ input_direct_mouse_radial(100,50,1,cursor,selector);
+ held_selector[0]=selector[0]; held_selector[1]=selector[1];
+ for(int i=0;i<100;i++) {
+ input_direct_mouse_radial(0,0,1,cursor,selector);
+ assert(selector[0]==held_selector[0] && selector[1]==held_selector[1]);
+ }
+ input_direct_mouse_radial(-100,-50,1,cursor,selector); assert(!selector[0] && !selector[1]);
+ input_direct_mouse_radial(100000,100000,1,cursor,selector);
+ assert((int64_t)selector[0]*selector[0]+(int64_t)selector[1]*selector[1]<=32768ll*32768);
+ // Quick lists must not latch a wheel direction or automatically drain a large flick after the mouse stops.
+ InputMouseRow row={0}; uint64_t row_time=0;
+ input_direct_mouse_row(10000,1,row_time,&row,selector); assert(selector[0]==32767 && !selector[1]);
+ input_direct_mouse_row(0,1,row_time+10000000,&row,selector); assert(selector[0]==32767);
+ for(int i=1;i<=100;i++) {
+ input_direct_mouse_row(0,1,row_time+i*100000000ull,&row,selector); assert(!selector[0] && !selector[1]);
+ }
+ // Repeated HID polls do not rearm a pulse; a frame that skips its deadline must still observe neutral first.
+ row=(InputMouseRow){0};
+ for(int i=0;i<31;i++) { input_direct_mouse_row(1,1,0,&row,selector); assert(!selector[0]); }
+ input_direct_mouse_row(1,1,0,&row,selector); assert(selector[0]==32767);
+ input_direct_mouse_row(1000,1,100000000,&row,selector); assert(!selector[0]);
+ input_direct_mouse_row(1000,1,110000000,&row,selector); assert(!selector[0]);
+ input_direct_mouse_row(1000,1,140000000,&row,selector); assert(selector[0]==32767);
+ input_direct_mouse_row(-1000,1,141000000,&row,selector); assert(!selector[0]);
+ input_direct_mouse_row(-1,1,180000000,&row,selector); assert(selector[0]==-32767);
+ selecting=1; c.x[20]=(uintptr_t)target; raw_x=42; raw_y=0; before=takes; hook(&c);
+ assert(takes==before && raw_x==42); selecting=0; raw_x=0;
+ // Deliberate large reversals with an active held object start a bounded shake; monotonic motion does not.
+ now+=800000000ull;
+ for(int i=0;i<4;i++) {
+ hand_hook(&c); mouse_shake_feed(i&1?-40:40,0,now); now+=50000000ull;
+ }
+ int32_t pulse[2]; assert(input_direct_mouse_shake(1,pulse) && abs(pulse[0])==32767 && pulse[1]==0);
+ int first=pulse[0]; now+=40000000ull; hand_hook(&c);
+ assert(input_direct_mouse_shake(1,pulse) && pulse[0]==-first);
+ captured=0; assert(!input_direct_mouse_shake(1,pulse)); captured=1;
+ now+=800000000ull;
+ for(int i=0;i<4;i++) { hand_hook(&c); mouse_shake_feed(40,0,now); now+=50000000ull; }
+ assert(!input_direct_mouse_shake(1,pulse));
+ for(int i=0;i<10;i++) { hand_hook(&c); mouse_shake_feed(i&1?-5:5,0,now); now+=10000000ull; }
+ assert(!input_direct_mouse_shake(1,pulse));
+ puts("direct mouse: register contract, routing, linearity, frame ratio and capture checks passed");
+ puts("direct mouse: final orbit angles, single-count motion, equal axes and held-object routing passed");
+ puts("direct mouse: persistent pitch target, radial cursor hold, deliberate shake and noise rejection passed");
+ puts("direct mouse: final-pitch recenter rejection, explicit handoff and bounded quick-list steps passed");
+}
+'''
+
+INPUT_HARNESS = r'''
+#include
+#include "input.c"
+GfxStats gfx_counters;
+InputMap input_map;
+// Other input entry points are linked by PE unwind metadata; reaching them is outside this script-only test.
+void ikb_cursor_update(void) { abort(); }
+void ikb_menu_closed(void) { abort(); }
+int cfg_bool(const char *key) { (void)key; abort(); }
+int input_menu_gate(int *h,int open,uint64_t *b,int32_t s[4]) { (void)h;(void)open;(void)b;(void)s;abort(); }
+int input_overlay_gate(int *h,uint64_t *b) { (void)h;(void)b;abort(); }
+int menu_is_open(void) { abort(); }
+void menu_toggle(void) { abort(); }
+void menu_perf_cycle(void) { abort(); }
+const char *input_action_name(int action) { (void)action;abort(); }
+void input_map_configure(void) { abort(); }
+int input_direct_mouse_shake(int allow,int32_t out[2]) { (void)allow;(void)out;abort(); }
+int input_direct_mouse_active(void) { return 1; }
+int input_direct_mouse_enabled(void) { return 1; }
+static int row_calls, radial_calls, live_mouse;
+void input_direct_mouse_row(int32_t dx,float sensitivity,uint64_t now,InputMouseRow *row,int32_t out[2]) {
+ (void)dx;(void)sensitivity;(void)now; row_calls++; out[0]=123;out[1]=0;row->direction=1;
+}
+void input_direct_mouse_radial(int32_t dx,int32_t dy,float sensitivity,float cursor[2],int32_t out[2]) {
+ (void)dx;(void)dy;(void)sensitivity;radial_calls++;cursor[0]=1;out[0]=456;out[1]=789;
+}
+static const char *script_path;
+static uint64_t test_tick;
+static int64_t test_world=-1;
+const char *cfg_get(const char *key) {
+ if (!strcmp(key,"TOTK_INPUT_SCRIPT")) return script_path;
+ if (!strcmp(key,"TOTK_INPUT")) return "none";
+ return NULL;
+}
+unsigned cfg_version(void) { return 0; }
+double cfg_double(const char *key) { (void)key; return 1; }
+uint64_t frame_step_ticks(void) { return test_tick; }
+int64_t frame_step_world_us(void) { return test_world; }
+void rt_log(const char *fmt, ...) { (void)fmt; }
+void plat_mutex_lock(PlatMutex *m) { (void)m; }
+void plat_mutex_unlock(PlatMutex *m) { (void)m; }
+int ikb_captured(void) { return live_mouse; }
+int ikb_foreground(void) { return 0; }
+void ikb_mouse_take(int32_t *x,int32_t *y) { *x=*y=0; }
+uint64_t plat_now_ns(void) { return 1000000000ull; }
+int main(int argc,char **argv) {
+ assert(argc==2); script_path=argv[1];
+ uint64_t buttons=0; int32_t left[2]={0},right[2]={0},dx,dy;
+ test_tick=10;
+ for(int i=0;i<3;i++) script_apply(&buttons,left,right);
+ input_direct_mouse_sample(1,&dx,&dy);
+ assert(dx==123 && dy==-45 && !buttons && !right[0] && !right[1]);
+ input_direct_mouse_sample(1,&dx,&dy); assert(!dx && !dy);
+ test_tick=20; script_apply(&buttons,left,right);
+ g_menu=1; input_direct_mouse_sample(1,&dx,&dy); assert(!dx && !dy);
+ g_menu=0; input_direct_mouse_sample(1,&dx,&dy); assert(!dx && !dy);
+ test_world=100000;
+ for(int i=0;i<3;i++) script_apply(&buttons,left,right);
+ rec=tmpfile(); assert(rec); rec_state=1;
+ input_direct_mouse_sample(1,&dx,&dy); assert(dx==-100 && dy==50);
+ rewind(rec); char line[128]; assert(fgets(line,sizeof line,rec));
+ assert(strstr(line,"MOUSE -100 50")); assert(!fgets(line,sizeof line,rec));
+ fclose(rec); rec_state=-1;
+ live_mouse=1;
+ mouse_camera(right,1); assert(radial_calls==1 && !row_calls && right[0]==456 && right[1]==789);
+ assert(input_direct_mouse_selector_active());
+ mouse_camera(right,2); assert(row_calls==1 && radial_calls==1 && right[0]==123 && !right[1]);
+ mouse_camera(right,0); assert(!input_direct_mouse_selector_active() && !right[0] && !right[1]);
+ mouse_camera(right,3); assert(row_calls==2 && right[0]==123 && !right[1]);
+ live_mouse=0; mouse_camera(right,3);
+ assert(!input_direct_mouse_selector_active() && !right[0] && !right[1]);
+ puts("direct mouse: one-shot script replay, host-menu blocking and raw-count recording passed");
+ puts("direct mouse: separate wheel/list routing, selector ownership and release passed");
+}
+'''
+
+def main():
+ ap = argparse.ArgumentParser(description=__doc__)
+ ap.add_argument('--cc', required=True)
+ ap.add_argument('--deps', type=Path, help='dependency include directory (SDL3/Vulkan), to also check input scripts')
+ args = ap.parse_args()
+ with tempfile.TemporaryDirectory(prefix='totk-mouse-') as tmp:
+ folder = Path(tmp)
+ (folder / 'patches.h').write_text('#define RT_PATCH_PAGE 0x7003adf000ull\n')
+ source = folder / 'check.c'
+ source.write_text(HARNESS)
+ exe = folder / ('check.exe' if os.name == 'nt' else 'check')
+ link = [] if os.name == 'nt' else ['-lm']
+ subprocess.run([args.cc, '-O2', '-Wall', '-Wextra', '-I', str(folder), '-I', str(ROOT/'runtime'),
+ str(source), *link, '-o', str(exe)], check=True)
+ subprocess.run([str(exe)], check=True)
+ if args.deps:
+ source.write_text(INPUT_HARNESS)
+ script = folder / 'input.txt'
+ script.write_text('10 MOUSE 123 -45\n20 MOUSE 1000 0\n@100 MOUSE -100 50\n')
+ subprocess.run([args.cc, '-O2', '-flto', '-ffunction-sections', '-fdata-sections', '-Wl,--gc-sections', *(['-Wl,--exclude-all-symbols'] if os.name == 'nt' else []),
+ '-I', str(ROOT/'runtime'), '-I', str(args.deps), '-I', str(args.deps/'vma'),
+ str(source), *link, '-o', str(exe)], check=True)
+ subprocess.run([str(exe), str(script)], check=True)
+
+if __name__ == '__main__':
+ main()
diff --git a/tools/build_game.py b/tools/build_game.py
index 4b9b0419..6de4345e 100644
--- a/tools/build_game.py
+++ b/tools/build_game.py
@@ -156,8 +156,8 @@ LLVM_LINK_LIBS = ['-lpsapi', '-lbcrypt', '-luser32', '-lgdi32', '-ldwmapi', '-li
DEFAULT_DEPS = ROOT / 'toolchain' / 'deps-mingw'
# Runtime sources compiled per install, not in the library: romfs.c includes romfs_config.h, patches.c and ov_zstd.c
# the patches.h of the player's game version (its patch page is the page after that version's main; ov_zstd.c's host
-# functions sit on it).
-INSTALL_SIDE = {'romfs.c', 'patches.c', 'ov_zstd.c'}
+# functions sit on it). mouse_direct.c also registers host callbacks relative to that version's patch page.
+INSTALL_SIDE = {'romfs.c', 'patches.c', 'ov_zstd.c', 'mouse_direct.c'}
LIB_NAME = 'libtotkrt.a'
AR = UCRT / 'llvm-ar.exe' if WIN else on_path('llvm-ar')
WINDRES = UCRT / 'windres.exe' # runtime/totk.rc: the manifest of totk.exe
diff --git a/totk.ini.example b/totk.ini.example
index f5c28b7e..3ada4ddc 100644
--- a/totk.ini.example
+++ b/totk.ini.example
@@ -298,6 +298,10 @@
# tab shows each stick's deflection now, so a drifting stick's resting value can be read off.
# lstick_deadzone = 8
# rstick_deadzone = 8
+# Mouse camera mode: stick (default) or direct (experimental, game 1.4.3 only). Direct free-camera input uses
+# raw displacement with equal horizontal/vertical sensitivity and bypasses stick response curves. Other game versions
+# keep stick emulation. The Controls tab changes this while the game runs.
+# mouse_mode = stick
# Mouse camera sensitivity (0 to 10; 0 = no mouse camera and no cursor capture).
# mouse_sens = 1
# The keyboard's sticks are all or nothing, so the game only sees a full tilt from them; while this key is held the