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
18 #include "wine/winbase16.h"
19 #include "wine/winuser16.h"
20 #include "wine/keyboard16.h"
27 #include "sysmetrics.h"
29 #include "debugtools.h"
34 static BOOL InputEnabled = TRUE;
35 static BOOL SwappedButtons = FALSE;
37 BOOL MouseButtonsStates[3];
38 BOOL AsyncMouseButtonsStates[3];
39 BYTE InputKeyStateTable[256];
40 BYTE QueueKeyStateTable[256];
41 BYTE AsyncKeyStateTable[256];
47 unsigned long count : 16;
48 unsigned long code : 8;
49 unsigned long extended : 1;
50 unsigned long unused : 2;
51 unsigned long win_internal : 2;
52 unsigned long context : 1;
53 unsigned long previous : 1;
54 unsigned long transition : 1;
59 /***********************************************************************
60 * keybd_event (USER32.583)
62 void WINAPI keybd_event( BYTE bVk, BYTE bScan,
63 DWORD dwFlags, DWORD dwExtraInfo )
65 DWORD posX, posY, time, extra;
70 if (!InputEnabled) return;
73 * If we are called by the Wine keyboard driver, use the additional
74 * info pointed to by the dwExtraInfo argument.
75 * Otherwise, we need to determine that info ourselves (probably
76 * less accurate, but we can't help that ...).
78 if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_KEYBDEVENT) )
79 && ((WINE_KEYBDEVENT *)dwExtraInfo)->magic == WINE_KEYBDEVENT_MAGIC )
81 WINE_KEYBDEVENT *wke = (WINE_KEYBDEVENT *)dwExtraInfo;
90 time = GetTickCount();
93 if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
99 keylp.lp1.code = bScan;
100 keylp.lp1.extended = (dwFlags & KEYEVENTF_EXTENDEDKEY) != 0;
101 keylp.lp1.win_internal = 0; /* this has something to do with dialogs,
102 * don't remember where I read it - AK */
103 /* it's '1' under windows, when a dialog box appears
104 * and you press one of the underlined keys - DF*/
106 if ( dwFlags & KEYEVENTF_KEYUP )
108 BOOL sysKey = (InputKeyStateTable[VK_MENU] & 0x80)
109 && !(InputKeyStateTable[VK_CONTROL] & 0x80)
110 && !(dwFlags & KEYEVENTF_WINE_FORCEEXTENDED); /* for Alt from AltGr */
112 InputKeyStateTable[bVk] &= ~0x80;
113 keylp.lp1.previous = 1;
114 keylp.lp1.transition = 1;
115 message = sysKey ? WM_SYSKEYUP : WM_KEYUP;
119 keylp.lp1.previous = (InputKeyStateTable[bVk] & 0x80) != 0;
120 keylp.lp1.transition = 0;
122 if (!(InputKeyStateTable[bVk] & 0x80))
123 InputKeyStateTable[bVk] ^= 0x01;
124 InputKeyStateTable[bVk] |= 0x80;
126 message = (InputKeyStateTable[VK_MENU] & 0x80)
127 && !(InputKeyStateTable[VK_CONTROL] & 0x80)
128 ? WM_SYSKEYDOWN : WM_KEYDOWN;
131 if ( message == WM_SYSKEYDOWN || message == WM_SYSKEYUP )
132 keylp.lp1.context = (InputKeyStateTable[VK_MENU] & 0x80) != 0; /* 1 if alt */
135 TRACE(key, " wParam=%04X, lParam=%08lX\n", bVk, keylp.lp2 );
136 TRACE(key, " InputKeyState=%X\n", InputKeyStateTable[bVk] );
138 hardware_event( message, bVk, keylp.lp2, posX, posY, time, extra );
141 /***********************************************************************
142 * mouse_event (USER32.584)
144 void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
145 DWORD cButtons, DWORD dwExtraInfo )
147 DWORD posX, posY, keyState, time, extra;
149 if (!InputEnabled) return;
152 * If we are called by the Wine mouse driver, use the additional
153 * info pointed to by the dwExtraInfo argument.
154 * Otherwise, we need to determine that info ourselves (probably
155 * less accurate, but we can't help that ...).
157 if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) )
158 && ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC )
160 WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo;
161 keyState = wme->keyState;
163 extra = (DWORD)wme->hWnd;
165 assert( dwFlags & MOUSEEVENTF_ABSOLUTE );
166 posX = (dx * SYSMETRICS_CXSCREEN) >> 16;
167 posY = (dy * SYSMETRICS_CYSCREEN) >> 16;
171 time = GetTickCount();
174 if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
177 if ( dwFlags & MOUSEEVENTF_MOVE )
179 if ( dwFlags & MOUSEEVENTF_ABSOLUTE )
181 posX = (dx * SYSMETRICS_CXSCREEN) >> 16;
182 posY = (dy * SYSMETRICS_CYSCREEN) >> 16;
189 /* We have to actually move the cursor */
190 SetCursorPos( posX, posY );
194 if ( dwFlags & MOUSEEVENTF_MOVE )
196 hardware_event( WM_MOUSEMOVE,
197 keyState, 0L, posX, posY, time, extra );
199 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN) )
201 MouseButtonsStates[0] = AsyncMouseButtonsStates[0] = TRUE;
202 hardware_event( WM_LBUTTONDOWN,
203 keyState, 0L, posX, posY, time, extra );
205 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP) )
207 MouseButtonsStates[0] = FALSE;
208 hardware_event( WM_LBUTTONUP,
209 keyState, 0L, posX, posY, time, extra );
211 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN) )
213 MouseButtonsStates[2] = AsyncMouseButtonsStates[2] = TRUE;
214 hardware_event( WM_RBUTTONDOWN,
215 keyState, 0L, posX, posY, time, extra );
217 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP) )
219 MouseButtonsStates[2] = FALSE;
220 hardware_event( WM_RBUTTONUP,
221 keyState, 0L, posX, posY, time, extra );
223 if ( dwFlags & MOUSEEVENTF_MIDDLEDOWN )
225 MouseButtonsStates[1] = AsyncMouseButtonsStates[1] = TRUE;
226 hardware_event( WM_MBUTTONDOWN,
227 keyState, 0L, posX, posY, time, extra );
229 if ( dwFlags & MOUSEEVENTF_MIDDLEUP )
231 MouseButtonsStates[1] = FALSE;
232 hardware_event( WM_MBUTTONUP,
233 keyState, 0L, posX, posY, time, extra );
237 /**********************************************************************
238 * EnableHardwareInput (USER.331)
240 BOOL16 WINAPI EnableHardwareInput16(BOOL16 bEnable)
242 BOOL16 bOldState = InputEnabled;
243 FIXME(event,"(%d) - stub\n", bEnable);
244 InputEnabled = bEnable;
249 /***********************************************************************
250 * SwapMouseButton16 (USER.186)
252 BOOL16 WINAPI SwapMouseButton16( BOOL16 fSwap )
254 BOOL16 ret = SwappedButtons;
255 SwappedButtons = fSwap;
260 /***********************************************************************
261 * SwapMouseButton32 (USER32.537)
263 BOOL WINAPI SwapMouseButton( BOOL fSwap )
265 BOOL ret = SwappedButtons;
266 SwappedButtons = fSwap;
270 /**********************************************************************
273 * We need this to be able to generate double click messages
274 * when menu code captures mouse in the window without CS_DBLCLK style.
276 HWND EVENT_Capture(HWND hwnd, INT16 ht)
278 HWND capturePrev = 0, captureWnd = 0;
279 MESSAGEQUEUE *pMsgQ = 0, *pCurMsgQ = 0;
283 /* Get the messageQ for the current thread */
284 if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
286 WARN( win, "\tCurrent message queue not found. Exiting!\n" );
290 /* Get the current capture window from the perQ data of the current message Q */
291 capturePrev = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData );
300 wndPtr = WIN_FindWndPtr( hwnd );
303 TRACE(win, "(0x%04x)\n", hwnd );
309 /* Update the perQ capture window and send messages */
310 if( capturePrev != captureWnd )
314 /* Retrieve the message queue associated with this window */
315 pMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( wndPtr->hmemTaskQ );
318 WARN( win, "\tMessage queue not found. Exiting!\n" );
322 /* Make sure that message queue for the window we are setting capture to
323 * shares the same perQ data as the current threads message queue.
325 if ( pCurMsgQ->pQData != pMsgQ->pQData )
329 PERQDATA_SetCaptureWnd( pCurMsgQ->pQData, captureWnd );
330 PERQDATA_SetCaptureInfo( pCurMsgQ->pQData, captureHT );
334 WND* wndPtr = WIN_FindWndPtr( capturePrev );
335 if( wndPtr && (wndPtr->flags & WIN_ISWIN32) )
336 SendMessageA( capturePrev, WM_CAPTURECHANGED, 0L, hwnd);
337 WIN_ReleaseWndPtr(wndPtr);
342 /* Unlock the queues before returning */
344 QUEUE_Unlock( pMsgQ );
346 QUEUE_Unlock( pCurMsgQ );
348 WIN_ReleaseWndPtr(wndPtr);
353 /**********************************************************************
354 * SetCapture16 (USER.18)
356 HWND16 WINAPI SetCapture16( HWND16 hwnd )
358 return (HWND16)EVENT_Capture( hwnd, HTCLIENT );
362 /**********************************************************************
363 * SetCapture32 (USER32.464)
365 HWND WINAPI SetCapture( HWND hwnd )
367 return EVENT_Capture( hwnd, HTCLIENT );
371 /**********************************************************************
372 * ReleaseCapture (USER.19) (USER32.439)
374 void WINAPI ReleaseCapture(void)
376 EVENT_Capture( 0, 0 );
380 /**********************************************************************
381 * GetCapture16 (USER.236)
383 HWND16 WINAPI GetCapture16(void)
385 return (HWND16)GetCapture();
388 /**********************************************************************
389 * GetCapture32 (USER32.208)
391 HWND WINAPI GetCapture(void)
393 MESSAGEQUEUE *pCurMsgQ = 0;
394 HWND hwndCapture = 0;
396 /* Get the messageQ for the current thread */
397 if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
399 TRACE( win, "GetCapture32: Current message queue not found. Exiting!\n" );
403 /* Get the current capture window from the perQ data of the current message Q */
404 hwndCapture = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData );
406 QUEUE_Unlock( pCurMsgQ );
410 /**********************************************************************
411 * GetKeyState (USER.106)
413 INT16 WINAPI GetKeyState16(INT16 vkey)
415 return GetKeyState(vkey);
418 /**********************************************************************
419 * GetKeyState (USER32.249)
421 * An application calls the GetKeyState function in response to a
422 * keyboard-input message. This function retrieves the state of the key
423 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
425 INT16 WINAPI GetKeyState(INT vkey)
431 case VK_LBUTTON : /* VK_LBUTTON is 1 */
432 retval = MouseButtonsStates[0] ? 0x8000 : 0;
434 case VK_MBUTTON : /* VK_MBUTTON is 4 */
435 retval = MouseButtonsStates[1] ? 0x8000 : 0;
437 case VK_RBUTTON : /* VK_RBUTTON is 2 */
438 retval = MouseButtonsStates[2] ? 0x8000 : 0;
441 if (vkey >= 'a' && vkey <= 'z')
443 retval = ( (WORD)(QueueKeyStateTable[vkey] & 0x80) << 8 ) |
444 (WORD)(QueueKeyStateTable[vkey] & 0x01);
446 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
450 /**********************************************************************
451 * GetKeyboardState (USER.222)(USER32.254)
453 * An application calls the GetKeyboardState function in response to a
454 * keyboard-input message. This function retrieves the state of the keyboard
455 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
457 VOID WINAPI GetKeyboardState(LPBYTE lpKeyState)
459 TRACE(key, "(%p)\n", lpKeyState);
460 if (lpKeyState != NULL) {
461 QueueKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
462 QueueKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
463 QueueKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
464 memcpy(lpKeyState, QueueKeyStateTable, 256);
468 /**********************************************************************
469 * SetKeyboardState (USER.223)(USER32.484)
471 VOID WINAPI SetKeyboardState(LPBYTE lpKeyState)
473 TRACE(key, "(%p)\n", lpKeyState);
474 if (lpKeyState != NULL) {
475 memcpy(QueueKeyStateTable, lpKeyState, 256);
476 MouseButtonsStates[0] = (QueueKeyStateTable[VK_LBUTTON] != 0);
477 MouseButtonsStates[1] = (QueueKeyStateTable[VK_MBUTTON] != 0);
478 MouseButtonsStates[2] = (QueueKeyStateTable[VK_RBUTTON] != 0);
482 /**********************************************************************
483 * GetAsyncKeyState32 (USER32.207)
485 * Determine if a key is or was pressed. retval has high-order
486 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
489 * This uses the variable AsyncMouseButtonsStates and
490 * AsyncKeyStateTable (set in event.c) which have the mouse button
491 * number or key number (whichever is applicable) set to true if the
492 * mouse or key had been depressed since the last call to
495 WORD WINAPI GetAsyncKeyState(INT nKey)
501 retval = (AsyncMouseButtonsStates[0] ? 0x0001 : 0) |
502 (MouseButtonsStates[0] ? 0x8000 : 0);
505 retval = (AsyncMouseButtonsStates[1] ? 0x0001 : 0) |
506 (MouseButtonsStates[1] ? 0x8000 : 0);
509 retval = (AsyncMouseButtonsStates[2] ? 0x0001 : 0) |
510 (MouseButtonsStates[2] ? 0x8000 : 0);
513 retval = AsyncKeyStateTable[nKey] |
514 ((InputKeyStateTable[nKey] & 0x80) ? 0x8000 : 0);
518 /* all states to false */
519 memset( AsyncMouseButtonsStates, 0, sizeof(AsyncMouseButtonsStates) );
520 memset( AsyncKeyStateTable, 0, sizeof(AsyncKeyStateTable) );
522 TRACE(key, "(%x) -> %x\n", nKey, retval);
526 /**********************************************************************
527 * GetAsyncKeyState16 (USER.249)
529 WORD WINAPI GetAsyncKeyState16(INT16 nKey)
531 return GetAsyncKeyState(nKey);
534 /**********************************************************************
535 * KBD_translate_accelerator
537 * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
539 static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg,
540 BYTE fVirt,WORD key,WORD cmd)
542 BOOL sendmsg = FALSE;
544 if(msg->wParam == key)
546 if (msg->message == WM_CHAR) {
547 if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) )
549 TRACE(accel,"found accel for WM_CHAR: ('%c')\n",
554 if(fVirt & FVIRTKEY) {
556 TRACE(accel,"found accel for virt_key %04x (scan %04x)\n",
557 msg->wParam,0xff & HIWORD(msg->lParam));
558 if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
559 if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
560 if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
561 if(mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
564 TRACE(accel,", but incorrect SHIFT/CTRL/ALT-state\n");
568 if (!(msg->lParam & 0x01000000)) /* no special_key */
570 if ((fVirt & FALT) && (msg->lParam & 0x20000000))
571 { /* ^^ ALT pressed */
572 TRACE(accel,"found accel for Alt-%c\n", msg->wParam&0xff);
579 if (sendmsg) /* found an accelerator, but send a message... ? */
581 INT16 iSysStat,iStat,mesg=0;
584 if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP)
590 if (!IsWindowEnabled(hWnd))
594 WND* wndPtr = WIN_FindWndPtr(hWnd);
596 hMenu = (wndPtr->dwStyle & WS_CHILD) ? 0 : (HMENU)wndPtr->wIDmenu;
597 iSysStat = (wndPtr->hSysMenu) ? GetMenuState(GetSubMenu16(wndPtr->hSysMenu, 0),
598 cmd, MF_BYCOMMAND) : -1 ;
599 iStat = (hMenu) ? GetMenuState(hMenu,
600 cmd, MF_BYCOMMAND) : -1 ;
602 WIN_ReleaseWndPtr(wndPtr);
606 if (iSysStat & (MF_DISABLED|MF_GRAYED))
619 if (iStat & (MF_DISABLED|MF_GRAYED))
629 if ( mesg==WM_COMMAND || mesg==WM_SYSCOMMAND )
631 TRACE(accel,", sending %s, wParam=%0x\n",
632 mesg==WM_COMMAND ? "WM_COMMAND" : "WM_SYSCOMMAND",
634 SendMessageA(hWnd, mesg, cmd, 0x00010000L);
638 /* some reasons for NOT sending the WM_{SYS}COMMAND message:
639 * #0: unknown (please report!)
640 * #1: for WM_KEYUP,WM_SYSKEYUP
641 * #2: mouse is captured
642 * #3: window is disabled
643 * #4: it's a disabled system menu option
644 * #5: it's a menu option, but window is iconic
645 * #6: it's a menu option, but disabled
647 TRACE(accel,", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg);
649 ERR(accel, " unknown reason - please report!");
657 /**********************************************************************
658 * TranslateAccelerator32 (USER32.551)(USER32.552)(USER32.553)
660 INT WINAPI TranslateAccelerator(HWND hWnd, HACCEL hAccel, LPMSG msg)
663 LPACCEL16 lpAccelTbl = (LPACCEL16)LockResource16(hAccel);
666 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);
668 if (hAccel == 0 || msg == NULL ||
669 (msg->message != WM_KEYDOWN &&
670 msg->message != WM_KEYUP &&
671 msg->message != WM_SYSKEYDOWN &&
672 msg->message != WM_SYSKEYUP &&
673 msg->message != WM_CHAR)) {
674 WARN(accel, "erraneous input parameters\n");
675 SetLastError(ERROR_INVALID_PARAMETER);
679 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,"
680 "msg->hwnd=%04x, msg->message=%04x\n",
681 hAccel,hWnd,msg->hwnd,msg->message);
686 if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
687 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
689 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
690 WARN(accel, "couldn't translate accelerator key\n");
694 /**********************************************************************
695 * TranslateAccelerator16 (USER.178)
697 INT16 WINAPI TranslateAccelerator16(HWND16 hWnd, HACCEL16 hAccel, LPMSG16 msg)
699 LPACCEL16 lpAccelTbl = (LPACCEL16)LockResource16(hAccel);
703 if (hAccel == 0 || msg == NULL ||
704 (msg->message != WM_KEYDOWN &&
705 msg->message != WM_KEYUP &&
706 msg->message != WM_SYSKEYDOWN &&
707 msg->message != WM_SYSKEYUP &&
708 msg->message != WM_CHAR)) {
709 WARN(accel, "erraneous input parameters\n");
710 SetLastError(ERROR_INVALID_PARAMETER);
714 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
715 msg->hwnd=%04x, msg->message=%04x\n", hAccel,hWnd,msg->hwnd,msg->message);
716 STRUCT32_MSG16to32(msg,&msg32);
722 if (KBD_translate_accelerator(hWnd,&msg32,lpAccelTbl[i].fVirt,
723 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
725 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
726 WARN(accel, "couldn't translate accelerator key\n");
731 /**********************************************************************
732 * VkKeyScanA (USER32.573)
734 WORD WINAPI VkKeyScanA(CHAR cChar)
736 return VkKeyScan16(cChar);
739 /******************************************************************************
740 * VkKeyScanW (USER32.576)
742 WORD WINAPI VkKeyScanW(WCHAR cChar)
744 return VkKeyScanA((CHAR)cChar); /* FIXME: check unicode */
747 /******************************************************************************
748 * GetKeyboardType32 (USER32.255)
750 INT WINAPI GetKeyboardType(INT nTypeFlag)
752 return GetKeyboardType16(nTypeFlag);
755 /******************************************************************************
756 * MapVirtualKey32A (USER32.383)
758 UINT WINAPI MapVirtualKeyA(UINT code, UINT maptype)
760 return MapVirtualKey16(code,maptype);
763 /******************************************************************************
764 * MapVirtualKey32W (USER32.385)
766 UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype)
768 return MapVirtualKey16(code,maptype);
771 /******************************************************************************
772 * MapVirtualKeyEx32A (USER32.384)
774 UINT WINAPI MapVirtualKeyEx32A(UINT code, UINT maptype, HKL hkl)
777 FIXME(keyboard,"(%d,%d,0x%08lx), hkl unhandled!\n",code,maptype,(DWORD)hkl);
778 return MapVirtualKey16(code,maptype);
781 /****************************************************************************
782 * GetKBCodePage32 (USER32.246)
784 UINT WINAPI GetKBCodePage(void)
786 return GetKBCodePage16();
789 /****************************************************************************
790 * GetKeyboardLayoutName16 (USER.477)
792 INT16 WINAPI GetKeyboardLayoutName16(LPSTR pwszKLID)
794 return GetKeyboardLayoutNameA(pwszKLID);
797 /***********************************************************************
798 * GetKeyboardLayout (USER32.250)
800 * FIXME: - device handle for keyboard layout defaulted to
801 * the language id. This is the way Windows default works.
802 * - the thread identifier (dwLayout) is also ignored.
804 HKL WINAPI GetKeyboardLayout(DWORD dwLayout)
807 layout = GetSystemDefaultLCID(); /* FIXME */
808 layout |= (layout<<16); /* FIXME */
809 TRACE(keyboard,"returning %08x\n",layout);
813 /****************************************************************************
814 * GetKeyboardLayoutName32A (USER32.252)
816 INT WINAPI GetKeyboardLayoutNameA(LPSTR pwszKLID)
818 sprintf(pwszKLID, "%08x",GetKeyboardLayout(0));
822 /****************************************************************************
823 * GetKeyboardLayoutName32W (USER32.253)
825 INT WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
827 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
828 int res = GetKeyboardLayoutNameA(buf);
829 lstrcpyAtoW(pwszKLID,buf);
830 HeapFree( GetProcessHeap(), 0, buf );
834 /****************************************************************************
835 * GetKeyNameText32A (USER32.247)
837 INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
839 return GetKeyNameText16(lParam,lpBuffer,nSize);
842 /****************************************************************************
843 * GetKeyNameText32W (USER32.248)
845 INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize)
847 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, nSize );
848 int res = GetKeyNameTextA(lParam,buf,nSize);
850 lstrcpynAtoW(lpBuffer,buf,nSize);
851 HeapFree( GetProcessHeap(), 0, buf );
855 /****************************************************************************
856 * ToAscii32 (USER32.546)
858 INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState,
859 LPWORD lpChar,UINT flags )
861 return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags);
864 /**********************************************************************
865 * ActivateKeyboardLayout32 (USER32.1)
867 * Call ignored. WINE supports only system default keyboard layout.
869 HKL WINAPI ActivateKeyboardLayout(HKL hLayout, UINT flags)
871 TRACE(keyboard, "(%d, %d)\n", hLayout, flags);
872 ERR(keyboard,"Only default system keyboard layout supported. Call ignored.\n");
877 /***********************************************************************
878 * GetKeyboardLayoutList (USER32.251)
880 * FIXME: Supports only the system default language and layout and
881 * returns only 1 value.
883 * Return number of values available if either input parm is
884 * 0, per MS documentation.
887 INT WINAPI GetKeyboardLayoutList(INT nBuff,HKL *layouts)
889 TRACE(keyboard,"(%d,%p)\n",nBuff,layouts);
890 if (!nBuff || !layouts)
893 layouts[0] = GetKeyboardLayout(0);
898 /***********************************************************************
899 * RegisterHotKey (USER32.433)
901 BOOL WINAPI RegisterHotKey(HWND hwnd,INT id,UINT modifiers,UINT vk) {
902 FIXME(keyboard,"(0x%08x,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk);
906 /***********************************************************************
907 * UnregisterHotKey (USER32.565)
909 BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id) {
910 FIXME(keyboard,"(0x%08x,%d): stub\n",hwnd,id);
915 /***********************************************************************
916 * ToUnicode32 (USER32.548)
918 INT WINAPI ToUnicode(
926 FIXME(keyboard,": stub\n");
930 /***********************************************************************
931 * LoadKeyboardLayout32A (USER32.367)
932 * Call ignored. WINE supports only system default keyboard layout.
934 HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags)
936 TRACE(keyboard, "(%s, %d)\n", pwszKLID, Flags);
937 ERR(keyboard,"Only default system keyboard layout supported. Call ignored.\n");
941 /***********************************************************************
942 * LoadKeyboardLayout32W (USER32.368)
944 HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags)
946 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
948 lstrcpynWtoA(buf,pwszKLID,8);
950 res = LoadKeyboardLayoutA(buf, Flags);
951 HeapFree( GetProcessHeap(), 0, buf );