Merge pull request #433 from annk15/master

Added option to switch primary and secondary mouse buttons
This commit is contained in:
Cameron Gutman 2020-09-05 10:40:00 -07:00 committed by GitHub
commit 1e29f61656
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 37 additions and 0 deletions

View File

@ -298,6 +298,7 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
parser.addToggleOption("multi-controller", "multiple controller support");
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("touchscreen-trackpad", "touchscreen in trackpad mode");
parser.addToggleOption("game-optimization", "game optimizations");
parser.addToggleOption("audio-on-host", "audio on host PC");
@ -389,6 +390,9 @@ void StreamCommandLineParser::parse(const QStringList &args, StreamingPreference
// Resolve --absolute-mouse and --no-absolute-mouse options
preferences->absoluteMouseMode = parser.getToggleOptionValue("absolute-mouse", preferences->absoluteMouseMode);
// Resolve --mouse-buttons-swap and --no-mouse-buttons-swap options
preferences->swapMouseButtons = parser.getToggleOptionValue("mouse-buttons-swap", preferences->swapMouseButtons);
// Resolve --touchscreen-trackpad and --no-touchscreen-trackpad options
preferences->absoluteTouchMode = !parser.getToggleOptionValue("touchscreen-trackpad", !preferences->absoluteTouchMode);

View File

@ -638,6 +638,23 @@ Flickable {
ToolTip.visible: hovered
ToolTip.text: "When enabled, holding the Start button will toggle mouse mode"
}
CheckBox {
id: swapMouseButtonsCheck
hoverEnabled: true
width: parent.width
text: "Swap mouse buttons"
font.pointSize: 12
checked: StreamingPreferences.swapMouseButtons
onCheckedChanged: {
StreamingPreferences.swapMouseButtons = checked
}
ToolTip.delay: 1000
ToolTip.timeout: 3000
ToolTip.visible: hovered
ToolTip.text: "When checked, swap the left and right mouse buttons"
}
}
}

View File

@ -29,6 +29,7 @@
#define SER_DEFAULTVER "defaultver"
#define SER_PACKETSIZE "packetsize"
#define SER_DETECTNETBLOCKING "detectnetblocking"
#define SER_SWAPMOUSEBUTTONS "swapmousebuttons"
#define CURRENT_DEFAULT_VER 1
@ -70,6 +71,7 @@ void StreamingPreferences::reload()
gamepadMouse = settings.value(SER_GAMEPADMOUSE, true).toBool();
detectNetworkBlocking = settings.value(SER_DETECTNETBLOCKING, true).toBool();
packetSize = settings.value(SER_PACKETSIZE, 0).toInt();
swapMouseButtons = settings.value(SER_SWAPMOUSEBUTTONS, false).toBool();
audioConfig = static_cast<AudioConfig>(settings.value(SER_AUDIOCFG,
static_cast<int>(AudioConfig::AC_STEREO)).toInt());
videoCodecConfig = static_cast<VideoCodecConfig>(settings.value(SER_VIDEOCFG,
@ -121,6 +123,7 @@ void StreamingPreferences::save()
settings.setValue(SER_VIDEODEC, static_cast<int>(videoDecoderSelection));
settings.setValue(SER_WINDOWMODE, static_cast<int>(windowMode));
settings.setValue(SER_DEFAULTVER, CURRENT_DEFAULT_VER);
settings.setValue(SER_SWAPMOUSEBUTTONS, swapMouseButtons);
}
int StreamingPreferences::getDefaultBitrate(int width, int height, int fps)

View File

@ -74,6 +74,7 @@ public:
Q_PROPERTY(VideoDecoderSelection videoDecoderSelection MEMBER videoDecoderSelection NOTIFY videoDecoderSelectionChanged)
Q_PROPERTY(WindowMode windowMode MEMBER windowMode NOTIFY windowModeChanged)
Q_PROPERTY(WindowMode recommendedFullScreenMode MEMBER recommendedFullScreenMode CONSTANT)
Q_PROPERTY(bool swapMouseButtons MEMBER swapMouseButtons NOTIFY mouseButtonsChanged)
// Directly accessible members for preferences
int width;
@ -95,6 +96,7 @@ public:
bool richPresence;
bool gamepadMouse;
bool detectNetworkBlocking;
bool swapMouseButtons;
int packetSize;
AudioConfig audioConfig;
VideoCodecConfig videoCodecConfig;
@ -124,5 +126,6 @@ signals:
void richPresenceChanged();
void gamepadMouseChanged();
void detectNetworkBlockingChanged();
void mouseButtonsChanged();
};

View File

@ -12,6 +12,7 @@
SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int streamWidth, int streamHeight)
: m_MultiController(prefs.multiController),
m_GamepadMouse(prefs.gamepadMouse),
m_SwapMouseButtons(prefs.swapMouseButtons),
m_MouseMoveTimer(0),
m_MousePositionLock(0),
m_MouseWasInVideoRegion(false),

View File

@ -118,6 +118,7 @@ private:
SDL_Window* m_Window;
bool m_MultiController;
bool m_GamepadMouse;
bool m_SwapMouseButtons;
SDL_TimerID m_MouseMoveTimer;
SDL_atomic_t m_MouseDeltaX;
SDL_atomic_t m_MouseDeltaY;

View File

@ -55,6 +55,14 @@ void SdlInputHandler::handleMouseButtonEvent(SDL_MouseButtonEvent* event)
return;
}
if (m_SwapMouseButtons) {
if (button == BUTTON_RIGHT)
button = BUTTON_LEFT;
else if (button == BUTTON_LEFT)
button = BUTTON_RIGHT;
}
LiSendMouseButtonEvent(event->state == SDL_PRESSED ?
BUTTON_ACTION_PRESS :
BUTTON_ACTION_RELEASE,