void RestoreLEDState(void) { if (bEmulateKeypresses) keypresses_RestoreLEDState(); else ToggleKeyboardLights((BYTE)(LedState(VK_SCROLL) + (LedState(VK_NUMLOCK)<<1) + (LedState(VK_CAPITAL)<<2))); }
static void __cdecl FlashThreadFunction(void*) { BOOL bEvent = FALSE; DWORD dwEventStarted = 0, dwFlashStarted = 0; BYTE data, unchangedLeds; while (TRUE) { unchangedLeds = (BYTE)(LedState(VK_PAUSE) * !bFlashLed[2] + ((LedState(VK_NUMLOCK) * !bFlashLed[0]) << 1) + ((LedState(VK_CAPITAL) * !bFlashLed[1]) << 2)); GetAsyncKeyState(VK_PAUSE); // empty Pause/Break's keystroke buffer // Start flashing while (bEvent && bFlashingEnabled) { // Let's give the user the opportunity of finishing flashing manually :) if (GetAsyncKeyState(VK_PAUSE) & 1) break; if ((bFlashUntil & UNTIL_NBLINKS) && GetTickCount() > (dwFlashStarted + wBlinksNumber * 1000)) break; if (bFlashUntil & UNTIL_REATTENDED) { if (bMirandaOrWindows == ACTIVE_WINDOWS && !bEmulateKeypresses) { LASTINPUTINFO ii = { sizeof(ii) }; GetLastInputInfo(&ii); dwLastInput = ii.dwTime; } if (dwLastInput > dwEventStarted) break; } if ((bFlashUntil & UNTIL_EVENTSOPEN) && !checkUnopenEvents()) break; if ((bFlashUntil & UNTIL_CONDITIONS) && (!checkNotifyOptions() || !checkGlobalStatus() || !checkGlobalXstatus())) break; data = getBlinkingLeds(); ToggleKeyboardLights((BYTE)(data | unchangedLeds)); // Wait for exit event if (WaitForSingleObject(hExitEvent, nWaitDelay) == WAIT_OBJECT_0) return; } RestoreLEDState(); setFlashingSequence(); bReminderDisabled = FALSE; // Wait for new event HANDLE Objects[2]; Objects[0] = hFlashEvent; Objects[1] = hExitEvent; if (WaitForMultipleObjects(2, Objects, FALSE, INFINITE) == WAIT_OBJECT_0 + 1) return; bEvent = TRUE; bReminderDisabled = TRUE; dwEventStarted = GetTickCount(); // Wait StartDelay seconds if (wStartDelay > 0) Sleep(wStartDelay * 1000); dwFlashStarted = GetTickCount(); } }
static void __cdecl TestThread(void *param) { FLASHING_SEQUENCE *pTest = (FLASHING_SEQUENCE *)param; unsigned int testNum = (unsigned int)db_get_b(NULL, KEYBDMODULE, "testnum", DEF_SETTING_TESTNUM); unsigned int testSecs = (unsigned int)db_get_b(NULL, KEYBDMODULE, "testsecs", DEF_SETTING_TESTSECS); for (unsigned i=0, dwEndTest=GetTickCount()+testSecs*1000; i < testNum || GetTickCount() < dwEndTest; i++) for (pTest->index=0; pTest->index < pTest->size; pTest->index++) { ToggleKeyboardLights(pTest->frame[pTest->index]); Sleep(nWaitDelay); } RestoreLEDState(); bTestSemaphore = FALSE; }
static void PreviewThread(void*) { if (wStartDelay > 0) Sleep(wStartDelay * 1000); BYTE unchangedLeds = (BYTE)(LedState(VK_SCROLL) * !bFlashLed[2] + ((LedState(VK_NUMLOCK) * !bFlashLed[0])<<1) + ((LedState(VK_CAPITAL) * !bFlashLed[1])<<2)); while (bPreview) for (unsigned i=0; bPreview && i < pFS->size; i++) { ToggleKeyboardLights((BYTE)(pFS->frame[i%pFS->size]|unchangedLeds)); Sleep(nWaitDelay); } RestoreLEDState(); bPreviewSemaphore = FALSE; }