Skip to content

feat(input): implement libvirtualhid adding new gamepad styles - #5368

Merged
ReenigneArcher merged 4 commits into
masterfrom
libvirtualhid
Aug 16, 2026
Merged

feat(input): implement libvirtualhid adding new gamepad styles#5368
ReenigneArcher merged 4 commits into
masterfrom
libvirtualhid

Conversation

@ReenigneArcher

@ReenigneArcher ReenigneArcher commented Jul 3, 2026

Copy link
Copy Markdown
Member

Description

This PR implements libvirtualhid in Sunshine, replacing inputtino on Linux, vigembus on Windows AMD64, and moves the mouse/keyboard input for macOS as well.

We will still falling back to vigembus on Windows ARM64 or in cases where the user doesn't have libvirtualhid's driver installed.

TODO:

  • CI/CD passing
  • Sonar
  • Ensure we cover changes in the following PRs:
  • Test coverage
  • Testing
    • Windows
      • Gamepads
      • Keyboard
      • Mouse
      • Touchscreen
      • Pen
      • Trackpad (not supported on Windows)
    • Linux
      • Gamepads
      • Keyboard
      • Mouse
      • Touchscreen
      • Pen
      • Trackpad
    • FreeBSD
      • Gamepads (gamepads don't appear in browser gamepad API)
      • Keyboard
      • Mouse
      • Touchscreen
      • Pen
      • Trackpad
    • macOS
      • Gamepads (not supported on macOS currently)
      • Keyboard
      • Mouse
      • Touchscreen (not supported on macOS)
      • Pen (not supported on macOS)
      • Trackpad (not supported on macOS)
  • Remove vigembus helpers from web-ui
  • Create release of libvirtualhid

Known issues:

Screenshot

image

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

  • 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

@ReenigneArcher ReenigneArcher changed the title feat: implement libvirtualhid feat(input): implement libvirtualhid Jul 3, 2026
@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Bundle Report

Changes will increase total bundle size by 57.33kB (2.38%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sunshine-esm 877.86kB 57.33kB (6.99%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sunshine-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/logo-*.js 2.5kB 384.41kB 0.65%
assets/logo-*.css 4.74kB 285.74kB 1.69%
assets/config-*.js -2.04kB 73.1kB -2.72%
assets/index-*.js 44.7kB 47.09kB 1872.69% ⚠️
assets/featured-*.js -320 bytes 29.75kB -1.06%
assets/troubleshooting-*.js 6.43kB 14.77kB 77.08% ⚠️
assets/Navbar-*.js 482 bytes 6.67kB 7.79% ⚠️
assets/external-*.js (New) 433 bytes 433 bytes 100.0% 🚀
assets/download-*.js (New) 414 bytes 414 bytes 100.0% 🚀

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.14465% with 268 lines in your changes missing coverage. Please review.
✅ Project coverage is 32.40%. Comparing base (cf52f4b) to head (8570785).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/input.cpp 60.19% 79 Missing and 1 partial ⚠️
src/confighttp.cpp 76.49% 51 Missing and 8 partials ⚠️
src/platform/windows/input.cpp 47.42% 35 Missing and 16 partials ⚠️
src/system_tray.cpp 86.77% 21 Missing and 11 partials ⚠️
src/platform/virtualhid_input.cpp 97.60% 13 Missing and 4 partials ⚠️
src/platform/linux/input/virtualhid.cpp 75.60% 3 Missing and 7 partials ⚠️
src/config.cpp 22.22% 7 Missing ⚠️
src/platform/macos/input.cpp 81.81% 4 Missing ⚠️
src/stream.cpp 20.00% 2 Missing and 2 partials ⚠️
src/rtsp.cpp 0.00% 2 Missing ⚠️
... and 2 more
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5368      +/-   ##
==========================================
+ Coverage   28.10%   32.40%   +4.30%     
==========================================
  Files         109      104       -5     
  Lines       24711    24931     +220     
  Branches    10910    11076     +166     
==========================================
+ Hits         6944     8079    +1135     
+ Misses      16783    14999    -1784     
- Partials      984     1853     +869     
Flag Coverage Δ
Archlinux 0.00% <0.00%> (ø)
FreeBSD-aarch64 ?
FreeBSD-amd64 18.16% <64.30%> (+4.17%) ⬆️
Homebrew-macos-14 28.01% <76.88%> (+5.45%) ⬆️
Homebrew-macos-15 28.70% <76.88%> (+5.49%) ⬆️
Homebrew-macos-26 28.83% <76.88%> (+5.48%) ⬆️
Homebrew-ubuntu-24.04 18.83% <71.58%> (+4.82%) ⬆️
Linux-AppImage 18.26% <73.13%> (+4.83%) ⬆️
Windows-AMD64 23.62% <76.22%> (+6.20%) ⬆️
Windows-ARM64 20.32% <65.20%> (+5.33%) ⬆️
macOS-arm64 25.22% <65.11%> (+5.40%) ⬆️
macOS-x86_64 25.86% <65.11%> (+5.34%) ⬆️

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

Files with missing lines Coverage Δ
src/audio.cpp 85.27% <ø> (ø)
src/config.h 11.11% <ø> (+11.11%) ⬆️
src/confighttp.h 100.00% <ø> (ø)
src/input.h 50.00% <ø> (ø)
src/platform/common.h 58.59% <100.00%> (+25.00%) ⬆️
src/platform/linux/audio.cpp 60.50% <100.00%> (ø)
src/thread_pool.h 30.00% <100.00%> (+5.00%) ⬆️
src/platform/virtualhid_input.h 0.00% <0.00%> (ø)
src/process.cpp 33.41% <0.00%> (-0.08%) ⬇️
src/rtsp.cpp 23.07% <0.00%> (-0.08%) ⬇️
... and 9 more

... and 20 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 cf52f4b...8570785. Read the comment docs.

Comment thread src/confighttp.cpp Fixed
Comment thread tests/unit/test_confighttp.cpp Fixed
Comment thread tests/unit/test_confighttp.cpp Fixed
@ReenigneArcher
ReenigneArcher force-pushed the libvirtualhid branch 7 times, most recently from a3e7ed7 to fe08cf1 Compare July 15, 2026 12:30
@github-actions

github-actions Bot commented Jul 30, 2026

Copy link
Copy Markdown
Last Updated 2026-08-16 19:23:09 UTC
Source Run CI Run #4978
Commit 8570785c6c089a0de465f1324a79ee1c9caf714f

Screenshot Comparison

PR #5368 screenshots vs screenshots baseline.

Matrix: AppImage

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-AMD64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: Windows-ARM64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-arm64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

Matrix: macOS-x86_64

Image Baseline PR
sunshine_tray_initial.png
sunshine_tray_menu.png
sunshine_tray_pairing_request.png
sunshine_tray_paused.png
sunshine_tray_stopped.png
sunshine_tray_streaming.png
sunshine_tray_tooltip.png

@ReenigneArcher
ReenigneArcher force-pushed the libvirtualhid branch 6 times, most recently from beab94f to 0af629e Compare August 10, 2026 19:59
@ReenigneArcher
ReenigneArcher force-pushed the libvirtualhid branch 3 times, most recently from c0e7306 to be323a2 Compare August 14, 2026 02:35
@ReenigneArcher
ReenigneArcher force-pushed the libvirtualhid branch 2 times, most recently from da01bf8 to 3d2a82d Compare August 15, 2026 16:35
Add session-scoped retained input state so virtual gamepads survive paused transport connections and are rebound on resume instead of being recreated. Introduce explicit gamepad termination APIs for global and per-session cleanup, and call them when streams, RTSP sessions, or launched processes are terminated. Add a platform-level `rebind_gamepad` path for both virtualhid and Windows ViGEm backends (with feedback routing synchronization), refactor shared allocation logic, and extend unit coverage for rebind behavior and retained gamepad lifecycle.
Add Linux udev rules that grant input/uaccess permissions to libvirtualhid devices matched by their `phys` path for both `hidraw*` and `event*` nodes, in addition to existing name-based matches. This improves device permission handling when names are inconsistent. Also updates the `third-party/libvirtualhid` submodule to commit `7902b766`.
@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment