Skip to content

feat(gamepad): improve Switch Pro motion and LED support - #114

Merged
ReenigneArcher merged 10 commits into
masterfrom
fix/switch-improvements
Aug 28, 2026
Merged

feat(gamepad): improve Switch Pro motion and LED support#114
ReenigneArcher merged 10 commits into
masterfrom
fix/switch-improvements

Conversation

@ReenigneArcher

@ReenigneArcher ReenigneArcher commented Aug 27, 2026

Copy link
Copy Markdown
Member

Description

Route Switch Pro controllers through native HID protocols, add IMU and player LED support, align report timing and device revision with physical hardware, and update compatibility documentation and tests.

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 Aug 27, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.06452% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.34%. Comparing base (61c0c19) to head (b98fb08).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
tools/virtualhid_control_model.cpp 89.47% 1 Missing and 1 partial ⚠️
src/platform/windows/windows_backend.cpp 97.87% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #114      +/-   ##
==========================================
+ Coverage   72.76%   73.34%   +0.58%     
==========================================
  Files          34       34              
  Lines        8969     9108     +139     
  Branches     3329     3386      +57     
==========================================
+ Hits         6526     6680     +154     
+ Misses       2132     2119      -13     
+ Partials      311      309       -2     
Flag Coverage Δ
FreeBSD 52.72% <79.03%> (+0.39%) ⬆️
Linux-Clang 55.02% <77.90%> (+0.57%) ⬆️
Linux-GCC 65.50% <96.62%> (+0.52%) ⬆️
Windows-MSVC 88.42% <98.42%> (+0.48%) ⬆️
Windows-MinGW-UCRT64 62.92% <95.86%> (+0.66%) ⬆️
macOS 48.64% <79.22%> (+0.50%) ⬆️

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

Files with missing lines Coverage Δ
src/core/gamepad_adapter.cpp 98.77% <100.00%> (+0.01%) ⬆️
src/core/profiles.cpp 94.87% <100.00%> (ø)
src/core/report.cpp 94.14% <100.00%> (+1.02%) ⬆️
src/include/libvirtualhid/gamepad_adapter.hpp 100.00% <100.00%> (ø)
src/include/libvirtualhid/types.hpp 96.52% <100.00%> (+0.09%) ⬆️
src/platform/linux/uhid_backend.cpp 81.64% <100.00%> (+0.36%) ⬆️
src/shared/switch_pro_protocol.hpp 97.00% <100.00%> (ø)
src/platform/windows/windows_backend.cpp 83.35% <97.87%> (+0.89%) ⬆️
tools/virtualhid_control_model.cpp 97.75% <89.47%> (-0.24%) ⬇️

... and 1 file 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 61c0c19...b98fb08. Read the comment docs.

@ReenigneArcher ReenigneArcher changed the title Add native Switch Pro IMU and player LED support fix(profiles): Switch Pro improvements Aug 27, 2026
@ReenigneArcher
ReenigneArcher force-pushed the fix/switch-improvements branch 6 times, most recently from 7766ae1 to 8bef278 Compare August 27, 2026 22:14
Route Linux Switch Pro controllers through descriptor-driven UHID, share the native handshake/reply protocol with Windows, and pack live IMU samples into Switch input reports. The API, control UI, tests, and docs now expose Switch Pro player LED output support and document the updated Linux backend behavior.
@ReenigneArcher
ReenigneArcher force-pushed the fix/switch-improvements branch from 8bef278 to bfeef3c Compare August 27, 2026 23:29
Set the Switch Pro profile version to `0x0210` (matching physical hardware revision behavior) and extend tests to assert the profile version and Windows HID `VersionNumber` exposure. Update platform and end-user compatibility docs with revised Switch Pro motion/battery status, HOME LED limitations, and refreshed validation notes across Windows/Linux and Moonlight clients.
@ReenigneArcher
ReenigneArcher force-pushed the fix/switch-improvements branch from 102f7c6 to 3c07292 Compare August 28, 2026 01:39
Update native Switch Pro input reports to advance Nintendo's packet timer by three for each full-state IMU batch. This better matches physical controller behavior so Windows HID consumers can detect fresh motion data, and it documents the remaining Steam retest gap. Unit and Windows consumer tests were updated to cover the timer progression.
Replace the separate full-state timer (incrementing by 3) with a single per-device counter shared by both subcommand replies (0x21) and full-state input reports (0x30). The counter now increments by 1 per report, matching native controller behavior. On Windows the counter is stored per-device in the VHF record and stamped at submission time. The shared `next_switch_pro_packet_timer` helper is moved to `switch_pro_protocol.hpp` and accepts an optional override so callers can inject a specific value.
Cache the latest native Switch Pro input report in the Windows backend and resend it every 15 ms to match the controller's native 0x30 report cadence. This coalesces separate motion updates, adjusts HID consumer tests to match reports by type instead of exact packet counters, and updates the related Windows support documentation.
Refresh the end-user gamepad compatibility matrix and footnotes to match the latest validation results, including marking Switch Pro motion as working and renumbering related notes and references. Also fix the IDE docs run configuration to open the generated HTML from the current `cmake-build-release-mingw-ucrt64-ninja` path.
Update Linux backend test hooks to capture packet timer bytes from UHID input reports, and adjust the Switch Pro native protocol test to verify the motion input report timer increments from the prior subcommand reply timer. This replaces a brittle fixed timer-byte check with a sequence check that validates correct packet counter behavior.
Refactor the Windows consumer Switch handshake test by moving duplicated proprietary command write/read logic into a shared `send_switch_proprietary_command` helper. This keeps the test focused on expected replies while preserving the existing assertions and behavior.
@ReenigneArcher ReenigneArcher changed the title fix(profiles): Switch Pro improvements feat(gamepad): improve Switch Pro motion and LED support Aug 28, 2026
@ReenigneArcher
ReenigneArcher marked this pull request as ready for review August 28, 2026 14:57
Updated the end-user compatibility guide to mark adaptive triggers as supported on the Linux host backend and refined the related compatibility note to reflect the upstream Moonlight/Sunshine protocol work that is merged but not yet in the latest released client. This keeps the public documentation aligned with the current backend and client support status.
@sonarqubecloud

Copy link
Copy Markdown

@ReenigneArcher
ReenigneArcher merged commit 70f9843 into master Aug 28, 2026
32 checks passed
@ReenigneArcher
ReenigneArcher deleted the fix/switch-improvements branch August 28, 2026 15:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant