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 "debugtools.h"
32 DECLARE_DEBUG_CHANNEL(accel
)
33 DECLARE_DEBUG_CHANNEL(event
)
34 DECLARE_DEBUG_CHANNEL(key
)
35 DECLARE_DEBUG_CHANNEL(keyboard
)
36 DECLARE_DEBUG_CHANNEL(win
)
38 static BOOL InputEnabled
= TRUE
;
39 static BOOL SwappedButtons
= FALSE
;
41 BOOL MouseButtonsStates
[3];
42 BOOL AsyncMouseButtonsStates
[3];
43 BYTE InputKeyStateTable
[256];
44 BYTE QueueKeyStateTable
[256];
45 BYTE AsyncKeyStateTable
[256];
51 unsigned long count
: 16;
52 unsigned long code
: 8;
53 unsigned long extended
: 1;
54 unsigned long unused
: 2;
55 unsigned long win_internal
: 2;
56 unsigned long context
: 1;
57 unsigned long previous
: 1;
58 unsigned long transition
: 1;
63 /***********************************************************************
64 * keybd_event (USER32.583)
66 void WINAPI
keybd_event( BYTE bVk
, BYTE bScan
,
67 DWORD dwFlags
, DWORD dwExtraInfo
)
69 DWORD posX
, posY
, time
, extra
;
74 if (!InputEnabled
) return;
77 * If we are called by the Wine keyboard driver, use the additional
78 * info pointed to by the dwExtraInfo argument.
79 * Otherwise, we need to determine that info ourselves (probably
80 * less accurate, but we can't help that ...).
82 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_KEYBDEVENT
) )
83 && ((WINE_KEYBDEVENT
*)dwExtraInfo
)->magic
== WINE_KEYBDEVENT_MAGIC
)
85 WINE_KEYBDEVENT
*wke
= (WINE_KEYBDEVENT
*)dwExtraInfo
;
94 time
= GetTickCount();
97 if ( !EVENT_QueryPointer( &posX
, &posY
, &keyState
))
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 * mouse_event (USER32.584)
148 void WINAPI
mouse_event( DWORD dwFlags
, DWORD dx
, DWORD dy
,
149 DWORD cButtons
, DWORD dwExtraInfo
)
151 DWORD posX
, posY
, keyState
, time
, extra
;
153 if (!InputEnabled
) return;
156 * If we are called by the Wine mouse driver, use the additional
157 * info pointed to by the dwExtraInfo argument.
158 * Otherwise, we need to determine that info ourselves (probably
159 * less accurate, but we can't help that ...).
161 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_MOUSEEVENT
) )
162 && ((WINE_MOUSEEVENT
*)dwExtraInfo
)->magic
== WINE_MOUSEEVENT_MAGIC
)
164 WINE_MOUSEEVENT
*wme
= (WINE_MOUSEEVENT
*)dwExtraInfo
;
165 keyState
= wme
->keyState
;
167 extra
= (DWORD
)wme
->hWnd
;
169 assert( dwFlags
& MOUSEEVENTF_ABSOLUTE
);
170 posX
= (dx
* GetSystemMetrics(SM_CXSCREEN
)) >> 16;
171 posY
= (dy
* GetSystemMetrics(SM_CYSCREEN
)) >> 16;
175 time
= GetTickCount();
178 if ( !EVENT_QueryPointer( &posX
, &posY
, &keyState
))
181 if ( dwFlags
& MOUSEEVENTF_MOVE
)
183 if ( dwFlags
& MOUSEEVENTF_ABSOLUTE
)
185 posX
= (dx
* GetSystemMetrics(SM_CXSCREEN
)) >> 16;
186 posY
= (dy
* GetSystemMetrics(SM_CYSCREEN
)) >> 16;
193 /* We have to actually move the cursor */
194 SetCursorPos( posX
, posY
);
198 if ( dwFlags
& MOUSEEVENTF_MOVE
)
200 hardware_event( WM_MOUSEMOVE
,
201 keyState
, 0L, posX
, posY
, time
, extra
);
203 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTDOWN
: MOUSEEVENTF_RIGHTDOWN
) )
205 MouseButtonsStates
[0] = AsyncMouseButtonsStates
[0] = TRUE
;
206 hardware_event( WM_LBUTTONDOWN
,
207 keyState
, 0L, posX
, posY
, time
, extra
);
209 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTUP
: MOUSEEVENTF_RIGHTUP
) )
211 MouseButtonsStates
[0] = FALSE
;
212 hardware_event( WM_LBUTTONUP
,
213 keyState
, 0L, posX
, posY
, time
, extra
);
215 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTDOWN
: MOUSEEVENTF_LEFTDOWN
) )
217 MouseButtonsStates
[2] = AsyncMouseButtonsStates
[2] = TRUE
;
218 hardware_event( WM_RBUTTONDOWN
,
219 keyState
, 0L, posX
, posY
, time
, extra
);
221 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTUP
: MOUSEEVENTF_LEFTUP
) )
223 MouseButtonsStates
[2] = FALSE
;
224 hardware_event( WM_RBUTTONUP
,
225 keyState
, 0L, posX
, posY
, time
, extra
);
227 if ( dwFlags
& MOUSEEVENTF_MIDDLEDOWN
)
229 MouseButtonsStates
[1] = AsyncMouseButtonsStates
[1] = TRUE
;
230 hardware_event( WM_MBUTTONDOWN
,
231 keyState
, 0L, posX
, posY
, time
, extra
);
233 if ( dwFlags
& MOUSEEVENTF_MIDDLEUP
)
235 MouseButtonsStates
[1] = FALSE
;
236 hardware_event( WM_MBUTTONUP
,
237 keyState
, 0L, posX
, posY
, time
, extra
);
241 /**********************************************************************
242 * EnableHardwareInput (USER.331)
244 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
246 BOOL16 bOldState
= InputEnabled
;
247 FIXME_(event
)("(%d) - stub\n", bEnable
);
248 InputEnabled
= bEnable
;
253 /***********************************************************************
254 * SwapMouseButton16 (USER.186)
256 BOOL16 WINAPI
SwapMouseButton16( BOOL16 fSwap
)
258 BOOL16 ret
= SwappedButtons
;
259 SwappedButtons
= fSwap
;
264 /***********************************************************************
265 * SwapMouseButton32 (USER32.537)
267 BOOL WINAPI
SwapMouseButton( BOOL fSwap
)
269 BOOL ret
= SwappedButtons
;
270 SwappedButtons
= fSwap
;
274 /**********************************************************************
277 * We need this to be able to generate double click messages
278 * when menu code captures mouse in the window without CS_DBLCLK style.
280 HWND
EVENT_Capture(HWND hwnd
, INT16 ht
)
282 HWND capturePrev
= 0, captureWnd
= 0;
283 MESSAGEQUEUE
*pMsgQ
= 0, *pCurMsgQ
= 0;
287 /* Get the messageQ for the current thread */
288 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
290 WARN_(win
)("\tCurrent message queue not found. Exiting!\n" );
294 /* Get the current capture window from the perQ data of the current message Q */
295 capturePrev
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
304 wndPtr
= WIN_FindWndPtr( hwnd
);
307 TRACE_(win
)("(0x%04x)\n", hwnd
);
313 /* Update the perQ capture window and send messages */
314 if( capturePrev
!= captureWnd
)
318 /* Retrieve the message queue associated with this window */
319 pMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( wndPtr
->hmemTaskQ
);
322 WARN_(win
)("\tMessage queue not found. Exiting!\n" );
326 /* Make sure that message queue for the window we are setting capture to
327 * shares the same perQ data as the current threads message queue.
329 if ( pCurMsgQ
->pQData
!= pMsgQ
->pQData
)
333 PERQDATA_SetCaptureWnd( pCurMsgQ
->pQData
, captureWnd
);
334 PERQDATA_SetCaptureInfo( pCurMsgQ
->pQData
, captureHT
);
338 WND
* wndPtr
= WIN_FindWndPtr( capturePrev
);
339 if( wndPtr
&& (wndPtr
->flags
& WIN_ISWIN32
) )
340 SendMessageA( capturePrev
, WM_CAPTURECHANGED
, 0L, hwnd
);
341 WIN_ReleaseWndPtr(wndPtr
);
346 /* Unlock the queues before returning */
348 QUEUE_Unlock( pMsgQ
);
350 QUEUE_Unlock( pCurMsgQ
);
352 WIN_ReleaseWndPtr(wndPtr
);
357 /**********************************************************************
358 * SetCapture16 (USER.18)
360 HWND16 WINAPI
SetCapture16( HWND16 hwnd
)
362 return (HWND16
)EVENT_Capture( hwnd
, HTCLIENT
);
366 /**********************************************************************
367 * SetCapture32 (USER32.464)
369 HWND WINAPI
SetCapture( HWND hwnd
)
371 return EVENT_Capture( hwnd
, HTCLIENT
);
375 /**********************************************************************
376 * ReleaseCapture (USER.19) (USER32.439)
378 BOOL WINAPI
ReleaseCapture(void)
380 return (EVENT_Capture( 0, 0 ) != 0);
384 /**********************************************************************
385 * GetCapture16 (USER.236)
387 HWND16 WINAPI
GetCapture16(void)
389 return (HWND16
)GetCapture();
392 /**********************************************************************
393 * GetCapture32 (USER32.208)
395 HWND WINAPI
GetCapture(void)
397 MESSAGEQUEUE
*pCurMsgQ
= 0;
398 HWND hwndCapture
= 0;
400 /* Get the messageQ for the current thread */
401 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
403 TRACE_(win
)("GetCapture32: Current message queue not found. Exiting!\n" );
407 /* Get the current capture window from the perQ data of the current message Q */
408 hwndCapture
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
410 QUEUE_Unlock( pCurMsgQ
);
414 /**********************************************************************
415 * GetKeyState (USER.106)
417 INT16 WINAPI
GetKeyState16(INT16 vkey
)
419 return GetKeyState(vkey
);
422 /**********************************************************************
423 * GetKeyState (USER32.249)
425 * An application calls the GetKeyState function in response to a
426 * keyboard-input message. This function retrieves the state of the key
427 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
429 INT16 WINAPI
GetKeyState(INT vkey
)
435 case VK_LBUTTON
: /* VK_LBUTTON is 1 */
436 retval
= MouseButtonsStates
[0] ? 0x8000 : 0;
438 case VK_MBUTTON
: /* VK_MBUTTON is 4 */
439 retval
= MouseButtonsStates
[1] ? 0x8000 : 0;
441 case VK_RBUTTON
: /* VK_RBUTTON is 2 */
442 retval
= MouseButtonsStates
[2] ? 0x8000 : 0;
445 if (vkey
>= 'a' && vkey
<= 'z')
447 retval
= ( (WORD
)(QueueKeyStateTable
[vkey
] & 0x80) << 8 ) |
448 (WORD
)(QueueKeyStateTable
[vkey
] & 0x01);
450 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
454 /**********************************************************************
455 * GetKeyboardState (USER.222)(USER32.254)
457 * An application calls the GetKeyboardState function in response to a
458 * keyboard-input message. This function retrieves the state of the keyboard
459 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
461 BOOL WINAPI
GetKeyboardState(LPBYTE lpKeyState
)
463 TRACE_(key
)("(%p)\n", lpKeyState
);
464 if (lpKeyState
!= NULL
) {
465 QueueKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
466 QueueKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
467 QueueKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
468 memcpy(lpKeyState
, QueueKeyStateTable
, 256);
474 /**********************************************************************
475 * SetKeyboardState (USER.223)(USER32.484)
477 BOOL 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);
490 /**********************************************************************
491 * GetAsyncKeyState32 (USER32.207)
493 * Determine if a key is or was pressed. retval has high-order
494 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
497 * This uses the variable AsyncMouseButtonsStates and
498 * AsyncKeyStateTable (set in event.c) which have the mouse button
499 * number or key number (whichever is applicable) set to true if the
500 * mouse or key had been depressed since the last call to
503 WORD WINAPI
GetAsyncKeyState(INT nKey
)
509 retval
= (AsyncMouseButtonsStates
[0] ? 0x0001 : 0) |
510 (MouseButtonsStates
[0] ? 0x8000 : 0);
513 retval
= (AsyncMouseButtonsStates
[1] ? 0x0001 : 0) |
514 (MouseButtonsStates
[1] ? 0x8000 : 0);
517 retval
= (AsyncMouseButtonsStates
[2] ? 0x0001 : 0) |
518 (MouseButtonsStates
[2] ? 0x8000 : 0);
521 retval
= AsyncKeyStateTable
[nKey
] |
522 ((InputKeyStateTable
[nKey
] & 0x80) ? 0x8000 : 0);
526 /* all states to false */
527 memset( AsyncMouseButtonsStates
, 0, sizeof(AsyncMouseButtonsStates
) );
528 memset( AsyncKeyStateTable
, 0, sizeof(AsyncKeyStateTable
) );
530 TRACE_(key
)("(%x) -> %x\n", nKey
, retval
);
534 /**********************************************************************
535 * GetAsyncKeyState16 (USER.249)
537 WORD WINAPI
GetAsyncKeyState16(INT16 nKey
)
539 return GetAsyncKeyState(nKey
);
542 /***********************************************************************
543 * IsUserIdle (USER.333)
545 BOOL16 WINAPI
IsUserIdle16(void)
547 if ( GetAsyncKeyState( VK_LBUTTON
) & 0x8000 )
550 if ( GetAsyncKeyState( VK_RBUTTON
) & 0x8000 )
553 if ( GetAsyncKeyState( VK_MBUTTON
) & 0x8000 )
556 /* Should check for screen saver activation here ... */
561 /**********************************************************************
562 * KBD_translate_accelerator
564 * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
566 static BOOL
KBD_translate_accelerator(HWND hWnd
,LPMSG msg
,
567 BYTE fVirt
,WORD key
,WORD cmd
)
569 BOOL sendmsg
= FALSE
;
571 if(msg
->wParam
== key
)
573 if (msg
->message
== WM_CHAR
) {
574 if ( !(fVirt
& FALT
) && !(fVirt
& FVIRTKEY
) )
576 TRACE_(accel
)("found accel for WM_CHAR: ('%c')\n",
581 if(fVirt
& FVIRTKEY
) {
583 TRACE_(accel
)("found accel for virt_key %04x (scan %04x)\n",
584 msg
->wParam
,0xff & HIWORD(msg
->lParam
));
585 if(GetKeyState(VK_SHIFT
) & 0x8000) mask
|= FSHIFT
;
586 if(GetKeyState(VK_CONTROL
) & 0x8000) mask
|= FCONTROL
;
587 if(GetKeyState(VK_MENU
) & 0x8000) mask
|= FALT
;
588 if(mask
== (fVirt
& (FSHIFT
| FCONTROL
| FALT
)))
591 TRACE_(accel
)(", but incorrect SHIFT/CTRL/ALT-state\n");
595 if (!(msg
->lParam
& 0x01000000)) /* no special_key */
597 if ((fVirt
& FALT
) && (msg
->lParam
& 0x20000000))
598 { /* ^^ ALT pressed */
599 TRACE_(accel
)("found accel for Alt-%c\n", msg
->wParam
&0xff);
606 if (sendmsg
) /* found an accelerator, but send a message... ? */
608 INT16 iSysStat
,iStat
,mesg
=0;
611 if (msg
->message
== WM_KEYUP
|| msg
->message
== WM_SYSKEYUP
)
617 if (!IsWindowEnabled(hWnd
))
621 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
623 hMenu
= (wndPtr
->dwStyle
& WS_CHILD
) ? 0 : (HMENU
)wndPtr
->wIDmenu
;
624 iSysStat
= (wndPtr
->hSysMenu
) ? GetMenuState(GetSubMenu16(wndPtr
->hSysMenu
, 0),
625 cmd
, MF_BYCOMMAND
) : -1 ;
626 iStat
= (hMenu
) ? GetMenuState(hMenu
,
627 cmd
, MF_BYCOMMAND
) : -1 ;
629 WIN_ReleaseWndPtr(wndPtr
);
633 if (iSysStat
& (MF_DISABLED
|MF_GRAYED
))
646 if (iStat
& (MF_DISABLED
|MF_GRAYED
))
656 if ( mesg
==WM_COMMAND
|| mesg
==WM_SYSCOMMAND
)
658 TRACE_(accel
)(", sending %s, wParam=%0x\n",
659 mesg
==WM_COMMAND
? "WM_COMMAND" : "WM_SYSCOMMAND",
661 SendMessageA(hWnd
, mesg
, cmd
, 0x00010000L
);
665 /* some reasons for NOT sending the WM_{SYS}COMMAND message:
666 * #0: unknown (please report!)
667 * #1: for WM_KEYUP,WM_SYSKEYUP
668 * #2: mouse is captured
669 * #3: window is disabled
670 * #4: it's a disabled system menu option
671 * #5: it's a menu option, but window is iconic
672 * #6: it's a menu option, but disabled
674 TRACE_(accel
)(", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg
);
676 ERR_(accel
)(" unknown reason - please report!");
684 /**********************************************************************
685 * TranslateAccelerator32 (USER32.551)(USER32.552)(USER32.553)
687 INT WINAPI
TranslateAccelerator(HWND hWnd
, HACCEL hAccel
, LPMSG msg
)
690 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
693 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
);
695 if (hAccel
== 0 || msg
== NULL
||
696 (msg
->message
!= WM_KEYDOWN
&&
697 msg
->message
!= WM_KEYUP
&&
698 msg
->message
!= WM_SYSKEYDOWN
&&
699 msg
->message
!= WM_SYSKEYUP
&&
700 msg
->message
!= WM_CHAR
)) {
701 WARN_(accel
)("erraneous input parameters\n");
702 SetLastError(ERROR_INVALID_PARAMETER
);
706 TRACE_(accel
)("TranslateAccelerators hAccel=%04x, hWnd=%04x,"
707 "msg->hwnd=%04x, msg->message=%04x\n",
708 hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
713 if (KBD_translate_accelerator(hWnd
,msg
,lpAccelTbl
[i
].fVirt
,
714 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
716 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
717 WARN_(accel
)("couldn't translate accelerator key\n");
721 /**********************************************************************
722 * TranslateAccelerator16 (USER.178)
724 INT16 WINAPI
TranslateAccelerator16(HWND16 hWnd
, HACCEL16 hAccel
, LPMSG16 msg
)
726 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
730 if (hAccel
== 0 || msg
== NULL
||
731 (msg
->message
!= WM_KEYDOWN
&&
732 msg
->message
!= WM_KEYUP
&&
733 msg
->message
!= WM_SYSKEYDOWN
&&
734 msg
->message
!= WM_SYSKEYUP
&&
735 msg
->message
!= WM_CHAR
)) {
736 WARN_(accel
)("erraneous input parameters\n");
737 SetLastError(ERROR_INVALID_PARAMETER
);
741 TRACE_(accel
)("TranslateAccelerators hAccel=%04x, hWnd=%04x,\
742 msg->hwnd=%04x, msg->message=%04x\n", hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
743 STRUCT32_MSG16to32(msg
,&msg32
);
749 if (KBD_translate_accelerator(hWnd
,&msg32
,lpAccelTbl
[i
].fVirt
,
750 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
752 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
753 WARN_(accel
)("couldn't translate accelerator key\n");
758 /**********************************************************************
759 * VkKeyScanA (USER32.573)
761 WORD WINAPI
VkKeyScanA(CHAR cChar
)
763 return VkKeyScan16(cChar
);
766 /******************************************************************************
767 * VkKeyScanW (USER32.576)
769 WORD WINAPI
VkKeyScanW(WCHAR cChar
)
771 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
774 /**********************************************************************
775 * VkKeyScanExA (USER32.574)
777 WORD WINAPI
VkKeyScanExA(CHAR cChar
, HKL dwhkl
)
779 /* FIXME: complete workaround this is */
780 return VkKeyScan16(cChar
);
783 /******************************************************************************
784 * VkKeyScanExW (USER32.575)
786 WORD WINAPI
VkKeyScanExW(WCHAR cChar
, HKL dwhkl
)
788 /* FIXME: complete workaround this is */
789 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
792 /******************************************************************************
793 * GetKeyboardType32 (USER32.255)
795 INT WINAPI
GetKeyboardType(INT nTypeFlag
)
797 return GetKeyboardType16(nTypeFlag
);
800 /******************************************************************************
801 * MapVirtualKey32A (USER32.383)
803 UINT WINAPI
MapVirtualKeyA(UINT code
, UINT maptype
)
805 return MapVirtualKey16(code
,maptype
);
808 /******************************************************************************
809 * MapVirtualKey32W (USER32.385)
811 UINT WINAPI
MapVirtualKeyW(UINT code
, UINT maptype
)
813 return MapVirtualKey16(code
,maptype
);
816 /******************************************************************************
817 * MapVirtualKeyEx32A (USER32.384)
819 UINT WINAPI
MapVirtualKeyEx32A(UINT code
, UINT maptype
, HKL hkl
)
822 FIXME_(keyboard
)("(%d,%d,0x%08lx), hkl unhandled!\n",code
,maptype
,(DWORD
)hkl
);
823 return MapVirtualKey16(code
,maptype
);
826 /****************************************************************************
827 * GetKBCodePage32 (USER32.246)
829 UINT WINAPI
GetKBCodePage(void)
831 return GetKBCodePage16();
834 /****************************************************************************
835 * GetKeyboardLayoutName16 (USER.477)
837 INT16 WINAPI
GetKeyboardLayoutName16(LPSTR pwszKLID
)
839 return GetKeyboardLayoutNameA(pwszKLID
);
842 /***********************************************************************
843 * GetKeyboardLayout (USER32.250)
845 * FIXME: - device handle for keyboard layout defaulted to
846 * the language id. This is the way Windows default works.
847 * - the thread identifier (dwLayout) is also ignored.
849 HKL WINAPI
GetKeyboardLayout(DWORD dwLayout
)
852 layout
= GetSystemDefaultLCID(); /* FIXME */
853 layout
|= (layout
<<16); /* FIXME */
854 TRACE_(keyboard
)("returning %08x\n",layout
);
858 /****************************************************************************
859 * GetKeyboardLayoutName32A (USER32.252)
861 INT WINAPI
GetKeyboardLayoutNameA(LPSTR pwszKLID
)
863 sprintf(pwszKLID
, "%08x",GetKeyboardLayout(0));
867 /****************************************************************************
868 * GetKeyboardLayoutName32W (USER32.253)
870 INT WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID
)
872 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
873 int res
= GetKeyboardLayoutNameA(buf
);
874 lstrcpyAtoW(pwszKLID
,buf
);
875 HeapFree( GetProcessHeap(), 0, buf
);
879 /****************************************************************************
880 * GetKeyNameText32A (USER32.247)
882 INT WINAPI
GetKeyNameTextA(LONG lParam
, LPSTR lpBuffer
, INT nSize
)
884 return GetKeyNameText16(lParam
,lpBuffer
,nSize
);
887 /****************************************************************************
888 * GetKeyNameText32W (USER32.248)
890 INT WINAPI
GetKeyNameTextW(LONG lParam
, LPWSTR lpBuffer
, INT nSize
)
892 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, nSize
);
893 int res
= GetKeyNameTextA(lParam
,buf
,nSize
);
895 lstrcpynAtoW(lpBuffer
,buf
,nSize
);
896 HeapFree( GetProcessHeap(), 0, buf
);
900 /****************************************************************************
901 * ToAscii32 (USER32.546)
903 INT WINAPI
ToAscii( UINT virtKey
,UINT scanCode
,LPBYTE lpKeyState
,
904 LPWORD lpChar
,UINT flags
)
906 return ToAscii16(virtKey
,scanCode
,lpKeyState
,lpChar
,flags
);
909 /****************************************************************************
910 * ToAscii32 (USER32.547)
912 INT WINAPI
ToAsciiEx( UINT virtKey
, UINT scanCode
, LPBYTE lpKeyState
,
913 LPWORD lpChar
, UINT flags
, HKL dwhkl
)
915 /* FIXME: need true implementation */
916 return ToAscii16(virtKey
,scanCode
,lpKeyState
,lpChar
,flags
);
919 /**********************************************************************
920 * ActivateKeyboardLayout32 (USER32.1)
922 * Call ignored. WINE supports only system default keyboard layout.
924 HKL WINAPI
ActivateKeyboardLayout(HKL hLayout
, UINT flags
)
926 TRACE_(keyboard
)("(%d, %d)\n", hLayout
, flags
);
927 ERR_(keyboard
)("Only default system keyboard layout supported. Call ignored.\n");
932 /***********************************************************************
933 * GetKeyboardLayoutList (USER32.251)
935 * FIXME: Supports only the system default language and layout and
936 * returns only 1 value.
938 * Return number of values available if either input parm is
939 * 0, per MS documentation.
942 INT WINAPI
GetKeyboardLayoutList(INT nBuff
,HKL
*layouts
)
944 TRACE_(keyboard
)("(%d,%p)\n",nBuff
,layouts
);
945 if (!nBuff
|| !layouts
)
948 layouts
[0] = GetKeyboardLayout(0);
953 /***********************************************************************
954 * RegisterHotKey (USER32.433)
956 BOOL WINAPI
RegisterHotKey(HWND hwnd
,INT id
,UINT modifiers
,UINT vk
) {
957 FIXME_(keyboard
)("(0x%08x,%d,0x%08x,%d): stub\n",hwnd
,id
,modifiers
,vk
);
961 /***********************************************************************
962 * UnregisterHotKey (USER32.565)
964 BOOL WINAPI
UnregisterHotKey(HWND hwnd
,INT id
) {
965 FIXME_(keyboard
)("(0x%08x,%d): stub\n",hwnd
,id
);
970 /***********************************************************************
971 * ToUnicode32 (USER32.548)
973 INT WINAPI
ToUnicode(
981 FIXME_(keyboard
)(": stub\n");
985 /***********************************************************************
986 * LoadKeyboardLayout32A (USER32.367)
987 * Call ignored. WINE supports only system default keyboard layout.
989 HKL WINAPI
LoadKeyboardLayoutA(LPCSTR pwszKLID
, UINT Flags
)
991 TRACE_(keyboard
)("(%s, %d)\n", pwszKLID
, Flags
);
992 ERR_(keyboard
)("Only default system keyboard layout supported. Call ignored.\n");
996 /***********************************************************************
997 * LoadKeyboardLayout32W (USER32.368)
999 HKL WINAPI
LoadKeyboardLayoutW(LPCWSTR pwszKLID
, UINT Flags
)
1001 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
1003 lstrcpynWtoA(buf
,pwszKLID
,8);
1005 res
= LoadKeyboardLayoutA(buf
, Flags
);
1006 HeapFree( GetProcessHeap(), 0, buf
);