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"
28 #include "sysmetrics.h"
30 #include "debugtools.h"
35 static BOOL InputEnabled = TRUE;
36 static BOOL SwappedButtons = FALSE;
38 BOOL MouseButtonsStates[3];
39 BOOL AsyncMouseButtonsStates[3];
40 BYTE InputKeyStateTable[256];
41 BYTE QueueKeyStateTable[256];
42 BYTE AsyncKeyStateTable[256];
48 unsigned long count : 16;
49 unsigned long code : 8;
50 unsigned long extended : 1;
51 unsigned long unused : 2;
52 unsigned long win_internal : 2;
53 unsigned long context : 1;
54 unsigned long previous : 1;
55 unsigned long transition : 1;
60 /***********************************************************************
61 * keybd_event (USER32.583)
63 void WINAPI keybd_event( BYTE bVk, BYTE bScan,
64 DWORD dwFlags, DWORD dwExtraInfo )
66 DWORD posX, posY, time, extra;
71 if (!InputEnabled) return;
74 * If we are called by the Wine keyboard driver, use the additional
75 * info pointed to by the dwExtraInfo argument.
76 * Otherwise, we need to determine that info ourselves (probably
77 * less accurate, but we can't help that ...).
79 if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_KEYBDEVENT) )
80 && ((WINE_KEYBDEVENT *)dwExtraInfo)->magic == WINE_KEYBDEVENT_MAGIC )
82 WINE_KEYBDEVENT *wke = (WINE_KEYBDEVENT *)dwExtraInfo;
91 time = GetTickCount();
94 if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
100 keylp.lp1.code = bScan;
101 keylp.lp1.extended = (dwFlags & KEYEVENTF_EXTENDEDKEY) != 0;
102 keylp.lp1.win_internal = 0; /* this has something to do with dialogs,
103 * don't remember where I read it - AK */
104 /* it's '1' under windows, when a dialog box appears
105 * and you press one of the underlined keys - DF*/
107 if ( dwFlags & KEYEVENTF_KEYUP )
109 BOOL sysKey = (InputKeyStateTable[VK_MENU] & 0x80)
110 && !(InputKeyStateTable[VK_CONTROL] & 0x80)
111 && !(dwFlags & KEYEVENTF_WINE_FORCEEXTENDED); /* for Alt from AltGr */
113 InputKeyStateTable[bVk] &= ~0x80;
114 keylp.lp1.previous = 1;
115 keylp.lp1.transition = 1;
116 message = sysKey ? WM_SYSKEYUP : WM_KEYUP;
120 keylp.lp1.previous = (InputKeyStateTable[bVk] & 0x80) != 0;
121 keylp.lp1.transition = 0;
123 if (!(InputKeyStateTable[bVk] & 0x80))
124 InputKeyStateTable[bVk] ^= 0x01;
125 InputKeyStateTable[bVk] |= 0x80;
127 message = (InputKeyStateTable[VK_MENU] & 0x80)
128 && !(InputKeyStateTable[VK_CONTROL] & 0x80)
129 ? WM_SYSKEYDOWN : WM_KEYDOWN;
132 if ( message == WM_SYSKEYDOWN || message == WM_SYSKEYUP )
133 keylp.lp1.context = (InputKeyStateTable[VK_MENU] & 0x80) != 0; /* 1 if alt */
136 TRACE(key, " wParam=%04X, lParam=%08lX\n", bVk, keylp.lp2 );
137 TRACE(key, " InputKeyState=%X\n", InputKeyStateTable[bVk] );
139 hardware_event( message, bVk, keylp.lp2, posX, posY, time, extra );
142 /***********************************************************************
143 * mouse_event (USER32.584)
145 void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
146 DWORD cButtons, DWORD dwExtraInfo )
148 DWORD posX, posY, keyState, time, extra;
150 if (!InputEnabled) return;
153 * If we are called by the Wine mouse driver, use the additional
154 * info pointed to by the dwExtraInfo argument.
155 * Otherwise, we need to determine that info ourselves (probably
156 * less accurate, but we can't help that ...).
158 if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) )
159 && ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC )
161 WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo;
162 keyState = wme->keyState;
164 extra = (DWORD)wme->hWnd;
166 assert( dwFlags & MOUSEEVENTF_ABSOLUTE );
167 posX = (dx * SYSMETRICS_CXSCREEN) >> 16;
168 posY = (dy * SYSMETRICS_CYSCREEN) >> 16;
172 time = GetTickCount();
175 if ( !EVENT_QueryPointer( &posX, &posY, &keyState ))
178 if ( dwFlags & MOUSEEVENTF_MOVE )
180 if ( dwFlags & MOUSEEVENTF_ABSOLUTE )
182 posX = (dx * SYSMETRICS_CXSCREEN) >> 16;
183 posY = (dy * SYSMETRICS_CYSCREEN) >> 16;
190 /* We have to actually move the cursor */
191 SetCursorPos( posX, posY );
195 if ( dwFlags & MOUSEEVENTF_MOVE )
197 hardware_event( WM_MOUSEMOVE,
198 keyState, 0L, posX, posY, time, extra );
200 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN) )
202 MouseButtonsStates[0] = AsyncMouseButtonsStates[0] = TRUE;
203 hardware_event( WM_LBUTTONDOWN,
204 keyState, 0L, posX, posY, time, extra );
206 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP) )
208 MouseButtonsStates[0] = FALSE;
209 hardware_event( WM_LBUTTONUP,
210 keyState, 0L, posX, posY, time, extra );
212 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN) )
214 MouseButtonsStates[2] = AsyncMouseButtonsStates[2] = TRUE;
215 hardware_event( WM_RBUTTONDOWN,
216 keyState, 0L, posX, posY, time, extra );
218 if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP) )
220 MouseButtonsStates[2] = FALSE;
221 hardware_event( WM_RBUTTONUP,
222 keyState, 0L, posX, posY, time, extra );
224 if ( dwFlags & MOUSEEVENTF_MIDDLEDOWN )
226 MouseButtonsStates[1] = AsyncMouseButtonsStates[1] = TRUE;
227 hardware_event( WM_MBUTTONDOWN,
228 keyState, 0L, posX, posY, time, extra );
230 if ( dwFlags & MOUSEEVENTF_MIDDLEUP )
232 MouseButtonsStates[1] = FALSE;
233 hardware_event( WM_MBUTTONUP,
234 keyState, 0L, posX, posY, time, extra );
238 /**********************************************************************
239 * EnableHardwareInput (USER.331)
241 BOOL16 WINAPI EnableHardwareInput16(BOOL16 bEnable)
243 BOOL16 bOldState = InputEnabled;
244 FIXME(event,"(%d) - stub\n", bEnable);
245 InputEnabled = bEnable;
250 /***********************************************************************
251 * SwapMouseButton16 (USER.186)
253 BOOL16 WINAPI SwapMouseButton16( BOOL16 fSwap )
255 BOOL16 ret = SwappedButtons;
256 SwappedButtons = fSwap;
261 /***********************************************************************
262 * SwapMouseButton32 (USER32.537)
264 BOOL WINAPI SwapMouseButton( BOOL fSwap )
266 BOOL ret = SwappedButtons;
267 SwappedButtons = fSwap;
271 /**********************************************************************
274 * We need this to be able to generate double click messages
275 * when menu code captures mouse in the window without CS_DBLCLK style.
277 HWND EVENT_Capture(HWND hwnd, INT16 ht)
279 HWND capturePrev = 0, captureWnd = 0;
280 MESSAGEQUEUE *pMsgQ = 0, *pCurMsgQ = 0;
284 /* Get the messageQ for the current thread */
285 if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
287 WARN( win, "\tCurrent message queue not found. Exiting!\n" );
291 /* Get the current capture window from the perQ data of the current message Q */
292 capturePrev = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData );
301 wndPtr = WIN_FindWndPtr( hwnd );
304 TRACE(win, "(0x%04x)\n", hwnd );
310 /* Update the perQ capture window and send messages */
311 if( capturePrev != captureWnd )
315 /* Retrieve the message queue associated with this window */
316 pMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( wndPtr->hmemTaskQ );
319 WARN( win, "\tMessage queue not found. Exiting!\n" );
323 /* Make sure that message queue for the window we are setting capture to
324 * shares the same perQ data as the current threads message queue.
326 if ( pCurMsgQ->pQData != pMsgQ->pQData )
330 PERQDATA_SetCaptureWnd( pCurMsgQ->pQData, captureWnd );
331 PERQDATA_SetCaptureInfo( pCurMsgQ->pQData, captureHT );
335 WND* wndPtr = WIN_FindWndPtr( capturePrev );
336 if( wndPtr && (wndPtr->flags & WIN_ISWIN32) )
337 SendMessageA( capturePrev, WM_CAPTURECHANGED, 0L, hwnd);
342 /* Unlock the queues before returning */
344 QUEUE_Unlock( pMsgQ );
346 QUEUE_Unlock( pCurMsgQ );
352 /**********************************************************************
353 * SetCapture16 (USER.18)
355 HWND16 WINAPI SetCapture16( HWND16 hwnd )
357 return (HWND16)EVENT_Capture( hwnd, HTCLIENT );
361 /**********************************************************************
362 * SetCapture32 (USER32.464)
364 HWND WINAPI SetCapture( HWND hwnd )
366 return EVENT_Capture( hwnd, HTCLIENT );
370 /**********************************************************************
371 * ReleaseCapture (USER.19) (USER32.439)
373 void WINAPI ReleaseCapture(void)
375 EVENT_Capture( 0, 0 );
379 /**********************************************************************
380 * GetCapture16 (USER.236)
382 HWND16 WINAPI GetCapture16(void)
384 return (HWND16)GetCapture();
387 /**********************************************************************
388 * GetCapture32 (USER32.208)
390 HWND WINAPI GetCapture(void)
392 MESSAGEQUEUE *pCurMsgQ = 0;
393 HWND hwndCapture = 0;
395 /* Get the messageQ for the current thread */
396 if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
398 TRACE( win, "GetCapture32: Current message queue not found. Exiting!\n" );
402 /* Get the current capture window from the perQ data of the current message Q */
403 hwndCapture = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData );
405 QUEUE_Unlock( pCurMsgQ );
409 /**********************************************************************
410 * GetKeyState (USER.106)
412 INT16 WINAPI GetKeyState16(INT16 vkey)
414 return GetKeyState(vkey);
417 /**********************************************************************
418 * GetKeyState (USER32.249)
420 * An application calls the GetKeyState function in response to a
421 * keyboard-input message. This function retrieves the state of the key
422 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
424 INT16 WINAPI GetKeyState(INT vkey)
430 case VK_LBUTTON : /* VK_LBUTTON is 1 */
431 retval = MouseButtonsStates[0] ? 0x8000 : 0;
433 case VK_MBUTTON : /* VK_MBUTTON is 4 */
434 retval = MouseButtonsStates[1] ? 0x8000 : 0;
436 case VK_RBUTTON : /* VK_RBUTTON is 2 */
437 retval = MouseButtonsStates[2] ? 0x8000 : 0;
440 if (vkey >= 'a' && vkey <= 'z')
442 retval = ( (WORD)(QueueKeyStateTable[vkey] & 0x80) << 8 ) |
443 (WORD)(QueueKeyStateTable[vkey] & 0x01);
445 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
449 /**********************************************************************
450 * GetKeyboardState (USER.222)(USER32.254)
452 * An application calls the GetKeyboardState function in response to a
453 * keyboard-input message. This function retrieves the state of the keyboard
454 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
456 VOID WINAPI GetKeyboardState(LPBYTE lpKeyState)
458 TRACE(key, "(%p)\n", lpKeyState);
459 if (lpKeyState != NULL) {
460 QueueKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
461 QueueKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
462 QueueKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
463 memcpy(lpKeyState, QueueKeyStateTable, 256);
467 /**********************************************************************
468 * SetKeyboardState (USER.223)(USER32.484)
470 VOID WINAPI SetKeyboardState(LPBYTE lpKeyState)
472 TRACE(key, "(%p)\n", lpKeyState);
473 if (lpKeyState != NULL) {
474 memcpy(QueueKeyStateTable, lpKeyState, 256);
475 MouseButtonsStates[0] = (QueueKeyStateTable[VK_LBUTTON] != 0);
476 MouseButtonsStates[1] = (QueueKeyStateTable[VK_MBUTTON] != 0);
477 MouseButtonsStates[2] = (QueueKeyStateTable[VK_RBUTTON] != 0);
481 /**********************************************************************
482 * GetAsyncKeyState32 (USER32.207)
484 * Determine if a key is or was pressed. retval has high-order
485 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
488 * This uses the variable AsyncMouseButtonsStates and
489 * AsyncKeyStateTable (set in event.c) which have the mouse button
490 * number or key number (whichever is applicable) set to true if the
491 * mouse or key had been depressed since the last call to
494 WORD WINAPI GetAsyncKeyState(INT nKey)
500 retval = (AsyncMouseButtonsStates[0] ? 0x0001 : 0) |
501 (MouseButtonsStates[0] ? 0x8000 : 0);
504 retval = (AsyncMouseButtonsStates[1] ? 0x0001 : 0) |
505 (MouseButtonsStates[1] ? 0x8000 : 0);
508 retval = (AsyncMouseButtonsStates[2] ? 0x0001 : 0) |
509 (MouseButtonsStates[2] ? 0x8000 : 0);
512 retval = AsyncKeyStateTable[nKey] |
513 ((InputKeyStateTable[nKey] & 0x80) ? 0x8000 : 0);
517 /* all states to false */
518 memset( AsyncMouseButtonsStates, 0, sizeof(AsyncMouseButtonsStates) );
519 memset( AsyncKeyStateTable, 0, sizeof(AsyncKeyStateTable) );
521 TRACE(key, "(%x) -> %x\n", nKey, retval);
525 /**********************************************************************
526 * GetAsyncKeyState16 (USER.249)
528 WORD WINAPI GetAsyncKeyState16(INT16 nKey)
530 return GetAsyncKeyState(nKey);
533 /**********************************************************************
534 * KBD_translate_accelerator
536 * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
538 static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg,
539 BYTE fVirt,WORD key,WORD cmd)
541 BOOL sendmsg = FALSE;
543 if(msg->wParam == key)
545 if (msg->message == WM_CHAR) {
546 if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) )
548 TRACE(accel,"found accel for WM_CHAR: ('%c')\n",
553 if(fVirt & FVIRTKEY) {
555 TRACE(accel,"found accel for virt_key %04x (scan %04x)\n",
556 msg->wParam,0xff & HIWORD(msg->lParam));
557 if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
558 if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
559 if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
560 if(mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
563 TRACE(accel,", but incorrect SHIFT/CTRL/ALT-state\n");
567 if (!(msg->lParam & 0x01000000)) /* no special_key */
569 if ((fVirt & FALT) && (msg->lParam & 0x20000000))
570 { /* ^^ ALT pressed */
571 TRACE(accel,"found accel for Alt-%c\n", msg->wParam&0xff);
578 if (sendmsg) /* found an accelerator, but send a message... ? */
580 INT16 iSysStat,iStat,mesg=0;
583 if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP)
589 if (!IsWindowEnabled(hWnd))
593 WND* wndPtr = WIN_FindWndPtr(hWnd);
595 hMenu = (wndPtr->dwStyle & WS_CHILD) ? 0 : (HMENU)wndPtr->wIDmenu;
596 iSysStat = (wndPtr->hSysMenu) ? GetMenuState(GetSubMenu16(wndPtr->hSysMenu, 0),
597 cmd, MF_BYCOMMAND) : -1 ;
598 iStat = (hMenu) ? GetMenuState(hMenu,
599 cmd, MF_BYCOMMAND) : -1 ;
603 if (iSysStat & (MF_DISABLED|MF_GRAYED))
616 if (iStat & (MF_DISABLED|MF_GRAYED))
626 if ( mesg==WM_COMMAND || mesg==WM_SYSCOMMAND )
628 TRACE(accel,", sending %s, wParam=%0x\n",
629 mesg==WM_COMMAND ? "WM_COMMAND" : "WM_SYSCOMMAND",
631 SendMessageA(hWnd, mesg, cmd, 0x00010000L);
635 /* some reasons for NOT sending the WM_{SYS}COMMAND message:
636 * #0: unknown (please report!)
637 * #1: for WM_KEYUP,WM_SYSKEYUP
638 * #2: mouse is captured
639 * #3: window is disabled
640 * #4: it's a disabled system menu option
641 * #5: it's a menu option, but window is iconic
642 * #6: it's a menu option, but disabled
644 TRACE(accel,", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg);
646 ERR(accel, " unknown reason - please report!");
654 /**********************************************************************
655 * TranslateAccelerator32 (USER32.551)(USER32.552)(USER32.553)
657 INT WINAPI TranslateAccelerator(HWND hWnd, HACCEL hAccel, LPMSG msg)
660 LPACCEL16 lpAccelTbl = (LPACCEL16)LockResource16(hAccel);
663 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);
665 if (hAccel == 0 || msg == NULL ||
666 (msg->message != WM_KEYDOWN &&
667 msg->message != WM_KEYUP &&
668 msg->message != WM_SYSKEYDOWN &&
669 msg->message != WM_SYSKEYUP &&
670 msg->message != WM_CHAR)) {
671 WARN(accel, "erraneous input parameters\n");
672 SetLastError(ERROR_INVALID_PARAMETER);
676 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,"
677 "msg->hwnd=%04x, msg->message=%04x\n",
678 hAccel,hWnd,msg->hwnd,msg->message);
683 if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
684 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
686 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
687 WARN(accel, "couldn't translate accelerator key\n");
691 /**********************************************************************
692 * TranslateAccelerator16 (USER.178)
694 INT16 WINAPI TranslateAccelerator16(HWND16 hWnd, HACCEL16 hAccel, LPMSG16 msg)
696 LPACCEL16 lpAccelTbl = (LPACCEL16)LockResource16(hAccel);
700 if (hAccel == 0 || msg == NULL ||
701 (msg->message != WM_KEYDOWN &&
702 msg->message != WM_KEYUP &&
703 msg->message != WM_SYSKEYDOWN &&
704 msg->message != WM_SYSKEYUP &&
705 msg->message != WM_CHAR)) {
706 WARN(accel, "erraneous input parameters\n");
707 SetLastError(ERROR_INVALID_PARAMETER);
711 TRACE(accel, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
712 msg->hwnd=%04x, msg->message=%04x\n", hAccel,hWnd,msg->hwnd,msg->message);
713 STRUCT32_MSG16to32(msg,&msg32);
719 if (KBD_translate_accelerator(hWnd,&msg32,lpAccelTbl[i].fVirt,
720 lpAccelTbl[i].key,lpAccelTbl[i].cmd))
722 } while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
723 WARN(accel, "couldn't translate accelerator key\n");
728 /**********************************************************************
729 * VkKeyScanA (USER32.573)
731 WORD WINAPI VkKeyScanA(CHAR cChar)
733 return VkKeyScan16(cChar);
736 /******************************************************************************
737 * VkKeyScanW (USER32.576)
739 WORD WINAPI VkKeyScanW(WCHAR cChar)
741 return VkKeyScanA((CHAR)cChar); /* FIXME: check unicode */
744 /******************************************************************************
745 * GetKeyboardType32 (USER32.255)
747 INT WINAPI GetKeyboardType(INT nTypeFlag)
749 return GetKeyboardType16(nTypeFlag);
752 /******************************************************************************
753 * MapVirtualKey32A (USER32.383)
755 UINT WINAPI MapVirtualKeyA(UINT code, UINT maptype)
757 return MapVirtualKey16(code,maptype);
760 /******************************************************************************
761 * MapVirtualKey32W (USER32.385)
763 UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype)
765 return MapVirtualKey16(code,maptype);
768 /******************************************************************************
769 * MapVirtualKeyEx32A (USER32.384)
771 UINT WINAPI MapVirtualKeyEx32A(UINT code, UINT maptype, HKL hkl)
774 FIXME(keyboard,"(%d,%d,0x%08lx), hkl unhandled!\n",code,maptype,(DWORD)hkl);
775 return MapVirtualKey16(code,maptype);
778 /****************************************************************************
779 * GetKBCodePage32 (USER32.246)
781 UINT WINAPI GetKBCodePage(void)
783 return GetKBCodePage16();
786 /****************************************************************************
787 * GetKeyboardLayoutName16 (USER.477)
789 INT16 WINAPI GetKeyboardLayoutName16(LPSTR pwszKLID)
791 return GetKeyboardLayoutNameA(pwszKLID);
794 /***********************************************************************
795 * GetKeyboardLayout (USER32.250)
797 * FIXME: - device handle for keyboard layout defaulted to
798 * the language id. This is the way Windows default works.
799 * - the thread identifier (dwLayout) is also ignored.
801 HKL WINAPI GetKeyboardLayout(DWORD dwLayout)
804 layout = GetSystemDefaultLCID(); /* FIXME */
805 layout |= (layout<<16); /* FIXME */
806 TRACE(keyboard,"returning %08x\n",layout);
810 /****************************************************************************
811 * GetKeyboardLayoutName32A (USER32.252)
813 INT WINAPI GetKeyboardLayoutNameA(LPSTR pwszKLID)
815 sprintf(pwszKLID, "%08x",GetKeyboardLayout(0));
819 /****************************************************************************
820 * GetKeyboardLayoutName32W (USER32.253)
822 INT WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
824 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
825 int res = GetKeyboardLayoutNameA(buf);
826 lstrcpyAtoW(pwszKLID,buf);
827 HeapFree( GetProcessHeap(), 0, buf );
831 /****************************************************************************
832 * GetKeyNameText32A (USER32.247)
834 INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
836 return GetKeyNameText16(lParam,lpBuffer,nSize);
839 /****************************************************************************
840 * GetKeyNameText32W (USER32.248)
842 INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize)
844 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, nSize );
845 int res = GetKeyNameTextA(lParam,buf,nSize);
847 lstrcpynAtoW(lpBuffer,buf,nSize);
848 HeapFree( GetProcessHeap(), 0, buf );
852 /****************************************************************************
853 * ToAscii32 (USER32.546)
855 INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState,
856 LPWORD lpChar,UINT flags )
858 return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags);
861 /**********************************************************************
862 * ActivateKeyboardLayout32 (USER32.1)
864 * Call ignored. WINE supports only system default keyboard layout.
866 HKL WINAPI ActivateKeyboardLayout(HKL hLayout, UINT flags)
868 TRACE(keyboard, "(%d, %d)\n", hLayout, flags);
869 ERR(keyboard,"Only default system keyboard layout supported. Call ignored.\n");
874 /***********************************************************************
875 * GetKeyboardLayoutList (USER32.251)
877 * FIXME: Supports only the system default language and layout and
878 * returns only 1 value.
880 * Return number of values available if either input parm is
881 * 0, per MS documentation.
884 INT WINAPI GetKeyboardLayoutList(INT nBuff,HKL *layouts)
886 TRACE(keyboard,"(%d,%p)\n",nBuff,layouts);
887 if (!nBuff || !layouts)
890 layouts[0] = GetKeyboardLayout(0);
895 /***********************************************************************
896 * RegisterHotKey (USER32.433)
898 BOOL WINAPI RegisterHotKey(HWND hwnd,INT id,UINT modifiers,UINT vk) {
899 FIXME(keyboard,"(0x%08x,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk);
903 /***********************************************************************
904 * UnregisterHotKey (USER32.565)
906 BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id) {
907 FIXME(keyboard,"(0x%08x,%d): stub\n",hwnd,id);
912 /***********************************************************************
913 * ToUnicode32 (USER32.548)
915 INT WINAPI ToUnicode(
923 FIXME(keyboard,": stub\n");
927 /***********************************************************************
928 * LoadKeyboardLayout32A (USER32.367)
929 * Call ignored. WINE supports only system default keyboard layout.
931 HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags)
933 TRACE(keyboard, "(%s, %d)\n", pwszKLID, Flags);
934 ERR(keyboard,"Only default system keyboard layout supported. Call ignored.\n");
938 /***********************************************************************
939 * LoadKeyboardLayout32W (USER32.368)
941 HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags)
943 LPSTR buf = HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
945 lstrcpynWtoA(buf,pwszKLID,8);
947 res = LoadKeyboardLayoutA(buf, Flags);
948 HeapFree( GetProcessHeap(), 0, buf );