Repository navigation
fix(hid-rp): a mouse is not a gamepad (looks_like_gamepad needs an absolute stick, hat or d-pad) - #967
Open
finger563 wants to merge 2 commits into
Open
fix(hid-rp): a mouse is not a gamepad (looks_like_gamepad needs an absolute stick, hat or d-pad)#967finger563 wants to merge 2 commits into
finger563 wants to merge 2 commits into
Conversation
…solute stick, hat or d-pad) GamepadDecoder::looks_like_gamepad() took any Button-page field plus a Generic Desktop X / Y / hat / d-pad as a gamepad, without checking whether the axes were relative. Relative X / Y is pointer motion, so a plain boot mouse, a keyboard with a built-in pointer and a SpaceMouse all classified as gamepads; decoded as one, a mouse's left click came out as South (A) and its motion was dropped. Only absolute direction fields count now. Keyboards were never affected (no Button-page fields). Tests: every hid-rp controller descriptor (Xbox, DualSense, DualShock 4, Switch Pro) is still a gamepad and only a gamepad; a boot mouse, a SpaceMouse, a boot keyboard and a keyboard + pointer combo are not; the new checks fail under the old rule. The Tab5 USB host example still recognises a SpaceMouse by vendor id first, since its descriptor now reads as a mouse. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
|
✅Static analysis result - no issues found! ✅ |
Contributor
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
std::spanrequires C++20; if this target/test suite is built with C++17 (common in… · Newstd::spanrequires C++20; if this target/test suite is built with C++17 (common in… · New This subcase asserts only what the SpaceMouse is not, but the PR description and related… · New The comment says an absolute direction source like 'a stick', but the logic setsdirection = true… · New
What changed in this PR
This PR refines HID device classification so looks_like_gamepad() only treats absolute direction inputs (stick/hat/d-pad) as gamepad signals, preventing mice and other relative-axis devices from being misclassified as controllers.
Changes:
- Update
GamepadDecoder::looks_like_gamepad()to ignore relative X/Y (pointer motion) when deciding gamepad-ness. - Add/adjust host tests to validate classification across shipped controller descriptors plus mouse/keyboard/SpaceMouse cases.
- Update example/inspector documentation/comments to reflect SpaceMouse now classifies as mouse, not gamepad.
| File | Description |
|---|---|
| components/usb_host/tab5_example/main/usb_host_tab5_example.cpp | Updates SpaceMouse classification comment to reflect relative axes. |
| components/usb_host/tab5_example/README.md | Updates SpaceMouse note consistent with new classification. |
| components/hid-rp/test/hid_rp_report_map_host_test.cpp | Adds classification test coverage for controllers vs mouse/keyboard/SpaceMouse. |
| components/hid-rp/test/hid_inspector_host_test.cpp | Updates expected SpaceMouse classification JSON. |
| components/hid-rp/include/hid-rp-report-map.hpp | Implements the core classification change (!f.relative). |
Review effort: Lite
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU
Copilot stopped reviewing on behalf of
finger563 due to an error
December 2, 2026 05:29
This branch has not been deployed
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.



What
GamepadDecoder::looks_like_gamepad()treated any Button-page field plus a Generic Desktop X / Y / hat / d-pad as a gamepad, without checking whether the axes were relative. Relative X / Y is pointer motion, so all of these classified as gamepads:When decoded as a gamepad, a mouse's left click came out as South (A) and all of its motion was dropped.
Now only absolute direction fields count: a stick, a hat or a d-pad.
Who it affects
looks_like_gamepad()alone to accept a device, as the gamepad_map example and README snippet do, accepted a mouse and treated it as a controller. Such a device is now rejected, and the bridge falls back to whatever it does for a non-gamepad.gamepad: false, mouse: true.Keyboards were never affected: they have no Button-page fields.
Tests
hid_rp_report_map_host_testgets a new case, "classification":Under the old rule, the mouse, SpaceMouse and keyboard-plus-pointer checks fail (3 of 31 assertions); with the fix, all pass.
The inspector host test's SpaceMouse expectation is updated. All 40 host tests pass locally, and so does the inspector's headless-Chrome UI test (8 checks) after rebuilding its WebAssembly module.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DFjjnq3XCTRAXENSxsCxJU