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
21 #include "wine/winbase16.h"
22 #include "wine/winuser16.h"
23 #include "wine/winestring.h"
24 #include "wine/keyboard16.h"
33 #include "debugtools.h"
37 DECLARE_DEBUG_CHANNEL(event
);
38 DECLARE_DEBUG_CHANNEL(key
);
39 DECLARE_DEBUG_CHANNEL(keyboard
);
40 DECLARE_DEBUG_CHANNEL(win
);
42 static BOOL InputEnabled
= TRUE
;
43 BOOL SwappedButtons
= FALSE
;
45 BOOL MouseButtonsStates
[3];
46 BOOL AsyncMouseButtonsStates
[3];
47 BYTE InputKeyStateTable
[256];
48 BYTE QueueKeyStateTable
[256];
49 BYTE AsyncKeyStateTable
[256];
51 /* Storage for the USER-maintained mouse positions */
58 unsigned long count
: 16;
59 unsigned long code
: 8;
60 unsigned long extended
: 1;
61 unsigned long unused
: 2;
62 unsigned long win_internal
: 2;
63 unsigned long context
: 1;
64 unsigned long previous
: 1;
65 unsigned long transition
: 1;
70 /***********************************************************************
71 * keybd_event (USER32.583)
73 void WINAPI
keybd_event( BYTE bVk
, BYTE bScan
,
74 DWORD dwFlags
, DWORD dwExtraInfo
)
81 if (!InputEnabled
) return;
84 * If we are called by the Wine keyboard driver, use the additional
85 * info pointed to by the dwExtraInfo argument.
86 * Otherwise, we need to determine that info ourselves (probably
87 * less accurate, but we can't help that ...).
89 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_KEYBDEVENT
) )
90 && ((WINE_KEYBDEVENT
*)dwExtraInfo
)->magic
== WINE_KEYBDEVENT_MAGIC
)
92 WINE_KEYBDEVENT
*wke
= (WINE_KEYBDEVENT
*)dwExtraInfo
;
98 time
= GetTickCount();
104 keylp
.lp1
.code
= bScan
;
105 keylp
.lp1
.extended
= (dwFlags
& KEYEVENTF_EXTENDEDKEY
) != 0;
106 keylp
.lp1
.win_internal
= 0; /* this has something to do with dialogs,
107 * don't remember where I read it - AK */
108 /* it's '1' under windows, when a dialog box appears
109 * and you press one of the underlined keys - DF*/
111 if ( dwFlags
& KEYEVENTF_KEYUP
)
113 BOOL sysKey
= (InputKeyStateTable
[VK_MENU
] & 0x80)
114 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
115 && !(dwFlags
& KEYEVENTF_WINE_FORCEEXTENDED
); /* for Alt from AltGr */
117 InputKeyStateTable
[bVk
] &= ~0x80;
118 keylp
.lp1
.previous
= 1;
119 keylp
.lp1
.transition
= 1;
120 message
= sysKey
? WM_SYSKEYUP
: WM_KEYUP
;
124 keylp
.lp1
.previous
= (InputKeyStateTable
[bVk
] & 0x80) != 0;
125 keylp
.lp1
.transition
= 0;
127 if (!(InputKeyStateTable
[bVk
] & 0x80))
128 InputKeyStateTable
[bVk
] ^= 0x01;
129 InputKeyStateTable
[bVk
] |= 0x80;
131 message
= (InputKeyStateTable
[VK_MENU
] & 0x80)
132 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
133 ? WM_SYSKEYDOWN
: WM_KEYDOWN
;
136 if ( message
== WM_SYSKEYDOWN
|| message
== WM_SYSKEYUP
)
137 keylp
.lp1
.context
= (InputKeyStateTable
[VK_MENU
] & 0x80) != 0; /* 1 if alt */
140 TRACE_(key
)(" wParam=%04X, lParam=%08lX\n", bVk
, keylp
.lp2
);
141 TRACE_(key
)(" InputKeyState=%X\n", InputKeyStateTable
[bVk
] );
143 hardware_event( message
, bVk
, keylp
.lp2
, PosX
, PosY
, time
, extra
);
146 /***********************************************************************
147 * WIN16_keybd_event (USER.289)
149 void WINAPI
WIN16_keybd_event( CONTEXT86
*context
)
153 if (AH_reg(context
) & 0x80) dwFlags
|= KEYEVENTF_KEYUP
;
154 if (BH_reg(context
) & 1 ) dwFlags
|= KEYEVENTF_EXTENDEDKEY
;
156 keybd_event( AL_reg(context
), BL_reg(context
),
157 dwFlags
, MAKELONG(SI_reg(context
), DI_reg(context
)) );
160 /***********************************************************************
161 * mouse_event (USER32.584)
163 void WINAPI
mouse_event( DWORD dwFlags
, DWORD dx
, DWORD dy
,
164 DWORD cButtons
, DWORD dwExtraInfo
)
169 if (!InputEnabled
) return;
171 if ( dwFlags
& MOUSEEVENTF_MOVE
)
173 if ( dwFlags
& MOUSEEVENTF_ABSOLUTE
)
175 PosX
= (dx
* GetSystemMetrics(SM_CXSCREEN
)) >> 16;
176 PosY
= (dy
* GetSystemMetrics(SM_CYSCREEN
)) >> 16;
180 int width
= GetSystemMetrics(SM_CXSCREEN
);
181 int height
= GetSystemMetrics(SM_CYSCREEN
);
182 long posX
= (long) PosX
, posY
= (long) PosY
;
184 /* dx and dy can be negative numbers for relative movements */
188 /* Clip to the current screen size */
189 if (posX
< 0) PosX
= 0;
190 else if (posX
>= width
) PosX
= width
- 1;
193 if (posY
< 0) PosY
= 0;
194 else if (posY
>= height
) PosY
= height
- 1;
200 * If we are called by the Wine mouse driver, use the additional
201 * info pointed to by the dwExtraInfo argument.
202 * Otherwise, we need to determine that info ourselves (probably
203 * less accurate, but we can't help that ...).
205 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_MOUSEEVENT
) )
206 && ((WINE_MOUSEEVENT
*)dwExtraInfo
)->magic
== WINE_MOUSEEVENT_MAGIC
)
208 WINE_MOUSEEVENT
*wme
= (WINE_MOUSEEVENT
*)dwExtraInfo
;
210 extra
= (DWORD
)wme
->hWnd
;
211 keyState
= wme
->keyState
;
213 if (keyState
!= GET_KEYSTATE()) {
214 /* We need to update the keystate with what X provides us */
215 MouseButtonsStates
[SwappedButtons
? 2 : 0] = (keyState
& MK_LBUTTON
? TRUE
: FALSE
);
216 MouseButtonsStates
[SwappedButtons
? 0 : 2] = (keyState
& MK_RBUTTON
? TRUE
: FALSE
);
217 MouseButtonsStates
[1] = (keyState
& MK_MBUTTON
? TRUE
: FALSE
);
218 InputKeyStateTable
[VK_SHIFT
] = (keyState
& MK_SHIFT
? 0x80 : 0);
219 InputKeyStateTable
[VK_CONTROL
] = (keyState
& MK_CONTROL
? 0x80 : 0);
224 time
= GetTickCount();
226 keyState
= GET_KEYSTATE();
228 if ( dwFlags
& MOUSEEVENTF_MOVE
)
230 /* We have to actually move the cursor */
231 SetCursorPos( PosX
, PosY
);
236 if ( dwFlags
& MOUSEEVENTF_MOVE
)
238 hardware_event( WM_MOUSEMOVE
,
239 keyState
, 0L, PosX
, PosY
, time
, extra
);
241 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTDOWN
: MOUSEEVENTF_RIGHTDOWN
) )
243 MouseButtonsStates
[0] = AsyncMouseButtonsStates
[0] = TRUE
;
244 hardware_event( WM_LBUTTONDOWN
,
245 keyState
, 0L, PosX
, PosY
, time
, extra
);
247 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTUP
: MOUSEEVENTF_RIGHTUP
) )
249 MouseButtonsStates
[0] = FALSE
;
250 hardware_event( WM_LBUTTONUP
,
251 keyState
, 0L, PosX
, PosY
, time
, extra
);
253 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTDOWN
: MOUSEEVENTF_LEFTDOWN
) )
255 MouseButtonsStates
[2] = AsyncMouseButtonsStates
[2] = TRUE
;
256 hardware_event( WM_RBUTTONDOWN
,
257 keyState
, 0L, PosX
, PosY
, time
, extra
);
259 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTUP
: MOUSEEVENTF_LEFTUP
) )
261 MouseButtonsStates
[2] = FALSE
;
262 hardware_event( WM_RBUTTONUP
,
263 keyState
, 0L, PosX
, PosY
, time
, extra
);
265 if ( dwFlags
& MOUSEEVENTF_MIDDLEDOWN
)
267 MouseButtonsStates
[1] = AsyncMouseButtonsStates
[1] = TRUE
;
268 hardware_event( WM_MBUTTONDOWN
,
269 keyState
, 0L, PosX
, PosY
, time
, extra
);
271 if ( dwFlags
& MOUSEEVENTF_MIDDLEUP
)
273 MouseButtonsStates
[1] = FALSE
;
274 hardware_event( WM_MBUTTONUP
,
275 keyState
, 0L, PosX
, PosY
, time
, extra
);
277 if ( dwFlags
& MOUSEEVENTF_WHEEL
)
279 hardware_event( WM_MOUSEWHEEL
,
280 keyState
, 0L, PosX
, PosY
, time
, extra
);
284 /***********************************************************************
285 * WIN16_mouse_event (USER.299)
287 void WINAPI
WIN16_mouse_event( CONTEXT86
*context
)
289 mouse_event( AX_reg(context
), BX_reg(context
), CX_reg(context
),
290 DX_reg(context
), MAKELONG(SI_reg(context
), DI_reg(context
)) );
293 /***********************************************************************
294 * GetMouseEventProc (USER.337)
296 FARPROC16 WINAPI
GetMouseEventProc16(void)
298 HMODULE16 hmodule
= GetModuleHandle16("USER");
299 return NE_GetEntryPoint( hmodule
, NE_GetOrdinal( hmodule
, "mouse_event" ));
303 /**********************************************************************
304 * EnableHardwareInput (USER.331)
306 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
308 BOOL16 bOldState
= InputEnabled
;
309 FIXME_(event
)("(%d) - stub\n", bEnable
);
310 InputEnabled
= bEnable
;
315 /***********************************************************************
316 * SwapMouseButton16 (USER.186)
318 BOOL16 WINAPI
SwapMouseButton16( BOOL16 fSwap
)
320 BOOL16 ret
= SwappedButtons
;
321 SwappedButtons
= fSwap
;
326 /***********************************************************************
327 * SwapMouseButton (USER32.537)
329 BOOL WINAPI
SwapMouseButton( BOOL fSwap
)
331 BOOL ret
= SwappedButtons
;
332 SwappedButtons
= fSwap
;
336 /**********************************************************************
339 * We need this to be able to generate double click messages
340 * when menu code captures mouse in the window without CS_DBLCLK style.
342 HWND
EVENT_Capture(HWND hwnd
, INT16 ht
)
344 HWND capturePrev
= 0, captureWnd
= 0;
345 MESSAGEQUEUE
*pMsgQ
= 0, *pCurMsgQ
= 0;
349 /* Get the messageQ for the current thread */
350 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
352 WARN_(win
)("\tCurrent message queue not found. Exiting!\n" );
356 /* Get the current capture window from the perQ data of the current message Q */
357 capturePrev
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
366 wndPtr
= WIN_FindWndPtr( hwnd
);
369 TRACE_(win
)("(0x%04x)\n", hwnd
);
375 /* Update the perQ capture window and send messages */
376 if( capturePrev
!= captureWnd
)
380 /* Retrieve the message queue associated with this window */
381 pMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( wndPtr
->hmemTaskQ
);
384 WARN_(win
)("\tMessage queue not found. Exiting!\n" );
388 /* Make sure that message queue for the window we are setting capture to
389 * shares the same perQ data as the current threads message queue.
391 if ( pCurMsgQ
->pQData
!= pMsgQ
->pQData
)
395 PERQDATA_SetCaptureWnd( pCurMsgQ
->pQData
, captureWnd
);
396 PERQDATA_SetCaptureInfo( pCurMsgQ
->pQData
, captureHT
);
400 WND
* xwndPtr
= WIN_FindWndPtr( capturePrev
);
401 if( xwndPtr
&& (xwndPtr
->flags
& WIN_ISWIN32
) )
402 SendMessageA( capturePrev
, WM_CAPTURECHANGED
, 0L, hwnd
);
403 WIN_ReleaseWndPtr(xwndPtr
);
408 /* Unlock the queues before returning */
410 QUEUE_Unlock( pMsgQ
);
412 QUEUE_Unlock( pCurMsgQ
);
414 WIN_ReleaseWndPtr(wndPtr
);
419 /**********************************************************************
420 * SetCapture16 (USER.18)
422 HWND16 WINAPI
SetCapture16( HWND16 hwnd
)
424 return (HWND16
)EVENT_Capture( hwnd
, HTCLIENT
);
428 /**********************************************************************
429 * SetCapture (USER32.464)
431 HWND WINAPI
SetCapture( HWND hwnd
)
433 return EVENT_Capture( hwnd
, HTCLIENT
);
437 /**********************************************************************
438 * ReleaseCapture (USER.19) (USER32.439)
440 BOOL WINAPI
ReleaseCapture(void)
442 return (EVENT_Capture( 0, 0 ) != 0);
446 /**********************************************************************
447 * GetCapture16 (USER.236)
449 HWND16 WINAPI
GetCapture16(void)
451 return (HWND16
)GetCapture();
454 /**********************************************************************
455 * GetCapture (USER32.208)
457 HWND WINAPI
GetCapture(void)
459 MESSAGEQUEUE
*pCurMsgQ
= 0;
460 HWND hwndCapture
= 0;
462 /* Get the messageQ for the current thread */
463 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
465 TRACE_(win
)("GetCapture: Current message queue not found. Exiting!\n" );
469 /* Get the current capture window from the perQ data of the current message Q */
470 hwndCapture
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
472 QUEUE_Unlock( pCurMsgQ
);
476 /**********************************************************************
477 * GetKeyState (USER.106)
479 INT16 WINAPI
GetKeyState16(INT16 vkey
)
481 return GetKeyState(vkey
);
484 /**********************************************************************
485 * GetKeyState (USER32.249)
487 * An application calls the GetKeyState function in response to a
488 * keyboard-input message. This function retrieves the state of the key
489 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
491 SHORT WINAPI
GetKeyState(INT vkey
)
497 case VK_LBUTTON
: /* VK_LBUTTON is 1 */
498 retval
= MouseButtonsStates
[0] ? 0x8000 : 0;
500 case VK_MBUTTON
: /* VK_MBUTTON is 4 */
501 retval
= MouseButtonsStates
[1] ? 0x8000 : 0;
503 case VK_RBUTTON
: /* VK_RBUTTON is 2 */
504 retval
= MouseButtonsStates
[2] ? 0x8000 : 0;
507 if (vkey
>= 'a' && vkey
<= 'z')
509 retval
= ( (WORD
)(QueueKeyStateTable
[vkey
] & 0x80) << 8 ) |
510 (WORD
)(QueueKeyStateTable
[vkey
] & 0x01);
512 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
516 /**********************************************************************
517 * GetKeyboardState (USER.222)(USER32.254)
519 * An application calls the GetKeyboardState function in response to a
520 * keyboard-input message. This function retrieves the state of the keyboard
521 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
523 BOOL WINAPI
GetKeyboardState(LPBYTE lpKeyState
)
525 TRACE_(key
)("(%p)\n", lpKeyState
);
526 if (lpKeyState
!= NULL
) {
527 QueueKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
528 QueueKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
529 QueueKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
530 memcpy(lpKeyState
, QueueKeyStateTable
, 256);
536 /**********************************************************************
537 * SetKeyboardState (USER.223)(USER32.484)
539 BOOL WINAPI
SetKeyboardState(LPBYTE lpKeyState
)
541 TRACE_(key
)("(%p)\n", lpKeyState
);
542 if (lpKeyState
!= NULL
) {
543 memcpy(QueueKeyStateTable
, lpKeyState
, 256);
544 MouseButtonsStates
[0] = (QueueKeyStateTable
[VK_LBUTTON
] != 0);
545 MouseButtonsStates
[1] = (QueueKeyStateTable
[VK_MBUTTON
] != 0);
546 MouseButtonsStates
[2] = (QueueKeyStateTable
[VK_RBUTTON
] != 0);
552 /**********************************************************************
553 * GetAsyncKeyState (USER32.207)
555 * Determine if a key is or was pressed. retval has high-order
556 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
559 * This uses the variable AsyncMouseButtonsStates and
560 * AsyncKeyStateTable (set in event.c) which have the mouse button
561 * number or key number (whichever is applicable) set to true if the
562 * mouse or key had been depressed since the last call to
565 WORD WINAPI
GetAsyncKeyState(INT nKey
)
571 retval
= (AsyncMouseButtonsStates
[0] ? 0x0001 : 0) |
572 (MouseButtonsStates
[0] ? 0x8000 : 0);
575 retval
= (AsyncMouseButtonsStates
[1] ? 0x0001 : 0) |
576 (MouseButtonsStates
[1] ? 0x8000 : 0);
579 retval
= (AsyncMouseButtonsStates
[2] ? 0x0001 : 0) |
580 (MouseButtonsStates
[2] ? 0x8000 : 0);
583 retval
= AsyncKeyStateTable
[nKey
] |
584 ((InputKeyStateTable
[nKey
] & 0x80) ? 0x8000 : 0);
588 /* all states to false */
589 memset( AsyncMouseButtonsStates
, 0, sizeof(AsyncMouseButtonsStates
) );
590 memset( AsyncKeyStateTable
, 0, sizeof(AsyncKeyStateTable
) );
592 TRACE_(key
)("(%x) -> %x\n", nKey
, retval
);
596 /**********************************************************************
597 * GetAsyncKeyState16 (USER.249)
599 WORD WINAPI
GetAsyncKeyState16(INT16 nKey
)
601 return GetAsyncKeyState(nKey
);
604 /***********************************************************************
605 * IsUserIdle (USER.333)
607 BOOL16 WINAPI
IsUserIdle16(void)
609 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
612 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
615 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
618 /* Should check for screen saver activation here ... */
623 /**********************************************************************
624 * VkKeyScanA (USER32.573)
626 WORD WINAPI
VkKeyScanA(CHAR cChar
)
628 return VkKeyScan16(cChar
);
631 /******************************************************************************
632 * VkKeyScanW (USER32.576)
634 WORD WINAPI
VkKeyScanW(WCHAR cChar
)
636 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
639 /**********************************************************************
640 * VkKeyScanExA (USER32.574)
642 WORD WINAPI
VkKeyScanExA(CHAR cChar
, HKL dwhkl
)
644 /* FIXME: complete workaround this is */
645 return VkKeyScan16(cChar
);
648 /******************************************************************************
649 * VkKeyScanExW (USER32.575)
651 WORD WINAPI
VkKeyScanExW(WCHAR cChar
, HKL dwhkl
)
653 /* FIXME: complete workaround this is */
654 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
657 /******************************************************************************
658 * GetKeyboardType (USER32.255)
660 INT WINAPI
GetKeyboardType(INT nTypeFlag
)
662 return GetKeyboardType16(nTypeFlag
);
665 /******************************************************************************
666 * MapVirtualKeyA (USER32.383)
668 UINT WINAPI
MapVirtualKeyA(UINT code
, UINT maptype
)
670 return MapVirtualKey16(code
,maptype
);
673 /******************************************************************************
674 * MapVirtualKeyW (USER32.385)
676 UINT WINAPI
MapVirtualKeyW(UINT code
, UINT maptype
)
678 return MapVirtualKey16(code
,maptype
);
681 /******************************************************************************
682 * MapVirtualKeyExA (USER32.384)
684 UINT WINAPI
MapVirtualKeyExA(UINT code
, UINT maptype
, HKL hkl
)
687 FIXME_(keyboard
)("(%d,%d,0x%08lx), hkl unhandled!\n",code
,maptype
,(DWORD
)hkl
);
688 return MapVirtualKey16(code
,maptype
);
691 /****************************************************************************
692 * GetKBCodePage (USER32.246)
694 UINT WINAPI
GetKBCodePage(void)
696 return GetKBCodePage16();
699 /****************************************************************************
700 * GetKeyboardLayoutName16 (USER.477)
702 INT16 WINAPI
GetKeyboardLayoutName16(LPSTR pwszKLID
)
704 return GetKeyboardLayoutNameA(pwszKLID
);
707 /***********************************************************************
708 * GetKeyboardLayout (USER32.250)
710 * FIXME: - device handle for keyboard layout defaulted to
711 * the language id. This is the way Windows default works.
712 * - the thread identifier (dwLayout) is also ignored.
714 HKL WINAPI
GetKeyboardLayout(DWORD dwLayout
)
717 layout
= GetSystemDefaultLCID(); /* FIXME */
718 layout
|= (layout
<<16); /* FIXME */
719 TRACE_(keyboard
)("returning %08x\n",layout
);
723 /****************************************************************************
724 * GetKeyboardLayoutNameA (USER32.252)
726 INT WINAPI
GetKeyboardLayoutNameA(LPSTR pwszKLID
)
728 sprintf(pwszKLID
, "%08x",GetKeyboardLayout(0));
732 /****************************************************************************
733 * GetKeyboardLayoutNameW (USER32.253)
735 INT WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID
)
738 int res
= GetKeyboardLayoutNameA(buf
);
739 lstrcpyAtoW(pwszKLID
,buf
);
743 /****************************************************************************
744 * GetKeyNameTextA (USER32.247)
746 INT WINAPI
GetKeyNameTextA(LONG lParam
, LPSTR lpBuffer
, INT nSize
)
748 return GetKeyNameText16(lParam
,lpBuffer
,nSize
);
751 /****************************************************************************
752 * GetKeyNameTextW (USER32.248)
754 INT WINAPI
GetKeyNameTextW(LONG lParam
, LPWSTR lpBuffer
, INT nSize
)
757 LPSTR buf
= HeapAlloc( GetProcessHeap(), 0, nSize
);
758 if(buf
== NULL
) return 0; /* FIXME: is this the correct failure value?*/
759 res
= GetKeyNameTextA(lParam
,buf
,nSize
);
761 lstrcpynAtoW(lpBuffer
,buf
,nSize
);
762 HeapFree( GetProcessHeap(), 0, buf
);
766 /****************************************************************************
767 * ToUnicode (USER32.@)
769 INT WINAPI
ToUnicode(UINT virtKey
, UINT scanCode
, LPBYTE lpKeyState
,
770 LPWSTR lpwStr
, int size
, UINT flags
)
772 return USER_Driver
.pToUnicode(virtKey
, scanCode
, lpKeyState
, lpwStr
, size
, flags
);
775 /****************************************************************************
776 * ToUnicodeEx (USER32.@)
778 INT WINAPI
ToUnicodeEx(UINT virtKey
, UINT scanCode
, LPBYTE lpKeyState
,
779 LPWSTR lpwStr
, int size
, UINT flags
, HKL hkl
)
781 /* FIXME: need true implementation */
782 return ToUnicode(virtKey
, scanCode
, lpKeyState
, lpwStr
, size
, flags
);
785 /****************************************************************************
786 * ToAscii (USER32.546)
788 INT WINAPI
ToAscii( UINT virtKey
,UINT scanCode
,LPBYTE lpKeyState
,
789 LPWORD lpChar
,UINT flags
)
794 ret
= ToUnicode(virtKey
, scanCode
, lpKeyState
, uni_chars
, 2, flags
);
795 if(ret
< 0) n_ret
= 1; /* FIXME: make ToUnicode return 2 for dead chars */
797 WideCharToMultiByte(CP_ACP
, 0, uni_chars
, n_ret
, (LPSTR
)lpChar
, 2, NULL
, NULL
);
801 /****************************************************************************
802 * ToAsciiEx (USER32.547)
804 INT WINAPI
ToAsciiEx( UINT virtKey
, UINT scanCode
, LPBYTE lpKeyState
,
805 LPWORD lpChar
, UINT flags
, HKL dwhkl
)
807 /* FIXME: need true implementation */
808 return ToAscii(virtKey
, scanCode
, lpKeyState
, lpChar
, flags
);
811 /**********************************************************************
812 * ActivateKeyboardLayout (USER32.1)
814 * Call ignored. WINE supports only system default keyboard layout.
816 HKL WINAPI
ActivateKeyboardLayout(HKL hLayout
, UINT flags
)
818 TRACE_(keyboard
)("(%d, %d)\n", hLayout
, flags
);
819 ERR_(keyboard
)("Only default system keyboard layout supported. Call ignored.\n");
824 /***********************************************************************
825 * GetKeyboardLayoutList (USER32.251)
827 * FIXME: Supports only the system default language and layout and
828 * returns only 1 value.
830 * Return number of values available if either input parm is
831 * 0, per MS documentation.
834 INT WINAPI
GetKeyboardLayoutList(INT nBuff
,HKL
*layouts
)
836 TRACE_(keyboard
)("(%d,%p)\n",nBuff
,layouts
);
837 if (!nBuff
|| !layouts
)
840 layouts
[0] = GetKeyboardLayout(0);
845 /***********************************************************************
846 * RegisterHotKey (USER32.433)
848 BOOL WINAPI
RegisterHotKey(HWND hwnd
,INT id
,UINT modifiers
,UINT vk
) {
849 FIXME_(keyboard
)("(0x%08x,%d,0x%08x,%d): stub\n",hwnd
,id
,modifiers
,vk
);
853 /***********************************************************************
854 * UnregisterHotKey (USER32.565)
856 BOOL WINAPI
UnregisterHotKey(HWND hwnd
,INT id
) {
857 FIXME_(keyboard
)("(0x%08x,%d): stub\n",hwnd
,id
);
861 /***********************************************************************
862 * LoadKeyboardLayoutA (USER32.367)
863 * Call ignored. WINE supports only system default keyboard layout.
865 HKL WINAPI
LoadKeyboardLayoutA(LPCSTR pwszKLID
, UINT Flags
)
867 TRACE_(keyboard
)("(%s, %d)\n", pwszKLID
, Flags
);
868 ERR_(keyboard
)("Only default system keyboard layout supported. Call ignored.\n");
872 /***********************************************************************
873 * LoadKeyboardLayoutW (USER32.368)
875 HKL WINAPI
LoadKeyboardLayoutW(LPCWSTR pwszKLID
, UINT Flags
)
879 lstrcpynWtoA(buf
,pwszKLID
,8);
881 return LoadKeyboardLayoutA(buf
, Flags
);