Skip to content

feat(input): implement libvirtualhid#5368

Draft
ReenigneArcher wants to merge 11 commits into
masterfrom
libvirtualhid
Draft

feat(input): implement libvirtualhid#5368
ReenigneArcher wants to merge 11 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
  • Test coverage
  • Testing
    • Windows
      • Gamepads
      • Keyboard
      • Mouse
      • Touchscreen
      • Pen
      • Trackpad (not supported on Windows)
    • Linux
      • Gamepads
      • Keyboard
      • Mouse
      • Touchscreen
      • Pen
      • Trackpad
    • FreeBSD
      • Gamepads
      • Keyboard
      • Mouse
      • Touchscreen
      • Pen
      • Trackpad
    • macOS
      • Gamepads (not supported on macOS)
      • 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
  • Publish libvirtualhid driver to MSFT store

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 1.31kB (0.05%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sunshine-esm 855.96kB 1.31kB (0.15%) ⬆️

Affected Assets, Files, and Routes:

view changes for bundle: sunshine-esm

Assets Changed:

Asset Name Size Change Total Size Change (%)
assets/createLucideIcon-*.js 232 bytes 358.72kB 0.06%
assets/config-*.js 969 bytes 70.65kB 1.39%
assets/index-*.js 388 bytes 46.42kB 0.84%
assets/troubleshooting-*.js 135 bytes 9.21kB 1.49%
assets/download-*.js (Deleted) -414 bytes 0 bytes -100.0% 🗑️

@codecov

codecov Bot commented Jul 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 31.26338% with 642 lines in your changes missing coverage. Please review.
✅ Project coverage is 27.26%. Comparing base (24cbf6f) to head (a3e7ed7).
⚠️ Report is 1 commits behind head on master.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/platform/virtualhid_input.cpp 30.61% 342 Missing and 50 partials ⚠️
src/confighttp.cpp 37.41% 61 Missing and 31 partials ⚠️
src/platform/windows/input.cpp 11.84% 57 Missing and 10 partials ⚠️
src/platform/linux/input/virtualhid.cpp 39.28% 43 Missing and 8 partials ⚠️
src/platform/macos/input.cpp 36.66% 38 Missing ⚠️
src/config.cpp 0.00% 0 Missing and 1 partial ⚠️
src/input.cpp 0.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5368      +/-   ##
==========================================
+ Coverage   26.71%   27.26%   +0.55%     
==========================================
  Files         111      105       -6     
  Lines       25329    25052     -277     
  Branches    11198    11182      -16     
==========================================
+ Hits         6766     6831      +65     
+ Misses      16511    14381    -2130     
- Partials     2052     3840    +1788     
Flag Coverage Δ
Archlinux 0.00% <0.00%> (ø)
FreeBSD-aarch64 ?
FreeBSD-amd64 12.83% <13.28%> (-0.36%) ⬇️
Homebrew-macos-14 19.80% <14.82%> (-0.56%) ⬇️
Homebrew-macos-15 19.97% <14.95%> (-0.56%) ⬇️
Homebrew-macos-26 20.09% <14.95%> (-0.56%) ⬇️
Homebrew-ubuntu-24.04 13.43% <18.49%> (+0.49%) ⬆️
Linux-AppImage 12.77% <18.49%> (+0.50%) ⬆️
Windows-AMD64 15.72% <12.89%> (+0.51%) ⬆️
Windows-ARM64 13.66% <11.34%> (+0.41%) ⬆️
macOS-arm64 17.13% <13.97%> (-0.56%) ⬇️
macOS-x86_64 17.78% <13.97%> (-0.60%) ⬇️

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

Files with missing lines Coverage Δ
src/config.h 0.00% <ø> (ø)
src/confighttp.h 100.00% <ø> (ø)
src/platform/common.h 34.37% <ø> (+0.78%) ⬆️
src/config.cpp 24.00% <0.00%> (ø)
src/input.cpp 18.01% <0.00%> (+0.02%) ⬆️
src/platform/macos/input.cpp 40.00% <36.66%> (-9.82%) ⬇️
src/platform/linux/input/virtualhid.cpp 39.28% <39.28%> (ø)
src/platform/windows/input.cpp 7.11% <11.84%> (+6.64%) ⬆️
src/confighttp.cpp 44.73% <37.41%> (+1.71%) ⬆️
src/platform/virtualhid_input.cpp 30.61% <30.61%> (ø)

... and 40 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 24cbf6f...a3e7ed7. 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 2 times, most recently from 818d3ea to 512d2aa Compare July 13, 2026 17:11
Replace the ViGEmBus install/status flow with a unified virtual input driver status endpoint and UI. Update Windows packaging, docs, locale strings, and troubleshooting pages to reflect libvirtualhid as the primary backend, with ViGEmBus shown only as a fallback. Add unit coverage for driver version parsing and status JSON helpers.
Replace Windows-native synthetic pointer/keyboard input implementations with libvirtualhid equivalents:

- Remove keylayout.h and its VK-to-scancode mapping (now handled by libvirtualhid)
- Remove Windows-specific touch/pen device management (HSYNTHETICPOINTERDEVICE, repeat tasks, slot compaction)
- Pass touch_port and flags through to libvirtualhid for keyboard, touch, and pen events
- Add pointer_viewport() and keyboard_event() helpers in virtualhid_input.cpp
- Differentiate LI_TOUCH_EVENT_UP, CANCEL, and HOVER_LEAVE handling for touch contacts
- Add PointerTransition support for pen events
- Update capability detection to use libvirtualhid runtime
- Update libvirtualhid submodule to c1cc7e0
Replace the macOS input implementation with a libvirtualhid-backed backend and route mouse, keyboard, scroll, touch/pen, and gamepad paths through shared virtualhid contexts. Update macOS CMake wiring to build/link libvirtualhid and include the new shared virtualhid input sources, and bump the libvirtualhid submodule to the required revision.
Move libvirtualhid integration from Linux/macOS/Windows compile definition files into common.cmake. This removes duplicated target/library/source wiring, keeps Linux-specific libevdev override variables set before inclusion, and preserves the libevdev -> libvirtualhid build dependency when using the ExternalProject fallback.
Refactor absolute mouse test to use platform-aware touch port helper and account for display origin offsets when verifying expected mouse position. Removes the incorrect `has_input_moved` assertion and updates libvirtualhid submodule.
Implement get_mouse_loc using GetCursorPos on Windows and XQueryPointer on Linux/X11. Remove the GTEST_SKIP for Windows and Linux virtual mouse tests. Replace fixed sleep with polling loop to wait for mouse movement, fix absolute mouse port to use virtual screen metrics on Windows, and relax movement assertions to direction-only checks to account for OS pointer acceleration.
Change `get_mouse_loc()` to return `std::optional<util::point_t>` instead of a sentinel value, properly indicating when the mouse location cannot be observed on a platform. Update all platform implementations (Linux, macOS, Windows) and tests to handle the optional return type. Add libxtst-dev dependency to Linux CI workflow.
Add `NOSONAR(cpp:S1313)` annotations to ViGEmBus version literals in `confighttp.cpp` and its unit test. This documents that `1.17.0.0` is a driver version, not an IP address, and prevents false-positive static analysis warnings.
@ReenigneArcher ReenigneArcher force-pushed the libvirtualhid branch 3 times, most recently from 295ae4f to 9e04ac4 Compare July 14, 2026 23:44
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
29 New issues
6.6% Duplication on New Code (required ≤ 2%)
29 New Code Smells (required ≤ 0)
2 Duplicated Blocks on New Code (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