Skip to content

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

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

fix(linux): route Xbox Series gamepad through uinput#54
ReenigneArcher wants to merge 9 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

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
102 3 99 2
View the top 3 failed test(s) by shortest run time
VirtualHidControlModelTest::SummarizesOutputState
Stack Traces | 0s run time
.../tests/unit/test_virtualhid_control_model.cpp:174
Expected equality of these values:
  control::output_summary(state, generic)
    Which is: L"Output: no reports received"
  L"Output: no reports received | profile has no normalized feedback categories"
VirtualHidControlModelTest::SummarizesProfileFeatures
Stack Traces | 0s run time
.../tests/unit/test_virtualhid_control_model.cpp:136
Expected equality of these values:
  control::profile_feature_summary(generic)
    Which is: L"Features: battery no | rumble yes | trigger rumble no | RGB LED no | adaptive triggers no | raw output yes"
  L"Features: battery no | rumble no | trigger rumble no | RGB LED no | adaptive triggers no | raw output no"
LinuxConsumerTest::SdlSeesGenericCanonicalButtons
Stack Traces | 0.244s run time
.../tests/unit/test_linux_consumers.cpp:372
Expected: (SDL_JoystickNumButtons(joystick)) >= (minimum_buttons), actual: 16 vs 20

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@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.
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
2 New issues
2 New Code Smells (required ≤ 0)

See analysis details on SonarQube Cloud

💡 Need a hand with PR review? Try Gitar by Sonar!

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