Implementation of the new monitor abstraction.
[wine.git] / windows / input.c
blobe09c7e078f2095352de5379648b05ca922e07d19
1 /*
2 * USER Input processing
4 * Copyright 1993 Bob Amstadt
5 * Copyright 1996 Albrecht Kleine
6 * Copyright 1997 David Faure
7 * Copyright 1998 Morten Welinder
8 * Copyright 1998 Ulrich Weigand
12 #include <stdlib.h>
13 #include <string.h>
14 #include <ctype.h>
15 #include <assert.h>
17 #include "windows.h"
18 #include "win.h"
19 #include "gdi.h"
20 #include "heap.h"
21 #include "input.h"
22 #include "keyboard.h"
23 #include "mouse.h"
24 #include "message.h"
25 #include "sysmetrics.h"
26 #include "debug.h"
27 #include "debugtools.h"
28 #include "struct32.h"
29 #include "winerror.h"
31 static INT16 captureHT = HTCLIENT;
32 static HWND32 captureWnd = 0;
33 static BOOL32 InputEnabled = TRUE;
34 static BOOL32 SwappedButtons = FALSE;
36 BOOL32 MouseButtonsStates[3];
37 BOOL32 AsyncMouseButtonsStates[3];
38 BYTE InputKeyStateTable[256];
39 BYTE QueueKeyStateTable[256];
40 BYTE AsyncKeyStateTable[256];
42 typedef union
44 struct
46 unsigned long count : 16;
47 unsigned long code : 8;
48 unsigned long extended : 1;
49 unsigned long unused : 2;
50 unsigned long win_internal : 2;
51 unsigned long context : 1;
52 unsigned long previous : 1;
53 unsigned long transition : 1;
54 } lp1;
55 unsigned long lp2;
56 } KEYLP;
58 /***********************************************************************
59 * keybd_event (USER32.583)
61 void WINAPI keybd_event( BYTE bVk, BYTE bScan,
62 DWORD dwFlags, DWORD dwExtraInfo )
64 DWORD posX, posY, time, extra;
65 WORD message;
66 KEYLP keylp;
67 keylp.lp2 = 0;
69 if (!InputEnabled) return;
72 * If we are called by the Wine keyboard driver, use the additional
73 * info pointed to by the dwExtraInfo argument.
74 * Otherwise, we need to determine that info ourselves (probably
75 * less accurate, but we can't help that ...).
77 if ( !IsBadReadPtr32( (LPVOID)dwExtraInfo, sizeof(WINE_KEYBDEVENT) )
78 && ((WINE_KEYBDEVENT *)dwExtraInfo)->magic == WINE_KEYBDEVENT_MAGIC )
80 WINE_KEYBDEVENT *wke = (WINE_KEYBDEVENT *)dwExtraInfo;
81 posX = wke->posX;
82 posY = wke->posY;
83 time = wke->time;
84 extra = 0;
86 else
88 DWORD keyState;
89 time = GetTickCount();
90 extra = dwExtraInfo;
92 if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
93 return;
97 keylp.lp1.count = 1;
98 keylp.lp1.code = bScan;
99 keylp.lp1.extended = (dwFlags & KEYEVENTF_EXTENDEDKEY) != 0;
100 keylp.lp1.win_internal = 0; /* this has something to do with dialogs,
101 * don't remember where I read it - AK */
102 /* it's '1' under windows, when a dialog box appears
103 * and you press one of the underlined keys - DF*/
105 if ( dwFlags & KEYEVENTF_KEYUP )
107 BOOL32 sysKey = (InputKeyStateTable[VK_MENU] & 0x80)
108 && !(InputKeyStateTable[VK_CONTROL] & 0x80)
109 && !(dwFlags & KEYEVENTF_WINE_FORCEEXTENDED); /* for Alt from AltGr */
111 InputKeyStateTable[bVk] &= ~0x80;
112 keylp.lp1.previous = 1;
113 keylp.lp1.transition = 1;
114 message = sysKey ? WM_SYSKEYUP : WM_KEYUP;
116 else
118 keylp.lp1.previous = (InputKeyStateTable[bVk] & 0x80) != 0;
119 keylp.lp1.transition = 0;
121 if (!(InputKeyStateTable[bVk] & 0x80))
122 InputKeyStateTable[bVk] ^= 0x01;
123 InputKeyStateTable[bVk] |= 0x80;
125 message = (InputKeyStateTable[VK_MENU] & 0x80)
126 && !(InputKeyStateTable[VK_CONTROL] & 0x80)
127 ? WM_SYSKEYDOWN : WM_KEYDOWN;
130 if ( message == WM_SYSKEYDOWN || message == WM_SYSKEYUP )
131 keylp.lp1.context = (InputKeyStateTable[VK_MENU] & 0x80) != 0; /* 1 if alt */
134 TRACE(key, " wParam=%04X, lParam=%08lX\n", bVk, keylp.lp2 );
135 TRACE(key, " InputKeyState=%X\n", InputKeyStateTable[bVk] );
137 hardware_event( message, bVk, keylp.lp2, posX, posY, time, extra );
140 /***********************************************************************
141 * mouse_event (USER32.584)
143 void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
144 DWORD cButtons, DWORD dwExtraInfo )
146 DWORD posX, posY, keyState, time, extra;
148 if (!InputEnabled) return;
151 * If we are called by the Wine mouse driver, use the additional
152 * info pointed to by the dwExtraInfo argument.
153 * Otherwise, we need to determine that info ourselves (probably
154 * less accurate, but we can't help that ...).
156 if ( !IsBadReadPtr32( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) )
157 && ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC )
159 WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo;
160 keyState = wme->keyState;
161 time = wme->time;
162 extra = (DWORD)wme->hWnd;
164 assert( dwFlags & MOUSEEVENTF_ABSOLUTE );
165 posX = (dx * SYSMETRICS_CXSCREEN) >> 16;
166 posY = (dy * SYSMETRICS_CYSCREEN) >> 16;
168 else
170 time = GetTickCount();
171 extra = dwExtraInfo;
173 if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
174 return;
176 if ( dwFlags & MOUSEEVENTF_MOVE )
178 if ( dwFlags & MOUSEEVENTF_ABSOLUTE )
180 posX = (dx * SYSMETRICS_CXSCREEN) >> 16;
181 posY = (dy * SYSMETRICS_CYSCREEN) >> 16;
183 else
185 posX += dx;
186 posY += dy;
188 /* We have to actually move the cursor */
189 SetCursorPos32( posX, posY );
193 if ( dwFlags & MOUSEEVENTF_MOVE )
195 hardware_event( WM_MOUSEMOVE,
196 keyState, 0L, posX, posY, time, extra );
198 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN) )
200 MouseButtonsStates[0] = AsyncMouseButtonsStates[0] = TRUE;
201 hardware_event( WM_LBUTTONDOWN,
202 keyState, 0L, posX, posY, time, extra );
204 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP) )
206 MouseButtonsStates[0] = FALSE;
207 hardware_event( WM_LBUTTONUP,
208 keyState, 0L, posX, posY, time, extra );
210 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN) )
212 MouseButtonsStates[2] = AsyncMouseButtonsStates[2] = TRUE;
213 hardware_event( WM_RBUTTONDOWN,
214 keyState, 0L, posX, posY, time, extra );
216 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP) )
218 MouseButtonsStates[2] = FALSE;
219 hardware_event( WM_RBUTTONUP,
220 keyState, 0L, posX, posY, time, extra );
222 if ( dwFlags & MOUSEEVENTF_MIDDLEDOWN )
224 MouseButtonsStates[1] = AsyncMouseButtonsStates[1] = TRUE;
225 hardware_event( WM_MBUTTONDOWN,
226 keyState, 0L, posX, posY, time, extra );
228 if ( dwFlags & MOUSEEVENTF_MIDDLEUP )
230 MouseButtonsStates[1] = FALSE;
231 hardware_event( WM_MBUTTONUP,
232 keyState, 0L, posX, posY, time, extra );
236 /**********************************************************************
237 * EnableHardwareInput (USER.331)
239 BOOL16 WINAPI EnableHardwareInput(BOOL16 bEnable)
241 BOOL16 bOldState = InputEnabled;
242 FIXME(event,"(%d) - stub\n", bEnable);
243 InputEnabled = bEnable;
244 return bOldState;
248 /***********************************************************************
249 * SwapMouseButton16 (USER.186)
251 BOOL16 WINAPI SwapMouseButton16( BOOL16 fSwap )
253 BOOL16 ret = SwappedButtons;
254 SwappedButtons = fSwap;
255 return ret;
259 /***********************************************************************
260 * SwapMouseButton32 (USER32.537)
262 BOOL32 WINAPI SwapMouseButton32( BOOL32 fSwap )
264 BOOL32 ret = SwappedButtons;
265 SwappedButtons = fSwap;
266 return ret;
269 /**********************************************************************
270 * EVENT_Capture
272 * We need this to be able to generate double click messages
273 * when menu code captures mouse in the window without CS_DBLCLK style.
275 HWND32 EVENT_Capture(HWND32 hwnd, INT16 ht)
277 HWND32 capturePrev = captureWnd;
279 if (!hwnd)
281 captureWnd = 0L;
282 captureHT = 0;
284 else
286 WND* wndPtr = WIN_FindWndPtr( hwnd );
287 if (wndPtr)
289 TRACE(win, "(0x%04x)\n", hwnd );
290 captureWnd = hwnd;
291 captureHT = ht;
295 if( capturePrev && capturePrev != captureWnd )
297 WND* wndPtr = WIN_FindWndPtr( capturePrev );
298 if( wndPtr && (wndPtr->flags & WIN_ISWIN32) )
299 SendMessage32A( capturePrev, WM_CAPTURECHANGED, 0L, hwnd);
301 return capturePrev;
304 /**********************************************************************
305 * EVENT_GetCaptureInfo
307 INT16 EVENT_GetCaptureInfo()
309 return captureHT;
312 /**********************************************************************
313 * SetCapture16 (USER.18)
315 HWND16 WINAPI SetCapture16( HWND16 hwnd )
317 return (HWND16)EVENT_Capture( hwnd, HTCLIENT );
321 /**********************************************************************
322 * SetCapture32 (USER32.464)
324 HWND32 WINAPI SetCapture32( HWND32 hwnd )
326 return EVENT_Capture( hwnd, HTCLIENT );
330 /**********************************************************************
331 * ReleaseCapture (USER.19) (USER32.439)
333 void WINAPI ReleaseCapture(void)
335 TRACE(win, "captureWnd=%04x\n", captureWnd );
336 if( captureWnd ) EVENT_Capture( 0, 0 );
340 /**********************************************************************
341 * GetCapture16 (USER.236)
343 HWND16 WINAPI GetCapture16(void)
345 return captureWnd;
348 /**********************************************************************
349 * GetCapture32 (USER32.208)
351 HWND32 WINAPI GetCapture32(void)
353 return captureWnd;
356 /**********************************************************************
357 * GetKeyState (USER.106)
359 INT16 WINAPI GetKeyState16(INT16 vkey)
361 return GetKeyState32(vkey);
364 /**********************************************************************
365 * GetKeyState (USER32.249)
367 * An application calls the GetKeyState function in response to a
368 * keyboard-input message. This function retrieves the state of the key
369 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
371 INT16 WINAPI GetKeyState32(INT32 vkey)
373 INT32 retval;
375 switch (vkey)
377 case VK_LBUTTON : /* VK_LBUTTON is 1 */
378 retval = MouseButtonsStates[0] ? 0x8000 : 0;
379 break;
380 case VK_MBUTTON : /* VK_MBUTTON is 4 */
381 retval = MouseButtonsStates[1] ? 0x8000 : 0;
382 break;
383 case VK_RBUTTON : /* VK_RBUTTON is 2 */
384 retval = MouseButtonsStates[2] ? 0x8000 : 0;
385 break;
386 default :
387 if (vkey >= 'a' && vkey <= 'z')
388 vkey += 'A' - 'a';
389 retval = ( (WORD)(QueueKeyStateTable[vkey] & 0x80) << 8 ) |
390 (WORD)(QueueKeyStateTable[vkey] & 0x01);
392 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
393 return retval;
396 /**********************************************************************
397 * GetKeyboardState (USER.222)(USER32.254)
399 * An application calls the GetKeyboardState function in response to a
400 * keyboard-input message. This function retrieves the state of the keyboard
401 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
403 VOID WINAPI GetKeyboardState(LPBYTE lpKeyState)
405 TRACE(key, "(%p)\n", lpKeyState);
406 if (lpKeyState != NULL) {
407 QueueKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
408 QueueKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
409 QueueKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
410 memcpy(lpKeyState, QueueKeyStateTable, 256);
414 /**********************************************************************
415 * SetKeyboardState (USER.223)(USER32.484)
417 VOID WINAPI SetKeyboardState(LPBYTE lpKeyState)
419 TRACE(key, "(%p)\n", lpKeyState);
420 if (lpKeyState != NULL) {
421 memcpy(QueueKeyStateTable, lpKeyState, 256);
422 MouseButtonsStates[0] = (QueueKeyStateTable[VK_LBUTTON] != 0);
423 MouseButtonsStates[1] = (QueueKeyStateTable[VK_MBUTTON] != 0);
424 MouseButtonsStates[2] = (QueueKeyStateTable[VK_RBUTTON] != 0);
428 /**********************************************************************
429 * GetAsyncKeyState32 (USER32.207)
431 * Determine if a key is or was pressed. retval has high-order
432 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
433 * been pressed.
435 * This uses the variable AsyncMouseButtonsStates and
436 * AsyncKeyStateTable (set in event.c) which have the mouse button
437 * number or key number (whichever is applicable) set to true if the
438 * mouse or key had been depressed since the last call to
439 * GetAsyncKeyState.
441 WORD WINAPI GetAsyncKeyState32(INT32 nKey)
443 short retval;
445 switch (nKey) {
446 case VK_LBUTTON:
447 retval = (AsyncMouseButtonsStates[0] ? 0x0001 : 0) |
448 (MouseButtonsStates[0] ? 0x8000 : 0);
449 break;
450 case VK_MBUTTON:
451 retval = (AsyncMouseButtonsStates[1] ? 0x0001 : 0) |
452 (MouseButtonsStates[1] ? 0x8000 : 0);
453 break;
454 case VK_RBUTTON:
455 retval = (AsyncMouseButtonsStates[2] ? 0x0001 : 0) |
456 (MouseButtonsStates[2] ? 0x8000 : 0);
457 break;
458 default:
459 retval = AsyncKeyStateTable[nKey] |
460 ((InputKeyStateTable[nKey] & 0x80) ? 0x8000 : 0);
461 break;
464 /* all states to false */
465 memset( AsyncMouseButtonsStates, 0, sizeof(AsyncMouseButtonsStates) );
466 memset( AsyncKeyStateTable, 0, sizeof(AsyncKeyStateTable) );
468 TRACE(key, "(%x) -> %x\n", nKey, retval);
469 return retval;
472 /**********************************************************************
473 * GetAsyncKeyState16 (USER.249)
475 WORD WINAPI GetAsyncKeyState16(INT16 nKey)
477 return GetAsyncKeyState32(nKey);
480 /**********************************************************************
481 * KBD_translate_accelerator
483 * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
485 static BOOL32 KBD_translate_accelerator(HWND32 hWnd,LPMSG32 msg,
486 BYTE fVirt,WORD key,WORD cmd)
488 BOOL32 sendmsg = FALSE;
490 if(msg->wParam == key)
492 if (msg->message == WM_CHAR) {
493 if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) )
495 TRACE(accel,"found accel for WM_CHAR: ('%c')\n",
496 msg->wParam&0xff);
497 sendmsg=TRUE;
499 } else {
500 if(fVirt & FVIRTKEY) {
501 INT32 mask = 0;
502 TRACE(accel,"found accel for virt_key %04x (scan %04x)\n",
503 msg->wParam,0xff & HIWORD(msg->lParam));
504 if(GetKeyState32(VK_SHIFT) & 0x8000) mask |= FSHIFT;
505 if(GetKeyState32(VK_CONTROL) & 0x8000) mask |= FCONTROL;
506 if(GetKeyState32(VK_MENU) & 0x8000) mask |= FALT;
507 if(mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
508 sendmsg=TRUE;
509 else
510 TRACE(accel,", but incorrect SHIFT/CTRL/ALT-state\n");
512 else
514 if (!(msg->lParam & 0x01000000)) /* no special_key */
516 if ((fVirt & FALT) && (msg->lParam & 0x20000000))
517 { /* ^^ ALT pressed */
518 TRACE(accel,"found accel for Alt-%c\n", msg->wParam&0xff);
519 sendmsg=TRUE;
525 if (sendmsg) /* found an accelerator, but send a message... ? */
527 INT16 iSysStat,iStat,mesg=0;
528 HMENU16 hMenu;
530 if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP)
531 mesg=1;
532 else
533 if (GetCapture32())
534 mesg=2;
535 else
536 if (!IsWindowEnabled32(hWnd))
537 mesg=3;
538 else
540 WND* wndPtr = WIN_FindWndPtr(hWnd);
542 hMenu = (wndPtr->dwStyle & WS_CHILD) ? 0 : (HMENU32)wndPtr->wIDmenu;
543 iSysStat = (wndPtr->hSysMenu) ? GetMenuState32(GetSubMenu16(wndPtr->hSysMenu, 0),
544 cmd, MF_BYCOMMAND) : -1 ;
545 iStat = (hMenu) ? GetMenuState32(hMenu,
546 cmd, MF_BYCOMMAND) : -1 ;
548 if (iSysStat!=-1)
550 if (iSysStat & (MF_DISABLED|MF_GRAYED))
551 mesg=4;
552 else
553 mesg=WM_SYSCOMMAND;
555 else
557 if (iStat!=-1)
559 if (IsIconic32(hWnd))
560 mesg=5;
561 else
563 if (iStat & (MF_DISABLED|MF_GRAYED))
564 mesg=6;
565 else
566 mesg=WM_COMMAND;
569 else
570 mesg=WM_COMMAND;
573 if ( mesg==WM_COMMAND || mesg==WM_SYSCOMMAND )
575 TRACE(accel,", sending %s, wParam=%0x\n",
576 mesg==WM_COMMAND ? "WM_COMMAND" : "WM_SYSCOMMAND",
577 cmd);
578 SendMessage32A(hWnd, mesg, cmd, 0x00010000L);
580 else
582 /* some reasons for NOT sending the WM_{SYS}COMMAND message:
583 * #0: unknown (please report!)
584 * #1: for WM_KEYUP,WM_SYSKEYUP
585 * #2: mouse is captured
586 * #3: window is disabled
587 * #4: it's a disabled system menu option
588 * #5: it's a menu option, but window is iconic
589 * #6: it's a menu option, but disabled
591 TRACE(accel,", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg);
592 if(mesg==0)
593 ERR(accel, " unknown reason - please report!");
595 return TRUE;
598 return FALSE;
601 /**********************************************************************
602 * TranslateAccelerator32 (USER32.551)(USER32.552)(USER32.553)
604 INT32 WINAPI TranslateAccelerator32(HWND32 hWnd, HACCEL32 hAccel, LPMSG32 msg)
606 /* YES, Accel16! */
607 LPACCEL16 lpAccelTbl = (LPACCEL16)LockResource16(hAccel);
608 int i;
610 TRACE(accel,"hwnd=0x%x hacc=0x%x msg=0x%x wp=0x%x lp=0x%lx\n", hWnd, hAccel, msg->message, msg->wParam, msg->lParam);
612 if (hAccel == 0 || msg == NULL ||
613 (msg->message != WM_KEYDOWN &&
614 msg->message != WM_KEYUP &&
615 msg->message != WM_SYSKEYDOWN &&
616 msg->message != WM_SYSKEYUP &&
617 msg->message != WM_CHAR)) {
618 WARN(accel, "erraneous input parameters\n");
619 SetLastError(ERROR_INVALID_PARAMETER);
620 return 0;
623 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,"
624 "msg->hwnd=%04x, msg->message=%04x\n",
625 hAccel,hWnd,msg->hwnd,msg->message);
627 i = 0;
630 if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
631 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
632 return 1;
633 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
634 WARN(accel, "couldn't translate accelerator key\n");
635 return 0;
638 /**********************************************************************
639 * TranslateAccelerator16 (USER.178)
641 INT16 WINAPI TranslateAccelerator16(HWND16 hWnd, HACCEL16 hAccel, LPMSG16 msg)
643 LPACCEL16 lpAccelTbl = (LPACCEL16)LockResource16(hAccel);
644 int i;
645 MSG32 msg32;
647 if (hAccel == 0 || msg == NULL ||
648 (msg->message != WM_KEYDOWN &&
649 msg->message != WM_KEYUP &&
650 msg->message != WM_SYSKEYDOWN &&
651 msg->message != WM_SYSKEYUP &&
652 msg->message != WM_CHAR)) {
653 WARN(accel, "erraneous input parameters\n");
654 SetLastError(ERROR_INVALID_PARAMETER);
655 return 0;
658 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
659 msg->hwnd=%04x, msg->message=%04x\n", hAccel,hWnd,msg->hwnd,msg->message);
660 STRUCT32_MSG16to32(msg,&msg32);
663 i = 0;
666 if (KBD_translate_accelerator(hWnd,&msg32,lpAccelTbl[i].fVirt,
667 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
668 return 1;
669 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
670 WARN(accel, "couldn't translate accelerator key\n");
671 return 0;
675 /**********************************************************************
676 * VkKeyScanA (USER32.573)
678 WORD WINAPI VkKeyScan32A(CHAR cChar)
680 return VkKeyScan16(cChar);
683 /******************************************************************************
684 * VkKeyScanW (USER32.576)
686 WORD WINAPI VkKeyScan32W(WCHAR cChar)
688 return VkKeyScan32A((CHAR)cChar); /* FIXME: check unicode */
691 /******************************************************************************
692 * GetKeyboardType32 (USER32.255)
694 INT32 WINAPI GetKeyboardType32(INT32 nTypeFlag)
696 return GetKeyboardType16(nTypeFlag);
699 /******************************************************************************
700 * MapVirtualKey32A (USER32.383)
702 UINT32 WINAPI MapVirtualKey32A(UINT32 code, UINT32 maptype)
704 return MapVirtualKey16(code,maptype);
707 /******************************************************************************
708 * MapVirtualKey32W (USER32.385)
710 UINT32 WINAPI MapVirtualKey32W(UINT32 code, UINT32 maptype)
712 return MapVirtualKey16(code,maptype);
715 /****************************************************************************
716 * GetKBCodePage32 (USER32.246)
718 UINT32 WINAPI GetKBCodePage32(void)
720 return GetKBCodePage16();
723 /****************************************************************************
724 * GetKeyboardLayoutName16 (USER.477)
726 INT16 WINAPI GetKeyboardLayoutName16(LPSTR pwszKLID)
728 return GetKeyboardLayoutName32A(pwszKLID);
731 /****************************************************************************
732 * GetKeyboardLayoutName32A (USER32.252)
734 INT32 WINAPI GetKeyboardLayoutName32A(LPSTR pwszKLID)
736 FIXME(keyboard,"always returns primary U.S. English layout\n");
737 strcpy(pwszKLID,"00000409");
738 return 1;
741 /****************************************************************************
742 * GetKeyboardLayoutName32W (USER32.253)
744 INT32 WINAPI GetKeyboardLayoutName32W(LPWSTR pwszKLID)
746 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
747 int res = GetKeyboardLayoutName32A(buf);
748 lstrcpyAtoW(pwszKLID,buf);
749 HeapFree( GetProcessHeap(), 0, buf );
750 return res;
753 /****************************************************************************
754 * GetKeyNameText32A (USER32.247)
756 INT32 WINAPI GetKeyNameText32A(LONG lParam, LPSTR lpBuffer, INT32 nSize)
758 return GetKeyNameText16(lParam,lpBuffer,nSize);
761 /****************************************************************************
762 * GetKeyNameText32W (USER32.248)
764 INT32 WINAPI GetKeyNameText32W(LONG lParam, LPWSTR lpBuffer, INT32 nSize)
766 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, nSize );
767 int res = GetKeyNameText32A(lParam,buf,nSize);
769 lstrcpynAtoW(lpBuffer,buf,nSize);
770 HeapFree( GetProcessHeap(), 0, buf );
771 return res;
774 /****************************************************************************
775 * ToAscii32 (USER32.546)
777 INT32 WINAPI ToAscii32( UINT32 virtKey,UINT32 scanCode,LPBYTE lpKeyState,
778 LPWORD lpChar,UINT32 flags )
780 return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags);
783 /***********************************************************************
784 * GetKeyboardLayout (USER32.250)
786 HKL32 WINAPI GetKeyboardLayout(DWORD dwLayout)
788 HKL32 layout;
789 FIXME(keyboard,"(%ld): stub\n",dwLayout);
790 layout = (0xcafe<<16)|GetSystemDefaultLCID(); /* FIXME */
791 TRACE(keyboard,"returning %x\n",layout);
792 return layout;
795 /**********************************************************************
796 * ActivateKeyboardLayout32 (USER32.1)
798 HKL32 WINAPI ActivateKeyboardLayout32(HKL32 hLayout, UINT32 flags)
800 FIXME(keyboard, "(%d, %d): stub\n", hLayout, flags);
802 return 0;
806 /***********************************************************************
807 * GetKeyboardLayoutList (USER32.251)
808 * FIXME
810 INT32 WINAPI GetKeyboardLayoutList(INT32 nBuff,HKL32 *layouts)
812 FIXME(keyboard,"(%d,%p): stub\n",nBuff,layouts);
813 if (layouts)
814 layouts[0] = GetKeyboardLayout(0);
815 return 1;
819 /***********************************************************************
820 * RegisterHotKey (USER32.433)
822 BOOL32 WINAPI RegisterHotKey(HWND32 hwnd,INT32 id,UINT32 modifiers,UINT32 vk) {
823 FIXME(keyboard,"(0x%08x,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk);
824 return TRUE;
827 /***********************************************************************
828 * UnregisterHotKey (USER32.565)
830 BOOL32 WINAPI UnregisterHotKey(HWND32 hwnd,INT32 id) {
831 FIXME(keyboard,"(0x%08x,%d): stub\n",hwnd,id);
832 return TRUE;
836 /***********************************************************************
837 * ToUnicode32 (USER32.548)
839 INT32 WINAPI ToUnicode32(
840 UINT32 wVirtKey,
841 UINT32 wScanCode,
842 PBYTE lpKeyState,
843 LPWSTR pwszBuff,
844 int cchBuff,
845 UINT32 wFlags) {
847 FIXME(keyboard,": stub\n");
848 return 0;
851 /***********************************************************************
852 * LoadKeyboardLayout32A (USER32.367)
854 HKL32 WINAPI LoadKeyboardLayout32A(LPCSTR pwszKLID, UINT32 Flags)
856 FIXME(keyboard, "%s, %d): stub\n", pwszKLID, Flags);
857 return 0;
860 /***********************************************************************
861 * LoadKeyboardLayout32W (USER32.368)
863 HKL32 WINAPI LoadKeyboardLayout32W(LPCWSTR pwszKLID, UINT32 Flags)
865 FIXME(keyboard, "%p, %d): stub\n", pwszKLID, Flags);
866 return 0;