Skip to content

fix(driver): Inject synthetic events for missing axis during rotation#97

Open
Gnarus-G wants to merge 1 commit intomainfrom
fix/rotation-missing-axis-injection
Open

fix(driver): Inject synthetic events for missing axis during rotation#97
Gnarus-G wants to merge 1 commit intomainfrom
fix/rotation-missing-axis-injection

Conversation

@Gnarus-G
Copy link
Owner

@Gnarus-G Gnarus-G commented Feb 7, 2026

Fix rotation not being applied when mouse reports only a single axis (REL_X or REL_Y).

Problem

When rotation is enabled and the mouse moves in a purely horizontal or vertical direction, the Linux kernel only sends EV_REL events for the axis that has movement — not both. The rotation transform (x' = x*cos(a) - y*sin(a), y' = x*sin(a) + y*cos(a)) produces a non-zero cross-axis component, but it was silently discarded because set_y_move()/set_x_move() no-ops when MOVEMENT.y/MOVEMENT.x is NULL (no event to write into).

Reproduction: Set rotation to 45 degrees, move the mouse exactly horizontally. The cursor moves straight — as if rotation isn't applied at all.

This issue was reported in #90 and also tracked upstream in YeetMouse#52.

Solution

When rotation is active and one axis is missing from a frame:

  1. mouse_move.h: ensure_axes_for_rotation() points the missing axis pointer to synthetic local storage (initialized to 0), allowing f_accelerate to write the rotated component through it.

  2. input_handler.h: After the compaction pass (which removes zero-valued events), if a synthetic axis has a non-zero value, inject it as a new EV_REL event into the vals array before SYN_REPORT. Uses handle->dev->max_vals for bounds checking.

  3. Tests: Added rotation test cases (45 and 90 degrees) to accel.test.c confirming the math is correct:

    • At 45°: (10, 0) => (7, 7)
    • At 90°: (10, 0) => (0, 10)

Zero overhead when rotation is disabled — ensure_axes_for_rotation() is only called when PARAM_ANGLE_ROTATION != "0".

Works on all kernel versions (pre and post 6.11.0), consistent with existing const-cast behavior on older kernels.

Closes #90

@vercel
Copy link

vercel bot commented Feb 7, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
maccel Error Error Feb 7, 2026 4:46pm

When rotation is enabled and the mouse moves along a single axis, the
kernel only sends REL_X or REL_Y (not both). The rotation transform
produces a cross-axis component that was silently discarded because
there was no event struct to write it into.

Inject synthetic EV_REL events into the vals array for the missing axis
when rotation produces a non-zero cross-axis value. Uses dev->max_vals
for bounds checking to ensure safe array access.

Closes #90
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rotation not being applied when moving along one axis

1 participant