Skip to content

fix(mapper): apply deadzones and stabilize gesture taps - #493

Merged
BANANASJIM merged 2 commits into
mainfrom
fix/issues-491-492-release
Jul 18, 2026
Merged

fix(mapper): apply deadzones and stabilize gesture taps#493
BANANASJIM merged 2 commits into
mainfrom
fix/issues-491-492-release

Conversation

@BANANASJIM

@BANANASJIM BANANASJIM commented Jul 18, 2026

Copy link
Copy Markdown
Owner

Summary

  • apply configured stick deadzones to gamepad-mode output while preserving zero-deadzone passthrough by default
  • keep gesture gamepad taps observable for 30 ms and emit their release from the timer path without requiring another physical report
  • add regression coverage for both stick sides, deadzone boundaries, omitted defaults, and LS/RS tap timing

Reproduction

Verification

  • ./scripts/padctl-docker test -Dtest-filter='issue 49' --summary all — 5/5 passed
  • ./scripts/padctl-docker test --summary all — 1976 passed, 11 environment-gated skipped
  • pre-push test-tsan in the canonical Zig 0.15.2 Docker image — 1972 passed, 11 environment-gated skipped

Closes #491
Closes #492

Summary by CodeRabbit

  • Bug Fixes

    • Fixed gesture-triggered gamepad taps so press and release events remain observable for the required tap duration.
    • Corrected timer-driven output to deliver both gamepad and auxiliary events.
    • Improved stick deadzone suppression and passthrough behavior when no deadzone is configured.
  • Documentation

    • Clarified default deadzone values and zero-output behavior for gamepad, mouse, and scroll stick modes.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@coderabbitai

coderabbitai Bot commented Jul 18, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

The 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.

Changes

Mapping runtime behavior

Layer / File(s) Summary
Gamepad stick deadzone processing
src/core/stick.zig, src/core/mapper.zig, src/core/mapper.zig tests, docs/src/mapping-config.md
Gamepad deadzone defaults and suppression are centralized, applied to mapped output frames, and covered by regression tests and documentation.
Gesture gamepad tap release tokens
src/core/mapper.zig
Per-source tokens keep gesture-generated gamepad taps active across polls and clear them during reset, auxiliary release, and layer changes.
Macro timer gamepad event dispatch
src/core/mapper.zig, src/event_loop.zig
Timer expiry returns gamepad and auxiliary events, refreshes gamepad frames for gesture tap releases, and emits both event types. Regression coverage validates release after timer expiry.

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
Loading

Possibly related PRs

Suggested reviewers: shakespear-dev

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches the main changes: deadzone handling and gesture tap stabilization.
Linked Issues check ✅ Passed The changes address both #491 deadzone suppression and #492 LS/RS tap observability.
Out of Scope Changes check ✅ Passed The docs, helper refactor, and event-loop updates all support the stated deadzone and tap fixes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/issues-491-492-release

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@BANANASJIM
BANANASJIM merged commit 2792873 into main Jul 18, 2026
37 of 38 checks passed
@BANANASJIM
BANANASJIM deleted the fix/issues-491-492-release branch July 18, 2026 01:26

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

📥 Commits

Reviewing files that changed from the base of the PR and between 3658e4c and beb2443.

📒 Files selected for processing (4)
  • docs/src/mapping-config.md
  • src/core/mapper.zig
  • src/core/stick.zig
  • src/event_loop.zig

Comment thread src/core/stick.zig
Comment on lines +83 to 86
pub fn applyAxisDeadzone(val: i16, deadzone: i16) i16 {
if (@abs(@as(i32, val)) < deadzone) return 0;
return @floatFromInt(val);
return val;
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎯 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.

Suggested change
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.

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.

tap for analog stick press (LS or RS) acting weirdly deadzone is not working?

1 participant