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"
28 #include "debugtools.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 BOOL 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);
476 /**********************************************************************
477 * SetKeyboardState (USER.223)(USER32.484)
479 BOOL WINAPI
SetKeyboardState(LPBYTE lpKeyState
)
481 TRACE_(key
)("(%p)\n", lpKeyState
);
482 if (lpKeyState
!= NULL
) {
483 memcpy(QueueKeyStateTable
, lpKeyState
, 256);
484 MouseButtonsStates
[0] = (QueueKeyStateTable
[VK_LBUTTON
] != 0);
485 MouseButtonsStates
[1] = (QueueKeyStateTable
[VK_MBUTTON
] != 0);
486 MouseButtonsStates
[2] = (QueueKeyStateTable
[VK_RBUTTON
] != 0);
492 /**********************************************************************
493 * GetAsyncKeyState32 (USER32.207)
495 * Determine if a key is or was pressed. retval has high-order
496 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
499 * This uses the variable AsyncMouseButtonsStates and
500 * AsyncKeyStateTable (set in event.c) which have the mouse button
501 * number or key number (whichever is applicable) set to true if the
502 * mouse or key had been depressed since the last call to
505 WORD WINAPI
GetAsyncKeyState(INT nKey
)
511 retval
= (AsyncMouseButtonsStates
[0] ? 0x0001 : 0) |
512 (MouseButtonsStates
[0] ? 0x8000 : 0);
515 retval
= (AsyncMouseButtonsStates
[1] ? 0x0001 : 0) |
516 (MouseButtonsStates
[1] ? 0x8000 : 0);
519 retval
= (AsyncMouseButtonsStates
[2] ? 0x0001 : 0) |
520 (MouseButtonsStates
[2] ? 0x8000 : 0);
523 retval
= AsyncKeyStateTable
[nKey
] |
524 ((InputKeyStateTable
[nKey
] & 0x80) ? 0x8000 : 0);
528 /* all states to false */
529 memset( AsyncMouseButtonsStates
, 0, sizeof(AsyncMouseButtonsStates
) );
530 memset( AsyncKeyStateTable
, 0, sizeof(AsyncKeyStateTable
) );
532 TRACE_(key
)("(%x) -> %x\n", nKey
, retval
);
536 /**********************************************************************
537 * GetAsyncKeyState16 (USER.249)
539 WORD WINAPI
GetAsyncKeyState16(INT16 nKey
)
541 return GetAsyncKeyState(nKey
);
544 /**********************************************************************
545 * KBD_translate_accelerator
547 * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
549 static BOOL
KBD_translate_accelerator(HWND hWnd
,LPMSG msg
,
550 BYTE fVirt
,WORD key
,WORD cmd
)
552 BOOL sendmsg
= FALSE
;
554 if(msg
->wParam
== key
)
556 if (msg
->message
== WM_CHAR
) {
557 if ( !(fVirt
& FALT
) && !(fVirt
& FVIRTKEY
) )
559 TRACE_(accel
)("found accel for WM_CHAR: ('%c')\n",
564 if(fVirt
& FVIRTKEY
) {
566 TRACE_(accel
)("found accel for virt_key %04x (scan %04x)\n",
567 msg
->wParam
,0xff & HIWORD(msg
->lParam
));
568 if(GetKeyState(VK_SHIFT
) & 0x8000) mask
|= FSHIFT
;
569 if(GetKeyState(VK_CONTROL
) & 0x8000) mask
|= FCONTROL
;
570 if(GetKeyState(VK_MENU
) & 0x8000) mask
|= FALT
;
571 if(mask
== (fVirt
& (FSHIFT
| FCONTROL
| FALT
)))
574 TRACE_(accel
)(", but incorrect SHIFT/CTRL/ALT-state\n");
578 if (!(msg
->lParam
& 0x01000000)) /* no special_key */
580 if ((fVirt
& FALT
) && (msg
->lParam
& 0x20000000))
581 { /* ^^ ALT pressed */
582 TRACE_(accel
)("found accel for Alt-%c\n", msg
->wParam
&0xff);
589 if (sendmsg
) /* found an accelerator, but send a message... ? */
591 INT16 iSysStat
,iStat
,mesg
=0;
594 if (msg
->message
== WM_KEYUP
|| msg
->message
== WM_SYSKEYUP
)
600 if (!IsWindowEnabled(hWnd
))
604 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
606 hMenu
= (wndPtr
->dwStyle
& WS_CHILD
) ? 0 : (HMENU
)wndPtr
->wIDmenu
;
607 iSysStat
= (wndPtr
->hSysMenu
) ? GetMenuState(GetSubMenu16(wndPtr
->hSysMenu
, 0),
608 cmd
, MF_BYCOMMAND
) : -1 ;
609 iStat
= (hMenu
) ? GetMenuState(hMenu
,
610 cmd
, MF_BYCOMMAND
) : -1 ;
612 WIN_ReleaseWndPtr(wndPtr
);
616 if (iSysStat
& (MF_DISABLED
|MF_GRAYED
))
629 if (iStat
& (MF_DISABLED
|MF_GRAYED
))
639 if ( mesg
==WM_COMMAND
|| mesg
==WM_SYSCOMMAND
)
641 TRACE_(accel
)(", sending %s, wParam=%0x\n",
642 mesg
==WM_COMMAND
? "WM_COMMAND" : "WM_SYSCOMMAND",
644 SendMessageA(hWnd
, mesg
, cmd
, 0x00010000L
);
648 /* some reasons for NOT sending the WM_{SYS}COMMAND message:
649 * #0: unknown (please report!)
650 * #1: for WM_KEYUP,WM_SYSKEYUP
651 * #2: mouse is captured
652 * #3: window is disabled
653 * #4: it's a disabled system menu option
654 * #5: it's a menu option, but window is iconic
655 * #6: it's a menu option, but disabled
657 TRACE_(accel
)(", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg
);
659 ERR_(accel
)(" unknown reason - please report!");
667 /**********************************************************************
668 * TranslateAccelerator32 (USER32.551)(USER32.552)(USER32.553)
670 INT WINAPI
TranslateAccelerator(HWND hWnd
, HACCEL hAccel
, LPMSG msg
)
673 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
676 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
);
678 if (hAccel
== 0 || msg
== NULL
||
679 (msg
->message
!= WM_KEYDOWN
&&
680 msg
->message
!= WM_KEYUP
&&
681 msg
->message
!= WM_SYSKEYDOWN
&&
682 msg
->message
!= WM_SYSKEYUP
&&
683 msg
->message
!= WM_CHAR
)) {
684 WARN_(accel
)("erraneous input parameters\n");
685 SetLastError(ERROR_INVALID_PARAMETER
);
689 TRACE_(accel
)("TranslateAccelerators hAccel=%04x, hWnd=%04x,"
690 "msg->hwnd=%04x, msg->message=%04x\n",
691 hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
696 if (KBD_translate_accelerator(hWnd
,msg
,lpAccelTbl
[i
].fVirt
,
697 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
699 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
700 WARN_(accel
)("couldn't translate accelerator key\n");
704 /**********************************************************************
705 * TranslateAccelerator16 (USER.178)
707 INT16 WINAPI
TranslateAccelerator16(HWND16 hWnd
, HACCEL16 hAccel
, LPMSG16 msg
)
709 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
713 if (hAccel
== 0 || msg
== NULL
||
714 (msg
->message
!= WM_KEYDOWN
&&
715 msg
->message
!= WM_KEYUP
&&
716 msg
->message
!= WM_SYSKEYDOWN
&&
717 msg
->message
!= WM_SYSKEYUP
&&
718 msg
->message
!= WM_CHAR
)) {
719 WARN_(accel
)("erraneous input parameters\n");
720 SetLastError(ERROR_INVALID_PARAMETER
);
724 TRACE_(accel
)("TranslateAccelerators hAccel=%04x, hWnd=%04x,\
725 msg->hwnd=%04x, msg->message=%04x\n", hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
726 STRUCT32_MSG16to32(msg
,&msg32
);
732 if (KBD_translate_accelerator(hWnd
,&msg32
,lpAccelTbl
[i
].fVirt
,
733 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
735 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
736 WARN_(accel
)("couldn't translate accelerator key\n");
741 /**********************************************************************
742 * VkKeyScanA (USER32.573)
744 WORD WINAPI
VkKeyScanA(CHAR cChar
)
746 return VkKeyScan16(cChar
);
749 /******************************************************************************
750 * VkKeyScanW (USER32.576)
752 WORD WINAPI
VkKeyScanW(WCHAR cChar
)
754 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
757 /**********************************************************************
758 * VkKeyScanExA (USER32.574)
760 WORD WINAPI
VkKeyScanExA(CHAR cChar
, HKL dwhkl
)
762 /* FIXME: complete workaround this is */
763 return VkKeyScan16(cChar
);
766 /******************************************************************************
767 * VkKeyScanExW (USER32.575)
769 WORD WINAPI
VkKeyScanExW(WCHAR cChar
, HKL dwhkl
)
771 /* FIXME: complete workaround this is */
772 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
775 /******************************************************************************
776 * GetKeyboardType32 (USER32.255)
778 INT WINAPI
GetKeyboardType(INT nTypeFlag
)
780 return GetKeyboardType16(nTypeFlag
);
783 /******************************************************************************
784 * MapVirtualKey32A (USER32.383)
786 UINT WINAPI
MapVirtualKeyA(UINT code
, UINT maptype
)
788 return MapVirtualKey16(code
,maptype
);
791 /******************************************************************************
792 * MapVirtualKey32W (USER32.385)
794 UINT WINAPI
MapVirtualKeyW(UINT code
, UINT maptype
)
796 return MapVirtualKey16(code
,maptype
);
799 /******************************************************************************
800 * MapVirtualKeyEx32A (USER32.384)
802 UINT WINAPI
MapVirtualKeyEx32A(UINT code
, UINT maptype
, HKL hkl
)
805 FIXME_(keyboard
)("(%d,%d,0x%08lx), hkl unhandled!\n",code
,maptype
,(DWORD
)hkl
);
806 return MapVirtualKey16(code
,maptype
);
809 /****************************************************************************
810 * GetKBCodePage32 (USER32.246)
812 UINT WINAPI
GetKBCodePage(void)
814 return GetKBCodePage16();
817 /****************************************************************************
818 * GetKeyboardLayoutName16 (USER.477)
820 INT16 WINAPI
GetKeyboardLayoutName16(LPSTR pwszKLID
)
822 return GetKeyboardLayoutNameA(pwszKLID
);
825 /***********************************************************************
826 * GetKeyboardLayout (USER32.250)
828 * FIXME: - device handle for keyboard layout defaulted to
829 * the language id. This is the way Windows default works.
830 * - the thread identifier (dwLayout) is also ignored.
832 HKL WINAPI
GetKeyboardLayout(DWORD dwLayout
)
835 layout
= GetSystemDefaultLCID(); /* FIXME */
836 layout
|= (layout
<<16); /* FIXME */
837 TRACE_(keyboard
)("returning %08x\n",layout
);
841 /****************************************************************************
842 * GetKeyboardLayoutName32A (USER32.252)
844 INT WINAPI
GetKeyboardLayoutNameA(LPSTR pwszKLID
)
846 sprintf(pwszKLID
, "%08x",GetKeyboardLayout(0));
850 /****************************************************************************
851 * GetKeyboardLayoutName32W (USER32.253)
853 INT WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID
)
855 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
856 int res
= GetKeyboardLayoutNameA(buf
);
857 lstrcpyAtoW(pwszKLID
,buf
);
858 HeapFree( GetProcessHeap(), 0, buf
);
862 /****************************************************************************
863 * GetKeyNameText32A (USER32.247)
865 INT WINAPI
GetKeyNameTextA(LONG lParam
, LPSTR lpBuffer
, INT nSize
)
867 return GetKeyNameText16(lParam
,lpBuffer
,nSize
);
870 /****************************************************************************
871 * GetKeyNameText32W (USER32.248)
873 INT WINAPI
GetKeyNameTextW(LONG lParam
, LPWSTR lpBuffer
, INT nSize
)
875 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, nSize
);
876 int res
= GetKeyNameTextA(lParam
,buf
,nSize
);
878 lstrcpynAtoW(lpBuffer
,buf
,nSize
);
879 HeapFree( GetProcessHeap(), 0, buf
);
883 /****************************************************************************
884 * ToAscii32 (USER32.546)
886 INT WINAPI
ToAscii( UINT virtKey
,UINT scanCode
,LPBYTE lpKeyState
,
887 LPWORD lpChar
,UINT flags
)
889 return ToAscii16(virtKey
,scanCode
,lpKeyState
,lpChar
,flags
);
892 /****************************************************************************
893 * ToAscii32 (USER32.547)
895 INT WINAPI
ToAsciiEx( UINT virtKey
, UINT scanCode
, LPBYTE lpKeyState
,
896 LPWORD lpChar
, UINT flags
, HKL dwhkl
)
898 /* FIXME: need true implementation */
899 return ToAscii16(virtKey
,scanCode
,lpKeyState
,lpChar
,flags
);
902 /**********************************************************************
903 * ActivateKeyboardLayout32 (USER32.1)
905 * Call ignored. WINE supports only system default keyboard layout.
907 HKL WINAPI
ActivateKeyboardLayout(HKL hLayout
, UINT flags
)
909 TRACE_(keyboard
)("(%d, %d)\n", hLayout
, flags
);
910 ERR_(keyboard
)("Only default system keyboard layout supported. Call ignored.\n");
915 /***********************************************************************
916 * GetKeyboardLayoutList (USER32.251)
918 * FIXME: Supports only the system default language and layout and
919 * returns only 1 value.
921 * Return number of values available if either input parm is
922 * 0, per MS documentation.
925 INT WINAPI
GetKeyboardLayoutList(INT nBuff
,HKL
*layouts
)
927 TRACE_(keyboard
)("(%d,%p)\n",nBuff
,layouts
);
928 if (!nBuff
|| !layouts
)
931 layouts
[0] = GetKeyboardLayout(0);
936 /***********************************************************************
937 * RegisterHotKey (USER32.433)
939 BOOL WINAPI
RegisterHotKey(HWND hwnd
,INT id
,UINT modifiers
,UINT vk
) {
940 FIXME_(keyboard
)("(0x%08x,%d,0x%08x,%d): stub\n",hwnd
,id
,modifiers
,vk
);
944 /***********************************************************************
945 * UnregisterHotKey (USER32.565)
947 BOOL WINAPI
UnregisterHotKey(HWND hwnd
,INT id
) {
948 FIXME_(keyboard
)("(0x%08x,%d): stub\n",hwnd
,id
);
953 /***********************************************************************
954 * ToUnicode32 (USER32.548)
956 INT WINAPI
ToUnicode(
964 FIXME_(keyboard
)(": stub\n");
968 /***********************************************************************
969 * LoadKeyboardLayout32A (USER32.367)
970 * Call ignored. WINE supports only system default keyboard layout.
972 HKL WINAPI
LoadKeyboardLayoutA(LPCSTR pwszKLID
, UINT Flags
)
974 TRACE_(keyboard
)("(%s, %d)\n", pwszKLID
, Flags
);
975 ERR_(keyboard
)("Only default system keyboard layout supported. Call ignored.\n");
979 /***********************************************************************
980 * LoadKeyboardLayout32W (USER32.368)
982 HKL WINAPI
LoadKeyboardLayoutW(LPCWSTR pwszKLID
, UINT Flags
)
984 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
986 lstrcpynWtoA(buf
,pwszKLID
,8);
988 res
= LoadKeyboardLayoutA(buf
, Flags
);
989 HeapFree( GetProcessHeap(), 0, buf
);