ReactOS 0.4.16-dev-112-g52265ae
keyboard.c File Reference
#include "main.h"
Include dependency graph for keyboard.c:

Go to the source code of this file.

Classes

struct  _SPEED_DATA
 

Macros

#define ID_BLINK_TIMER   345
 

Typedefs

typedef struct _SPEED_DATA SPEED_DATA
 
typedef struct _SPEED_DATAPSPEED_DATA
 

Functions

static VOID UpdateCaretBlinkTimeReg (_In_ UINT uCaretBlinkTime)
 
static INT_PTR CALLBACK KeyboardSpeedProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static INT_PTR CALLBACK KeybHardwareProc (IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
 
static int CALLBACK PropSheetProc (HWND hwndDlg, UINT uMsg, LPARAM lParam)
 
LONG APIENTRY KeyboardApplet (HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam)
 

Macro Definition Documentation

◆ ID_BLINK_TIMER

#define ID_BLINK_TIMER   345

Definition at line 28 of file keyboard.c.

Typedef Documentation

◆ PSPEED_DATA

◆ SPEED_DATA

Function Documentation

◆ KeybHardwareProc()

static INT_PTR CALLBACK KeybHardwareProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 314 of file keyboard.c.

318{
319 GUID Guids[1];
320 Guids[0] = GUID_DEVCLASS_KEYBOARD;
321
324
325 switch(uMsg)
326 {
327 case WM_INITDIALOG:
328 /* Create the hardware page */
330 Guids,
331 sizeof(Guids) / sizeof(Guids[0]),
333 break;
334 }
335
336 return FALSE;
337}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define FALSE
Definition: types.h:117
@ HWPD_STANDARDLIST
Definition: main.h:24
HWND WINAPI DeviceCreateHardwarePageEx(HWND hWndParent, LPGUID lpGuids, UINT uNumberOfGuids, HWPAGE_DISPLAYMODE DisplayMode)
#define UNREFERENCED_PARAMETER(P)
Definition: ntbasedef.h:317
#define WM_INITDIALOG
Definition: winuser.h:1742

Referenced by KeyboardApplet().

◆ KeyboardApplet()

LONG APIENTRY KeyboardApplet ( HWND  hwnd,
UINT  uMsg,
LPARAM  wParam,
LPARAM  lParam 
)

Definition at line 357 of file keyboard.c.

358{
360 PROPSHEETHEADER psh;
361 HPSXA hpsxa;
362 INT nPage = 0;
363 LONG ret;
364
369
370 if (uMsg == CPL_STARTWPARMSW && lParam != 0)
371 nPage = _wtoi((PWSTR)lParam);
372
373 ZeroMemory(&psh, sizeof(PROPSHEETHEADER));
374 psh.dwSize = sizeof(PROPSHEETHEADER);
376 psh.hwndParent = hwnd;
377 psh.hInstance = hApplet;
378 psh.pszIcon = MAKEINTRESOURCE(IDC_CPLICON_2);
379 psh.pszCaption = MAKEINTRESOURCE(IDS_CPLNAME_2);
380 psh.nStartPage = 0;
381 psh.phpage = hpsp;
382 psh.pfnCallback = PropSheetProc;
383
384 /* Load additional pages provided by shell extensions */
386
387 /* NOTE: The speed page (CPLPAGE_KEYBOARD_SPEED) cannot be replaced by
388 shell extensions since Win2k! */
391
392 if (hpsxa != NULL)
394
395 if (nPage != 0 && nPage <= psh.nPages)
396 psh.nStartPage = nPage;
397
398 ret = (LONG)(PropertySheet(&psh) != -1);
399
400 if (hpsxa != NULL)
402
403 return ret;
404}
static BOOL CALLBACK PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
Definition: advmon.c:12
static VOID InitPropSheetPage(PROPSHEETPAGE *psp, PSERVICEPROPSHEET dlgInfo, WORD idDlg, DLGPROC DlgProc)
Definition: propsheet.c:15
#define CPL_STARTWPARMSW
Definition: cpl.h:21
#define NULL
Definition: types.h:112
HINSTANCE hApplet
Definition: access.c:17
static int CALLBACK PropSheetProc(HWND hwndDlg, UINT uMsg, LPARAM lParam)
Definition: keyboard.c:340
static INT_PTR CALLBACK KeybHardwareProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: keyboard.c:314
static INT_PTR CALLBACK KeyboardSpeedProc(IN HWND hwndDlg, IN UINT uMsg, IN WPARAM wParam, IN LPARAM lParam)
Definition: keyboard.c:69
#define MAX_CPL_PAGES
Definition: main.h:47
#define IDC_CPLICON_2
Definition: resource.h:6
#define IDS_CPLNAME_2
Definition: resource.h:38
#define IDD_HARDWARE
Definition: resource.h:30
#define IDD_KEYBSPEED
Definition: resource.h:31
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
#define TEXT(s)
Definition: k32.h:26
struct _PSP * HPROPSHEETPAGE
Definition: mstask.idl:90
long LONG
Definition: pedump.c:60
#define PROPSHEETHEADER
Definition: prsht.h:392
#define PSH_PROPTITLE
Definition: prsht.h:40
#define PSH_USECALLBACK
Definition: prsht.h:48
#define PropertySheet
Definition: prsht.h:400
#define PSH_USEICONID
Definition: prsht.h:42
#define REGSTR_PATH_CONTROLSFOLDER
Definition: regstr.h:76
void WINAPI SHDestroyPropSheetExtArray(HPSXA hpsxa)
Definition: shellord.c:2390
UINT WINAPI SHAddFromPropSheetExtArray(HPSXA hpsxa, LPFNADDPROPSHEETPAGE lpfnAddPage, LPARAM lParam)
Definition: shellord.c:2213
HPSXA WINAPI SHCreatePropSheetExtArray(HKEY hKey, LPCWSTR pszSubKey, UINT max_iface)
Definition: shellord.c:2243
uint16_t * PWSTR
Definition: typedefs.h:56
int32_t INT
Definition: typedefs.h:58
int ret
#define ZeroMemory
Definition: winbase.h:1712
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12
#define MAKEINTRESOURCE
Definition: winuser.h:591

◆ KeyboardSpeedProc()

static INT_PTR CALLBACK KeyboardSpeedProc ( IN HWND  hwndDlg,
IN UINT  uMsg,
IN WPARAM  wParam,
IN LPARAM  lParam 
)
static

Definition at line 69 of file keyboard.c.

73{
74 PSPEED_DATA pSpeedData;
75
76 pSpeedData = (PSPEED_DATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
77
78 switch (uMsg)
79 {
80 case WM_INITDIALOG:
81 pSpeedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(SPEED_DATA));
82 SetWindowLongPtr(hwndDlg, DWLP_USER, (LONG_PTR)pSpeedData);
83
84 /* Get current keyboard delay */
86 sizeof(INT),
87 &pSpeedData->nKeyboardDelay,
88 0))
89 {
90 pSpeedData->nKeyboardDelay = 2;
91 }
92
93 pSpeedData->nOrigKeyboardDelay = pSpeedData->nKeyboardDelay;
94
95 /* Get current keyboard delay */
97 sizeof(DWORD),
98 &pSpeedData->dwKeyboardSpeed,
99 0))
100 {
101 pSpeedData->dwKeyboardSpeed = 31;
102 }
103
104 pSpeedData->dwOrigKeyboardSpeed = pSpeedData->dwKeyboardSpeed;
105
106 pSpeedData->fShowCursor = TRUE;
108 ScreenToClient(hwndDlg, (LPPOINT)&pSpeedData->rcCursor.left);
109 ScreenToClient(hwndDlg, (LPPOINT)&pSpeedData->rcCursor.right);
110
111 /* Get the caret blink time and save its original value */
113 pSpeedData->uCaretBlinkTime = pSpeedData->uOrigCaretBlinkTime;
114
117
120
123
124 /* Start the blink timer */
125 pSpeedData->uCaretBlinkTime = pSpeedData->uCaretBlinkTime >= 1200 ? -1 : pSpeedData->uCaretBlinkTime;
126 if ((INT)pSpeedData->uCaretBlinkTime > 0)
127 {
128 SetTimer(hwndDlg, ID_BLINK_TIMER, pSpeedData->uCaretBlinkTime, NULL);
129 }
130 else
131 {
132 PostMessage(hwndDlg, WM_TIMER, ID_BLINK_TIMER, 0);
133 }
134
135 break;
136
137 case WM_HSCROLL:
139 {
140 switch (LOWORD(wParam))
141 {
142 case TB_LINEUP:
143 case TB_LINEDOWN:
144 case TB_PAGEUP:
145 case TB_PAGEDOWN:
146 case TB_TOP:
147 case TB_BOTTOM:
148 case TB_ENDTRACK:
149 pSpeedData->nKeyboardDelay = 3 - (INT)SendDlgItemMessage(hwndDlg, IDC_SLIDER_REPEAT_DELAY, TBM_GETPOS, 0, 0);
151 pSpeedData->nKeyboardDelay,
152 0,
153 0);
154 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
155 break;
156
157 case TB_THUMBTRACK:
158 pSpeedData->nKeyboardDelay = 3 - (INT)HIWORD(wParam);
160 pSpeedData->nKeyboardDelay,
161 0,
162 0);
163 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
164 break;
165 }
166 }
167 else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_REPEAT_RATE))
168 {
169 switch (LOWORD(wParam))
170 {
171 case TB_LINEUP:
172 case TB_LINEDOWN:
173 case TB_PAGEUP:
174 case TB_PAGEDOWN:
175 case TB_TOP:
176 case TB_BOTTOM:
177 case TB_ENDTRACK:
180 pSpeedData->dwKeyboardSpeed,
181 0,
182 0);
183 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
184 break;
185
186 case TB_THUMBTRACK:
187 pSpeedData->dwKeyboardSpeed = (DWORD)HIWORD(wParam);
189 pSpeedData->dwKeyboardSpeed,
190 0,
191 0);
192 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
193 break;
194 }
195 }
196 else if ((HWND)lParam == GetDlgItem(hwndDlg, IDC_SLIDER_CURSOR_BLINK))
197 {
198 switch (LOWORD(wParam))
199 {
200 case TB_LINEUP:
201 case TB_LINEDOWN:
202 case TB_PAGEUP:
203 case TB_PAGEDOWN:
204 case TB_TOP:
205 case TB_BOTTOM:
206 case TB_ENDTRACK:
207 pSpeedData->uCaretBlinkTime = (12 - (UINT)SendDlgItemMessage(hwndDlg, IDC_SLIDER_CURSOR_BLINK, TBM_GETPOS, 0, 0)) * 100;
208 KillTimer(hwndDlg, ID_BLINK_TIMER);
209 pSpeedData->uCaretBlinkTime = pSpeedData->uCaretBlinkTime >= 1200 ? -1 : pSpeedData->uCaretBlinkTime;
210 if ((INT)pSpeedData->uCaretBlinkTime > 0)
211 {
212 SetTimer(hwndDlg, ID_BLINK_TIMER, pSpeedData->uCaretBlinkTime, NULL);
213 }
214 else if (pSpeedData->fShowCursor)
215 {
216 SendMessage(hwndDlg, WM_TIMER, ID_BLINK_TIMER, 0);
217 }
219 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
220 break;
221
222 case TB_THUMBTRACK:
223 pSpeedData->uCaretBlinkTime = (12 - (UINT)HIWORD(wParam)) * 100;
224 KillTimer(hwndDlg, ID_BLINK_TIMER);
225 pSpeedData->uCaretBlinkTime = pSpeedData->uCaretBlinkTime >= 1200 ? -1 : pSpeedData->uCaretBlinkTime;
226 if ((INT)pSpeedData->uCaretBlinkTime > 0)
227 {
228 SetTimer(hwndDlg, ID_BLINK_TIMER, pSpeedData->uCaretBlinkTime, NULL);
229 }
230 else if (pSpeedData->fShowCursor)
231 {
232 SendMessage(hwndDlg, WM_TIMER, ID_BLINK_TIMER, 0);
233 }
235 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
236 break;
237 }
238 }
239 break;
240
241 case WM_TIMER:
242 if (wParam == ID_BLINK_TIMER)
243 {
244 if (pSpeedData->fShowCursor)
245 {
246 HDC hDC = GetDC(hwndDlg);
247 HBRUSH hBrush = GetSysColorBrush(COLOR_BTNTEXT);
248 FillRect(hDC, &pSpeedData->rcCursor, hBrush);
249 ReleaseDC(hwndDlg, hDC);
250 }
251 else
252 {
253 InvalidateRect(hwndDlg, &pSpeedData->rcCursor, TRUE);
254 }
255
256 pSpeedData->fShowCursor = !pSpeedData->fShowCursor;
257 }
258 break;
259
260 case WM_NOTIFY:
261 {
262 LPNMHDR lpnm = (LPNMHDR)lParam;
263
264 switch(lpnm->code)
265 {
266 case PSN_APPLY:
267 /* Set the new keyboard settings */
268 if (pSpeedData->uOrigCaretBlinkTime != pSpeedData->uCaretBlinkTime)
269 {
271 }
272
274 pSpeedData->nKeyboardDelay,
275 0,
276 0);
278 pSpeedData->dwKeyboardSpeed,
279 0,
281 return TRUE;
282
283 case PSN_RESET:
284 /* Restore the original settings */
287 pSpeedData->nOrigKeyboardDelay,
288 0,
289 0);
291 pSpeedData->dwOrigKeyboardSpeed,
292 0,
293 0);
294 break;
295
296 default:
297 break;
298 }
299 }
300 break;
301
302 case WM_DESTROY:
303 KillTimer(hwndDlg, ID_BLINK_TIMER);
304 HeapFree(GetProcessHeap(), 0, pSpeedData);
305 break;
306 }
307
308 return FALSE;
309}
static HDC hDC
Definition: 3dtext.c:33
#define TRUE
Definition: types.h:120
#define ID_BLINK_TIMER
Definition: keyboard.c:28
struct _SPEED_DATA * PSPEED_DATA
static VOID UpdateCaretBlinkTimeReg(_In_ UINT uCaretBlinkTime)
Definition: keyboard.c:43
#define IDC_SLIDER_CURSOR_BLINK
Definition: resource.h:104
#define IDC_SLIDER_REPEAT_RATE
Definition: resource.h:102
#define IDC_SLIDER_REPEAT_DELAY
Definition: resource.h:100
#define IDC_TEXT_CURSOR_BLINK
Definition: resource.h:105
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned long DWORD
Definition: ntddk_ex.h:95
static HDC
Definition: imagelist.c:88
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define DWORD
Definition: nt_native.h:44
#define LOWORD(l)
Definition: pedump.c:82
#define INT
Definition: polytest.cpp:20
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_APPLY
Definition: prsht.h:117
#define PSN_RESET
Definition: prsht.h:118
#define TB_TOP
Definition: commctrl.h:2084
#define TB_ENDTRACK
Definition: commctrl.h:2086
#define TB_PAGEUP
Definition: commctrl.h:2080
#define TB_BOTTOM
Definition: commctrl.h:2085
#define TBM_GETPOS
Definition: commctrl.h:2036
#define TB_PAGEDOWN
Definition: commctrl.h:2081
#define TBM_SETRANGE
Definition: commctrl.h:2042
#define TB_THUMBTRACK
Definition: commctrl.h:2083
#define TB_LINEUP
Definition: commctrl.h:2078
#define TBM_SETPOS
Definition: commctrl.h:2041
#define TB_LINEDOWN
Definition: commctrl.h:2079
#define WM_NOTIFY
Definition: richedit.h:61
DWORD dwOrigKeyboardSpeed
Definition: keyboard.c:35
BOOL fShowCursor
Definition: keyboard.c:38
RECT rcCursor
Definition: keyboard.c:39
UINT uOrigCaretBlinkTime
Definition: keyboard.c:37
INT nOrigKeyboardDelay
Definition: keyboard.c:33
INT nKeyboardDelay
Definition: keyboard.c:32
DWORD dwKeyboardSpeed
Definition: keyboard.c:34
UINT uCaretBlinkTime
Definition: keyboard.c:36
UINT code
Definition: winuser.h:3162
LONG right
Definition: windef.h:308
LONG left
Definition: windef.h:306
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
UINT_PTR WPARAM
Definition: windef.h:207
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define COLOR_BTNTEXT
Definition: winuser.h:936
#define DWLP_USER
Definition: winuser.h:875
#define WM_HSCROLL
Definition: winuser.h:1746
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
BOOL WINAPI SetCaretBlinkTime(_In_ UINT)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define SPIF_SENDCHANGE
Definition: winuser.h:1575
#define SPI_SETKEYBOARDSPEED
Definition: winuser.h:1363
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1574
#define WM_TIMER
Definition: winuser.h:1745
#define SPI_GETKEYBOARDSPEED
Definition: winuser.h:1362
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5855
HDC WINAPI GetDC(_In_opt_ HWND)
#define PostMessage
Definition: winuser.h:5844
HWND WINAPI GetParent(_In_ HWND)
#define WM_DESTROY
Definition: winuser.h:1612
#define SPI_GETKEYBOARDDELAY
Definition: winuser.h:1374
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define SystemParametersInfo
Definition: winuser.h:5870
#define SendDlgItemMessage
Definition: winuser.h:5854
#define SPI_SETKEYBOARDDELAY
Definition: winuser.h:1375
UINT WINAPI GetCaretBlinkTime(void)
Definition: ntwrapper.h:166
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)

Referenced by KeyboardApplet().

◆ PropSheetProc()

static int CALLBACK PropSheetProc ( HWND  hwndDlg,
UINT  uMsg,
LPARAM  lParam 
)
static

Definition at line 340 of file keyboard.c.

341{
342 // NOTE: This callback is needed to set large icon correctly.
343 HICON hIcon;
344 switch (uMsg)
345 {
346 case PSCB_INITIALIZED:
347 {
349 SendMessageW(hwndDlg, WM_SETICON, ICON_BIG, (LPARAM)hIcon);
350 break;
351 }
352 }
353 return 0;
354}
static HICON
Definition: imagelist.c:80
HICON hIcon
Definition: msconfig.c:44
#define PSCB_INITIALIZED
Definition: prsht.h:75
#define ICON_BIG
Definition: tnclass.cpp:51
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
HICON WINAPI LoadIconW(_In_opt_ HINSTANCE hInstance, _In_ LPCWSTR lpIconName)
Definition: cursoricon.c:2127
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by KeyboardApplet().

◆ UpdateCaretBlinkTimeReg()

static VOID UpdateCaretBlinkTimeReg ( _In_ UINT  uCaretBlinkTime)
static

Definition at line 43 of file keyboard.c.

45{
46 HKEY hKey;
47 WCHAR szBuffer[12];
48
50 L"Control Panel\\Desktop",
53 {
54 return;
55 }
56
57 wsprintf(szBuffer, L"%d", uCaretBlinkTime);
58
59 RegSetValueExW(hKey, L"CursorBlinkRate",
60 0, REG_SZ,
61 (CONST BYTE*)szBuffer,
62 (wcslen(szBuffer) + 1) * sizeof(WCHAR));
63
65}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3333
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
FxAutoRegKey hKey
_CRTIMP size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define REG_SZ
Definition: layer.c:22
#define KEY_SET_VALUE
Definition: nt_native.h:1017
#define L(x)
Definition: ntvdm.h:50
#define CONST
Definition: pedump.c:81
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define wsprintf
Definition: winuser.h:5877
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by KeyboardSpeedProc().