| 6439 | } |
| 6440 | |
| 6441 | bool QKeyMapper_Worker::matchFakerInputMouseButtonExtraInfo(WPARAM wParam, WORD xbutton, ULONG_PTR &outExtraInfo) |
| 6442 | { |
| 6443 | QMutexLocker locker(&s_FakerInputMouseButtonExtraInfoQueue_Mutex); |
| 6444 | |
| 6445 | if (s_FakerInputMouseButtonExtraInfoQueue.isEmpty()) { |
| 6446 | return false; |
| 6447 | } |
| 6448 | |
| 6449 | qint64 currentTime = QDateTime::currentMSecsSinceEpoch(); |
| 6450 | |
| 6451 | // Check if the front of the queue matches the current mouse event |
| 6452 | const FakerInputMouseButtonExtraInfo &front = s_FakerInputMouseButtonExtraInfoQueue.head(); |
| 6453 | |
| 6454 | // Check time window first - if event is too old, it's likely a stale entry |
| 6455 | qint64 timeDiff = currentTime - front.timestamp; |
| 6456 | if (timeDiff > FAKERINPUT_EXTRAINFO_MATCH_TIME_WINDOW_MS) { |
| 6457 | // Event is too old, remove stale entry and don't match |
| 6458 | s_FakerInputMouseButtonExtraInfoQueue.dequeue(); |
| 6459 | #ifdef DEBUG_LOGOUT_ON |
| 6460 | qDebug("[matchFakerInputMouseButtonExtraInfo] Discarded stale entry: wParam:0x%04X, Age:%lldms > %lldms", |
| 6461 | (unsigned int)front.wParam, timeDiff, FAKERINPUT_EXTRAINFO_MATCH_TIME_WINDOW_MS); |
| 6462 | #endif |
| 6463 | return false; |
| 6464 | } |
| 6465 | |
| 6466 | if (front.wParam == wParam && front.xbutton == xbutton) { |
| 6467 | outExtraInfo = front.extraInfo; |
| 6468 | s_FakerInputMouseButtonExtraInfoQueue.dequeue(); |
| 6469 | #ifdef DEBUG_LOGOUT_ON |
| 6470 | qDebug("[matchFakerInputMouseButtonExtraInfo] Matched wParam:0x%04X, XButton:%d, ExtraInfo:0x%08X, QueueSize:%d", |
| 6471 | (unsigned int)wParam, xbutton, (unsigned int)outExtraInfo, |
| 6472 | s_FakerInputMouseButtonExtraInfoQueue.size()); |
| 6473 | #endif |
| 6474 | return true; |
| 6475 | } |
| 6476 | |
| 6477 | return false; |
| 6478 | } |
| 6479 | |
| 6480 | bool QKeyMapper_Worker::matchFakerInputMouseWheelExtraInfo(WPARAM wParam, short wheelDelta, ULONG_PTR &outExtraInfo) |
| 6481 | { |