From 76b4922bbe9d7b34d5a492ebe7a5c7a8ebbf52d0 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 12 Jan 2021 20:05:18 -0600 Subject: [PATCH] Add toggle for system key capture --- app/cli/commandlineparser.cpp | 4 ++++ app/gui/SettingsView.qml | 19 +++++++++++++++++++ app/settings/streamingpreferences.cpp | 3 +++ app/settings/streamingpreferences.h | 3 +++ app/streaming/input/input.cpp | 3 ++- 5 files changed, 31 insertions(+), 1 deletion(-) diff --git a/app/cli/commandlineparser.cpp b/app/cli/commandlineparser.cpp index 478b44a2..fbfcdbf5 100644 --- a/app/cli/commandlineparser.cpp +++ b/app/cli/commandlineparser.cpp @@ -307,6 +307,7 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference parser.addToggleOption("background-gamepad", "background gamepad input"); parser.addToggleOption("reverse-scroll-direction", "inverted scroll direction"); parser.addToggleOption("swap-gamepad-buttons", "swap A/B and X/Y gamepad buttons (Nintendo-style)"); + parser.addToggleOption("capture-system-keys", "capture system key combos in fullscreen mode"); parser.addChoiceOption("video-codec", "video codec", m_VideoCodecMap.keys()); parser.addChoiceOption("video-decoder", "video decoder", m_VideoDecoderMap.keys()); @@ -421,6 +422,9 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference // Resolve --swap-gamepad-buttons and --no-swap-gamepad-buttons options preferences->swapFaceButtons = parser.getToggleOptionValue("swap-gamepad-buttons", preferences->swapFaceButtons); + // Resolve --capture-system-keys and --no-capture-system-keys options + preferences->captureSysKeys = parser.getToggleOptionValue("capture-system-keys", preferences->captureSysKeys); + // Resolve --video-codec option if (parser.isSet("video-codec")) { preferences->videoCodecConfig = mapValue(m_VideoCodecMap, parser.getChoiceOptionValue("video-codec")); diff --git a/app/gui/SettingsView.qml b/app/gui/SettingsView.qml index 5606680c..a011f08b 100644 --- a/app/gui/SettingsView.qml +++ b/app/gui/SettingsView.qml @@ -837,6 +837,25 @@ Flickable { qsTr("NOTE: Due to a bug in GeForce Experience, this option may not work properly if your host PC has multiple monitors.") } + CheckBox { + id: captureSysKeysCheck + hoverEnabled: true + width: parent.width + text: qsTr("Capture system keyboard shortcuts while streaming in fullscreen mode") + font.pointSize: 12 + enabled: SystemProperties.hasWindowManager + checked: StreamingPreferences.captureSysKeys && SystemProperties.hasWindowManager + onCheckedChanged: { + StreamingPreferences.captureSysKeys = checked + } + + ToolTip.delay: 1000 + ToolTip.timeout: 10000 + ToolTip.visible: hovered + ToolTip.text: qsTr("This enables the capture of system-wide keyboard shortcuts like Alt+Tab that would normally be handled by the client OS while streaming in fullscreen.") + "\n\n" + + qsTr("NOTE: Certain keyboard shortcuts like Ctrl+Alt+Del on Windows cannot be intercepted by any application, including Moonlight.") + } + CheckBox { id: absoluteTouchCheck hoverEnabled: true diff --git a/app/settings/streamingpreferences.cpp b/app/settings/streamingpreferences.cpp index d84b420c..38ef46ab 100644 --- a/app/settings/streamingpreferences.cpp +++ b/app/settings/streamingpreferences.cpp @@ -35,6 +35,7 @@ #define SER_BACKGROUNDGAMEPAD "backgroundgamepad" #define SER_REVERSESCROLL "reversescroll" #define SER_SWAPFACEBUTTONS "swapfacebuttons" +#define SER_CAPTURESYSKEYS "capturesyskeys" #define CURRENT_DEFAULT_VER 1 @@ -80,6 +81,7 @@ void StreamingPreferences::reload() backgroundGamepad = settings.value(SER_BACKGROUNDGAMEPAD, false).toBool(); reverseScrollDirection = settings.value(SER_REVERSESCROLL, false).toBool(); swapFaceButtons = settings.value(SER_SWAPFACEBUTTONS, false).toBool(); + captureSysKeys = settings.value(SER_CAPTURESYSKEYS, false).toBool(); audioConfig = static_cast(settings.value(SER_AUDIOCFG, static_cast(AudioConfig::AC_STEREO)).toInt()); videoCodecConfig = static_cast(settings.value(SER_VIDEOCFG, @@ -140,6 +142,7 @@ void StreamingPreferences::save() settings.setValue(SER_BACKGROUNDGAMEPAD, backgroundGamepad); settings.setValue(SER_REVERSESCROLL, reverseScrollDirection); settings.setValue(SER_SWAPFACEBUTTONS, swapFaceButtons); + settings.setValue(SER_CAPTURESYSKEYS, captureSysKeys); } int StreamingPreferences::getDefaultBitrate(int width, int height, int fps) diff --git a/app/settings/streamingpreferences.h b/app/settings/streamingpreferences.h index 9826d6bc..229227b6 100644 --- a/app/settings/streamingpreferences.h +++ b/app/settings/streamingpreferences.h @@ -87,6 +87,7 @@ public: Q_PROPERTY(bool backgroundGamepad MEMBER backgroundGamepad NOTIFY backgroundGamepadChanged) Q_PROPERTY(bool reverseScrollDirection MEMBER reverseScrollDirection NOTIFY reverseScrollDirectionChanged) Q_PROPERTY(bool swapFaceButtons MEMBER swapFaceButtons NOTIFY swapFaceButtonsChanged) + Q_PROPERTY(bool captureSysKeys MEMBER captureSysKeys NOTIFY captureSysKeysChanged) // Directly accessible members for preferences int width; @@ -112,6 +113,7 @@ public: bool backgroundGamepad; bool reverseScrollDirection; bool swapFaceButtons; + bool captureSysKeys; int packetSize; AudioConfig audioConfig; VideoCodecConfig videoCodecConfig; @@ -147,5 +149,6 @@ signals: void backgroundGamepadChanged(); void reverseScrollDirectionChanged(); void swapFaceButtonsChanged(); + void captureSysKeysChanged(); }; diff --git a/app/streaming/input/input.cpp b/app/streaming/input/input.cpp index a7f96470..1a6aaac1 100644 --- a/app/streaming/input/input.cpp +++ b/app/streaming/input/input.cpp @@ -3,6 +3,7 @@ #include "streaming/session.h" #include "settings/mappingmanager.h" #include "path.h" +#include "utils.h" #include #include @@ -24,7 +25,7 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s m_MouseWasInVideoRegion(false), m_PendingMouseButtonsAllUpOnVideoRegionLeave(false), m_FakeCaptureActive(false), - m_CaptureSystemKeysEnabled(false), + m_CaptureSystemKeysEnabled(prefs.captureSysKeys || !WMUtils::isRunningWindowManager()), m_LongPressTimer(0), m_StreamWidth(streamWidth), m_StreamHeight(streamHeight),