Added option to swap left and right mouse buttons

Changed the use of SDL buttons to Moonlight buttons definitions
This commit is contained in:
Anton 2020-08-23 16:05:00 +02:00
commit 89319dc7aa
7 changed files with 37 additions and 0 deletions

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,