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
22 #include "wine/winbase16.h"
23 #include "wine/winuser16.h"
24 #include "wine/keyboard16.h"
32 #include "debugtools.h"
36 DECLARE_DEBUG_CHANNEL(event
);
37 DECLARE_DEBUG_CHANNEL(key
);
38 DECLARE_DEBUG_CHANNEL(keyboard
);
39 DECLARE_DEBUG_CHANNEL(win
);
41 static BOOL InputEnabled
= TRUE
;
42 BOOL SwappedButtons
= FALSE
;
44 BOOL MouseButtonsStates
[3];
45 BOOL AsyncMouseButtonsStates
[3];
46 BYTE InputKeyStateTable
[256];
47 BYTE QueueKeyStateTable
[256];
48 BYTE AsyncKeyStateTable
[256];
50 /* Storage for the USER-maintained mouse positions */
57 unsigned long count
: 16;
58 unsigned long code
: 8;
59 unsigned long extended
: 1;
60 unsigned long unused
: 2;
61 unsigned long win_internal
: 2;
62 unsigned long context
: 1;
63 unsigned long previous
: 1;
64 unsigned long transition
: 1;
69 /***********************************************************************
70 * keybd_event (USER32.583)
72 void WINAPI
keybd_event( BYTE bVk
, BYTE bScan
,
73 DWORD dwFlags
, DWORD dwExtraInfo
)
80 if (!InputEnabled
) return;
83 * If we are called by the Wine keyboard driver, use the additional
84 * info pointed to by the dwExtraInfo argument.
85 * Otherwise, we need to determine that info ourselves (probably
86 * less accurate, but we can't help that ...).
88 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_KEYBDEVENT
) )
89 && ((WINE_KEYBDEVENT
*)dwExtraInfo
)->magic
== WINE_KEYBDEVENT_MAGIC
)
91 WINE_KEYBDEVENT
*wke
= (WINE_KEYBDEVENT
*)dwExtraInfo
;
97 time
= GetTickCount();
103 keylp
.lp1
.code
= bScan
;
104 keylp
.lp1
.extended
= (dwFlags
& KEYEVENTF_EXTENDEDKEY
) != 0;
105 keylp
.lp1
.win_internal
= 0; /* this has something to do with dialogs,
106 * don't remember where I read it - AK */
107 /* it's '1' under windows, when a dialog box appears
108 * and you press one of the underlined keys - DF*/
110 if ( dwFlags
& KEYEVENTF_KEYUP
)
112 BOOL sysKey
= (InputKeyStateTable
[VK_MENU
] & 0x80)
113 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
114 && !(dwFlags
& KEYEVENTF_WINE_FORCEEXTENDED
); /* for Alt from AltGr */
116 InputKeyStateTable
[bVk
] &= ~0x80;
117 keylp
.lp1
.previous
= 1;
118 keylp
.lp1
.transition
= 1;
119 message
= sysKey
? WM_SYSKEYUP
: WM_KEYUP
;
123 keylp
.lp1
.previous
= (InputKeyStateTable
[bVk
] & 0x80) != 0;
124 keylp
.lp1
.transition
= 0;
126 if (!(InputKeyStateTable
[bVk
] & 0x80))
127 InputKeyStateTable
[bVk
] ^= 0x01;
128 InputKeyStateTable
[bVk
] |= 0x80;
130 message
= (InputKeyStateTable
[VK_MENU
] & 0x80)
131 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
132 ? WM_SYSKEYDOWN
: WM_KEYDOWN
;
135 if ( message
== WM_SYSKEYDOWN
|| message
== WM_SYSKEYUP
)
136 keylp
.lp1
.context
= (InputKeyStateTable
[VK_MENU
] & 0x80) != 0; /* 1 if alt */
139 TRACE_(key
)(" wParam=%04X, lParam=%08lX\n", bVk
, keylp
.lp2
);
140 TRACE_(key
)(" InputKeyState=%X\n", InputKeyStateTable
[bVk
] );
142 hardware_event( message
, bVk
, keylp
.lp2
, PosX
, PosY
, time
, extra
);
145 /***********************************************************************
146 * WIN16_keybd_event (USER.289)
148 void WINAPI
WIN16_keybd_event( CONTEXT86
*context
)
152 if (AH_reg(context
) & 0x80) dwFlags
|= KEYEVENTF_KEYUP
;
153 if (BH_reg(context
) & 1 ) dwFlags
|= KEYEVENTF_EXTENDEDKEY
;
155 keybd_event( AL_reg(context
), BL_reg(context
),
156 dwFlags
, MAKELONG(SI_reg(context
), DI_reg(context
)) );
159 /***********************************************************************
160 * mouse_event (USER32.584)
162 void WINAPI
mouse_event( DWORD dwFlags
, DWORD dx
, DWORD dy
,
163 DWORD cButtons
, DWORD dwExtraInfo
)
168 if (!InputEnabled
) return;
170 if ( dwFlags
& MOUSEEVENTF_MOVE
)
172 if ( dwFlags
& MOUSEEVENTF_ABSOLUTE
)
174 PosX
= (dx
* GetSystemMetrics(SM_CXSCREEN
)) >> 16;
175 PosY
= (dy
* GetSystemMetrics(SM_CYSCREEN
)) >> 16;
179 int width
= GetSystemMetrics(SM_CXSCREEN
);
180 int height
= GetSystemMetrics(SM_CYSCREEN
);
181 long posX
= (long) PosX
, posY
= (long) PosY
;
183 /* dx and dy can be negative numbers for relative movements */
187 /* Clip to the current screen size */
188 if (posX
< 0) PosX
= 0;
189 else if (posX
>= width
) PosX
= width
- 1;
192 if (posY
< 0) PosY
= 0;
193 else if (posY
>= height
) PosY
= height
- 1;
199 * If we are called by the Wine mouse driver, use the additional
200 * info pointed to by the dwExtraInfo argument.
201 * Otherwise, we need to determine that info ourselves (probably
202 * less accurate, but we can't help that ...).
204 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_MOUSEEVENT
) )
205 && ((WINE_MOUSEEVENT
*)dwExtraInfo
)->magic
== WINE_MOUSEEVENT_MAGIC
)
207 WINE_MOUSEEVENT
*wme
= (WINE_MOUSEEVENT
*)dwExtraInfo
;
209 extra
= (DWORD
)wme
->hWnd
;
210 keyState
= wme
->keyState
;
212 if (keyState
!= GET_KEYSTATE()) {
213 /* We need to update the keystate with what X provides us */
214 MouseButtonsStates
[SwappedButtons
? 2 : 0] = (keyState
& MK_LBUTTON
? TRUE
: FALSE
);
215 MouseButtonsStates
[SwappedButtons
? 0 : 2] = (keyState
& MK_RBUTTON
? TRUE
: FALSE
);
216 MouseButtonsStates
[1] = (keyState
& MK_MBUTTON
? TRUE
: FALSE
);
217 InputKeyStateTable
[VK_SHIFT
] = (keyState
& MK_SHIFT
? 0x80 : 0);
218 InputKeyStateTable
[VK_CONTROL
] = (keyState
& MK_CONTROL
? 0x80 : 0);
223 time
= GetTickCount();
225 keyState
= GET_KEYSTATE();
227 if ( dwFlags
& MOUSEEVENTF_MOVE
)
229 /* We have to actually move the cursor */
230 SetCursorPos( PosX
, PosY
);
235 if ( dwFlags
& MOUSEEVENTF_MOVE
)
237 hardware_event( WM_MOUSEMOVE
,
238 keyState
, 0L, PosX
, PosY
, time
, extra
);
240 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTDOWN
: MOUSEEVENTF_RIGHTDOWN
) )
242 MouseButtonsStates
[0] = AsyncMouseButtonsStates
[0] = TRUE
;
243 hardware_event( WM_LBUTTONDOWN
,
244 keyState
, 0L, PosX
, PosY
, time
, extra
);
246 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTUP
: MOUSEEVENTF_RIGHTUP
) )
248 MouseButtonsStates
[0] = FALSE
;
249 hardware_event( WM_LBUTTONUP
,
250 keyState
, 0L, PosX
, PosY
, time
, extra
);
252 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTDOWN
: MOUSEEVENTF_LEFTDOWN
) )
254 MouseButtonsStates
[2] = AsyncMouseButtonsStates
[2] = TRUE
;
255 hardware_event( WM_RBUTTONDOWN
,
256 keyState
, 0L, PosX
, PosY
, time
, extra
);
258 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTUP
: MOUSEEVENTF_LEFTUP
) )
260 MouseButtonsStates
[2] = FALSE
;
261 hardware_event( WM_RBUTTONUP
,
262 keyState
, 0L, PosX
, PosY
, time
, extra
);
264 if ( dwFlags
& MOUSEEVENTF_MIDDLEDOWN
)
266 MouseButtonsStates
[1] = AsyncMouseButtonsStates
[1] = TRUE
;
267 hardware_event( WM_MBUTTONDOWN
,
268 keyState
, 0L, PosX
, PosY
, time
, extra
);
270 if ( dwFlags
& MOUSEEVENTF_MIDDLEUP
)
272 MouseButtonsStates
[1] = FALSE
;
273 hardware_event( WM_MBUTTONUP
,
274 keyState
, 0L, PosX
, PosY
, time
, extra
);
276 if ( dwFlags
& MOUSEEVENTF_WHEEL
)
278 hardware_event( WM_MOUSEWHEEL
,
279 keyState
, 0L, PosX
, PosY
, time
, extra
);
283 /***********************************************************************
284 * WIN16_mouse_event (USER.299)
286 void WINAPI
WIN16_mouse_event( CONTEXT86
*context
)
288 mouse_event( AX_reg(context
), BX_reg(context
), CX_reg(context
),
289 DX_reg(context
), MAKELONG(SI_reg(context
), DI_reg(context
)) );
292 /***********************************************************************
293 * GetMouseEventProc (USER.337)
295 FARPROC16 WINAPI
GetMouseEventProc16(void)
297 HMODULE16 hmodule
= GetModuleHandle16("USER");
298 return GetProcAddress16( hmodule
, "mouse_event" );
302 /**********************************************************************
303 * EnableHardwareInput (USER.331)
305 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
307 BOOL16 bOldState
= InputEnabled
;
308 FIXME_(event
)("(%d) - stub\n", bEnable
);
309 InputEnabled
= bEnable
;
314 /***********************************************************************
315 * SwapMouseButton16 (USER.186)
317 BOOL16 WINAPI
SwapMouseButton16( BOOL16 fSwap
)
319 BOOL16 ret
= SwappedButtons
;
320 SwappedButtons
= fSwap
;
325 /***********************************************************************
326 * SwapMouseButton (USER32.537)
328 BOOL WINAPI
SwapMouseButton( BOOL fSwap
)
330 BOOL ret
= SwappedButtons
;
331 SwappedButtons
= fSwap
;
335 /**********************************************************************
338 * We need this to be able to generate double click messages
339 * when menu code captures mouse in the window without CS_DBLCLK style.
341 HWND
EVENT_Capture(HWND hwnd
, INT16 ht
)
343 HWND capturePrev
= 0, captureWnd
= 0;
344 MESSAGEQUEUE
*pMsgQ
= 0, *pCurMsgQ
= 0;
348 /* Get the messageQ for the current thread */
349 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
351 WARN_(win
)("\tCurrent message queue not found. Exiting!\n" );
355 /* Get the current capture window from the perQ data of the current message Q */
356 capturePrev
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
365 wndPtr
= WIN_FindWndPtr( hwnd
);
368 TRACE_(win
)("(0x%04x)\n", hwnd
);
374 /* Update the perQ capture window and send messages */
375 if( capturePrev
!= captureWnd
)
379 /* Retrieve the message queue associated with this window */
380 pMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( wndPtr
->hmemTaskQ
);
383 WARN_(win
)("\tMessage queue not found. Exiting!\n" );
387 /* Make sure that message queue for the window we are setting capture to
388 * shares the same perQ data as the current threads message queue.
390 if ( pCurMsgQ
->pQData
!= pMsgQ
->pQData
)
394 PERQDATA_SetCaptureWnd( pCurMsgQ
->pQData
, captureWnd
);
395 PERQDATA_SetCaptureInfo( pCurMsgQ
->pQData
, captureHT
);
399 WND
* xwndPtr
= WIN_FindWndPtr( capturePrev
);
400 if( xwndPtr
&& (xwndPtr
->flags
& WIN_ISWIN32
) )
401 SendMessageA( capturePrev
, WM_CAPTURECHANGED
, 0L, hwnd
);
402 WIN_ReleaseWndPtr(xwndPtr
);
407 /* Unlock the queues before returning */
409 QUEUE_Unlock( pMsgQ
);
411 QUEUE_Unlock( pCurMsgQ
);
413 WIN_ReleaseWndPtr(wndPtr
);
418 /**********************************************************************
419 * SetCapture16 (USER.18)
421 HWND16 WINAPI
SetCapture16( HWND16 hwnd
)
423 return (HWND16
)EVENT_Capture( hwnd
, HTCLIENT
);
427 /**********************************************************************
428 * SetCapture (USER32.464)
430 HWND WINAPI
SetCapture( HWND hwnd
)
432 return EVENT_Capture( hwnd
, HTCLIENT
);
436 /**********************************************************************
437 * ReleaseCapture (USER.19) (USER32.439)
439 BOOL WINAPI
ReleaseCapture(void)
441 return (EVENT_Capture( 0, 0 ) != 0);
445 /**********************************************************************
446 * GetCapture16 (USER.236)
448 HWND16 WINAPI
GetCapture16(void)
450 return (HWND16
)GetCapture();
453 /**********************************************************************
454 * GetCapture (USER32.208)
456 HWND WINAPI
GetCapture(void)
458 MESSAGEQUEUE
*pCurMsgQ
= 0;
459 HWND hwndCapture
= 0;
461 /* Get the messageQ for the current thread */
462 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
464 TRACE_(win
)("GetCapture: Current message queue not found. Exiting!\n" );
468 /* Get the current capture window from the perQ data of the current message Q */
469 hwndCapture
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
471 QUEUE_Unlock( pCurMsgQ
);
475 /**********************************************************************
476 * GetKeyState (USER.106)
478 INT16 WINAPI
GetKeyState16(INT16 vkey
)
480 return GetKeyState(vkey
);
483 /**********************************************************************
484 * GetKeyState (USER32.249)
486 * An application calls the GetKeyState function in response to a
487 * keyboard-input message. This function retrieves the state of the key
488 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
490 SHORT WINAPI
GetKeyState(INT vkey
)
496 case VK_LBUTTON
: /* VK_LBUTTON is 1 */
497 retval
= MouseButtonsStates
[0] ? 0x8000 : 0;
499 case VK_MBUTTON
: /* VK_MBUTTON is 4 */
500 retval
= MouseButtonsStates
[1] ? 0x8000 : 0;
502 case VK_RBUTTON
: /* VK_RBUTTON is 2 */
503 retval
= MouseButtonsStates
[2] ? 0x8000 : 0;
506 if (vkey
>= 'a' && vkey
<= 'z')
508 retval
= ( (WORD
)(QueueKeyStateTable
[vkey
] & 0x80) << 8 ) |
509 (WORD
)(QueueKeyStateTable
[vkey
] & 0x01);
511 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
515 /**********************************************************************
516 * GetKeyboardState (USER.222)(USER32.254)
518 * An application calls the GetKeyboardState function in response to a
519 * keyboard-input message. This function retrieves the state of the keyboard
520 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
522 BOOL WINAPI
GetKeyboardState(LPBYTE lpKeyState
)
524 TRACE_(key
)("(%p)\n", lpKeyState
);
525 if (lpKeyState
!= NULL
) {
526 QueueKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
527 QueueKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
528 QueueKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
529 memcpy(lpKeyState
, QueueKeyStateTable
, 256);
535 /**********************************************************************
536 * SetKeyboardState (USER.223)(USER32.484)
538 BOOL WINAPI
SetKeyboardState(LPBYTE lpKeyState
)
540 TRACE_(key
)("(%p)\n", lpKeyState
);
541 if (lpKeyState
!= NULL
) {
542 memcpy(QueueKeyStateTable
, lpKeyState
, 256);
543 MouseButtonsStates
[0] = (QueueKeyStateTable
[VK_LBUTTON
] != 0);
544 MouseButtonsStates
[1] = (QueueKeyStateTable
[VK_MBUTTON
] != 0);
545 MouseButtonsStates
[2] = (QueueKeyStateTable
[VK_RBUTTON
] != 0);
551 /**********************************************************************
552 * GetAsyncKeyState (USER32.207)
554 * Determine if a key is or was pressed. retval has high-order
555 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
558 * This uses the variable AsyncMouseButtonsStates and
559 * AsyncKeyStateTable (set in event.c) which have the mouse button
560 * number or key number (whichever is applicable) set to true if the
561 * mouse or key had been depressed since the last call to
564 WORD WINAPI
GetAsyncKeyState(INT nKey
)
570 retval
= (AsyncMouseButtonsStates
[0] ? 0x0001 : 0) |
571 (MouseButtonsStates
[0] ? 0x8000 : 0);
574 retval
= (AsyncMouseButtonsStates
[1] ? 0x0001 : 0) |
575 (MouseButtonsStates
[1] ? 0x8000 : 0);
578 retval
= (AsyncMouseButtonsStates
[2] ? 0x0001 : 0) |
579 (MouseButtonsStates
[2] ? 0x8000 : 0);
582 retval
= AsyncKeyStateTable
[nKey
] |
583 ((InputKeyStateTable
[nKey
] & 0x80) ? 0x8000 : 0);
587 /* all states to false */
588 memset( AsyncMouseButtonsStates
, 0, sizeof(AsyncMouseButtonsStates
) );
589 memset( AsyncKeyStateTable
, 0, sizeof(AsyncKeyStateTable
) );
591 TRACE_(key
)("(%x) -> %x\n", nKey
, retval
);
595 /**********************************************************************
596 * GetAsyncKeyState16 (USER.249)
598 WORD WINAPI
GetAsyncKeyState16(INT16 nKey
)
600 return GetAsyncKeyState(nKey
);
603 /***********************************************************************
604 * IsUserIdle (USER.333)
606 BOOL16 WINAPI
IsUserIdle16(void)
608 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
611 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
614 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
617 /* Should check for screen saver activation here ... */
622 /**********************************************************************
623 * VkKeyScanA (USER32.573)
625 WORD WINAPI
VkKeyScanA(CHAR cChar
)
627 return VkKeyScan16(cChar
);
630 /******************************************************************************
631 * VkKeyScanW (USER32.576)
633 WORD WINAPI
VkKeyScanW(WCHAR cChar
)
635 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
638 /**********************************************************************
639 * VkKeyScanExA (USER32.574)
641 WORD WINAPI
VkKeyScanExA(CHAR cChar
, HKL dwhkl
)
643 /* FIXME: complete workaround this is */
644 return VkKeyScan16(cChar
);
647 /******************************************************************************
648 * VkKeyScanExW (USER32.575)
650 WORD WINAPI
VkKeyScanExW(WCHAR cChar
, HKL dwhkl
)
652 /* FIXME: complete workaround this is */
653 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
656 /******************************************************************************
657 * GetKeyboardType (USER32.255)
659 INT WINAPI
GetKeyboardType(INT nTypeFlag
)
661 return GetKeyboardType16(nTypeFlag
);
664 /******************************************************************************
665 * MapVirtualKeyA (USER32.383)
667 UINT WINAPI
MapVirtualKeyA(UINT code
, UINT maptype
)
669 return MapVirtualKey16(code
,maptype
);
672 /******************************************************************************
673 * MapVirtualKeyW (USER32.385)
675 UINT WINAPI
MapVirtualKeyW(UINT code
, UINT maptype
)
677 return MapVirtualKey16(code
,maptype
);
680 /******************************************************************************
681 * MapVirtualKeyExA (USER32.384)
683 UINT WINAPI
MapVirtualKeyExA(UINT code
, UINT maptype
, HKL hkl
)
686 FIXME_(keyboard
)("(%d,%d,0x%08lx), hkl unhandled!\n",code
,maptype
,(DWORD
)hkl
);
687 return MapVirtualKey16(code
,maptype
);
690 /****************************************************************************
691 * GetKBCodePage (USER32.246)
693 UINT WINAPI
GetKBCodePage(void)
695 return GetKBCodePage16();
698 /****************************************************************************
699 * GetKeyboardLayoutName16 (USER.477)
701 INT16 WINAPI
GetKeyboardLayoutName16(LPSTR pwszKLID
)
703 return GetKeyboardLayoutNameA(pwszKLID
);
706 /***********************************************************************
707 * GetKeyboardLayout (USER32.250)
709 * FIXME: - device handle for keyboard layout defaulted to
710 * the language id. This is the way Windows default works.
711 * - the thread identifier (dwLayout) is also ignored.
713 HKL WINAPI
GetKeyboardLayout(DWORD dwLayout
)
716 layout
= GetSystemDefaultLCID(); /* FIXME */
717 layout
|= (layout
<<16); /* FIXME */
718 TRACE_(keyboard
)("returning %08x\n",layout
);
722 /****************************************************************************
723 * GetKeyboardLayoutNameA (USER32.252)
725 INT WINAPI
GetKeyboardLayoutNameA(LPSTR pwszKLID
)
727 sprintf(pwszKLID
, "%08x",GetKeyboardLayout(0));
731 /****************************************************************************
732 * GetKeyboardLayoutNameW (USER32.253)
734 INT WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID
)
736 char buf
[KL_NAMELENGTH
];
737 int res
= GetKeyboardLayoutNameA(buf
);
738 MultiByteToWideChar( CP_ACP
, 0, buf
, -1, pwszKLID
, KL_NAMELENGTH
);
742 /****************************************************************************
743 * GetKeyNameTextA (USER32.247)
745 INT WINAPI
GetKeyNameTextA(LONG lParam
, LPSTR lpBuffer
, INT nSize
)
747 return GetKeyNameText16(lParam
,lpBuffer
,nSize
);
750 /****************************************************************************
751 * GetKeyNameTextW (USER32.248)
753 INT WINAPI
GetKeyNameTextW(LONG lParam
, LPWSTR lpBuffer
, INT nSize
)
756 LPSTR buf
= HeapAlloc( GetProcessHeap(), 0, nSize
);
757 if(buf
== NULL
) return 0; /* FIXME: is this the correct failure value?*/
758 res
= GetKeyNameTextA(lParam
,buf
,nSize
);
760 if (nSize
> 0 && !MultiByteToWideChar( CP_ACP
, 0, buf
, -1, lpBuffer
, nSize
))
761 lpBuffer
[nSize
-1] = 0;
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 WideCharToMultiByte( CP_ACP
, 0, pwszKLID
, -1, buf
, sizeof(buf
), NULL
, NULL
);
881 return LoadKeyboardLayoutA(buf
, Flags
);