Detach a fused part by shaking the mouse while Ultrahand holds an object

The game detaches a fused part when the right stick swings left and right a few times. In direct mode the mouse never
reaches that stick, so shaking the mouse did nothing and only the shake key worked. A shake of the mouse while
Ultrahand holds an object (at least three changes of direction within 0.6 s, each swing worth 10 degrees of camera turn
or more) now plays the shake key's right-stick swing. Turning a held object back and forth at an ordinary pace takes
longer and does not count.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Tempus3214andClaude Opus 5.5 committed 2026-11-04 23:01:33 -03:00
1 parent 55083b69b3
commit 27f4d40e80
5 files changed
+64 -4

No files matched your search

+6 -3
View File
@@ -140,9 +140,12 @@ with at least 32 ms of neutral between them. At sensitivity 1, 32 horizontal cou
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.
The mouse never stands in for a stick shake: to detach a fused part, press G (`bind_SHAKE`). A press swings the right
stick left and right for 0.8 s, holding the key keeps it swinging. The arrow keys or the gamepad's right stick shaken by
hand work too. A mouse gesture for it would also fire while a held object is turned back and forth.
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 plays the same swing: at least three changes of direction within 0.6 s,
each swing worth 10 degrees of camera turn or more (about 214 counts at sensitivity 1). Turning a held object back and
forth at an ordinary pace takes longer and does not count. The arrow keys or the gamepad's right stick shaken by hand
work too.
A step of the gamepad alone, with no mouse motion and no pitch the mouse holds, reaches the camera exactly as without
the hooks.
The mapping below is still used when the camera-input hook is unavailable or the game disables camera input.
+1 -1
View File
@@ -621,7 +621,7 @@ static void poll_merged(uint64_t *buttons, int32_t *lx, int32_t *ly, int32_t *rx
b & (1ull << B_LEFT) ? 3 : b & (1ull << B_RIGHT) ? 4 : 0;
mouse_camera(k, selector);
pick(&sr[0], &sr[1], k[0], k[1]);
int32_t shake = shake_stick(input_map_held(down, B_SHAKE));
int32_t shake = shake_stick(input_map_held(down, B_SHAKE) || input_direct_mouse_shake());
if (shake) sr[0] = shake, sr[1] = 0;
static uint32_t travel_seen;
uint32_t travel = ikb_mouse_travel();
+2
View File
@@ -25,6 +25,8 @@ int input_direct_mouse_selector_active(void);
void input_direct_mouse_sample(int enabled, int32_t *dx, int32_t *dy);
// The buttons (B_* bits) of the last poll, keys and gamepad merged; any thread (mouse_direct.c: ZR for the bow's scale)
uint64_t input_buttons_last(void);
// mouse_direct.c: the mouse was shaken while Ultrahand holds an object; input.c plays the stick shake as for the key
int input_direct_mouse_shake(void);
// menu_cursor.c: the pointer in the game's menus (1.4.3). poll: once per pad read, adds a click's A or B; pointer: a
// menu has the pointer, so the mouse camera's capture is released
void menu_cursor_poll(uint64_t *buttons);
+39
View File
@@ -66,6 +66,11 @@ int input_direct_mouse_active(void) {
int input_direct_mouse_enabled(void) { return direct_mode(); }
// A shake of the mouse while Ultrahand holds an object (camera_input, mouse_shake_step): input.c's shake_stick plays the
// right-stick swing that detaches a fused part, as the shake key does, for a press until this time
static volatile uint64_t shake_until;
int input_direct_mouse_shake(void) { return plat_now_ns() < __atomic_load_n(&shake_until, __ATOMIC_RELAXED); }
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;
@@ -266,6 +271,32 @@ static void mouse_stick_add(int32_t dx, int32_t dy, float k, int ability, float
}
}
// The game detaches a fused part when the right stick swings left and right a few times; in direct mode the mouse
// never reaches that stick. A shake: horizontal swings of at least SHAKE_SWING_DEG of camera turn each, changing
// direction SHAKE_TURNS times within SHAKE_WINDOW_NS of the first change. Turning a held object back and forth at an
// ordinary pace takes longer than that, and a reversal after a shorter swing starts the count again.
#define SHAKE_SWING_DEG 10.0f
#define SHAKE_TURNS 3
#define SHAKE_WINDOW_NS 600000000ull
typedef struct { int dir, turns; float swing; uint64_t first; } MouseShake;
// deg: this step's horizontal motion in degrees of camera turn. 1 when it completes a shake (the state starts over).
static int mouse_shake_step(MouseShake *s, float deg, uint64_t now) {
if (s->turns && now - s->first > SHAKE_WINDOW_NS) s->turns = 0;
if (deg == 0) return 0;
int d = deg > 0 ? 1 : -1;
if (d == s->dir) { s->swing += fabsf(deg); return 0; }
if (s->dir && s->swing >= SHAKE_SWING_DEG) {
if (!s->turns) s->first = now;
s->turns++;
} else {
s->turns = 0;
}
s->dir = d, s->swing = fabsf(deg);
if (s->turns < SHAKE_TURNS) return 0;
*s = (MouseShake){0};
return 1;
}
// 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) {
@@ -289,6 +320,14 @@ static void camera_input(Cpu *c) {
// The bow drawn (in hand with ZR held): mouse_aim_scale times the mouse's motion on every path
if ((player & PLAYER_BOW) && (input_buttons_last() & (1ull << B_ZR)))
sensitivity *= (float)fminf(3, fmaxf(0.1, cfg_double("TOTK_MOUSE_AIM_SCALE")));
// Ultrahand holding an object: a shake of the mouse is the stick shake (a press held 100 ms for shake_stick)
static MouseShake shake;
uint64_t step_now = plat_now_ns();
if (hand_active(step_now) && mouse_shake_step(&shake, dx * DEG_PER_COUNT * sensitivity, step_now)) {
__atomic_store_n(&shake_until, step_now + 100000000ull, __ATOMIC_RELAXED);
static int logged;
if (!logged) logged = 1, rt_log("mouse: a shake while Ultrahand holds an object shakes the right stick");
}
// 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;
+16
View File
@@ -232,7 +232,23 @@ int main(void) {
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 and gamepad-only steps untouched passed");
puts("direct mouse: final-pitch recenter rejection, explicit handoff and bounded quick-list steps passed");
// A shake: three direction changes of swings of at least 10 degrees within 0.6 s of the first change
{
MouseShake s={0}; uint64_t t=0; int got=0;
for(int i=0;i<4;i++) got|=mouse_shake_step(&s,(i&1)?-12.f:12.f,t+=100000000ull);
assert(got);
s=(MouseShake){0}; t=0; got=0; // a swing made of several small steps counts as one
for(int i=0;i<8;i++) got|=mouse_shake_step(&s,(i/2&1)?-6.f:6.f,t+=50000000ull);
assert(got);
s=(MouseShake){0}; t=0; got=0; // the same swings over 1.2 s: a held object turned back and forth
for(int i=0;i<4;i++) got|=mouse_shake_step(&s,(i&1)?-12.f:12.f,t+=400000000ull);
assert(!got);
s=(MouseShake){0}; t=0; got=0; // swings under 10 degrees
for(int i=0;i<8;i++) got|=mouse_shake_step(&s,(i&1)?-4.f:4.f,t+=50000000ull);
assert(!got);
}
puts("direct mouse: one turn rate, the pitch's square undone, ability gains and the hold after a handoff passed");
puts("direct mouse: a mouse shake while holding, not a slow turn nor small swings passed");
}
'''