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 DECLARE_DEBUG_CHANNEL(accel
)
35 DECLARE_DEBUG_CHANNEL(event
)
36 DECLARE_DEBUG_CHANNEL(key
)
37 DECLARE_DEBUG_CHANNEL(keyboard
)
38 DECLARE_DEBUG_CHANNEL(win
)
40 static BOOL InputEnabled
= TRUE
;
41 static BOOL SwappedButtons
= FALSE
;
43 BOOL MouseButtonsStates
[3];
44 BOOL AsyncMouseButtonsStates
[3];
45 BYTE InputKeyStateTable
[256];
46 BYTE QueueKeyStateTable
[256];
47 BYTE AsyncKeyStateTable
[256];
53 unsigned long count
: 16;
54 unsigned long code
: 8;
55 unsigned long extended
: 1;
56 unsigned long unused
: 2;
57 unsigned long win_internal
: 2;
58 unsigned long context
: 1;
59 unsigned long previous
: 1;
60 unsigned long transition
: 1;
65 /***********************************************************************
66 * keybd_event (USER32.583)
68 void WINAPI
keybd_event( BYTE bVk
, BYTE bScan
,
69 DWORD dwFlags
, DWORD dwExtraInfo
)
71 DWORD posX
, posY
, time
, extra
;
76 if (!InputEnabled
) return;
79 * If we are called by the Wine keyboard driver, use the additional
80 * info pointed to by the dwExtraInfo argument.
81 * Otherwise, we need to determine that info ourselves (probably
82 * less accurate, but we can't help that ...).
84 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_KEYBDEVENT
) )
85 && ((WINE_KEYBDEVENT
*)dwExtraInfo
)->magic
== WINE_KEYBDEVENT_MAGIC
)
87 WINE_KEYBDEVENT
*wke
= (WINE_KEYBDEVENT
*)dwExtraInfo
;
96 time
= GetTickCount();
99 if ( !EVENT_QueryPointer( &posX
, &posY
, &keyState
))
105 keylp
.lp1
.code
= bScan
;
106 keylp
.lp1
.extended
= (dwFlags
& KEYEVENTF_EXTENDEDKEY
) != 0;
107 keylp
.lp1
.win_internal
= 0; /* this has something to do with dialogs,
108 * don't remember where I read it - AK */
109 /* it's '1' under windows, when a dialog box appears
110 * and you press one of the underlined keys - DF*/
112 if ( dwFlags
& KEYEVENTF_KEYUP
)
114 BOOL sysKey
= (InputKeyStateTable
[VK_MENU
] & 0x80)
115 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
116 && !(dwFlags
& KEYEVENTF_WINE_FORCEEXTENDED
); /* for Alt from AltGr */
118 InputKeyStateTable
[bVk
] &= ~0x80;
119 keylp
.lp1
.previous
= 1;
120 keylp
.lp1
.transition
= 1;
121 message
= sysKey
? WM_SYSKEYUP
: WM_KEYUP
;
125 keylp
.lp1
.previous
= (InputKeyStateTable
[bVk
] & 0x80) != 0;
126 keylp
.lp1
.transition
= 0;
128 if (!(InputKeyStateTable
[bVk
] & 0x80))
129 InputKeyStateTable
[bVk
] ^= 0x01;
130 InputKeyStateTable
[bVk
] |= 0x80;
132 message
= (InputKeyStateTable
[VK_MENU
] & 0x80)
133 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
134 ? WM_SYSKEYDOWN
: WM_KEYDOWN
;
137 if ( message
== WM_SYSKEYDOWN
|| message
== WM_SYSKEYUP
)
138 keylp
.lp1
.context
= (InputKeyStateTable
[VK_MENU
] & 0x80) != 0; /* 1 if alt */
141 TRACE(key
, " wParam=%04X, lParam=%08lX\n", bVk
, keylp
.lp2
);
142 TRACE(key
, " InputKeyState=%X\n", InputKeyStateTable
[bVk
] );
144 hardware_event( message
, bVk
, keylp
.lp2
, posX
, posY
, time
, extra
);
147 /***********************************************************************
148 * mouse_event (USER32.584)
150 void WINAPI
mouse_event( DWORD dwFlags
, DWORD dx
, DWORD dy
,
151 DWORD cButtons
, DWORD dwExtraInfo
)
153 DWORD posX
, posY
, keyState
, time
, extra
;
155 if (!InputEnabled
) return;
158 * If we are called by the Wine mouse driver, use the additional
159 * info pointed to by the dwExtraInfo argument.
160 * Otherwise, we need to determine that info ourselves (probably
161 * less accurate, but we can't help that ...).
163 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_MOUSEEVENT
) )
164 && ((WINE_MOUSEEVENT
*)dwExtraInfo
)->magic
== WINE_MOUSEEVENT_MAGIC
)
166 WINE_MOUSEEVENT
*wme
= (WINE_MOUSEEVENT
*)dwExtraInfo
;
167 keyState
= wme
->keyState
;
169 extra
= (DWORD
)wme
->hWnd
;
171 assert( dwFlags
& MOUSEEVENTF_ABSOLUTE
);
172 posX
= (dx
* SYSMETRICS_CXSCREEN
) >> 16;
173 posY
= (dy
* SYSMETRICS_CYSCREEN
) >> 16;
177 time
= GetTickCount();
180 if ( !EVENT_QueryPointer( &posX
, &posY
, &keyState
))
183 if ( dwFlags
& MOUSEEVENTF_MOVE
)
185 if ( dwFlags
& MOUSEEVENTF_ABSOLUTE
)
187 posX
= (dx
* SYSMETRICS_CXSCREEN
) >> 16;
188 posY
= (dy
* SYSMETRICS_CYSCREEN
) >> 16;
195 /* We have to actually move the cursor */
196 SetCursorPos( posX
, posY
);
200 if ( dwFlags
& MOUSEEVENTF_MOVE
)
202 hardware_event( WM_MOUSEMOVE
,
203 keyState
, 0L, posX
, posY
, time
, extra
);
205 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTDOWN
: MOUSEEVENTF_RIGHTDOWN
) )
207 MouseButtonsStates
[0] = AsyncMouseButtonsStates
[0] = TRUE
;
208 hardware_event( WM_LBUTTONDOWN
,
209 keyState
, 0L, posX
, posY
, time
, extra
);
211 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTUP
: MOUSEEVENTF_RIGHTUP
) )
213 MouseButtonsStates
[0] = FALSE
;
214 hardware_event( WM_LBUTTONUP
,
215 keyState
, 0L, posX
, posY
, time
, extra
);
217 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTDOWN
: MOUSEEVENTF_LEFTDOWN
) )
219 MouseButtonsStates
[2] = AsyncMouseButtonsStates
[2] = TRUE
;
220 hardware_event( WM_RBUTTONDOWN
,
221 keyState
, 0L, posX
, posY
, time
, extra
);
223 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTUP
: MOUSEEVENTF_LEFTUP
) )
225 MouseButtonsStates
[2] = FALSE
;
226 hardware_event( WM_RBUTTONUP
,
227 keyState
, 0L, posX
, posY
, time
, extra
);
229 if ( dwFlags
& MOUSEEVENTF_MIDDLEDOWN
)
231 MouseButtonsStates
[1] = AsyncMouseButtonsStates
[1] = TRUE
;
232 hardware_event( WM_MBUTTONDOWN
,
233 keyState
, 0L, posX
, posY
, time
, extra
);
235 if ( dwFlags
& MOUSEEVENTF_MIDDLEUP
)
237 MouseButtonsStates
[1] = FALSE
;
238 hardware_event( WM_MBUTTONUP
,
239 keyState
, 0L, posX
, posY
, time
, extra
);
243 /**********************************************************************
244 * EnableHardwareInput (USER.331)
246 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
248 BOOL16 bOldState
= InputEnabled
;
249 FIXME(event
,"(%d) - stub\n", bEnable
);
250 InputEnabled
= bEnable
;
255 /***********************************************************************
256 * SwapMouseButton16 (USER.186)
258 BOOL16 WINAPI
SwapMouseButton16( BOOL16 fSwap
)
260 BOOL16 ret
= SwappedButtons
;
261 SwappedButtons
= fSwap
;
266 /***********************************************************************
267 * SwapMouseButton32 (USER32.537)
269 BOOL WINAPI
SwapMouseButton( BOOL fSwap
)
271 BOOL ret
= SwappedButtons
;
272 SwappedButtons
= fSwap
;
276 /**********************************************************************
279 * We need this to be able to generate double click messages
280 * when menu code captures mouse in the window without CS_DBLCLK style.
282 HWND
EVENT_Capture(HWND hwnd
, INT16 ht
)
284 HWND capturePrev
= 0, captureWnd
= 0;
285 MESSAGEQUEUE
*pMsgQ
= 0, *pCurMsgQ
= 0;
289 /* Get the messageQ for the current thread */
290 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
292 WARN( win
, "\tCurrent message queue not found. Exiting!\n" );
296 /* Get the current capture window from the perQ data of the current message Q */
297 capturePrev
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
306 wndPtr
= WIN_FindWndPtr( hwnd
);
309 TRACE(win
, "(0x%04x)\n", hwnd
);
315 /* Update the perQ capture window and send messages */
316 if( capturePrev
!= captureWnd
)
320 /* Retrieve the message queue associated with this window */
321 pMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( wndPtr
->hmemTaskQ
);
324 WARN( win
, "\tMessage queue not found. Exiting!\n" );
328 /* Make sure that message queue for the window we are setting capture to
329 * shares the same perQ data as the current threads message queue.
331 if ( pCurMsgQ
->pQData
!= pMsgQ
->pQData
)
335 PERQDATA_SetCaptureWnd( pCurMsgQ
->pQData
, captureWnd
);
336 PERQDATA_SetCaptureInfo( pCurMsgQ
->pQData
, captureHT
);
340 WND
* wndPtr
= WIN_FindWndPtr( capturePrev
);
341 if( wndPtr
&& (wndPtr
->flags
& WIN_ISWIN32
) )
342 SendMessageA( capturePrev
, WM_CAPTURECHANGED
, 0L, hwnd
);
343 WIN_ReleaseWndPtr(wndPtr
);
348 /* Unlock the queues before returning */
350 QUEUE_Unlock( pMsgQ
);
352 QUEUE_Unlock( pCurMsgQ
);
354 WIN_ReleaseWndPtr(wndPtr
);
359 /**********************************************************************
360 * SetCapture16 (USER.18)
362 HWND16 WINAPI
SetCapture16( HWND16 hwnd
)
364 return (HWND16
)EVENT_Capture( hwnd
, HTCLIENT
);
368 /**********************************************************************
369 * SetCapture32 (USER32.464)
371 HWND WINAPI
SetCapture( HWND hwnd
)
373 return EVENT_Capture( hwnd
, HTCLIENT
);
377 /**********************************************************************
378 * ReleaseCapture (USER.19) (USER32.439)
380 BOOL WINAPI
ReleaseCapture(void)
382 return (EVENT_Capture( 0, 0 ) != 0);
386 /**********************************************************************
387 * GetCapture16 (USER.236)
389 HWND16 WINAPI
GetCapture16(void)
391 return (HWND16
)GetCapture();
394 /**********************************************************************
395 * GetCapture32 (USER32.208)
397 HWND WINAPI
GetCapture(void)
399 MESSAGEQUEUE
*pCurMsgQ
= 0;
400 HWND hwndCapture
= 0;
402 /* Get the messageQ for the current thread */
403 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
405 TRACE( win
, "GetCapture32: Current message queue not found. Exiting!\n" );
409 /* Get the current capture window from the perQ data of the current message Q */
410 hwndCapture
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
412 QUEUE_Unlock( pCurMsgQ
);
416 /**********************************************************************
417 * GetKeyState (USER.106)
419 INT16 WINAPI
GetKeyState16(INT16 vkey
)
421 return GetKeyState(vkey
);
424 /**********************************************************************
425 * GetKeyState (USER32.249)
427 * An application calls the GetKeyState function in response to a
428 * keyboard-input message. This function retrieves the state of the key
429 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
431 INT16 WINAPI
GetKeyState(INT vkey
)
437 case VK_LBUTTON
: /* VK_LBUTTON is 1 */
438 retval
= MouseButtonsStates
[0] ? 0x8000 : 0;
440 case VK_MBUTTON
: /* VK_MBUTTON is 4 */
441 retval
= MouseButtonsStates
[1] ? 0x8000 : 0;
443 case VK_RBUTTON
: /* VK_RBUTTON is 2 */
444 retval
= MouseButtonsStates
[2] ? 0x8000 : 0;
447 if (vkey
>= 'a' && vkey
<= 'z')
449 retval
= ( (WORD
)(QueueKeyStateTable
[vkey
] & 0x80) << 8 ) |
450 (WORD
)(QueueKeyStateTable
[vkey
] & 0x01);
452 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
456 /**********************************************************************
457 * GetKeyboardState (USER.222)(USER32.254)
459 * An application calls the GetKeyboardState function in response to a
460 * keyboard-input message. This function retrieves the state of the keyboard
461 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
463 VOID WINAPI
GetKeyboardState(LPBYTE lpKeyState
)
465 TRACE(key
, "(%p)\n", lpKeyState
);
466 if (lpKeyState
!= NULL
) {
467 QueueKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
468 QueueKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
469 QueueKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
470 memcpy(lpKeyState
, QueueKeyStateTable
, 256);
474 /**********************************************************************
475 * SetKeyboardState (USER.223)(USER32.484)
477 VOID WINAPI
SetKeyboardState(LPBYTE lpKeyState
)
479 TRACE(key
, "(%p)\n", lpKeyState
);
480 if (lpKeyState
!= NULL
) {
481 memcpy(QueueKeyStateTable
, lpKeyState
, 256);
482 MouseButtonsStates
[0] = (QueueKeyStateTable
[VK_LBUTTON
] != 0);
483 MouseButtonsStates
[1] = (QueueKeyStateTable
[VK_MBUTTON
] != 0);
484 MouseButtonsStates
[2] = (QueueKeyStateTable
[VK_RBUTTON
] != 0);
488 /**********************************************************************
489 * GetAsyncKeyState32 (USER32.207)
491 * Determine if a key is or was pressed. retval has high-order
492 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
495 * This uses the variable AsyncMouseButtonsStates and
496 * AsyncKeyStateTable (set in event.c) which have the mouse button
497 * number or key number (whichever is applicable) set to true if the
498 * mouse or key had been depressed since the last call to
501 WORD WINAPI
GetAsyncKeyState(INT nKey
)
507 retval
= (AsyncMouseButtonsStates
[0] ? 0x0001 : 0) |
508 (MouseButtonsStates
[0] ? 0x8000 : 0);
511 retval
= (AsyncMouseButtonsStates
[1] ? 0x0001 : 0) |
512 (MouseButtonsStates
[1] ? 0x8000 : 0);
515 retval
= (AsyncMouseButtonsStates
[2] ? 0x0001 : 0) |
516 (MouseButtonsStates
[2] ? 0x8000 : 0);
519 retval
= AsyncKeyStateTable
[nKey
] |
520 ((InputKeyStateTable
[nKey
] & 0x80) ? 0x8000 : 0);
524 /* all states to false */
525 memset( AsyncMouseButtonsStates
, 0, sizeof(AsyncMouseButtonsStates
) );
526 memset( AsyncKeyStateTable
, 0, sizeof(AsyncKeyStateTable
) );
528 TRACE(key
, "(%x) -> %x\n", nKey
, retval
);
532 /**********************************************************************
533 * GetAsyncKeyState16 (USER.249)
535 WORD WINAPI
GetAsyncKeyState16(INT16 nKey
)
537 return GetAsyncKeyState(nKey
);
540 /**********************************************************************
541 * KBD_translate_accelerator
543 * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
545 static BOOL
KBD_translate_accelerator(HWND hWnd
,LPMSG msg
,
546 BYTE fVirt
,WORD key
,WORD cmd
)
548 BOOL sendmsg
= FALSE
;
550 if(msg
->wParam
== key
)
552 if (msg
->message
== WM_CHAR
) {
553 if ( !(fVirt
& FALT
) && !(fVirt
& FVIRTKEY
) )
555 TRACE(accel
,"found accel for WM_CHAR: ('%c')\n",
560 if(fVirt
& FVIRTKEY
) {
562 TRACE(accel
,"found accel for virt_key %04x (scan %04x)\n",
563 msg
->wParam
,0xff & HIWORD(msg
->lParam
));
564 if(GetKeyState(VK_SHIFT
) & 0x8000) mask
|= FSHIFT
;
565 if(GetKeyState(VK_CONTROL
) & 0x8000) mask
|= FCONTROL
;
566 if(GetKeyState(VK_MENU
) & 0x8000) mask
|= FALT
;
567 if(mask
== (fVirt
& (FSHIFT
| FCONTROL
| FALT
)))
570 TRACE(accel
,", but incorrect SHIFT/CTRL/ALT-state\n");
574 if (!(msg
->lParam
& 0x01000000)) /* no special_key */
576 if ((fVirt
& FALT
) && (msg
->lParam
& 0x20000000))
577 { /* ^^ ALT pressed */
578 TRACE(accel
,"found accel for Alt-%c\n", msg
->wParam
&0xff);
585 if (sendmsg
) /* found an accelerator, but send a message... ? */
587 INT16 iSysStat
,iStat
,mesg
=0;
590 if (msg
->message
== WM_KEYUP
|| msg
->message
== WM_SYSKEYUP
)
596 if (!IsWindowEnabled(hWnd
))
600 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
602 hMenu
= (wndPtr
->dwStyle
& WS_CHILD
) ? 0 : (HMENU
)wndPtr
->wIDmenu
;
603 iSysStat
= (wndPtr
->hSysMenu
) ? GetMenuState(GetSubMenu16(wndPtr
->hSysMenu
, 0),
604 cmd
, MF_BYCOMMAND
) : -1 ;
605 iStat
= (hMenu
) ? GetMenuState(hMenu
,
606 cmd
, MF_BYCOMMAND
) : -1 ;
608 WIN_ReleaseWndPtr(wndPtr
);
612 if (iSysStat
& (MF_DISABLED
|MF_GRAYED
))
625 if (iStat
& (MF_DISABLED
|MF_GRAYED
))
635 if ( mesg
==WM_COMMAND
|| mesg
==WM_SYSCOMMAND
)
637 TRACE(accel
,", sending %s, wParam=%0x\n",
638 mesg
==WM_COMMAND
? "WM_COMMAND" : "WM_SYSCOMMAND",
640 SendMessageA(hWnd
, mesg
, cmd
, 0x00010000L
);
644 /* some reasons for NOT sending the WM_{SYS}COMMAND message:
645 * #0: unknown (please report!)
646 * #1: for WM_KEYUP,WM_SYSKEYUP
647 * #2: mouse is captured
648 * #3: window is disabled
649 * #4: it's a disabled system menu option
650 * #5: it's a menu option, but window is iconic
651 * #6: it's a menu option, but disabled
653 TRACE(accel
,", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg
);
655 ERR(accel
, " unknown reason - please report!");
663 /**********************************************************************
664 * TranslateAccelerator32 (USER32.551)(USER32.552)(USER32.553)
666 INT WINAPI
TranslateAccelerator(HWND hWnd
, HACCEL hAccel
, LPMSG msg
)
669 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
672 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
);
674 if (hAccel
== 0 || msg
== NULL
||
675 (msg
->message
!= WM_KEYDOWN
&&
676 msg
->message
!= WM_KEYUP
&&
677 msg
->message
!= WM_SYSKEYDOWN
&&
678 msg
->message
!= WM_SYSKEYUP
&&
679 msg
->message
!= WM_CHAR
)) {
680 WARN(accel
, "erraneous input parameters\n");
681 SetLastError(ERROR_INVALID_PARAMETER
);
685 TRACE(accel
, "TranslateAccelerators hAccel=%04x, hWnd=%04x,"
686 "msg->hwnd=%04x, msg->message=%04x\n",
687 hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
692 if (KBD_translate_accelerator(hWnd
,msg
,lpAccelTbl
[i
].fVirt
,
693 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
695 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
696 WARN(accel
, "couldn't translate accelerator key\n");
700 /**********************************************************************
701 * TranslateAccelerator16 (USER.178)
703 INT16 WINAPI
TranslateAccelerator16(HWND16 hWnd
, HACCEL16 hAccel
, LPMSG16 msg
)
705 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
709 if (hAccel
== 0 || msg
== NULL
||
710 (msg
->message
!= WM_KEYDOWN
&&
711 msg
->message
!= WM_KEYUP
&&
712 msg
->message
!= WM_SYSKEYDOWN
&&
713 msg
->message
!= WM_SYSKEYUP
&&
714 msg
->message
!= WM_CHAR
)) {
715 WARN(accel
, "erraneous input parameters\n");
716 SetLastError(ERROR_INVALID_PARAMETER
);
720 TRACE(accel
, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
721 msg->hwnd=%04x, msg->message=%04x\n", hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
722 STRUCT32_MSG16to32(msg
,&msg32
);
728 if (KBD_translate_accelerator(hWnd
,&msg32
,lpAccelTbl
[i
].fVirt
,
729 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
731 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
732 WARN(accel
, "couldn't translate accelerator key\n");
737 /**********************************************************************
738 * VkKeyScanA (USER32.573)
740 WORD WINAPI
VkKeyScanA(CHAR cChar
)
742 return VkKeyScan16(cChar
);
745 /******************************************************************************
746 * VkKeyScanW (USER32.576)
748 WORD WINAPI
VkKeyScanW(WCHAR cChar
)
750 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
753 /**********************************************************************
754 * VkKeyScanExA (USER32.574)
756 WORD WINAPI
VkKeyScanExA(CHAR cChar
, HKL dwhkl
)
758 /* FIXME: complete workaround this is */
759 return VkKeyScan16(cChar
);
762 /******************************************************************************
763 * VkKeyScanExW (USER32.575)
765 WORD WINAPI
VkKeyScanExW(WCHAR cChar
, HKL dwhkl
)
767 /* FIXME: complete workaround this is */
768 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
771 /******************************************************************************
772 * GetKeyboardType32 (USER32.255)
774 INT WINAPI
GetKeyboardType(INT nTypeFlag
)
776 return GetKeyboardType16(nTypeFlag
);
779 /******************************************************************************
780 * MapVirtualKey32A (USER32.383)
782 UINT WINAPI
MapVirtualKeyA(UINT code
, UINT maptype
)
784 return MapVirtualKey16(code
,maptype
);
787 /******************************************************************************
788 * MapVirtualKey32W (USER32.385)
790 UINT WINAPI
MapVirtualKeyW(UINT code
, UINT maptype
)
792 return MapVirtualKey16(code
,maptype
);
795 /******************************************************************************
796 * MapVirtualKeyEx32A (USER32.384)
798 UINT WINAPI
MapVirtualKeyEx32A(UINT code
, UINT maptype
, HKL hkl
)
801 FIXME(keyboard
,"(%d,%d,0x%08lx), hkl unhandled!\n",code
,maptype
,(DWORD
)hkl
);
802 return MapVirtualKey16(code
,maptype
);
805 /****************************************************************************
806 * GetKBCodePage32 (USER32.246)
808 UINT WINAPI
GetKBCodePage(void)
810 return GetKBCodePage16();
813 /****************************************************************************
814 * GetKeyboardLayoutName16 (USER.477)
816 INT16 WINAPI
GetKeyboardLayoutName16(LPSTR pwszKLID
)
818 return GetKeyboardLayoutNameA(pwszKLID
);
821 /***********************************************************************
822 * GetKeyboardLayout (USER32.250)
824 * FIXME: - device handle for keyboard layout defaulted to
825 * the language id. This is the way Windows default works.
826 * - the thread identifier (dwLayout) is also ignored.
828 HKL WINAPI
GetKeyboardLayout(DWORD dwLayout
)
831 layout
= GetSystemDefaultLCID(); /* FIXME */
832 layout
|= (layout
<<16); /* FIXME */
833 TRACE(keyboard
,"returning %08x\n",layout
);
837 /****************************************************************************
838 * GetKeyboardLayoutName32A (USER32.252)
840 INT WINAPI
GetKeyboardLayoutNameA(LPSTR pwszKLID
)
842 sprintf(pwszKLID
, "%08x",GetKeyboardLayout(0));
846 /****************************************************************************
847 * GetKeyboardLayoutName32W (USER32.253)
849 INT WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID
)
851 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
852 int res
= GetKeyboardLayoutNameA(buf
);
853 lstrcpyAtoW(pwszKLID
,buf
);
854 HeapFree( GetProcessHeap(), 0, buf
);
858 /****************************************************************************
859 * GetKeyNameText32A (USER32.247)
861 INT WINAPI
GetKeyNameTextA(LONG lParam
, LPSTR lpBuffer
, INT nSize
)
863 return GetKeyNameText16(lParam
,lpBuffer
,nSize
);
866 /****************************************************************************
867 * GetKeyNameText32W (USER32.248)
869 INT WINAPI
GetKeyNameTextW(LONG lParam
, LPWSTR lpBuffer
, INT nSize
)
871 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, nSize
);
872 int res
= GetKeyNameTextA(lParam
,buf
,nSize
);
874 lstrcpynAtoW(lpBuffer
,buf
,nSize
);
875 HeapFree( GetProcessHeap(), 0, buf
);
879 /****************************************************************************
880 * ToAscii32 (USER32.546)
882 INT WINAPI
ToAscii( UINT virtKey
,UINT scanCode
,LPBYTE lpKeyState
,
883 LPWORD lpChar
,UINT flags
)
885 return ToAscii16(virtKey
,scanCode
,lpKeyState
,lpChar
,flags
);
888 /****************************************************************************
889 * ToAscii32 (USER32.547)
891 INT WINAPI
ToAsciiEx( UINT virtKey
, UINT scanCode
, LPBYTE lpKeyState
,
892 LPWORD lpChar
, UINT flags
, HKL dwhkl
)
894 /* FIXME: need true implementation */
895 return ToAscii16(virtKey
,scanCode
,lpKeyState
,lpChar
,flags
);
898 /**********************************************************************
899 * ActivateKeyboardLayout32 (USER32.1)
901 * Call ignored. WINE supports only system default keyboard layout.
903 HKL WINAPI
ActivateKeyboardLayout(HKL hLayout
, UINT flags
)
905 TRACE(keyboard
, "(%d, %d)\n", hLayout
, flags
);
906 ERR(keyboard
,"Only default system keyboard layout supported. Call ignored.\n");
911 /***********************************************************************
912 * GetKeyboardLayoutList (USER32.251)
914 * FIXME: Supports only the system default language and layout and
915 * returns only 1 value.
917 * Return number of values available if either input parm is
918 * 0, per MS documentation.
921 INT WINAPI
GetKeyboardLayoutList(INT nBuff
,HKL
*layouts
)
923 TRACE(keyboard
,"(%d,%p)\n",nBuff
,layouts
);
924 if (!nBuff
|| !layouts
)
927 layouts
[0] = GetKeyboardLayout(0);
932 /***********************************************************************
933 * RegisterHotKey (USER32.433)
935 BOOL WINAPI
RegisterHotKey(HWND hwnd
,INT id
,UINT modifiers
,UINT vk
) {
936 FIXME(keyboard
,"(0x%08x,%d,0x%08x,%d): stub\n",hwnd
,id
,modifiers
,vk
);
940 /***********************************************************************
941 * UnregisterHotKey (USER32.565)
943 BOOL WINAPI
UnregisterHotKey(HWND hwnd
,INT id
) {
944 FIXME(keyboard
,"(0x%08x,%d): stub\n",hwnd
,id
);
949 /***********************************************************************
950 * ToUnicode32 (USER32.548)
952 INT WINAPI
ToUnicode(
960 FIXME(keyboard
,": stub\n");
964 /***********************************************************************
965 * LoadKeyboardLayout32A (USER32.367)
966 * Call ignored. WINE supports only system default keyboard layout.
968 HKL WINAPI
LoadKeyboardLayoutA(LPCSTR pwszKLID
, UINT Flags
)
970 TRACE(keyboard
, "(%s, %d)\n", pwszKLID
, Flags
);
971 ERR(keyboard
,"Only default system keyboard layout supported. Call ignored.\n");
975 /***********************************************************************
976 * LoadKeyboardLayout32W (USER32.368)
978 HKL WINAPI
LoadKeyboardLayoutW(LPCWSTR pwszKLID
, UINT Flags
)
980 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
982 lstrcpynWtoA(buf
,pwszKLID
,8);
984 res
= LoadKeyboardLayoutA(buf
, Flags
);
985 HeapFree( GetProcessHeap(), 0, buf
);