fix(mapper): apply deadzones and stabilize gesture taps - #493
Conversation
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
📝 WalkthroughWalkthroughThe mapper now applies mode-aware gamepad stick deadzones and preserves gesture-generated gamepad taps until their release timers expire. Macro timer expiry emits both gamepad and auxiliary events, with regression tests and updated configuration documentation. ChangesMapping runtime behavior
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant Input as Physical input
participant Mapper
participant Timer as Macro timer
participant EventLoop as Event loop
participant Output as Gamepad output
Input->>Mapper: Gesture tap
Mapper->>Timer: Arm per-source release token
Mapper->>Output: Emit active gamepad tap frame
Timer->>EventLoop: Expiry notification
EventLoop->>Mapper: onMacroTimerExpiredEvents()
Mapper->>Output: Emit refreshed gamepad release frame
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/core/stick.zig`:
- Around line 83-86: Update applyAxisDeadzone so its suppression condition
treats values whose absolute magnitude equals deadzone as suppressed by using a
less-than-or-equal comparison. Preserve returning 0 for values within or exactly
at the boundary, and return val for larger magnitudes.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 60f1050a-3bb5-4eb1-80ea-15fae51112d5
📒 Files selected for processing (4)
docs/src/mapping-config.mdsrc/core/mapper.zigsrc/core/stick.zigsrc/event_loop.zig
| pub fn applyAxisDeadzone(val: i16, deadzone: i16) i16 { | ||
| if (@abs(@as(i32, val)) < deadzone) return 0; | ||
| return @floatFromInt(val); | ||
| return val; | ||
| } |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Include the deadzone value in the suppression boundary.
The PR objective explicitly requires that a reported value exactly matching the deadzone is suppressed (e.g., suppressing 100 when the deadzone is 100). The strict less-than operator fails this requirement. Update the condition to be less-than-or-equal (<=).
🐛 Proposed fix
pub fn applyAxisDeadzone(val: i16, deadzone: i16) i16 {
- if (`@abs`(`@as`(i32, val)) < deadzone) return 0;
+ if (`@abs`(`@as`(i32, val)) <= deadzone) return 0;
return val;
}📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| pub fn applyAxisDeadzone(val: i16, deadzone: i16) i16 { | |
| if (@abs(@as(i32, val)) < deadzone) return 0; | |
| return @floatFromInt(val); | |
| return val; | |
| } | |
| pub fn applyAxisDeadzone(val: i16, deadzone: i16) i16 { | |
| if (`@abs`(`@as`(i32, val)) <= deadzone) return 0; | |
| return val; | |
| } |
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
In `@src/core/stick.zig` around lines 83 - 86, Update applyAxisDeadzone so its
suppression condition treats values whose absolute magnitude equals deadzone as
suppressed by using a less-than-or-equal comparison. Preserve returning 0 for
values within or exactly at the boundary, and return val for larger magnitudes.
Summary
Reproduction
tapfor analog stick press (LSorRS) acting weirdly #492: an LS/RS gesture tap disappeared on the next 1 ms controller reportVerification
./scripts/padctl-docker test -Dtest-filter='issue 49' --summary all— 5/5 passed./scripts/padctl-docker test --summary all— 1976 passed, 11 environment-gated skippedtest-tsanin the canonical Zig 0.15.2 Docker image — 1972 passed, 11 environment-gated skippedCloses #491
Closes #492
Summary by CodeRabbit
Bug Fixes
Documentation