Add setting for swapping win & alt keys

This commit is contained in:
Brian Kendall 2023-10-02 23:19:10 -04:00
parent 6fa53691aa
commit be4c9a0714
7 changed files with 30 additions and 6 deletions

View file

@ -362,6 +362,7 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
parser.addToggleOption("quit-after", "quit app after session");
parser.addToggleOption("absolute-mouse", "remote desktop optimized mouse control");
parser.addToggleOption("mouse-buttons-swap", "left and right mouse buttons swap");
parser.addToggleOption("win-alt-swap", "win and alt keys swap");
parser.addToggleOption("touchscreen-trackpad", "touchscreen in trackpad mode");
parser.addToggleOption("game-optimization", "game optimizations");
parser.addToggleOption("audio-on-host", "audio on host PC");
@ -457,6 +458,9 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
// Resolve --mouse-buttons-swap and --no-mouse-buttons-swap options
preferences->swapMouseButtons = parser.getToggleOptionValue("mouse-buttons-swap", preferences->swapMouseButtons);
// Resolve --win-alt-swap and --no-win-alt-swap options
preferences->swapWinAltKeys = parser.getToggleOptionValue("win-alt-swap", preferences->swapWinAltKeys);
// Resolve --touchscreen-trackpad and --no-touchscreen-trackpad options
preferences->absoluteTouchMode = !parser.getToggleOptionValue("touchscreen-trackpad", !preferences->absoluteTouchMode);

View file

@ -1316,6 +1316,18 @@ Flickable {
StreamingPreferences.swapMouseButtons = checked
}
}
CheckBox {
id: swapWinAltKeysCheck
hoverEnabled: true
width: parent.width
text: qsTr("Swap Alt and Win keys")
font.pointSize: 12
checked: StreamingPreferences.swapWinAltKeys
onCheckedChanged: {
StreamingPreferences.swapWinAltKeys = checked
}
}
CheckBox {
id: reverseScrollButtonsCheck

View file

@ -38,6 +38,7 @@
#define SER_PACKETSIZE "packetsize"
#define SER_DETECTNETBLOCKING "detectnetblocking"
#define SER_SWAPMOUSEBUTTONS "swapmousebuttons"
#define SER_SWAPWINALTKEYS "swapwinaltkeys"
#define SER_MUTEONFOCUSLOSS "muteonfocusloss"
#define SER_BACKGROUNDGAMEPAD "backgroundgamepad"
#define SER_REVERSESCROLL "reversescroll"
@ -99,6 +100,7 @@ void StreamingPreferences::reload()
detectNetworkBlocking = settings.value(SER_DETECTNETBLOCKING, true).toBool();
packetSize = settings.value(SER_PACKETSIZE, 0).toInt();
swapMouseButtons = settings.value(SER_SWAPMOUSEBUTTONS, false).toBool();
swapWinAltKeys = settings.value(SER_SWAPWINALTKEYS, false).toBool();
muteOnFocusLoss = settings.value(SER_MUTEONFOCUSLOSS, false).toBool();
backgroundGamepad = settings.value(SER_BACKGROUNDGAMEPAD, false).toBool();
reverseScrollDirection = settings.value(SER_REVERSESCROLL, false).toBool();
@ -289,6 +291,7 @@ void StreamingPreferences::save()
settings.setValue(SER_LANGUAGE, static_cast<int>(language));
settings.setValue(SER_DEFAULTVER, CURRENT_DEFAULT_VER);
settings.setValue(SER_SWAPMOUSEBUTTONS, swapMouseButtons);
settings.setValue(SER_SWAPWINALTKEYS, swapWinAltKeys);
settings.setValue(SER_MUTEONFOCUSLOSS, muteOnFocusLoss);
settings.setValue(SER_BACKGROUNDGAMEPAD, backgroundGamepad);
settings.setValue(SER_REVERSESCROLL, reverseScrollDirection);

View file

@ -128,6 +128,7 @@ public:
Q_PROPERTY(WindowMode recommendedFullScreenMode MEMBER recommendedFullScreenMode CONSTANT)
Q_PROPERTY(UIDisplayMode uiDisplayMode MEMBER uiDisplayMode NOTIFY uiDisplayModeChanged)
Q_PROPERTY(bool swapMouseButtons MEMBER swapMouseButtons NOTIFY mouseButtonsChanged)
Q_PROPERTY(bool swapWinAltKeys MEMBER swapWinAltKeys NOTIFY swapWinAltKeysChanged)
Q_PROPERTY(bool muteOnFocusLoss MEMBER muteOnFocusLoss NOTIFY muteOnFocusLossChanged)
Q_PROPERTY(bool backgroundGamepad MEMBER backgroundGamepad NOTIFY backgroundGamepadChanged)
Q_PROPERTY(bool reverseScrollDirection MEMBER reverseScrollDirection NOTIFY reverseScrollDirectionChanged)
@ -157,6 +158,7 @@ public:
bool gamepadMouse;
bool detectNetworkBlocking;
bool swapMouseButtons;
bool swapWinAltKeys;
bool muteOnFocusLoss;
bool backgroundGamepad;
bool reverseScrollDirection;
@ -197,6 +199,7 @@ signals:
void gamepadMouseChanged();
void detectNetworkBlockingChanged();
void mouseButtonsChanged();
void swapWinAltKeysChanged();
void muteOnFocusLossChanged();
void backgroundGamepadChanged();
void reverseScrollDirectionChanged();

View file

@ -13,6 +13,7 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, int streamWidth, i
: m_MultiController(prefs.multiController),
m_GamepadMouse(prefs.gamepadMouse),
m_SwapMouseButtons(prefs.swapMouseButtons),
m_SwapWinAltKeys(prefs.swapWinAltKeys),
m_ReverseScrollDirection(prefs.reverseScrollDirection),
m_SwapFaceButtons(prefs.swapFaceButtons),
m_MouseWasInVideoRegion(false),

View file

@ -167,6 +167,7 @@ private:
bool m_MultiController;
bool m_GamepadMouse;
bool m_SwapMouseButtons;
bool m_SwapWinAltKeys;
bool m_ReverseScrollDirection;
bool m_SwapFaceButtons;

View file

@ -192,14 +192,14 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
modifiers |= MODIFIER_CTRL;
}
if (event->keysym.mod & KMOD_ALT) {
modifiers |= MODIFIER_ALT;
modifiers |= m_SwapWinAltKeys ? MODIFIER_META : MODIFIER_ALT;
}
if (event->keysym.mod & KMOD_SHIFT) {
modifiers |= MODIFIER_SHIFT;
}
if (event->keysym.mod & KMOD_GUI) {
if (isSystemKeyCaptureActive()) {
modifiers |= MODIFIER_META;
modifiers |= m_SwapWinAltKeys ? MODIFIER_ALT : MODIFIER_META;
}
}
@ -337,22 +337,22 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event)
keyCode = 0xA3;
break;
case SDL_SCANCODE_LALT:
keyCode = 0xA4;
keyCode = m_SwapWinAltKeys ? 0x5B : 0xA4;
break;
case SDL_SCANCODE_RALT:
keyCode = 0xA5;
keyCode = m_SwapWinAltKeys ? 0x5C : 0xA5;
break;
case SDL_SCANCODE_LGUI:
if (!isSystemKeyCaptureActive()) {
return;
}
keyCode = 0x5B;
keyCode = m_SwapWinAltKeys ? 0xA4 : 0x5B;
break;
case SDL_SCANCODE_RGUI:
if (!isSystemKeyCaptureActive()) {
return;
}
keyCode = 0x5C;
keyCode = m_SwapWinAltKeys ? 0xA5 : 0x5C;
break;
case SDL_SCANCODE_APPLICATION:
keyCode = 0x5D;