-
Notifications
You must be signed in to change notification settings - Fork 862
Description
Description
On Linux, the default Moonlight/Sunshine keyboard shortcuts for display switching and disconnect — Ctrl+Alt+Shift+F1/F2/F3… and Ctrl+Alt+Shift+Esc — conflict with system-level shortcuts (TTY switching, KDE global shortcuts, etc.).
This makes it impossible to use the built-in display switching feature while streaming without remapping or disabling system hotkeys.
Proposed Solution
Add an alternative key mapping on Linux builds: remap Ctrl+Alt+Shift+1..9 to Ctrl+Alt+Shift+F1..F9 before handling shortcuts.
This allows Linux users to switch displays without breaking system TTY/KDE shortcuts.
Patch Location
The change can be applied in
moonlight-qt/app/streaming/input/keyboard.cpp
inside void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
right after the if (event->repeat) {} check (around line 172).
Example Code
// Remap Ctrl+Alt+Shift+1..9 to Ctrl+Alt+Shift+F1..F9 on Linux
if ((event->state == SDL_PRESSED || event->state == SDL_RELEASED) &&
(event->keysym.mod & KMOD_CTRL) &&
(event->keysym.mod & KMOD_ALT) &&
(event->keysym.mod & KMOD_SHIFT) &&
(event->keysym.scancode >= SDL_SCANCODE_1 && event->keysym.scancode <= SDL_SCANCODE_9)) {
int offset = event->keysym.scancode - SDL_SCANCODE_1;
event->keysym.scancode = static_cast<SDL_Scancode>(SDL_SCANCODE_F1 + offset);
event->keysym.sym = static_cast<SDL_Keycode>(SDLK_F1 + offset);
}
This effectively remaps the number row (1–9) when pressed with Ctrl+Alt+Shift to F1–F9.
Now Linux users can press Ctrl+Alt+Shift+1..9 instead of Ctrl+Alt+Shift+F1..F9 to switch displays.
Rationale
This small conditional change solves the conflict on Linux without breaking existing behavior on other platforms.
It can be wrapped in #ifdef linux to only apply on Linux.