Skip to content

Fix Legion Go Y1 being mapped to middle mouse#1384

Open
p3stuff wants to merge 1 commit intoValkirie:mainfrom
p3stuff:fix-legion-go-y1-middle-mouse
Open

Fix Legion Go Y1 being mapped to middle mouse#1384
p3stuff wants to merge 1 commit intoValkirie:mainfrom
p3stuff:fix-legion-go-y1-middle-mouse

Conversation

@p3stuff
Copy link
Copy Markdown

@p3stuff p3stuff commented Mar 13, 2026

This tracks down the Legion Go Y1 binding issue to the Lenovo input parser.

Y1 and B6 were both being decoded from the same BACK_IDX value (128). On Legion Go, B6 is mapped to middle mouse, so pressing Y1 always also triggered middle click even when Y1 was disabled.

This change updates the parser so wheel events use a dedicated wheel byte (WHEEL_IDX = 24) instead of sharing the Y1 byte.

After this change:

  • Y1 no longer generates middle mouse
  • disabling Y1 works as expected
  • wheel click still maps to middle mouse separately

Fixes #1329

Summary by CodeRabbit

  • Refactor
    • Improved Lenovo Legion controller wheel button handling with enhanced input detection logic for buttons B6, B7, and B8, ensuring more reliable and responsive button actions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Mar 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: a8dd4971-bcb8-40cf-807a-a741db5ea732

📥 Commits

Reviewing files that changed from the base of the PR and between 51759a7 and 9048fdb.

📒 Files selected for processing (1)
  • HandheldCompanion/Controllers/Lenovo/LegionController.cs

📝 Walkthrough

Walkthrough

The Legion controller now uses a dedicated WheelState enum to handle wheel button parsing instead of direct byte comparisons. This refactoring replaces magic byte value checks with named enum states (Click, Up, Down, None), improving code clarity while maintaining existing functionality.

Changes

Cohort / File(s) Summary
Wheel State Refactoring
HandheldCompanion/Controllers/Lenovo/LegionController.cs
Introduced WheelState enum and WHEEL_IDX constant. Replaced direct data[BACK_IDX] byte comparisons for wheel actions with WheelState enum parsing from data[WHEEL_IDX]. Updated button mappings: B6→WheelState.Click, B7→WheelState.Up, B8→WheelState.Down.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Poem

🐰 A wheel turns round, now shiny and clean,
With enums so clear—no magic bytes seen!
B6, B7, B8 in order they stand,
States named with pride, as the code was planned.

🚥 Pre-merge checks | ✅ 4 | ❌ 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 (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Fix Legion Go Y1 being mapped to middle mouse' clearly summarizes the main change: resolving the issue where Y1 button incorrectly triggers middle mouse on Legion Go devices.
Linked Issues check ✅ Passed The pull request directly addresses issue #1329 by refactoring the Lenovo input parser to use a dedicated WHEEL_IDX byte for wheel events instead of sharing the Y1 byte, ensuring Y1 can be properly disabled without triggering middle mouse.
Out of Scope Changes check ✅ Passed All changes are contained to the LegionController.cs file and directly address the wheel/Y1 input mapping issue; no unrelated modifications or scope creep are present.

✏️ 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.

Tip

Migrating from UI to YAML configuration.

Use the @coderabbitai configuration command in a PR comment to get a dump of all your UI settings in YAML format. You can then edit this YAML file and upload it to the root of your repository to configure CodeRabbit programmatically.

@Valkirie
Copy link
Copy Markdown
Owner

Valkirie commented Mar 14, 2026

Logic appears correct, except that on my Legion Go 2 controllers, wheel byte IDX is 25 not 24. Are you using Legion Go 1 controllers ?

See current EA fix: https://www.diffchecker.com/FuCy6xgQ/

@p3stuff
Copy link
Copy Markdown
Author

p3stuff commented Mar 18, 2026

Ahh yes, I am using the Legion Go 1 controllers.

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.

Y1 in gamepad mode is permanently bound to middle mouse

2 participants