| 5994 | } |
| 5995 | |
| 5996 | bool QKeyMapper_Worker::FakerInputClient_sendMouseButton(const QString &mouseButton, int keyupdown, ULONG_PTR extraInfo) |
| 5997 | { |
| 5998 | QMutexLocker locker(&s_FakerInputClient_Mutex); |
| 5999 | |
| 6000 | if (s_FakerInputClient == Q_NULLPTR || s_FakerInputClient_ConnectState != FAKERINPUT_CONNECT_SUCCESS) { |
| 6001 | #ifdef DEBUG_LOGOUT_ON |
| 6002 | qWarning() << "[FakerInputClient_sendMouseButton] FakerInput not connected!"; |
| 6003 | #endif |
| 6004 | return false; |
| 6005 | } |
| 6006 | |
| 6007 | BYTE buttonBit = MouseButtonStringToHIDButton(mouseButton, keyupdown); |
| 6008 | if (buttonBit == 0) { |
| 6009 | #ifdef DEBUG_LOGOUT_ON |
| 6010 | qWarning() << "[FakerInputClient_sendMouseButton] Unknown mouse button:" << mouseButton; |
| 6011 | #endif |
| 6012 | return false; |
| 6013 | } |
| 6014 | |
| 6015 | // Update button state |
| 6016 | if (keyupdown == KEY_DOWN) { |
| 6017 | s_FakerInputMouseReport_Buttons |= buttonBit; |
| 6018 | } else { |
| 6019 | s_FakerInputMouseReport_Buttons &= ~buttonBit; |
| 6020 | } |
| 6021 | |
| 6022 | #ifdef FAKERINPUT_EXTRAINFO |
| 6023 | // Pre-enqueue extraInfo BEFORE calling fakerinput_update_relative_mouse to avoid race condition |
| 6024 | // where the hook receives the event before we have a chance to enqueue |
| 6025 | bool enqueued = false; |
| 6026 | if (extraInfo != 0) { |
| 6027 | // Determine the corresponding Windows message type |
| 6028 | WPARAM wParam = 0; |
| 6029 | WORD xbutton = 0; |
| 6030 | if (mouseButton == "Mouse-L") { |
| 6031 | wParam = (keyupdown == KEY_DOWN) ? WM_LBUTTONDOWN : WM_LBUTTONUP; |
| 6032 | } else if (mouseButton == "Mouse-R") { |
| 6033 | wParam = (keyupdown == KEY_DOWN) ? WM_RBUTTONDOWN : WM_RBUTTONUP; |
| 6034 | } else if (mouseButton == "Mouse-M") { |
| 6035 | wParam = (keyupdown == KEY_DOWN) ? WM_MBUTTONDOWN : WM_MBUTTONUP; |
| 6036 | } else if (mouseButton == "Mouse-X1") { |
| 6037 | wParam = (keyupdown == KEY_DOWN) ? WM_XBUTTONDOWN : WM_XBUTTONUP; |
| 6038 | xbutton = XBUTTON1; |
| 6039 | } else if (mouseButton == "Mouse-X2") { |
| 6040 | wParam = (keyupdown == KEY_DOWN) ? WM_XBUTTONDOWN : WM_XBUTTONUP; |
| 6041 | xbutton = XBUTTON2; |
| 6042 | } |
| 6043 | |
| 6044 | if (wParam != 0) { |
| 6045 | QMutexLocker queueLocker(&s_FakerInputMouseButtonExtraInfoQueue_Mutex); |
| 6046 | s_FakerInputMouseButtonExtraInfoQueue.enqueue(FakerInputMouseButtonExtraInfo(wParam, xbutton, extraInfo, QDateTime::currentMSecsSinceEpoch())); |
| 6047 | enqueued = true; |
| 6048 | #ifdef DEBUG_LOGOUT_ON |
| 6049 | qDebug("[FakerInputClient_sendMouseButton] Enqueued ExtraInfo: Button:%s, wParam:0x%04X, XButton:%d, ExtraInfo:0x%08X, QueueSize:%d", |
| 6050 | mouseButton.toLatin1().constData(), (unsigned int)wParam, xbutton, (unsigned int)extraInfo, |
| 6051 | s_FakerInputMouseButtonExtraInfoQueue.size()); |
| 6052 | #endif |
| 6053 | } |
nothing calls this directly
no test coverage detected