diff --git a/docs/controls.md b/docs/controls.md index b02b85b7..326e7be0 100644 --- a/docs/controls.md +++ b/docs/controls.md @@ -110,9 +110,8 @@ bind_Y = pad:north, key:mouse_l ## Mouse camera `mouse_mode = direct` (the default) turns the camera by the raw mouse motion on game 1.4.3, through hooks in the game's camera code (`runtime/mouse_direct.c`, the `mouse_direct` sites of `recomp/patches-v143.txt`). None of them changes a step of the gamepad alone. The free-orbit camera receives raw-count -angular increments at its final spherical-angle output: 70/1500 = 0.0467 degrees per count on both axes at -sensitivity 1 (the on-foot camera's full-stick 70 degrees a second for 1500 counts a second; about 24.5 cm a turn at -800 DPI), with no time multiplier, curve or carry into later frames. The controller's persistent pitch/yaw move with +angular increments at its final spherical-angle output: 0.08 degrees per count on both axes at sensitivity 1 (about +14.3 cm a turn at 800 DPI), 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. The aiming camera (bow, throwing), the Purah Pad camera, the scope, the ability camera (Ultrahand, Fuse, Ascend, @@ -145,17 +144,19 @@ Two inputs stay stick input: the waterfall's vertical axis moves the camera's he lock-on without a target (HorseLockOnEmpty) turns the stick's position into an offset that returns when the stick does, which a mouse has no position for. Those receive input after -the radial dead zone, unit-circle clamp and stick response exponent: x is 0.02 stick units a count over the frame +the radial dead zone, unit-circle clamp and stick response exponent: x is 0.0343 stick units a count over the frame ratio (the stick turns yaw 70 x / 30 degrees a step) and y 70 / 51 times that, linear like their pitch (51 y / 30 degrees a step), so both axes turn by the same amount for the same motion. `stick_sens` (which scales the game's stick turn rates) is divided out. While the player uses an ability and the ability camera's hooks do not take the mouse, its part is scaled by 1 / 0.8 and 70 / (1.5 x 51), the ability camera's own stick scales. The player's verbs are read every 50 ms from the player actor (the player root's GOT slot main+0x3969918, the component array +0x228, its AS component +0x158 and the verbs of its five slots). Ultrahand has a separate hook after -its manipulation input's power curves; it gets the camera's stick value per count, at most three full tilts a step. +its manipulation input's power curves; it gets 0.01 stick units a count over the frame ratio, at most three full tilts +a step. `mouse_aim_scale` (0.1 to 3, default 1) multiplies the mouse's motion while the bow is drawn (the verb UseBow or DrawnBow with ZR held). 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. +counts, with the same meaning as in 0.3.10 (the free camera turns 0.08 degrees a count at 1, and now every other camera +does too); its scale differs from the stick-emulation mode. The Controls tab switches between *Direct* and *Stick emulation* (`mouse_mode = stick`). 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 @@ -175,7 +176,7 @@ not consumed by the direct camera or Ultrahand hooks. 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 -or more each, about 214 counts at sensitivity 1) change direction twice within 0.35 s, the stick goes full tilt the +or more each, 125 counts at sensitivity 1) change direction twice within 0.35 s, the stick goes full tilt the way the mouse moves, each side held at least two frames so the game reads it, and goes neutral as soon as the mouse rests. Only your own swings reach the stick, so nothing keeps swinging after you stop; shake until the part comes off. The camera hooks ignore that swing (the mouse turns the camera in degrees already). Turning a held object back and diff --git a/runtime/mouse_direct.c b/runtime/mouse_direct.c index 37441243..60d8b102 100644 --- a/runtime/mouse_direct.c +++ b/runtime/mouse_direct.c @@ -26,10 +26,11 @@ #include "patches.h" #endif -// One turn rate for every camera, as a PC game has: degrees per raw count at sensitivity 1. The on-foot camera turns -// 70 degrees a second at a full stick, so this is a full stick's turn for 1500 counts a second. The stick rates and the -// ability camera's scales below are those Weeping of the Empire's engine/runtime/pc_mouse.cpp works with. -#define DEG_PER_COUNT (70.0f / 1500.0f) +// One turn rate for every camera, as a PC game has: degrees per raw count at sensitivity 1. It is the free camera's rate +// since the direct mode came (0.08, about 14.3 cm a turn at 800 DPI), so a mouse_sens set for it keeps its meaning. The +// stick rates and the ability camera's scales below are those Weeping of the Empire's engine/runtime/pc_mouse.cpp +// works with. +#define DEG_PER_COUNT 0.08f // The stick turns yaw 70 x / 30 degrees per step at the 30 Hz frame ratio: a processed stick value of STICK_PER_COUNT a // count turns yaw DEG_PER_COUNT in the cameras that still take the mouse as stick (mouse_stick_add). #define STICK_PER_COUNT (DEG_PER_COUNT * 30.0f / 70.0f) @@ -41,10 +42,10 @@ // x / 0.8, and pitch linear at 70 / (1.5 * 51). #define ABILITY_GAIN_X (1.0f / 0.8f) #define ABILITY_GAIN_Y (70.0f / (1.5f * 51.0f)) -// Ultrahand's held object moves by its post-curve input times its speed at a full tilt, as the camera turns by the -// stick: the mouse's part is the camera's stick value a count, so the object follows the hand as the camera would, -// at most HAND_MAX full tilts a step -#define HAND_PER_COUNT STICK_PER_COUNT +// Ultrahand's held object moves by its post-curve input times its speed at a full tilt: the mouse's part is +// HAND_PER_COUNT a count over the frame ratio, the rate the direct mode has had since it came, at most HAND_MAX full +// tilts a step +#define HAND_PER_COUNT 0.01f #define HAND_MAX 3.0f static int direct_mode(void) { diff --git a/tests/mouse_direct_check.py b/tests/mouse_direct_check.py index b3db55e8..ab4b3ce2 100644 --- a/tests/mouse_direct_check.py +++ b/tests/mouse_direct_check.py @@ -190,12 +190,12 @@ int main(void) { angles_hook(&c); } assert(fabsf(guest_float((uintptr_t)camera+0x120)-(40-100*DEG_PER_COUNT))<0.001f); - // A held object receives mouse deltas after its own curves at the camera's stick rate, at most HAND_MAX full + // A held object receives mouse deltas after its own curves at HAND_PER_COUNT a count, at most HAND_MAX full // tilts a step, 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[20]=(uintptr_t)target; c.v[9]=c.v[10]=0; raw_x=200; 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(100*HAND_PER_COUNT/ratio>HAND_MAX && fabsf(guest_float((uintptr_t)frame+0x60)-HAND_MAX)<0.00001f); + assert(200*HAND_PER_COUNT/ratio>HAND_MAX && fabsf(guest_float((uintptr_t)frame+0x60)-HAND_MAX)<0.00001f); assert(fabsf(scalar(c.v[15])+50*HAND_PER_COUNT/ratio)<0.00001f); hand_hook(&c); assert(fabsf(scalar(c.v[15])+50*HAND_PER_COUNT/ratio)<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()); diff --git a/totk.ini.example b/totk.ini.example index c48480b3..50874a78 100644 --- a/totk.ini.example +++ b/totk.ini.example @@ -310,10 +310,10 @@ # the map to the keys and the pad. Changes while the game runs. # menu_cursor = 1 # Mouse camera sensitivity (0 to 10; 0 = no mouse camera and no cursor capture). With mouse_mode = direct, 1 turns the -# camera 0.0467 degrees per count, the same in every camera mode (about 24.5 cm a turn at 800 DPI). +# camera 0.08 degrees per count, the same in every camera mode (about 14.3 cm a turn at 800 DPI). # mouse_sens = 1 # The mouse's camera motion times this while the bow is drawn (0.1 to 3; mouse_mode = direct, game 1.4.3), on top of -# the 0.0467 degrees per count every camera turns, the bow's included. Changes while the game runs. +# the 0.08 degrees per count every camera turns, the bow's included. Changes while the game runs. # mouse_aim_scale = 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 # keyboard-driven stick values shrink and the keyboard can walk instead of run. Key names as in the bind_ lines below,