Skip to content

fix(linux): route Xbox Series gamepad through uinput#54

Draft
ReenigneArcher wants to merge 15 commits into
masterfrom
fix/linux/gamepad-mappings
Draft

fix(linux): route Xbox Series gamepad through uinput#54
ReenigneArcher wants to merge 15 commits into
masterfrom
fix/linux/gamepad-mappings

Conversation

@ReenigneArcher

@ReenigneArcher ReenigneArcher commented Jul 14, 2026

Copy link
Copy Markdown
Member

Description

Adds a dedicated Linux uinput Xbox Series backend that emits canonical evdev button/axis events and translates force-feedback effects back into normalized rumble callbacks, while keeping other gamepads on UHID. The backend gamepad submit interface now accepts both normalized state and packed report so native backends can consume state directly. It also updates gamepad descriptors/report packing (including misc1 button handling and hat-based dpad bits), sets Switch Pro UHID bus to virtual, refreshes platform/usage docs, and expands Linux adapter/backend/consumer tests accordingly.

Screenshot

Issues Fixed or Closed

Roadmap Issues

Type of Change

  • feat: New feature (non-breaking change which adds functionality)
  • fix: Bug fix (non-breaking change which fixes an issue)
  • docs: Documentation only changes
  • style: Changes that do not affect the meaning of the code (white-space, formatting, missing semicolons, etc.)
  • refactor: Code change that neither fixes a bug nor adds a feature
  • perf: Code change that improves performance
  • test: Adding missing tests or correcting existing tests
  • build: Changes that affect the build system or external dependencies
  • ci: Changes to CI configuration files and scripts
  • chore: Other changes that don't modify src or test files
  • revert: Reverts a previous commit
  • BREAKING CHANGE: Introduces a breaking change (can be combined with any type above)

Checklist

  • Code follows the style guidelines of this project
  • Code has been self-reviewed
  • Code has been commented, particularly in hard-to-understand areas
  • Code docstring/documentation-blocks for new or existing methods/components have been added or updated
  • Unit tests have been added or updated for any new or modified functionality

AI Usage

See our AI usage policy.

  • None: No AI tools were used in creating this PR
  • Light: AI provided minor assistance (formatting, simple suggestions)
  • Moderate: AI helped with code generation or debugging specific parts
  • Heavy: AI generated most or all of the code changes

@codecov

codecov Bot commented Jul 14, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.77446% with 283 lines in your changes missing coverage. Please review.
✅ Project coverage is 75.90%. Comparing base (7bcfe6c) to head (719d013).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/linux/uhid_backend.cpp 71.79% 64 Missing and 68 partials ⚠️
src/platform/windows/shared/generic_pid_rumble.hpp 69.95% 70 Missing and 3 partials ⚠️
...c/platform/windows/shared/generic_pid_protocol.hpp 68.22% 61 Missing ⚠️
...rm/windows/shared/playstation_feature_protocol.hpp 95.09% 5 Missing ⚠️
src/core/report.cpp 97.48% 2 Missing and 2 partials ⚠️
...rc/platform/windows/shared/switch_pro_protocol.hpp 96.80% 3 Missing ⚠️
src/platform/windows/windows_backend.cpp 97.52% 3 Missing ⚠️
src/core/profiles.cpp 94.11% 2 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #54      +/-   ##
==========================================
+ Coverage   74.88%   75.90%   +1.01%     
==========================================
  Files          19       24       +5     
  Lines        5890     7260    +1370     
  Branches     2246     2730     +484     
==========================================
+ Hits         4411     5511    +1100     
- Misses       1279     1484     +205     
- Partials      200      265      +65     
Flag Coverage Δ
Linux-Clang 57.34% <60.18%> (+1.54%) ⬆️
Linux-GCC 68.38% <68.75%> (+<0.01%) ⬆️
Windows-MSVC 87.92% <85.66%> (-0.69%) ⬇️
Windows-MinGW-UCRT64 65.74% <75.17%> (+2.24%) ⬆️
macOS 51.19% <56.79%> (+1.16%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
src/core/backend.cpp 100.00% <100.00%> (ø)
src/core/backend.hpp 82.00% <ø> (ø)
src/core/gamepad_adapter.cpp 98.76% <100.00%> (ø)
src/core/runtime.cpp 82.02% <100.00%> (+0.02%) ⬆️
src/platform/windows/control_protocol.hpp 100.00% <100.00%> (ø)
...latform/windows/shared/windows_device_identity.hpp 100.00% <100.00%> (ø)
src/core/profiles.cpp 94.80% <94.11%> (+2.97%) ⬆️
...rc/platform/windows/shared/switch_pro_protocol.hpp 96.80% <96.80%> (ø)
src/platform/windows/windows_backend.cpp 86.55% <97.52%> (+1.24%) ⬆️
src/core/report.cpp 92.36% <97.48%> (+1.56%) ⬆️
... and 4 more

... and 2 files with indirect coverage changes


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 7bcfe6c...719d013. Read the comment docs.

@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from b799c70 to cb4c5f9 Compare July 14, 2026 23:03
@ReenigneArcher ReenigneArcher changed the title fix(linux): refine gamepad HID mappings and Linux bus fix(linux): route Xbox Series gamepad through uinput Jul 14, 2026
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch 2 times, most recently from 61eb72a to 01dec7e Compare July 14, 2026 23:44
Adds a dedicated Linux uinput Xbox Series backend that emits canonical evdev button/axis events and translates force-feedback effects back into normalized rumble callbacks, while keeping other gamepads on UHID. The backend gamepad submit interface now accepts both normalized state and packed report so native backends can consume state directly. It also updates gamepad descriptors/report packing (including misc1 button handling and hat-based dpad bits), sets Switch Pro UHID bus to virtual, refreshes platform/usage docs, and expands Linux adapter/backend/consumer tests accordingly.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from 01dec7e to b44a75e Compare July 15, 2026 02:07
Match the active evdev capabilities exposed by the USB xpad driver instead of the full 15-slot HID layout. Remove unused BTN_C, BTN_Z, BTN_TL2, and BTN_TR2 capabilities that shifted Guide, L3, and R3 indices. Set firmware version to 0x050D for a known SDL/Steam USB mapping. Add Guide button to consumer test coverage.
Update the Linux uinput backend to advertise Xbox Series controllers as Bluetooth with product ID 0x0B13, while keeping the public profile identity unchanged. The evdev key capabilities now include the full 15-slot HID button range (including reserved C/Z/TL2/TR2 slots) so SDL/Steam button indices stay stable and Guide/L3/R3 map correctly. Unit and consumer tests were updated accordingly, and platform support docs now describe the identity split and reserved-slot behavior.
Generalizes the Linux uinput gamepad backend from Xbox Series-only to support Generic, Xbox 360, Xbox One, and Xbox Series profiles. Extracts `uses_uinput_gamepad_profile()` predicate, renames `UinputXboxGamepad` to `UinputGamepad`, makes rumble and misc1 (Share) button conditional on profile capabilities, and updates tests and docs accordingly.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch 3 times, most recently from 26e03dd to 5e41124 Compare July 16, 2026 20:51
Enable generic and Xbox 360 gamepad profiles to emit BTN_DPAD_* events alongside their hat axes, allowing consumers that prefer digital D-pad buttons to receive them directly.

Also correct Xbox One and Xbox Series to use their Bluetooth product IDs (0x0B20 and 0x0B13) for their Linux uinput devices, matching the standard consumer mappings those identities carry.

Update documentation and tests to verify D-pad button capabilities and events across profiles.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from 5e41124 to af8d805 Compare July 17, 2026 01:51
Update the Linux uinput backend so Xbox 360 profiles use the sparse Linux gamepad button slots like the other uinput gamepads, while limiting BTN_DPAD_* emission to the generic profile. The tests and platform support docs were updated to reflect the new capability layout and D-pad behavior.
Use the Bluetooth bus for the sparse Xbox uinput evdev mapping across Xbox 360, One, and Series profiles, and rename the bus constant to reflect the broader scope.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from 87a1526 to c5fadf4 Compare July 17, 2026 03:23
@ReenigneArcher
ReenigneArcher marked this pull request as draft July 17, 2026 03:58
Split Linux uhid/uinput gamepad setup and submit logic into focused helper functions for event types, buttons, axes, and force-feedback while preserving behavior. This improves readability and reduces duplication in button emission paths. Unit tests were updated to reuse a shared pressed-key extraction helper, and consumer profile setup now explicitly checks optional product IDs with `has_value()` for clarity.
Moves Linux Switch Pro gamepads from descriptor-driven UHID behavior to a uinput-native mapping, including Nintendo face-button positions, button-based ZL/ZR triggers, BTN_Z for Capture, and hat-only D-pad reporting. The Linux backend now treats Generic/Xbox/Switch Pro as uinput gamepads with normalized FF rumble callbacks, while DualShock 4 and DualSense stay on UHID.

Also enables rumble capability for Generic and Switch Pro profiles, updates output parsing so Switch Pro reports remain raw instead of being misread as generic rumble packets, and improves UHID output handling by honoring SET_REPORT report numbers and control-path output frames. Tests and docs were updated to match the new profile capabilities and Linux platform behavior.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from ca031eb to 0b0f6df Compare July 17, 2026 21:29
Update built-in profiles to use clearer default device names and document those names in the usage guide. On Linux, adjust uinput gamepad behavior so the generic profile uses BTN_DPAD_* instead of hat axes, expand supported force-feedback effect normalization beyond FF_RUMBLE, and stop re-inserting UHID report numbers into output reports. Tests were extended to cover the new profile names, D-pad capabilities, Switch Pro SDL behavior, and additional rumble effect types.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from ef6afa8 to fbfa4df Compare July 18, 2026 12:51
Move the generic gamepad's D-pad into the platform-neutral button bitmap and expose all Linux uinput gamepads through ABS_HAT0X/ABS_HAT0Y for a single evdev mapping. On the Linux UHID path, normalize SET_REPORT payloads, discover hidraw nodes by UHID metadata, and add a short startup delay before reading feedback so PlayStation and early rumble output stay reliable. Docs and tests were updated to match the new report layout and backend behavior.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from fbfa4df to 3246918 Compare July 18, 2026 14:29
Reworks gamepad output handling to use native PID-style rumble for Generic/Xbox profiles, decodes Switch Pro native rumble reports, and limits legacy 5-byte rumble parsing to Xbox 360. On Windows, UMDF output reads/events are now tracked per file handle so output callbacks are delivered to the runtime that created each device. On Linux, Generic uinput devices now use an Xbox-compatible VID/PID mapping for better Steam/browser behavior while keeping the public profile identity unchanged.

Also updates CI udev rules, platform docs, and broad test coverage (including new Windows consumer integration tests) to validate descriptor changes, button packing, output normalization, and backend routing behavior.
Introduces major gamepad protocol upgrades across backends: Windows now maps the Generic profile to a DirectInput PID joystick (descriptor rewrite, feature/output handling, timed rumble scheduling), adds shared driver helpers, and implements native PlayStation feature-report responses plus Switch Pro handshake/reply behavior. Linux backend now reuses shared PlayStation feature payloads, keeps Generic VID/PID on uinput while exposing both hat and BTN_DPAD events, and fixes force-feedback lifetime handling for infinite and reuploaded effects. CI/docs/tests were expanded to cover the new behavior, including hid_playstation module requirements and new Windows driver protocol and consumer integration coverage.
@ReenigneArcher
ReenigneArcher force-pushed the fix/linux/gamepad-mappings branch from 5a46bbd to 7bde9bd Compare July 19, 2026 04:07
Switch Xbox Series Windows transport from XInputHID (0x0B12/&IG_00) to the native Bluetooth HID identity (0x0B13) with a 17-byte input packet, exposing the Share button to SDL/Steam without binding the legacy 15-button XInput surface.

Expand the Generic PID report descriptor to the complete DirectInput output-report set required for enumeration; Constant and Sine are still the only effects normalized as rumble.

Bump the Windows control-protocol version to 2 and double the max descriptor capacity to 2048 bytes so a stale driver fails explicitly on version mismatch.

Extend Xbox Series rumble parsing to accept report-ID-3 packets from the Bluetooth HID path.

Move the Linux Generic profile onto the sparse uinput button-slot sequence and drop BTN_DPAD_* capabilities so D-pad directions are published only through hat axes.

Fix Switch Pro stick Y-axis sign inversion.

Downgrade the hid_playstation CI load failure to a warning; replace per-test output-wait boilerplate with a GamepadOutputCapture helper.
Stops rewriting Xbox Series reports/descriptors to the Bluetooth HID format and keeps the profile’s native transport data in Windows create requests and report submission. The Windows driver now advertises a Series-specific XInputHID-compatible match ID (`VID_045E&PID_0B13&IG_00`) while preserving the public `VID_045E&PID_0B12` identity. Updates docs, validation scripts, and unit/consumer tests to reflect the new identity behavior. Also enables `BTN_DPAD_*` events for the Linux Generic profile alongside hat axes, and adjusts CI/test expectations when `hid_playstation` is unavailable.
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant