diff --git a/.gitignore b/.gitignore index c41d075f..3a5180ac 100644 --- a/.gitignore +++ b/.gitignore @@ -4,30 +4,5 @@ **/.vs/ .vscode/ build/ -.qmake.cache -.qmake.stash -/Makefile -/config.log -/config.tests/ -/app/Makefile -/app/Makefile.Debug -/app/Makefile.Release -/app/release/ -/app/moonlight -/h264bitstream/Makefile -/h264bitstream/Makefile.Debug -/h264bitstream/Makefile.Release -/h264bitstream/release/ -/h264bitstream/libh264bitstream.a -/moonlight-common-c/Makefile -/moonlight-common-c/Makefile.Debug -/moonlight-common-c/Makefile.Release -/moonlight-common-c/release/ -/moonlight-common-c/libmoonlight-common-c.a -/qmdnsengine/Makefile -/qmdnsengine/Makefile.Debug -/qmdnsengine/Makefile.Release -/qmdnsengine/release/ -/qmdnsengine/libqmdnsengine.a config.tests/*/.qmake.stash config.tests/*/Makefile diff --git a/app/streaming/input/abstouch.cpp b/app/streaming/input/abstouch.cpp index 9e8b51a9..0fe6dac6 100644 --- a/app/streaming/input/abstouch.cpp +++ b/app/streaming/input/abstouch.cpp @@ -1,5 +1,4 @@ #include "input.h" -#include "streaming/session.h" #include #include "SDL_compat.h" @@ -8,12 +7,6 @@ #include -static bool isKeyboardMouseInputAllowed() -{ - auto session = Session::get(); - return session == nullptr || session->isKeyboardMouseInputAllowed(); -} - // How long the fingers must be stationary to start a right click #define LONG_PRESS_ACTIVATION_DELAY 650 @@ -29,10 +22,8 @@ static bool isKeyboardMouseInputAllowed() Uint32 SdlInputHandler::longPressTimerCallback(Uint32, void*) { // Raise the left click and start a right click - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); return 0; } @@ -119,7 +110,7 @@ void SdlInputHandler::handleAbsoluteFingerEvent(SDL_TouchFingerEvent* event) } // Try to send it as a native pen/touch event, otherwise fall back to our touch emulation - if (isKeyboardMouseInputAllowed() && (LiGetHostFeatureFlags() & LI_FF_PEN_TOUCH_EVENTS)) { + if (LiGetHostFeatureFlags() & LI_FF_PEN_TOUCH_EVENTS) { #if SDL_VERSION_ATLEAST(2, 0, 22) bool isPen = false; @@ -206,9 +197,7 @@ void SdlInputHandler::emulateAbsoluteFingerEvent(SDL_TouchFingerEvent* event) short y = qMin(qMax((int)(event->y * windowHeight), dst.y), dst.y + dst.h); // Update the cursor position relative to the video region - if (isKeyboardMouseInputAllowed()) { - LiSendMousePositionEvent(x - dst.x, y - dst.y, dst.w, dst.h); - } + LiSendMousePositionEvent(x - dst.x, y - dst.y, dst.w, dst.h); } if (event->type == SDL_FINGERDOWN) { @@ -221,9 +210,7 @@ void SdlInputHandler::emulateAbsoluteFingerEvent(SDL_TouchFingerEvent* event) nullptr); // Left button down on finger down - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); } else if (event->type == SDL_FINGERUP) { m_LastTouchUpEvent = *event; @@ -233,13 +220,9 @@ void SdlInputHandler::emulateAbsoluteFingerEvent(SDL_TouchFingerEvent* event) m_LongPressTimer = 0; // Left button up on finger up - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); // Raise right button too in case we triggered a long press gesture - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); } } diff --git a/app/streaming/input/gamepad.cpp b/app/streaming/input/gamepad.cpp index d5171f22..e0d7f004 100644 --- a/app/streaming/input/gamepad.cpp +++ b/app/streaming/input/gamepad.cpp @@ -6,18 +6,6 @@ #include -static bool isGamepadInputAllowed() -{ - auto session = Session::get(); - return session == nullptr || session->isGamepadInputAllowed(); -} - -static bool isKeyboardMouseInputAllowed() -{ - auto session = Session::get(); - return session == nullptr || session->isKeyboardMouseInputAllowed(); -} - // How long the Start button must be pressed to toggle mouse emulation #define MOUSE_EMULATION_LONG_PRESS_TIME 750 @@ -113,17 +101,15 @@ void SdlInputHandler::sendGamepadState(GamepadState* state) } } - if (isGamepadInputAllowed()) { - LiSendMultiControllerEvent(state->index, - m_GamepadMask, - buttons, - lt, - rt, - lsX, - lsY, - rsX, - rsY); - } + LiSendMultiControllerEvent(state->index, + m_GamepadMask, + buttons, + lt, + rt, + lsX, + lsY, + rsX, + rsY); } void SdlInputHandler::sendGamepadBatteryState(GamepadState* state, SDL_JoystickPowerLevel level) @@ -164,9 +150,7 @@ void SdlInputHandler::sendGamepadBatteryState(GamepadState* state, SDL_JoystickP return; } - if (isGamepadInputAllowed()) { - LiSendControllerBatteryEvent(state->index, batteryState, batteryPercentage); - } + LiSendControllerBatteryEvent(state->index, batteryState, batteryPercentage); } Uint32 SdlInputHandler::mouseEmulationTimerCallback(Uint32 interval, void *param) @@ -197,7 +181,7 @@ Uint32 SdlInputHandler::mouseEmulationTimerCallback(Uint32 interval, void *param deltaX = qAbs(deltaX) > MOUSE_EMULATION_DEADZONE ? deltaX - MOUSE_EMULATION_DEADZONE : 0; deltaY = qAbs(deltaY) > MOUSE_EMULATION_DEADZONE ? deltaY - MOUSE_EMULATION_DEADZONE : 0; - if ((deltaX != 0 || deltaY != 0) && isKeyboardMouseInputAllowed()) { + if (deltaX != 0 || deltaY != 0) { LiSendMouseMoveEvent((short)deltaX, (short)deltaY); } @@ -307,49 +291,31 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve } else if (state->mouseEmulationTimer != 0) { if (event->button == SDL_CONTROLLER_BUTTON_A) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); } else if (event->button == SDL_CONTROLLER_BUTTON_B) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); } else if (event->button == SDL_CONTROLLER_BUTTON_X) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_MIDDLE); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_MIDDLE); } else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X1); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X1); } else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X2); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X2); } else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_UP) { - if (isKeyboardMouseInputAllowed()) { - LiSendScrollEvent(1); - } + LiSendScrollEvent(1); } else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) { - if (isKeyboardMouseInputAllowed()) { - LiSendScrollEvent(-1); - } + LiSendScrollEvent(-1); } else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) { - if (isKeyboardMouseInputAllowed()) { - LiSendHScrollEvent(1); - } + LiSendHScrollEvent(1); } else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) { - if (isKeyboardMouseInputAllowed()) { - LiSendHScrollEvent(-1); - } + LiSendHScrollEvent(-1); } } } @@ -380,29 +346,19 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve } else if (state->mouseEmulationTimer != 0) { if (event->button == SDL_CONTROLLER_BUTTON_A) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); } else if (event->button == SDL_CONTROLLER_BUTTON_B) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); } else if (event->button == SDL_CONTROLLER_BUTTON_X) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_MIDDLE); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_MIDDLE); } else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X1); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X1); } else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X2); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X2); } } } @@ -419,10 +375,8 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve SDL_PushEvent(&event); // Clear buttons down on this gamepad - if (isGamepadInputAllowed()) { - LiSendMultiControllerEvent(state->index, m_GamepadMask, - 0, 0, 0, 0, 0, 0, 0); - } + LiSendMultiControllerEvent(state->index, m_GamepadMask, + 0, 0, 0, 0, 0, 0, 0); return; } @@ -436,41 +390,8 @@ void SdlInputHandler::handleControllerButtonEvent(SDL_ControllerButtonEvent* eve !Session::get()->getOverlayManager().isOverlayEnabled(Overlay::OverlayDebug)); // Clear buttons down on this gamepad - if (isGamepadInputAllowed()) { - LiSendMultiControllerEvent(state->index, m_GamepadMask, - 0, 0, 0, 0, 0, 0, 0); - } - return; - } - - if (state->buttons == (BACK_FLAG | LB_FLAG | RB_FLAG | Y_FLAG)) { - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Detected keyboard/mouse input toggle gamepad combo"); - - Session::get()->toggleKeyboardMouseInputAllowed(); - - if (isGamepadInputAllowed()) { - LiSendMultiControllerEvent(state->index, m_GamepadMask, - 0, 0, 0, 0, 0, 0, 0); - } - return; - } - - if (state->buttons == (BACK_FLAG | LB_FLAG | RB_FLAG | A_FLAG)) { - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Detected gamepad input toggle gamepad combo"); - - bool gamepadWasEnabled = isGamepadInputAllowed(); - if (gamepadWasEnabled) { - LiSendMultiControllerEvent(state->index, m_GamepadMask, - 0, 0, 0, 0, 0, 0, 0); - } - Session::get()->toggleGamepadInputAllowed(); - - if (isGamepadInputAllowed()) { - LiSendMultiControllerEvent(state->index, m_GamepadMask, - 0, 0, 0, 0, 0, 0, 0); - } + LiSendMultiControllerEvent(state->index, m_GamepadMask, + 0, 0, 0, 0, 0, 0, 0); return; } @@ -497,9 +418,7 @@ void SdlInputHandler::handleControllerSensorEvent(SDL_ControllerSensorEvent* eve memcpy(state->lastAccelEventData, event->data, sizeof(event->data)); state->lastAccelEventTime = event->timestamp; - if (isGamepadInputAllowed()) { - LiSendControllerMotionEvent((uint8_t)state->index, LI_MOTION_TYPE_ACCEL, event->data[0], event->data[1], event->data[2]); - } + LiSendControllerMotionEvent((uint8_t)state->index, LI_MOTION_TYPE_ACCEL, event->data[0], event->data[1], event->data[2]); } break; case SDL_SENSOR_GYRO: @@ -510,12 +429,10 @@ void SdlInputHandler::handleControllerSensorEvent(SDL_ControllerSensorEvent* eve state->lastGyroEventTime = event->timestamp; // Convert rad/s to deg/s - if (isGamepadInputAllowed()) { - LiSendControllerMotionEvent((uint8_t)state->index, LI_MOTION_TYPE_GYRO, - event->data[0] * 57.2957795f, - event->data[1] * 57.2957795f, - event->data[2] * 57.2957795f); - } + LiSendControllerMotionEvent((uint8_t)state->index, LI_MOTION_TYPE_GYRO, + event->data[0] * 57.2957795f, + event->data[1] * 57.2957795f, + event->data[2] * 57.2957795f); } break; } @@ -543,9 +460,7 @@ void SdlInputHandler::handleControllerTouchpadEvent(SDL_ControllerTouchpadEvent* return; } - if (isGamepadInputAllowed()) { - LiSendControllerTouchEvent((uint8_t)state->index, eventType, event->finger, event->x, event->y, event->pressure); - } + LiSendControllerTouchEvent((uint8_t)state->index, eventType, event->finger, event->x, event->y, event->pressure); } #endif @@ -793,9 +708,7 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve #endif type == LI_CTYPE_PS; - if (isGamepadInputAllowed()) { - LiSendControllerArrivalEvent(state->index, m_GamepadMask, type, supportedButtonFlags, capabilities); - } + LiSendControllerArrivalEvent(state->index, m_GamepadMask, type, supportedButtonFlags, capabilities); #else // Send an empty event to tell the PC we've arrived @@ -837,10 +750,8 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve state->index); // Send a final event to let the PC know this gamepad is gone - if (isGamepadInputAllowed()) { - LiSendMultiControllerEvent(state->index, m_GamepadMask, - 0, 0, 0, 0, 0, 0, 0); - } + LiSendMultiControllerEvent(state->index, m_GamepadMask, + 0, 0, 0, 0, 0, 0, 0); // Clear all remaining state from this slot SDL_memset(state, 0, sizeof(*state)); diff --git a/app/streaming/input/input.cpp b/app/streaming/input/input.cpp index 844e0ab4..982eaaa9 100644 --- a/app/streaming/input/input.cpp +++ b/app/streaming/input/input.cpp @@ -106,16 +106,6 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, int streamWidth, i m_SpecialKeyCombos[KeyComboPasteText].scanCode = SDL_SCANCODE_V; m_SpecialKeyCombos[KeyComboPasteText].enabled = true; - m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].keyCombo = KeyComboToggleKeyboardMouseInput; - m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].keyCode = SDLK_k; - m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].scanCode = SDL_SCANCODE_K; - m_SpecialKeyCombos[KeyComboToggleKeyboardMouseInput].enabled = true; - - m_SpecialKeyCombos[KeyComboToggleGamepadInput].keyCombo = KeyComboToggleGamepadInput; - m_SpecialKeyCombos[KeyComboToggleGamepadInput].keyCode = SDLK_g; - m_SpecialKeyCombos[KeyComboToggleGamepadInput].scanCode = SDL_SCANCODE_G; - m_SpecialKeyCombos[KeyComboToggleGamepadInput].enabled = true; - m_SpecialKeyCombos[KeyComboTogglePointerRegionLock].keyCombo = KeyComboTogglePointerRegionLock; m_SpecialKeyCombos[KeyComboTogglePointerRegionLock].keyCode = SDLK_l; m_SpecialKeyCombos[KeyComboTogglePointerRegionLock].scanCode = SDL_SCANCODE_L; diff --git a/app/streaming/input/input.h b/app/streaming/input/input.h index 91a020ce..20bbbc33 100644 --- a/app/streaming/input/input.h +++ b/app/streaming/input/input.h @@ -165,8 +165,6 @@ private: KeyComboToggleCursorHide, KeyComboToggleMinimize, KeyComboPasteText, - KeyComboToggleKeyboardMouseInput, - KeyComboToggleGamepadInput, KeyComboTogglePointerRegionLock, KeyComboQuitAndExit, KeyComboMax diff --git a/app/streaming/input/keyboard.cpp b/app/streaming/input/keyboard.cpp index 819837c0..273816f4 100644 --- a/app/streaming/input/keyboard.cpp +++ b/app/streaming/input/keyboard.cpp @@ -13,12 +13,6 @@ #define VK_NUMPAD0 0x60 #endif -static bool isKeyboardMouseInputAllowed() -{ - auto session = Session::get(); - return session == nullptr || session->isKeyboardMouseInputAllowed(); -} - void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo) { switch (combo) { @@ -120,9 +114,7 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo) } // Send this text to the PC - if (isKeyboardMouseInputAllowed()) { - LiSendUtf8TextEvent(text, (unsigned int)strlen(text)); - } + LiSendUtf8TextEvent(text, (unsigned int)strlen(text)); // SDL_GetClipboardText() allocates, so we must free SDL_free((void*)text); @@ -134,22 +126,6 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo) break; } - case KeyComboToggleKeyboardMouseInput: - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Detected keyboard/mouse input toggle combo"); - if (auto session = Session::get(); session != nullptr) { - session->toggleKeyboardMouseInputAllowed(); - } - break; - - case KeyComboToggleGamepadInput: - SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, - "Detected gamepad input toggle combo"); - if (auto session = Session::get(); session != nullptr) { - session->toggleGamepadInputAllowed(); - } - break; - case KeyComboTogglePointerRegionLock: SDL_LogInfo(SDL_LOG_CATEGORY_APPLICATION, "Detected pointer region lock toggle combo"); @@ -481,11 +457,9 @@ void SdlInputHandler::handleKeyEvent(SDL_KeyboardEvent* event) m_KeysDown.remove(keyCode); } - if (isKeyboardMouseInputAllowed()) { - LiSendKeyboardEvent2(0x8000 | keyCode, - event->state == SDL_PRESSED ? - KEY_ACTION_DOWN : KEY_ACTION_UP, - modifiers, - shouldNotConvertToScanCodeOnServer ? SS_KBE_FLAG_NON_NORMALIZED : 0); - } + LiSendKeyboardEvent2(0x8000 | keyCode, + event->state == SDL_PRESSED ? + KEY_ACTION_DOWN : KEY_ACTION_UP, + modifiers, + shouldNotConvertToScanCodeOnServer ? SS_KBE_FLAG_NON_NORMALIZED : 0); } diff --git a/app/streaming/input/mouse.cpp b/app/streaming/input/mouse.cpp index c86eae54..66bb4413 100644 --- a/app/streaming/input/mouse.cpp +++ b/app/streaming/input/mouse.cpp @@ -1,16 +1,9 @@ #include "input.h" -#include "streaming/session.h" #include #include "SDL_compat.h" #include "streaming/streamutils.h" -static bool isKeyboardMouseInputAllowed() -{ - auto session = Session::get(); - return session == nullptr || session->isKeyboardMouseInputAllowed(); -} - void SdlInputHandler::handleMouseButtonEvent(SDL_MouseButtonEvent* event) { int button; @@ -69,12 +62,10 @@ void SdlInputHandler::handleMouseButtonEvent(SDL_MouseButtonEvent* event) button = BUTTON_RIGHT; } - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(event->state == SDL_PRESSED ? - BUTTON_ACTION_PRESS : - BUTTON_ACTION_RELEASE, - button); - } + LiSendMouseButtonEvent(event->state == SDL_PRESSED ? + BUTTON_ACTION_PRESS : + BUTTON_ACTION_RELEASE, + button); } void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event) @@ -143,9 +134,7 @@ void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event) } } if (mouseInVideoRegion || m_MouseWasInVideoRegion || m_PendingMouseButtonsAllUpOnVideoRegionLeave) { - if (isKeyboardMouseInputAllowed()) { - LiSendMousePositionEvent((short)x, (short)y, dst.w, dst.h); - } + LiSendMousePositionEvent((short)x, (short)y, dst.w, dst.h); } // Adjust the cursor visibility if applicable @@ -161,9 +150,7 @@ void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event) m_MouseWasInVideoRegion = mouseInVideoRegion; } else { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseMoveEvent(xrel, yrel); - } + LiSendMouseMoveEvent(xrel, yrel); } } @@ -200,9 +187,7 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event) event->preciseY = SDL_clamp(event->preciseY, -1.0f, 1.0f); #endif - if (isKeyboardMouseInputAllowed()) { - LiSendHighResScrollEvent((short)(event->preciseY * 120)); // WHEEL_DELTA - } + LiSendHighResScrollEvent((short)(event->preciseY * 120)); // WHEEL_DELTA } if (event->preciseX != 0.0f) { @@ -217,9 +202,7 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event) event->preciseX = SDL_clamp(event->preciseX, -1.0f, 1.0f); #endif - if (isKeyboardMouseInputAllowed()) { - LiSendHighResHScrollEvent((short)(event->preciseX * 120)); // WHEEL_DELTA - } + LiSendHighResHScrollEvent((short)(event->preciseX * 120)); // WHEEL_DELTA } #else if (event->y != 0) { @@ -233,9 +216,7 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event) event->y = SDL_clamp(event->y, -1, 1); #endif - if (isKeyboardMouseInputAllowed()) { - LiSendScrollEvent((signed char)event->y); - } + LiSendScrollEvent((signed char)event->y); } if (event->x != 0) { @@ -249,9 +230,7 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event) event->x = SDL_clamp(event->x, -1, 1); #endif - if (isKeyboardMouseInputAllowed()) { - LiSendHScrollEvent((signed char)event->x); - } + LiSendHScrollEvent((signed char)event->x); } #endif } diff --git a/app/streaming/input/reltouch.cpp b/app/streaming/input/reltouch.cpp index 1649f1c1..0ddc778a 100644 --- a/app/streaming/input/reltouch.cpp +++ b/app/streaming/input/reltouch.cpp @@ -1,17 +1,10 @@ #include "input.h" -#include "streaming/session.h" #include #include "SDL_compat.h" #include -static bool isKeyboardMouseInputAllowed() -{ - auto session = Session::get(); - return session == nullptr || session->isKeyboardMouseInputAllowed(); -} - // How long the mouse button will be pressed for a tap to click gesture #define TAP_BUTTON_RELEASE_DELAY 100 @@ -23,17 +16,13 @@ static bool isKeyboardMouseInputAllowed() Uint32 SdlInputHandler::releaseLeftButtonTimerCallback(Uint32, void*) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT); return 0; } Uint32 SdlInputHandler::releaseRightButtonTimerCallback(Uint32, void*) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT); return 0; } @@ -50,9 +39,7 @@ Uint32 SdlInputHandler::dragTimerCallback(Uint32, void *param) me->m_DragButton = BUTTON_LEFT; } - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, me->m_DragButton); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, me->m_DragButton); return 0; } @@ -112,7 +99,7 @@ void SdlInputHandler::handleRelativeFingerEvent(SDL_TouchFingerEvent* event) // than the client window dimensions. short deltaX = static_cast(event->dx * m_StreamWidth); short deltaY = static_cast(event->dy * m_StreamHeight); - if ((deltaX != 0 || deltaY != 0) && isKeyboardMouseInputAllowed()) { + if (deltaX != 0 || deltaY != 0) { LiSendMouseMoveEvent(deltaX, deltaY); } } @@ -146,9 +133,7 @@ void SdlInputHandler::handleRelativeFingerEvent(SDL_TouchFingerEvent* event) // Release any drag if (m_DragButton != 0) { - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, m_DragButton); - } + LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, m_DragButton); m_DragButton = 0; } // 2 finger tap @@ -158,9 +143,7 @@ void SdlInputHandler::handleRelativeFingerEvent(SDL_TouchFingerEvent* event) m_TouchDownEvent[0].timestamp = 0; // Press down the right mouse button - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT); // Queue a timer to release it in 100 ms SDL_RemoveTimer(m_RightButtonReleaseTimer); @@ -171,9 +154,7 @@ void SdlInputHandler::handleRelativeFingerEvent(SDL_TouchFingerEvent* event) // 1 finger tap else if (event->timestamp - m_TouchDownEvent[0].timestamp < 250) { // Press down the left mouse button - if (isKeyboardMouseInputAllowed()) { - LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); - } + LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT); // Queue a timer to release it in 100 ms SDL_RemoveTimer(m_LeftButtonReleaseTimer); diff --git a/app/streaming/session.cpp b/app/streaming/session.cpp index c314ae83..ad3741b0 100644 --- a/app/streaming/session.cpp +++ b/app/streaming/session.cpp @@ -556,8 +556,6 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere m_VideoDecoder(nullptr), m_DecoderLock(SDL_CreateMutex()), m_AudioMuted(false), - m_AllowGamepadInput(true), - m_AllowKeyboardMouseInput(true), m_QtWindow(nullptr), m_UnexpectedTermination(true), // Failure prior to streaming is unexpected m_InputHandler(nullptr), @@ -573,45 +571,6 @@ Session::Session(NvComputer* computer, NvApp& app, StreamingPreferences *prefere { } -void Session::setGamepadInputAllowed(bool allowed) -{ - m_AllowGamepadInput.store(allowed, std::memory_order_relaxed); - notifyInputPermissionState(); -} - -void Session::setKeyboardMouseInputAllowed(bool allowed) -{ - bool previous = m_AllowKeyboardMouseInput.exchange(allowed, std::memory_order_relaxed); - if (previous && !allowed && m_InputHandler != nullptr) { - m_InputHandler->raiseAllKeys(); - } - - notifyInputPermissionState(); -} - -void Session::toggleGamepadInputAllowed() -{ - setGamepadInputAllowed(!isGamepadInputAllowed()); -} - -void Session::toggleKeyboardMouseInputAllowed() -{ - setKeyboardMouseInputAllowed(!isKeyboardMouseInputAllowed()); -} - -void Session::notifyInputPermissionState() -{ - char buffer[96]; - SDL_snprintf(buffer, - sizeof(buffer), - "Keyboard/Mouse: %s\nGamepad: %s", - isKeyboardMouseInputAllowed() ? "ON" : "OFF", - isGamepadInputAllowed() ? "ON" : "OFF"); - - m_OverlayManager.updateOverlayText(Overlay::OverlayStatusUpdate, buffer); - m_OverlayManager.setOverlayState(Overlay::OverlayStatusUpdate, true); -} - Session::~Session() { // NB: This may not get destroyed for a long time! Don't put any non-trivial cleanup here. diff --git a/app/streaming/session.h b/app/streaming/session.h index d232bdbc..b4bba36d 100644 --- a/app/streaming/session.h +++ b/app/streaming/session.h @@ -2,7 +2,6 @@ #include #include -#include #include #include @@ -126,22 +125,6 @@ public: void setShouldExit(bool quitHostApp = false); - bool isGamepadInputAllowed() const - { - return m_AllowGamepadInput.load(std::memory_order_relaxed); - } - - bool isKeyboardMouseInputAllowed() const - { - return m_AllowKeyboardMouseInput.load(std::memory_order_relaxed); - } - - void setGamepadInputAllowed(bool allowed); - void setKeyboardMouseInputAllowed(bool allowed); - void toggleGamepadInputAllowed(); - void toggleKeyboardMouseInputAllowed(); - void notifyInputPermissionState(); - signals: void stageStarting(QString stage); @@ -272,8 +255,6 @@ private: SDL_mutex* m_DecoderLock; bool m_AudioDisabled; bool m_AudioMuted; - std::atomic m_AllowGamepadInput; - std::atomic m_AllowKeyboardMouseInput; Uint32 m_FullScreenFlag; QQuickWindow* m_QtWindow; bool m_UnexpectedTermination;