MCPcopy Create free account
hub / github.com/KangLin/RabbitRemoteControl / slotUpdateLedState

Method slotUpdateLedState

Src/FrmViewer.cpp:482–565  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

480#endif
481
482void CFrmViewer::slotUpdateLedState(unsigned int state)
483{
484 qDebug(log, "Got server LED state: 0x%08x", state);
485
486 if (!hasFocus())
487 return;
488
489 //TODO: test led
490
491#if defined(WIN32)
492 INPUT input[6];
493 UINT count;
494 UINT ret;
495
496 memset(input, 0, sizeof(input));
497 count = 0;
498
499 if (!!(state & CapsLock) != !!(GetKeyState(VK_CAPITAL) & 0x1)) {
500 input[count].type = input[count+1].type = INPUT_KEYBOARD;
501 input[count].ki.wVk = input[count+1].ki.wVk = VK_CAPITAL;
502 //input[count].ki.wScan = input[count+1].ki.wScan = SCAN_FAKE;
503 input[count].ki.dwFlags = 0;
504 input[count+1].ki.dwFlags = KEYEVENTF_KEYUP;
505 count += 2;
506 }
507
508 if (!!(state & NumLock) != !!(GetKeyState(VK_NUMLOCK) & 0x1)) {
509 input[count].type = input[count+1].type = INPUT_KEYBOARD;
510 input[count].ki.wVk = input[count+1].ki.wVk = VK_NUMLOCK;
511 //input[count].ki.wScan = input[count+1].ki.wScan = SCAN_FAKE;
512 input[count].ki.dwFlags = KEYEVENTF_EXTENDEDKEY;
513 input[count+1].ki.dwFlags = KEYEVENTF_KEYUP | KEYEVENTF_EXTENDEDKEY;
514 count += 2;
515 }
516
517 if (!!(state & ScrollLock) != !!(GetKeyState(VK_SCROLL) & 0x1)) {
518 input[count].type = input[count+1].type = INPUT_KEYBOARD;
519 input[count].ki.wVk = input[count+1].ki.wVk = VK_SCROLL;
520 //input[count].ki.wScan = input[count+1].ki.wScan = SCAN_FAKE;
521 input[count].ki.dwFlags = 0;
522 input[count+1].ki.dwFlags = KEYEVENTF_KEYUP;
523 count += 2;
524 }
525
526 if (count == 0)
527 return;
528
529 ret = SendInput(count, input, sizeof(*input));
530 if (ret < count)
531 qCritical(log) << "Failed to update keyboard LED state:" << GetLastError();
532#elif defined(Q_OS_APPLE)
533
534 // No support for Scroll Lock //
535 ;
536
537#elif defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) && !defined(Q_OS_APPLE)
538 unsigned int affect, values;
539 unsigned int mask;

Callers

nothing calls this directly

Calls 1

getModifierMaskFunction · 0.85

Tested by

no test coverage detected