Add options to invert scroll direction and swap gamepad buttons

Fixes #463
Fixes #467
This commit is contained in:
Cameron Gutman 2020-12-25 22:21:20 -06:00
commit 5096ff6496
9 changed files with 103 additions and 1 deletions

View file

@ -167,6 +167,23 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve
return;
}
if (m_SwapFaceButtons) {
switch (event->button) {
case SDL_CONTROLLER_BUTTON_A:
event->button = SDL_CONTROLLER_BUTTON_B;
break;
case SDL_CONTROLLER_BUTTON_B:
event->button = SDL_CONTROLLER_BUTTON_A;
break;
case SDL_CONTROLLER_BUTTON_X:
event->button = SDL_CONTROLLER_BUTTON_Y;
break;
case SDL_CONTROLLER_BUTTON_Y:
event->button = SDL_CONTROLLER_BUTTON_X;
break;
}
}
if (event->state == SDL_PRESSED) {
state->buttons |= k_ButtonMap[event->button];

View file

@ -13,6 +13,8 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, NvComputer*, int s
: m_MultiController(prefs.multiController),
m_GamepadMouse(prefs.gamepadMouse),
m_SwapMouseButtons(prefs.swapMouseButtons),
m_ReverseScrollDirection(prefs.reverseScrollDirection),
m_SwapFaceButtons(prefs.swapFaceButtons),
m_MouseMoveTimer(0),
m_MousePositionLock(0),
m_MouseWasInVideoRegion(false),

View file

@ -121,6 +121,8 @@ private:
bool m_MultiController;
bool m_GamepadMouse;
bool m_SwapMouseButtons;
bool m_ReverseScrollDirection;
bool m_SwapFaceButtons;
SDL_TimerID m_MouseMoveTimer;
SDL_atomic_t m_MouseDeltaX;
SDL_atomic_t m_MouseDeltaY;

View file

@ -204,6 +204,11 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event)
}
if (event->y != 0) {
// Invert the scroll direction if needed
if (m_ReverseScrollDirection) {
event->y = -event->y;
}
LiSendScrollEvent((signed char)event->y);
}
}