diff --git a/app/streaming/input/abstouch.cpp b/app/streaming/input/abstouch.cpp index 56b35f9b..dc1bf75e 100644 --- a/app/streaming/input/abstouch.cpp +++ b/app/streaming/input/abstouch.cpp @@ -2,6 +2,7 @@ #include #include +#include #include "streaming/streamutils.h" #include @@ -27,6 +28,40 @@ Uint32 SdlInputHandler::longPressTimerCallback(Uint32, void*) return 0; } +void SdlInputHandler::disableTouchFeedback() +{ + SDL_SysWMinfo info; + + SDL_VERSION(&info.version); + SDL_GetWindowWMInfo(m_Window, &info); + +#ifdef Q_OS_WIN32 + if (info.subsystem == SDL_SYSWM_WINDOWS) { + auto fnSetWindowFeedbackSetting = (decltype(SetWindowFeedbackSetting)*)GetProcAddress(GetModuleHandleW(L"user32.dll"), "SetWindowFeedbackSetting"); + if (fnSetWindowFeedbackSetting) { + constexpr FEEDBACK_TYPE feedbackTypes[] = { + FEEDBACK_TOUCH_CONTACTVISUALIZATION, + FEEDBACK_PEN_BARRELVISUALIZATION, + FEEDBACK_PEN_TAP, + FEEDBACK_PEN_DOUBLETAP, + FEEDBACK_PEN_PRESSANDHOLD, + FEEDBACK_PEN_RIGHTTAP, + FEEDBACK_TOUCH_TAP, + FEEDBACK_TOUCH_DOUBLETAP, + FEEDBACK_TOUCH_PRESSANDHOLD, + FEEDBACK_TOUCH_RIGHTTAP, + FEEDBACK_GESTURE_PRESSANDTAP, + }; + + for (FEEDBACK_TYPE ft : feedbackTypes) { + BOOL val = FALSE; + fnSetWindowFeedbackSetting(info.info.win.window, ft, 0, sizeof(val), &val); + } + } + } +#endif +} + void SdlInputHandler::handleAbsoluteFingerEvent(SDL_TouchFingerEvent* event) { SDL_Rect src, dst; @@ -81,6 +116,11 @@ void SdlInputHandler::handleAbsoluteFingerEvent(SDL_TouchFingerEvent* event) 0.0f, 0.0f, LI_ROT_UNKNOWN) == LI_ERR_UNSUPPORTED) { emulateAbsoluteFingerEvent(event); } + else if (!m_DisabledTouchFeedback) { + // Disable touch feedback when passing touch natively + disableTouchFeedback(); + m_DisabledTouchFeedback = true; + } } void SdlInputHandler::emulateAbsoluteFingerEvent(SDL_TouchFingerEvent* event) diff --git a/app/streaming/input/input.cpp b/app/streaming/input/input.cpp index 7858f822..6d41d4f6 100644 --- a/app/streaming/input/input.cpp +++ b/app/streaming/input/input.cpp @@ -27,6 +27,7 @@ SdlInputHandler::SdlInputHandler(StreamingPreferences& prefs, int streamWidth, i m_StreamHeight(streamHeight), m_AbsoluteMouseMode(prefs.absoluteMouseMode), m_AbsoluteTouchMode(prefs.absoluteTouchMode), + m_DisabledTouchFeedback(false), m_LeftButtonReleaseTimer(0), m_RightButtonReleaseTimer(0), m_DragTimer(0), diff --git a/app/streaming/input/input.h b/app/streaming/input/input.h index b8d569e6..eb638902 100644 --- a/app/streaming/input/input.h +++ b/app/streaming/input/input.h @@ -140,6 +140,8 @@ private: void emulateAbsoluteFingerEvent(SDL_TouchFingerEvent* event); + void disableTouchFeedback(); + void handleRelativeFingerEvent(SDL_TouchFingerEvent* event); void performSpecialKeyCombo(KeyCombo combo); @@ -194,6 +196,7 @@ private: int m_StreamHeight; bool m_AbsoluteMouseMode; bool m_AbsoluteTouchMode; + bool m_DisabledTouchFeedback; SDL_TouchFingerEvent m_TouchDownEvent[MAX_FINGERS]; SDL_TimerID m_LeftButtonReleaseTimer;