Compare commits

..

2 commits

Author SHA1 Message Date
f78a63ab75 Add runtime input toggles and gated input sending
Some checks are pending
Build / setup (push) Waiting to run
Build / build-appimage (push) Blocked by required conditions
Build / build-steamlink (push) Blocked by required conditions
Build / build-windows-macos (push) Blocked by required conditions
2026-02-11 17:18:53 -07:00
f426032b1b Ignore local qmake and build outputs 2026-02-11 17:18:53 -07:00
10 changed files with 337 additions and 68 deletions

25
.gitignore vendored
View file

@ -4,5 +4,30 @@
**/.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

View file

@ -1,4 +1,5 @@
#include "input.h"
#include "streaming/session.h"
#include <Limelight.h>
#include "SDL_compat.h"
@ -7,6 +8,12 @@
#include <QtMath>
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
@ -22,8 +29,10 @@
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);
}
return 0;
}
@ -110,7 +119,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 (LiGetHostFeatureFlags() & LI_FF_PEN_TOUCH_EVENTS) {
if (isKeyboardMouseInputAllowed() && (LiGetHostFeatureFlags() & LI_FF_PEN_TOUCH_EVENTS)) {
#if SDL_VERSION_ATLEAST(2, 0, 22)
bool isPen = false;
@ -197,8 +206,10 @@ 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);
}
}
if (event->type == SDL_FINGERDOWN) {
m_LastTouchDownEvent = *event;
@ -210,8 +221,10 @@ void SdlInputHandler::emulateAbsoluteFingerEvent(SDL_TouchFingerEvent* event)
nullptr);
// Left button down on finger down
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_LEFT);
}
}
else if (event->type == SDL_FINGERUP) {
m_LastTouchUpEvent = *event;
@ -220,9 +233,13 @@ void SdlInputHandler::emulateAbsoluteFingerEvent(SDL_TouchFingerEvent* event)
m_LongPressTimer = 0;
// Left button up on finger up
if (isKeyboardMouseInputAllowed()) {
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);
}
}
}

View file

@ -6,6 +6,18 @@
#include <QtMath>
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
@ -101,6 +113,7 @@ void SdlInputHandler::sendGamepadState(GamepadState* state)
}
}
if (isGamepadInputAllowed()) {
LiSendMultiControllerEvent(state->index,
m_GamepadMask,
buttons,
@ -111,6 +124,7 @@ void SdlInputHandler::sendGamepadState(GamepadState* state)
rsX,
rsY);
}
}
void SdlInputHandler::sendGamepadBatteryState(GamepadState* state, SDL_JoystickPowerLevel level)
{
@ -150,8 +164,10 @@ void SdlInputHandler::sendGamepadBatteryState(GamepadState* state, SDL_JoystickP
return;
}
if (isGamepadInputAllowed()) {
LiSendControllerBatteryEvent(state->index, batteryState, batteryPercentage);
}
}
Uint32 SdlInputHandler::mouseEmulationTimerCallback(Uint32 interval, void *param)
{
@ -181,7 +197,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) {
if ((deltaX != 0 || deltaY != 0) && isKeyboardMouseInputAllowed()) {
LiSendMouseMoveEvent((short)deltaX, (short)deltaY);
}
@ -291,34 +307,52 @@ 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);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_RIGHT);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_MIDDLE);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X1);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, BUTTON_X2);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_UP) {
if (isKeyboardMouseInputAllowed()) {
LiSendScrollEvent(1);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_DOWN) {
if (isKeyboardMouseInputAllowed()) {
LiSendScrollEvent(-1);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_RIGHT) {
if (isKeyboardMouseInputAllowed()) {
LiSendHScrollEvent(1);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_DPAD_LEFT) {
if (isKeyboardMouseInputAllowed()) {
LiSendHScrollEvent(-1);
}
}
}
}
else {
state->buttons &= ~k_ButtonMap[event->button];
@ -346,22 +380,32 @@ 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);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_B) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_X) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_MIDDLE);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_LEFTSHOULDER) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X1);
}
}
else if (event->button == SDL_CONTROLLER_BUTTON_RIGHTSHOULDER) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_X2);
}
}
}
}
// Handle Start+Select+L1+R1 as a gamepad quit combo
if (state->buttons == (PLAY_FLAG | BACK_FLAG | LB_FLAG | RB_FLAG) && qgetenv("NO_GAMEPAD_QUIT") != "1") {
@ -375,8 +419,10 @@ 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);
}
return;
}
@ -390,8 +436,41 @@ 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);
}
return;
}
@ -418,8 +497,10 @@ 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]);
}
}
break;
case SDL_SENSOR_GYRO:
if (state->gyroReportPeriodMs &&
@ -429,11 +510,13 @@ 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);
}
}
break;
}
}
@ -460,8 +543,10 @@ void SdlInputHandler::handleControllerTouchpadEvent(SDL_ControllerTouchpadEvent*
return;
}
if (isGamepadInputAllowed()) {
LiSendControllerTouchEvent((uint8_t)state->index, eventType, event->finger, event->x, event->y, event->pressure);
}
}
#endif
@ -708,7 +793,9 @@ void SdlInputHandler::handleControllerDeviceEvent(SDL_ControllerDeviceEvent* eve
#endif
type == LI_CTYPE_PS;
if (isGamepadInputAllowed()) {
LiSendControllerArrivalEvent(state->index, m_GamepadMask, type, supportedButtonFlags, capabilities);
}
#else
// Send an empty event to tell the PC we've arrived
@ -750,8 +837,10 @@ 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);
}
// Clear all remaining state from this slot
SDL_memset(state, 0, sizeof(*state));

View file

@ -106,6 +106,16 @@ 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;

View file

@ -165,6 +165,8 @@ private:
KeyComboToggleCursorHide,
KeyComboToggleMinimize,
KeyComboPasteText,
KeyComboToggleKeyboardMouseInput,
KeyComboToggleGamepadInput,
KeyComboTogglePointerRegionLock,
KeyComboQuitAndExit,
KeyComboMax

View file

@ -13,6 +13,12 @@
#define VK_NUMPAD0 0x60
#endif
static bool isKeyboardMouseInputAllowed()
{
auto session = Session::get();
return session == nullptr || session->isKeyboardMouseInputAllowed();
}
void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo)
{
switch (combo) {
@ -114,7 +120,9 @@ void SdlInputHandler::performSpecialKeyCombo(KeyCombo combo)
}
// Send this text to the PC
if (isKeyboardMouseInputAllowed()) {
LiSendUtf8TextEvent(text, (unsigned int)strlen(text));
}
// SDL_GetClipboardText() allocates, so we must free
SDL_free((void*)text);
@ -126,6 +134,22 @@ 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");
@ -457,9 +481,11 @@ 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);
}
}

View file

@ -1,9 +1,16 @@
#include "input.h"
#include "streaming/session.h"
#include <Limelight.h>
#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;
@ -62,11 +69,13 @@ void SdlInputHandler::handleMouseButtonEvent(SDL_MouseButtonEvent* event)
button = BUTTON_RIGHT;
}
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(event->state == SDL_PRESSED ?
BUTTON_ACTION_PRESS :
BUTTON_ACTION_RELEASE,
button);
}
}
void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event)
{
@ -134,8 +143,10 @@ void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event)
}
}
if (mouseInVideoRegion || m_MouseWasInVideoRegion || m_PendingMouseButtonsAllUpOnVideoRegionLeave) {
if (isKeyboardMouseInputAllowed()) {
LiSendMousePositionEvent((short)x, (short)y, dst.w, dst.h);
}
}
// Adjust the cursor visibility if applicable
if (mouseInVideoRegion ^ m_MouseWasInVideoRegion) {
@ -150,9 +161,11 @@ void SdlInputHandler::handleMouseMotionEvent(SDL_MouseMotionEvent* event)
m_MouseWasInVideoRegion = mouseInVideoRegion;
}
else {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseMoveEvent(xrel, yrel);
}
}
}
void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event)
{
@ -187,8 +200,10 @@ 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
}
}
if (event->preciseX != 0.0f) {
// Invert the scroll direction if needed
@ -202,8 +217,10 @@ 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
}
}
#else
if (event->y != 0) {
// Invert the scroll direction if needed
@ -216,8 +233,10 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event)
event->y = SDL_clamp(event->y, -1, 1);
#endif
if (isKeyboardMouseInputAllowed()) {
LiSendScrollEvent((signed char)event->y);
}
}
if (event->x != 0) {
// Invert the scroll direction if needed
@ -230,8 +249,10 @@ void SdlInputHandler::handleMouseWheelEvent(SDL_MouseWheelEvent* event)
event->x = SDL_clamp(event->x, -1, 1);
#endif
if (isKeyboardMouseInputAllowed()) {
LiSendHScrollEvent((signed char)event->x);
}
}
#endif
}

View file

@ -1,10 +1,17 @@
#include "input.h"
#include "streaming/session.h"
#include <Limelight.h>
#include "SDL_compat.h"
#include <QtMath>
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
@ -16,13 +23,17 @@
Uint32 SdlInputHandler::releaseLeftButtonTimerCallback(Uint32, void*)
{
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_LEFT);
}
return 0;
}
Uint32 SdlInputHandler::releaseRightButtonTimerCallback(Uint32, void*)
{
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, BUTTON_RIGHT);
}
return 0;
}
@ -39,7 +50,9 @@ Uint32 SdlInputHandler::dragTimerCallback(Uint32, void *param)
me->m_DragButton = BUTTON_LEFT;
}
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_PRESS, me->m_DragButton);
}
return 0;
}
@ -99,7 +112,7 @@ void SdlInputHandler::handleRelativeFingerEvent(SDL_TouchFingerEvent* event)
// than the client window dimensions.
short deltaX = static_cast<short>(event->dx * m_StreamWidth);
short deltaY = static_cast<short>(event->dy * m_StreamHeight);
if (deltaX != 0 || deltaY != 0) {
if ((deltaX != 0 || deltaY != 0) && isKeyboardMouseInputAllowed()) {
LiSendMouseMoveEvent(deltaX, deltaY);
}
}
@ -133,7 +146,9 @@ void SdlInputHandler::handleRelativeFingerEvent(SDL_TouchFingerEvent* event)
// Release any drag
if (m_DragButton != 0) {
if (isKeyboardMouseInputAllowed()) {
LiSendMouseButtonEvent(BUTTON_ACTION_RELEASE, m_DragButton);
}
m_DragButton = 0;
}
// 2 finger tap
@ -143,7 +158,9 @@ 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);
}
// Queue a timer to release it in 100 ms
SDL_RemoveTimer(m_RightButtonReleaseTimer);
@ -154,7 +171,9 @@ 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);
}
// Queue a timer to release it in 100 ms
SDL_RemoveTimer(m_LeftButtonReleaseTimer);

View file

@ -556,6 +556,8 @@ 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),
@ -571,6 +573,45 @@ 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.

View file

@ -2,6 +2,7 @@
#include <QSemaphore>
#include <QQuickWindow>
#include <atomic>
#include <Limelight.h>
#include <opus_multistream.h>
@ -125,6 +126,22 @@ 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);
@ -255,6 +272,8 @@ private:
SDL_mutex* m_DecoderLock;
bool m_AudioDisabled;
bool m_AudioMuted;
std::atomic<bool> m_AllowGamepadInput;
std::atomic<bool> m_AllowKeyboardMouseInput;
Uint32 m_FullScreenFlag;
QQuickWindow* m_QtWindow;
bool m_UnexpectedTermination;