Skip to content

feat: add Undo/Cut/Copy/Paste keycodes - #5591

Merged
ReenigneArcher merged 1 commit into
SunshineStream:masterfrom
TinfoilSubmarine:undo_cut_copy_paste
Nov 10, 2026
Merged

ReenigneArcher merged 1 commit into
SunshineStream:masterfrom
TinfoilSubmarine:undo_cut_copy_paste

Conversation

@TinfoilSubmarine

Copy link
Copy Markdown
Contributor

Description

Continuation of #5397 with libvirtualhid.

Add support for Undo/Cut/Copy/Paste keycodes (keyboard HID spec usage IDs 0x7A-0x7D). In order to do this I added some ad-hoc/bespoke keycodes in libvirtualhid.

Depends on LizardByte/libvirtualhid#120

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

@TinfoilSubmarine TinfoilSubmarine changed the title add non-VK Undo/Cut/Copy/Paste keycodes add Undo/Cut/Copy/Paste keycodes Aug 31, 2026
@TinfoilSubmarine TinfoilSubmarine changed the title add Undo/Cut/Copy/Paste keycodes feat: add Undo/Cut/Copy/Paste keycodes Aug 31, 2026

@ReenigneArcher ReenigneArcher left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you preserve whether the original packet contained the 0x8000 normalized-key prefix before applying this conversion?

SS_KBE_FLAG_NON_NORMALIZED alone does not distinguish these SDL scancodes from F11–F14. Moonlight Android can set that flag when keyboard-layout normalization is unavailable while still sending 0x8000 | VK_*. With the current ordering, 0x807A becomes 0x7A and is then converted from F11 to Undo; F12–F14 similarly become Cut/Copy/Paste.

Please either apply the 0x7A–0x7D aliases only when the original keycode did not contain 0x8000, or remove the ambiguous aliases and accept only the dedicated 0x0100–0x0103 values. A regression test should cover 0x807A–0x807D with SS_KBE_FLAG_NON_NORMALIZED.


When rebasing this PR, please preserve master’s current remapped-key release behavior.

@sonarqubecloud

Copy link
Copy Markdown

@ReenigneArcher ReenigneArcher left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The F11–F14 prefix handling and regression tests address the earlier finding. The editing-key feature is still absent from current master, but the disconnect cleanup needs the correction described inline.

GitHub confirms merge conflicts against master (d23354d). Please rebase and resolve them before merging, preserving the current extended-key release handling and libvirtualhid updates. The linked LizardByte/libvirtualhid PR #120 is also still open.

A focused MSYS2 UCRT64 gtest harness using the PR's keyboard functions reproduced 16 disconnect/remapping failures; removing the cleanup mask made all 32 cases pass. This used a recorder and stubbed scheduling, so it does not establish full Sunshine or Linux-device validation. Native CI, CodeQL, and lint await maintainer approval; the GH-Pages documentation check timed out waiting for those jobs.

The repository formatter also flags the new condition in src/input.cpp:1180 and the missing blank line after the local test struct in tests/unit/test_input.cpp:316. Please run uv run --locked lb-update-clang-format.

Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh

Comment thread src/input.cpp Resolved
@TinfoilSubmarine

Copy link
Copy Markdown
Contributor Author

Fixed. reset_keyboard_keys() no longer masks the key to the low byte, so held editing keys are released with the same 16-bit code they were pressed with. Added ReleasesHeldEditingKeysWhenClientDisconnects (all 8 scancode and dedicated keycodes) and a remapped-key variant to test_keyboard.cpp. Both fail with the mask restored. Also rebased onto current master with the current remapped-key release behavior preserved, ran lb-update-clang-format, and updated the libvirtualhid pin. Verified manually on a Linux host: a held Paste is released after the client times out.

ReenigneArcher
ReenigneArcher previously approved these changes Nov 9, 2026

Copy link
Copy Markdown
Member

@TinfoilSubmarine LizardByte/libvirtualhid#120 is now merged. Please update third-party/libvirtualhid to the latest libvirtualhid master commit, currently be43bef46e7f7f53c4eb4c93e51ea78a66f3795e, so this PR references the merged upstream commit.

Review completed by Codex | Model: gpt-6.1-sol | Thinking: xhigh

Map the non-normalized Undo/Cut/Copy/Paste keys (sent by clients as SDL
scancodes 0x7A-0x7D or dedicated 0x0100-0x0103 values) to the native
Linux editing keys via libvirtualhid. Only apply the scancode aliases
when the original keycode lacked the 0x8000 normalized-key prefix so the
F11-F14 virtual keys are not reinterpreted.

Release held keys with their full 16-bit keycode when a client
disconnects, so the editing keys are not left held after the stream
ends.
@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Bundle Report

Bundle size has no change ✅

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@codecov

codecov Bot commented Nov 9, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 49.39%. Comparing base (0ddc73d) to head (5574791).
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #5591      +/-   ##
==========================================
+ Coverage   49.36%   49.39%   +0.03%     
==========================================
  Files         143      143              
  Lines       31302    31320      +18     
  Branches    13353    13362       +9     
==========================================
+ Hits        15451    15471      +20     
- Misses      13453    13771     +318     
+ Partials     2398     2078     -320     
Flag Coverage Δ
Alpine-aarch64 33.11% <100.00%> (+0.05%) ⬆️
Alpine-x86_64 33.24% <100.00%> (+0.05%) ⬆️
Archlinux 34.26% <ø> (ø)
FreeBSD-amd64 33.91% <100.00%> (+0.06%) ⬆️
Homebrew-macos-15 47.98% <100.00%> (+0.06%) ⬆️
Homebrew-macos-26 48.39% <100.00%> (+0.08%) ⬆️
Homebrew-ubuntu-24.04 36.35% <100.00%> (+0.05%) ⬆️
Linux-AppImage-aarch64 38.87% <100.00%> (+0.04%) ⬆️
Linux-AppImage-x86_64 39.13% <100.00%> (+0.04%) ⬆️
PowerShell 100.00% <ø> (ø)
Web-UI 56.67% <ø> (ø)
Windows-AMD64 39.85% <ø> (ø)
Windows-ARM64 33.86% <ø> (ø)
macOS-arm64 40.55% <100.00%> (+0.06%) ⬆️
macOS-x86_64 40.10% <100.00%> (+0.07%) ⬆️

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

Files with missing lines Coverage Δ
src/input.cpp 69.92% <100.00%> (+0.41%) ⬆️

... and 30 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 0ddc73d...5574791. Read the comment docs.

@github-actions

github-actions Bot commented Nov 9, 2026 •

Copy link
Copy Markdown
Last Updated 2026-11-10 03:35:10 UTC
Source Run CI Run #6655
Commit 5574791fb0917b230835dad409f59f1c8d3bc218

Screenshot Comparison

PR #5591 screenshots vs screenshots baseline.

Matrix: AppImage-aarch64

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: AppImage-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

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 merged commit 9874dfa into SunshineStream:master Nov 10, 2026
152 of 155 checks passed
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.

2 participants