Skip to content

add option to suppress gamepad bindings for sticks/dpad when in remapped layer#22

Merged
BANANASJIM merged 2 commits intoBANANASJIM:mainfrom
kirpy0x:suppress-base-bindings
Mar 13, 2026
Merged

add option to suppress gamepad bindings for sticks/dpad when in remapped layer#22
BANANASJIM merged 2 commits intoBANANASJIM:mainfrom
kirpy0x:suppress-base-bindings

Conversation

@kirpy0x
Copy link
Copy Markdown
Contributor

@kirpy0x kirpy0x commented Mar 10, 2026

Adds an optional config value "suppress_base_binding" that can be added to stick_left, stick_right and dpad that suppresses the controllers normal binding while in that layer.

Summary by CodeRabbit

  • New Features
    • Added per-layer suppress_gamepad option for sticks and D-pad to disable gamepad inputs when a layer is active
    • Separate left/right stick support for mouse control with independent sensitivity and deadzone handling
    • Per-stick scrolling (left/right) and improved per-layer trigger suppression to prevent unintended inputs
  • Behavior
    • Suppressed inputs are now zeroed out when a layer requests suppression

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 10, 2026

📝 Walkthrough

Walkthrough

Per-layer gamepad suppression added: config gains suppress_gamepad for sticks and D-pad; Gamepad class tracks per-input suppression flags; gamepad processing applies layer-driven suppression for left/right sticks, D-pad, and triggers and prevents suppressed inputs from being emitted or translated to mouse/scroll.

Changes

Cohort / File(s) Summary
Config TOML
config/config.toml
Added suppress_gamepad = true entries to relevant per-layer stick_right, stick_left, and dpad configurations.
Config Parsing
src/config.cpp
Parse and assign suppress_gamepad for stick and dpad configs when loading TOML.
Config Types
include/vader5/config.hpp
Added bool suppress_gamepad{false}; to StickConfig and DpadConfig.
Gamepad State
include/vader5/gamepad.hpp
Added private suppression state flags: suppress_{left,right}_stick_, suppress_dpad_, suppress_{left,right}_trigger_ and matching prev_suppress_* fields.
Suppression & Input Flow
src/gamepad.cpp
Apply per-layer suppression during processing: compute left/right mouse modes, set suppression flags when layers with suppress_gamepad are active, per-stick deadzone/sensitivity handling, per-stick scrolling, propagate layer remap suppression to triggers, clear suppressed axes/triggers when emitting state, and maintain prev-suppression tracking for delta emissions.

Sequence Diagram(s)

sequenceDiagram
    autonumber
    participant Config as Config Loader
    participant Gamepad as Gamepad Poll
    participant LayerMgr as Layer Manager
    participant Mouse as Mouse/Scroll
    participant Emitter as Output Emitter

    Config->>Gamepad: load stick/dpad suppress_gamepad flags
    Gamepad->>LayerMgr: poll active layers & layer remaps
    LayerMgr-->>Gamepad: indicate active layers + suppress flags
    Gamepad->>Gamepad: set suppress_left/right_stick_, suppress_dpad_, suppress_triggers_
    Gamepad->>Mouse: if not suppressed -> translate stick to mouse/scroll (apply deadzone/sensitivity)
    Gamepad->>Emitter: build output state (zero suppressed axes/triggers)
    Emitter-->>Gamepad: ack / sync (prev_suppress_* updated)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

Review effort 3/5

Poem

🐰 In layered fields where buttons play,
I nudge the sticks from stray display.
Some inputs hush when layers say "stay" —
A quiet hop, then on our way! 🎮✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The PR title accurately and concisely describes the main change: adding a suppress_gamepad option for sticks and dpad in remapped layers.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
📝 Coding Plan
  • Generate coding plan for human review comments

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 and usage tips.

Copy link
Copy Markdown
Owner

@BANANASJIM BANANASJIM left a comment

Choose a reason for hiding this comment

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

Nice idea — suppressing the base gamepad input when a layer remaps sticks/dpad to mouse/arrows makes a lot of sense to avoid double input.

A few things I noticed:

  1. Left stick mouse mode: process_mouse_stick only sets suppress_right_stick_, so if a user configures stick_left = { mode = "mouse", suppress_base_binding = true }, the left stick won't actually be suppressed. Might need to handle both sticks there.

  2. Naming: suppress_base_binding is a bit ambiguous — something like suppress_gamepad or exclusive might be clearer about what it does (i.e. "don't emit the raw gamepad axis/dpad when this mode is active").

  3. Base config interaction: If someone sets suppress_base_binding = true in the base config (not inside a layer), the stick/dpad would be permanently zeroed out. Might be worth either documenting that this is layer-only, or adding a warning when it's set outside a layer.

Happy to discuss any of these!

@kirpy0x
Copy link
Copy Markdown
Contributor Author

kirpy0x commented Mar 11, 2026

Yeah I've noticed I struggle with config option names sometimes lol, I'll swap it to suppress_gamepad. Good catch on the left stick mouse mode. I'll take a look at that and warning and maybe also ignoring it when outside a layer in a couple days.

@xl666
Copy link
Copy Markdown

xl666 commented Mar 12, 2026

Sorry for bumping.

I noticed that the PR solves the problem except for RT and LT. Also related to the discussion, there is a general problem in wich this config is not possible:
stick_left = { mode = "mouse"}
stick_right = { mode = "scroll"}

Looking at the code right stick is only considered for mouse and left stick is only considered for scroll.

@kirpy0x kirpy0x force-pushed the suppress-base-bindings branch 2 times, most recently from 2ec8b68 to 6c126cb Compare March 13, 2026 14:56
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

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 the current code and only fix it if needed.

Inline comments:
In `@src/gamepad.cpp`:
- Around line 511-529: In needs_mouse(), update the layer check so that
left-stick layers that set mode to Mouse are treated the same as Scroll: modify
the condition that currently only tests layer.stick_left->mode ==
StickConfig::Scroll to also accept layer.stick_left->mode == StickConfig::Mouse;
this aligns needs_mouse() with the base logic in get_effective_stick_left() and
the runtime behavior in process_mouse_stick() so an InputDevice is created when
a layer declares stick_left with mode Mouse.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 9035dd06-b26a-4b5f-b249-412186785568

📥 Commits

Reviewing files that changed from the base of the PR and between a978121 and 6c126cb.

📒 Files selected for processing (5)
  • config/config.toml
  • include/vader5/config.hpp
  • include/vader5/gamepad.hpp
  • src/config.cpp
  • src/gamepad.cpp

Comment thread src/gamepad.cpp
@kirpy0x kirpy0x force-pushed the suppress-base-bindings branch from 6c126cb to 3df5a90 Compare March 13, 2026 15:23
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/gamepad.cpp (1)

122-135: ⚠️ Potential issue | 🟠 Major

needs_mouse() still misses right-stick Scroll, which can disable scrolling at runtime.

Line 108 and Line 127 only treat right stick Mouse as requiring InputDevice. Since process_scroll_stick() now supports right stick scroll, a config using only right-stick scroll may never create input_, and scroll output won’t work.

🔧 Proposed fix
 auto needs_mouse(const Config& cfg) -> bool {
@@
-    if (cfg.right_stick.mode == StickConfig::Mouse) {
+    if (cfg.right_stick.mode == StickConfig::Mouse ||
+        cfg.right_stick.mode == StickConfig::Scroll) {
         return true;
     }
@@
-        if (layer.stick_right && layer.stick_right->mode == StickConfig::Mouse) {
+        if (layer.stick_right &&
+            (layer.stick_right->mode == StickConfig::Mouse ||
+             layer.stick_right->mode == StickConfig::Scroll)) {
             return true;
         }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/gamepad.cpp` around lines 122 - 135, The needs_mouse() loop over
cfg.layers misses the case where the right stick uses Scroll, so add a check for
layer.stick_right->mode == StickConfig::Scroll (similar to the existing
left-stick Scroll check) so configs that rely on right-stick scrolling still
create the input_ device; update the needs_mouse() function to test both
stick_right Mouse and stick_right Scroll (referencing cfg.layers, needs_mouse(),
and StickConfig::Scroll) to ensure process_scroll_stick() will have input_
available at runtime.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Outside diff comments:
In `@src/gamepad.cpp`:
- Around line 122-135: The needs_mouse() loop over cfg.layers misses the case
where the right stick uses Scroll, so add a check for layer.stick_right->mode ==
StickConfig::Scroll (similar to the existing left-stick Scroll check) so configs
that rely on right-stick scrolling still create the input_ device; update the
needs_mouse() function to test both stick_right Mouse and stick_right Scroll
(referencing cfg.layers, needs_mouse(), and StickConfig::Scroll) to ensure
process_scroll_stick() will have input_ available at runtime.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 912b921b-5113-4baa-b826-06268d7effac

📥 Commits

Reviewing files that changed from the base of the PR and between 6c126cb and 3df5a90.

📒 Files selected for processing (5)
  • config/config.toml
  • include/vader5/config.hpp
  • include/vader5/gamepad.hpp
  • src/config.cpp
  • src/gamepad.cpp
🚧 Files skipped from review as they are similar to previous changes (2)
  • include/vader5/config.hpp
  • include/vader5/gamepad.hpp

@kirpy0x
Copy link
Copy Markdown
Contributor Author

kirpy0x commented Mar 13, 2026

  • Renamed to suppress_gamepad
  • now ignoring the option if not in a layer
  • Works for both stick for both modes.
  • triggers will be suppress similar to face buttons when remapped in layer.

@BANANASJIM
Copy link
Copy Markdown
Owner

lgtm, Thanks for you contribution!

@BANANASJIM BANANASJIM merged commit 7849084 into BANANASJIM:main Mar 13, 2026
6 checks passed
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.

3 participants