fix(driver): Inject synthetic events for missing axis during rotation#97
Open
fix(driver): Inject synthetic events for missing axis during rotation#97
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
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
5994d33 to
6646f9a
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_RELevents 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 becauseset_y_move()/set_x_move()no-ops whenMOVEMENT.y/MOVEMENT.xis 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:
mouse_move.h:ensure_axes_for_rotation()points the missing axis pointer to synthetic local storage (initialized to 0), allowingf_accelerateto write the rotated component through it.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 newEV_RELevent into thevalsarray beforeSYN_REPORT. Useshandle->dev->max_valsfor bounds checking.Tests: Added rotation test cases (45 and 90 degrees) to
accel.test.cconfirming the math is correct:(10, 0) => (7, 7)✓(10, 0) => (0, 10)✓Zero overhead when rotation is disabled —
ensure_axes_for_rotation()is only called whenPARAM_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