mirror of
https://github.com/reactos/reactos.git
synced 2025-02-22 08:25:03 +00:00
[OSK] Reduce the delay when redrawing LED keyboard resources (#1385)
200 ms would mean that the LEDs redraw each 0,2 second and this adds a slight delay. This can be seen if you press the Num lock key (for example) many times in a row and the LED resources won't update instantly. Therefore reducing the value of uElapse should significantly decrease the delay and the LEDs should update in a realistic way. Furthermore, before invalidating the LED resource check the toggle state of the keys.
This commit is contained in:
parent
eb0f16433b
commit
411a599610
2 changed files with 62 additions and 6 deletions
|
@ -14,6 +14,13 @@
|
|||
|
||||
OSK_GLOBALS Globals;
|
||||
|
||||
OSK_KEYLEDINDICATOR LedKey[] =
|
||||
{
|
||||
{VK_NUMLOCK, IDC_LED_NUM, 0x0145, FALSE},
|
||||
{VK_CAPITAL, IDC_LED_CAPS, 0x013A, FALSE},
|
||||
{VK_SCROLL, IDC_LED_SCROLL, 0x0146, FALSE}
|
||||
};
|
||||
|
||||
/* FUNCTIONS ******************************************************************/
|
||||
|
||||
/***********************************************************************
|
||||
|
@ -237,7 +244,7 @@ int OSK_DlgInitDialog(HWND hDlg)
|
|||
Globals.hBrushGreenLed = CreateSolidBrush(RGB(0, 255, 0));
|
||||
|
||||
/* Set a timer for periodics tasks */
|
||||
Globals.iTimer = SetTimer(hDlg, 0, 200, NULL);
|
||||
Globals.iTimer = SetTimer(hDlg, 0, 50, NULL);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -281,6 +288,29 @@ int OSK_DlgClose(void)
|
|||
return TRUE;
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* OSK_RefreshLEDKeys
|
||||
*
|
||||
* Updates (invalidates) the LED icon resources then the respective
|
||||
* keys (Caps Lock, Scroll Lock or Num Lock) are being held down
|
||||
*/
|
||||
VOID OSK_RefreshLEDKeys(VOID)
|
||||
{
|
||||
INT i;
|
||||
BOOL bKeyIsPressed;
|
||||
|
||||
for (i = 0; i < _countof(LedKey); i++)
|
||||
{
|
||||
bKeyIsPressed = (GetAsyncKeyState(LedKey[i].vKey) & 0x8000) != 0;
|
||||
if (LedKey[i].bWasKeyPressed != bKeyIsPressed)
|
||||
{
|
||||
LedKey[i].bWasKeyPressed = bKeyIsPressed;
|
||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, LedKey[i].DlgResource), NULL, FALSE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/***********************************************************************
|
||||
*
|
||||
* OSK_DlgTimer
|
||||
|
@ -298,10 +328,11 @@ int OSK_DlgTimer(void)
|
|||
Globals.hActiveWnd = hWndActiveWindow;
|
||||
}
|
||||
|
||||
/* Always redraw leds because it can be changed by the real keyboard) */
|
||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_NUM), NULL, TRUE);
|
||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_CAPS), NULL, TRUE);
|
||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, IDC_LED_SCROLL), NULL, TRUE);
|
||||
/*
|
||||
Update the LED key indicators accordingly to their state (if one
|
||||
of the specific keys is held down).
|
||||
*/
|
||||
OSK_RefreshLEDKeys();
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
@ -320,6 +351,7 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
|||
BOOL bKeyDown;
|
||||
BOOL bKeyUp;
|
||||
LONG WindowStyle;
|
||||
INT i;
|
||||
|
||||
/* FIXME: To be deleted when ReactOS will support WS_EX_NOACTIVATE */
|
||||
if (Globals.hActiveWnd)
|
||||
|
@ -357,8 +389,23 @@ BOOL OSK_DlgCommand(WPARAM wCommand, HWND hWndControl)
|
|||
bKeyUp = TRUE;
|
||||
}
|
||||
|
||||
/* Extended key ? */
|
||||
/* Get the key from dialog control key command */
|
||||
ScanCode = wCommand;
|
||||
|
||||
/*
|
||||
The user could've pushed one of the key buttons of the dialog that
|
||||
can trigger particular function toggling (Caps Lock, Num Lock or Scroll Lock). Update
|
||||
(invalidate) the LED icon resources accordingly.
|
||||
*/
|
||||
for (i = 0; i < _countof(LedKey); i++)
|
||||
{
|
||||
if (LedKey[i].wScanCode == ScanCode)
|
||||
{
|
||||
InvalidateRect(GetDlgItem(Globals.hMainWnd, LedKey[i].DlgResource), NULL, FALSE);
|
||||
}
|
||||
}
|
||||
|
||||
/* Extended key ? */
|
||||
if (ScanCode & 0x0200)
|
||||
bExtendedKey = TRUE;
|
||||
else
|
||||
|
|
|
@ -46,6 +46,14 @@ typedef struct
|
|||
INT PosY;
|
||||
} OSK_GLOBALS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
INT vKey;
|
||||
INT DlgResource;
|
||||
WORD wScanCode;
|
||||
BOOL bWasKeyPressed;
|
||||
} OSK_KEYLEDINDICATOR;
|
||||
|
||||
/* PROTOTYPES *****************************************************************/
|
||||
|
||||
/* main.c */
|
||||
|
@ -59,6 +67,7 @@ INT_PTR APIENTRY OSK_DlgProc(HWND hDlg, UINT msg, WPARAM wParam, LPARAM lParam);
|
|||
LRESULT APIENTRY OSK_ThemeHandler(HWND hDlg, NMCUSTOMDRAW *pNmDraw);
|
||||
int WINAPI wWinMain(HINSTANCE, HINSTANCE, LPWSTR, int);
|
||||
VOID OSK_RestoreDlgPlacement(HWND hDlg);
|
||||
VOID OSK_RefreshLEDKeys(VOID);
|
||||
|
||||
/* settings.c */
|
||||
BOOL LoadDataFromRegistry(VOID);
|
||||
|
|
Loading…
Reference in a new issue