Added a few authors.
[wine/multimedia.git] / windows / input.c
blobe38e90e77ea5030eb136a2cdb6585ccc8abbda88
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 "debug.h"
26 #include "debugtools.h"
27 #include "struct32.h"
28 #include "winerror.h"
29 #include "x11drv.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 * screenWidth) >> 16;
166 posY = (dy * screenHeight) >> 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 * screenWidth) >> 16;
181 posY = (dy * screenHeight) >> 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 LPACCEL32 lpAccelTbl = (LPACCEL32)LockResource32(hAccel);
607 int i;
609 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);
611 if (hAccel == 0 || msg == NULL ||
612 (msg->message != WM_KEYDOWN &&
613 msg->message != WM_KEYUP &&
614 msg->message != WM_SYSKEYDOWN &&
615 msg->message != WM_SYSKEYUP &&
616 msg->message != WM_CHAR)) {
617 WARN(accel, "erraneous input parameters\n");
618 SetLastError(ERROR_INVALID_PARAMETER);
619 return 0;
622 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,"
623 "msg->hwnd=%04x, msg->message=%04x\n",
624 hAccel,hWnd,msg->hwnd,msg->message);
626 i = 0;
629 if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
630 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
631 return 1;
632 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
633 WARN(accel, "couldn't translate accelerator key\n");
634 return 0;
637 /**********************************************************************
638 * TranslateAccelerator16 (USER.178)
640 INT16 WINAPI TranslateAccelerator16(HWND16 hWnd, HACCEL16 hAccel, LPMSG16 msg)
642 LPACCEL16 lpAccelTbl = (LPACCEL16)LockResource16(hAccel);
643 int i;
644 MSG32 msg32;
646 if (hAccel == 0 || msg == NULL ||
647 (msg->message != WM_KEYDOWN &&
648 msg->message != WM_KEYUP &&
649 msg->message != WM_SYSKEYDOWN &&
650 msg->message != WM_SYSKEYUP &&
651 msg->message != WM_CHAR)) {
652 WARN(accel, "erraneous input parameters\n");
653 SetLastError(ERROR_INVALID_PARAMETER);
654 return 0;
657 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
658 msg->hwnd=%04x, msg->message=%04x\n", hAccel,hWnd,msg->hwnd,msg->message);
659 STRUCT32_MSG16to32(msg,&msg32);
662 i = 0;
665 if (KBD_translate_accelerator(hWnd,&msg32,lpAccelTbl[i].fVirt,
666 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
667 return 1;
668 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
669 WARN(accel, "couldn't translate accelerator key\n");
670 return 0;
674 /**********************************************************************
675 * VkKeyScanA (USER32.573)
677 WORD WINAPI VkKeyScan32A(CHAR cChar)
679 return VkKeyScan16(cChar);
682 /******************************************************************************
683 * VkKeyScanW (USER32.576)
685 WORD WINAPI VkKeyScan32W(WCHAR cChar)
687 return VkKeyScan32A((CHAR)cChar); /* FIXME: check unicode */
690 /******************************************************************************
691 * GetKeyboardType32 (USER32.255)
693 INT32 WINAPI GetKeyboardType32(INT32 nTypeFlag)
695 return GetKeyboardType16(nTypeFlag);
698 /******************************************************************************
699 * MapVirtualKey32A (USER32.383)
701 UINT32 WINAPI MapVirtualKey32A(UINT32 code, UINT32 maptype)
703 return MapVirtualKey16(code,maptype);
706 /******************************************************************************
707 * MapVirtualKey32W (USER32.385)
709 UINT32 WINAPI MapVirtualKey32W(UINT32 code, UINT32 maptype)
711 return MapVirtualKey16(code,maptype);
714 /****************************************************************************
715 * GetKBCodePage32 (USER32.246)
717 UINT32 WINAPI GetKBCodePage32(void)
719 return GetKBCodePage16();
722 /****************************************************************************
723 * GetKeyboardLayoutName16 (USER.477)
725 INT16 WINAPI GetKeyboardLayoutName16(LPSTR pwszKLID)
727 return GetKeyboardLayoutName32A(pwszKLID);
730 /****************************************************************************
731 * GetKeyboardLayoutName32A (USER32.252)
733 INT32 WINAPI GetKeyboardLayoutName32A(LPSTR pwszKLID)
735 FIXME(keyboard,"always returns primary U.S. English layout\n");
736 strcpy(pwszKLID,"00000409");
737 return 1;
740 /****************************************************************************
741 * GetKeyboardLayoutName32W (USER32.253)
743 INT32 WINAPI GetKeyboardLayoutName32W(LPWSTR pwszKLID)
745 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
746 int res = GetKeyboardLayoutName32A(buf);
747 lstrcpyAtoW(pwszKLID,buf);
748 HeapFree( GetProcessHeap(), 0, buf );
749 return res;
752 /****************************************************************************
753 * GetKeyNameText32A (USER32.247)
755 INT32 WINAPI GetKeyNameText32A(LONG lParam, LPSTR lpBuffer, INT32 nSize)
757 return GetKeyNameText16(lParam,lpBuffer,nSize);
760 /****************************************************************************
761 * GetKeyNameText32W (USER32.248)
763 INT32 WINAPI GetKeyNameText32W(LONG lParam, LPWSTR lpBuffer, INT32 nSize)
765 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, nSize );
766 int res = GetKeyNameText32A(lParam,buf,nSize);
768 lstrcpynAtoW(lpBuffer,buf,nSize);
769 HeapFree( GetProcessHeap(), 0, buf );
770 return res;
773 /****************************************************************************
774 * ToAscii32 (USER32.546)
776 INT32 WINAPI ToAscii32( UINT32 virtKey,UINT32 scanCode,LPBYTE lpKeyState,
777 LPWORD lpChar,UINT32 flags )
779 return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags);
782 /***********************************************************************
783 * GetKeyboardLayout (USER32.250)
785 HKL32 WINAPI GetKeyboardLayout(DWORD dwLayout)
787 HKL32 layout;
788 FIXME(keyboard,"(%ld): stub\n",dwLayout);
789 layout = (0xcafe<<16)|GetSystemDefaultLCID(); /* FIXME */
790 TRACE(keyboard,"returning %x\n",layout);
791 return layout;
794 /***********************************************************************
795 * GetKeyboardLayoutList (USER32.251)
796 * FIXME
798 INT32 WINAPI GetKeyboardLayoutList(INT32 nBuff,HKL32 *layouts)
800 FIXME(keyboard,"(%d,%p): stub\n",nBuff,layouts);
801 if (layouts)
802 layouts[0] = GetKeyboardLayout(0);
803 return 1;
807 /***********************************************************************
808 * RegisterHotKey (USER32.433)
810 BOOL32 WINAPI RegisterHotKey(HWND32 hwnd,INT32 id,UINT32 modifiers,UINT32 vk) {
811 FIXME(keyboard,"(0x%08x,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk);
812 return TRUE;
815 /***********************************************************************
816 * UnregisterHotKey (USER32.565)
818 BOOL32 WINAPI UnregisterHotKey(HWND32 hwnd,INT32 id) {
819 FIXME(keyboard,"(0x%08x,%d): stub\n",hwnd,id);
820 return TRUE;