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"
28 #include "sysmetrics.h"
30 #include "debugtools.h"
35 static BOOL InputEnabled
= TRUE
;
36 static BOOL SwappedButtons
= FALSE
;
38 BOOL MouseButtonsStates
[3];
39 BOOL AsyncMouseButtonsStates
[3];
40 BYTE InputKeyStateTable
[256];
41 BYTE QueueKeyStateTable
[256];
42 BYTE AsyncKeyStateTable
[256];
48 unsigned long count
: 16;
49 unsigned long code
: 8;
50 unsigned long extended
: 1;
51 unsigned long unused
: 2;
52 unsigned long win_internal
: 2;
53 unsigned long context
: 1;
54 unsigned long previous
: 1;
55 unsigned long transition
: 1;
60 /***********************************************************************
61 * keybd_event (USER32.583)
63 void WINAPI
keybd_event( BYTE bVk
, BYTE bScan
,
64 DWORD dwFlags
, DWORD dwExtraInfo
)
66 DWORD posX
, posY
, time
, extra
;
71 if (!InputEnabled
) return;
74 * If we are called by the Wine keyboard driver, use the additional
75 * info pointed to by the dwExtraInfo argument.
76 * Otherwise, we need to determine that info ourselves (probably
77 * less accurate, but we can't help that ...).
79 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_KEYBDEVENT
) )
80 && ((WINE_KEYBDEVENT
*)dwExtraInfo
)->magic
== WINE_KEYBDEVENT_MAGIC
)
82 WINE_KEYBDEVENT
*wke
= (WINE_KEYBDEVENT
*)dwExtraInfo
;
91 time
= GetTickCount();
94 if ( !EVENT_QueryPointer( &posX
, &posY
, &keyState
))
100 keylp
.lp1
.code
= bScan
;
101 keylp
.lp1
.extended
= (dwFlags
& KEYEVENTF_EXTENDEDKEY
) != 0;
102 keylp
.lp1
.win_internal
= 0; /* this has something to do with dialogs,
103 * don't remember where I read it - AK */
104 /* it's '1' under windows, when a dialog box appears
105 * and you press one of the underlined keys - DF*/
107 if ( dwFlags
& KEYEVENTF_KEYUP
)
109 BOOL sysKey
= (InputKeyStateTable
[VK_MENU
] & 0x80)
110 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
111 && !(dwFlags
& KEYEVENTF_WINE_FORCEEXTENDED
); /* for Alt from AltGr */
113 InputKeyStateTable
[bVk
] &= ~0x80;
114 keylp
.lp1
.previous
= 1;
115 keylp
.lp1
.transition
= 1;
116 message
= sysKey
? WM_SYSKEYUP
: WM_KEYUP
;
120 keylp
.lp1
.previous
= (InputKeyStateTable
[bVk
] & 0x80) != 0;
121 keylp
.lp1
.transition
= 0;
123 if (!(InputKeyStateTable
[bVk
] & 0x80))
124 InputKeyStateTable
[bVk
] ^= 0x01;
125 InputKeyStateTable
[bVk
] |= 0x80;
127 message
= (InputKeyStateTable
[VK_MENU
] & 0x80)
128 && !(InputKeyStateTable
[VK_CONTROL
] & 0x80)
129 ? WM_SYSKEYDOWN
: WM_KEYDOWN
;
132 if ( message
== WM_SYSKEYDOWN
|| message
== WM_SYSKEYUP
)
133 keylp
.lp1
.context
= (InputKeyStateTable
[VK_MENU
] & 0x80) != 0; /* 1 if alt */
136 TRACE(key
, " wParam=%04X, lParam=%08lX\n", bVk
, keylp
.lp2
);
137 TRACE(key
, " InputKeyState=%X\n", InputKeyStateTable
[bVk
] );
139 hardware_event( message
, bVk
, keylp
.lp2
, posX
, posY
, time
, extra
);
142 /***********************************************************************
143 * mouse_event (USER32.584)
145 void WINAPI
mouse_event( DWORD dwFlags
, DWORD dx
, DWORD dy
,
146 DWORD cButtons
, DWORD dwExtraInfo
)
148 DWORD posX
, posY
, keyState
, time
, extra
;
150 if (!InputEnabled
) return;
153 * If we are called by the Wine mouse driver, use the additional
154 * info pointed to by the dwExtraInfo argument.
155 * Otherwise, we need to determine that info ourselves (probably
156 * less accurate, but we can't help that ...).
158 if ( !IsBadReadPtr( (LPVOID
)dwExtraInfo
, sizeof(WINE_MOUSEEVENT
) )
159 && ((WINE_MOUSEEVENT
*)dwExtraInfo
)->magic
== WINE_MOUSEEVENT_MAGIC
)
161 WINE_MOUSEEVENT
*wme
= (WINE_MOUSEEVENT
*)dwExtraInfo
;
162 keyState
= wme
->keyState
;
164 extra
= (DWORD
)wme
->hWnd
;
166 assert( dwFlags
& MOUSEEVENTF_ABSOLUTE
);
167 posX
= (dx
* SYSMETRICS_CXSCREEN
) >> 16;
168 posY
= (dy
* SYSMETRICS_CYSCREEN
) >> 16;
172 time
= GetTickCount();
175 if ( !EVENT_QueryPointer( &posX
, &posY
, &keyState
))
178 if ( dwFlags
& MOUSEEVENTF_MOVE
)
180 if ( dwFlags
& MOUSEEVENTF_ABSOLUTE
)
182 posX
= (dx
* SYSMETRICS_CXSCREEN
) >> 16;
183 posY
= (dy
* SYSMETRICS_CYSCREEN
) >> 16;
190 /* We have to actually move the cursor */
191 SetCursorPos( posX
, posY
);
195 if ( dwFlags
& MOUSEEVENTF_MOVE
)
197 hardware_event( WM_MOUSEMOVE
,
198 keyState
, 0L, posX
, posY
, time
, extra
);
200 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTDOWN
: MOUSEEVENTF_RIGHTDOWN
) )
202 MouseButtonsStates
[0] = AsyncMouseButtonsStates
[0] = TRUE
;
203 hardware_event( WM_LBUTTONDOWN
,
204 keyState
, 0L, posX
, posY
, time
, extra
);
206 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_LEFTUP
: MOUSEEVENTF_RIGHTUP
) )
208 MouseButtonsStates
[0] = FALSE
;
209 hardware_event( WM_LBUTTONUP
,
210 keyState
, 0L, posX
, posY
, time
, extra
);
212 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTDOWN
: MOUSEEVENTF_LEFTDOWN
) )
214 MouseButtonsStates
[2] = AsyncMouseButtonsStates
[2] = TRUE
;
215 hardware_event( WM_RBUTTONDOWN
,
216 keyState
, 0L, posX
, posY
, time
, extra
);
218 if ( dwFlags
& (!SwappedButtons
? MOUSEEVENTF_RIGHTUP
: MOUSEEVENTF_LEFTUP
) )
220 MouseButtonsStates
[2] = FALSE
;
221 hardware_event( WM_RBUTTONUP
,
222 keyState
, 0L, posX
, posY
, time
, extra
);
224 if ( dwFlags
& MOUSEEVENTF_MIDDLEDOWN
)
226 MouseButtonsStates
[1] = AsyncMouseButtonsStates
[1] = TRUE
;
227 hardware_event( WM_MBUTTONDOWN
,
228 keyState
, 0L, posX
, posY
, time
, extra
);
230 if ( dwFlags
& MOUSEEVENTF_MIDDLEUP
)
232 MouseButtonsStates
[1] = FALSE
;
233 hardware_event( WM_MBUTTONUP
,
234 keyState
, 0L, posX
, posY
, time
, extra
);
238 /**********************************************************************
239 * EnableHardwareInput (USER.331)
241 BOOL16 WINAPI
EnableHardwareInput16(BOOL16 bEnable
)
243 BOOL16 bOldState
= InputEnabled
;
244 FIXME(event
,"(%d) - stub\n", bEnable
);
245 InputEnabled
= bEnable
;
250 /***********************************************************************
251 * SwapMouseButton16 (USER.186)
253 BOOL16 WINAPI
SwapMouseButton16( BOOL16 fSwap
)
255 BOOL16 ret
= SwappedButtons
;
256 SwappedButtons
= fSwap
;
261 /***********************************************************************
262 * SwapMouseButton32 (USER32.537)
264 BOOL WINAPI
SwapMouseButton( BOOL fSwap
)
266 BOOL ret
= SwappedButtons
;
267 SwappedButtons
= fSwap
;
271 /**********************************************************************
274 * We need this to be able to generate double click messages
275 * when menu code captures mouse in the window without CS_DBLCLK style.
277 HWND
EVENT_Capture(HWND hwnd
, INT16 ht
)
279 HWND capturePrev
= 0, captureWnd
= 0;
280 MESSAGEQUEUE
*pMsgQ
= 0, *pCurMsgQ
= 0;
284 /* Get the messageQ for the current thread */
285 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
287 WARN( win
, "\tCurrent message queue not found. Exiting!\n" );
291 /* Get the current capture window from the perQ data of the current message Q */
292 capturePrev
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
301 wndPtr
= WIN_FindWndPtr( hwnd
);
304 TRACE(win
, "(0x%04x)\n", hwnd
);
310 /* Update the perQ capture window and send messages */
311 if( capturePrev
!= captureWnd
)
315 /* Retrieve the message queue associated with this window */
316 pMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( wndPtr
->hmemTaskQ
);
319 WARN( win
, "\tMessage queue not found. Exiting!\n" );
323 /* Make sure that message queue for the window we are setting capture to
324 * shares the same perQ data as the current threads message queue.
326 if ( pCurMsgQ
->pQData
!= pMsgQ
->pQData
)
330 PERQDATA_SetCaptureWnd( pCurMsgQ
->pQData
, captureWnd
);
331 PERQDATA_SetCaptureInfo( pCurMsgQ
->pQData
, captureHT
);
335 WND
* wndPtr
= WIN_FindWndPtr( capturePrev
);
336 if( wndPtr
&& (wndPtr
->flags
& WIN_ISWIN32
) )
337 SendMessageA( capturePrev
, WM_CAPTURECHANGED
, 0L, hwnd
);
338 WIN_ReleaseWndPtr(wndPtr
);
343 /* Unlock the queues before returning */
345 QUEUE_Unlock( pMsgQ
);
347 QUEUE_Unlock( pCurMsgQ
);
349 WIN_ReleaseWndPtr(wndPtr
);
354 /**********************************************************************
355 * SetCapture16 (USER.18)
357 HWND16 WINAPI
SetCapture16( HWND16 hwnd
)
359 return (HWND16
)EVENT_Capture( hwnd
, HTCLIENT
);
363 /**********************************************************************
364 * SetCapture32 (USER32.464)
366 HWND WINAPI
SetCapture( HWND hwnd
)
368 return EVENT_Capture( hwnd
, HTCLIENT
);
372 /**********************************************************************
373 * ReleaseCapture (USER.19) (USER32.439)
375 void WINAPI
ReleaseCapture(void)
377 EVENT_Capture( 0, 0 );
381 /**********************************************************************
382 * GetCapture16 (USER.236)
384 HWND16 WINAPI
GetCapture16(void)
386 return (HWND16
)GetCapture();
389 /**********************************************************************
390 * GetCapture32 (USER32.208)
392 HWND WINAPI
GetCapture(void)
394 MESSAGEQUEUE
*pCurMsgQ
= 0;
395 HWND hwndCapture
= 0;
397 /* Get the messageQ for the current thread */
398 if (!(pCurMsgQ
= (MESSAGEQUEUE
*)QUEUE_Lock( GetFastQueue16() )))
400 TRACE( win
, "GetCapture32: Current message queue not found. Exiting!\n" );
404 /* Get the current capture window from the perQ data of the current message Q */
405 hwndCapture
= PERQDATA_GetCaptureWnd( pCurMsgQ
->pQData
);
407 QUEUE_Unlock( pCurMsgQ
);
411 /**********************************************************************
412 * GetKeyState (USER.106)
414 INT16 WINAPI
GetKeyState16(INT16 vkey
)
416 return GetKeyState(vkey
);
419 /**********************************************************************
420 * GetKeyState (USER32.249)
422 * An application calls the GetKeyState function in response to a
423 * keyboard-input message. This function retrieves the state of the key
424 * at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
426 INT16 WINAPI
GetKeyState(INT vkey
)
432 case VK_LBUTTON
: /* VK_LBUTTON is 1 */
433 retval
= MouseButtonsStates
[0] ? 0x8000 : 0;
435 case VK_MBUTTON
: /* VK_MBUTTON is 4 */
436 retval
= MouseButtonsStates
[1] ? 0x8000 : 0;
438 case VK_RBUTTON
: /* VK_RBUTTON is 2 */
439 retval
= MouseButtonsStates
[2] ? 0x8000 : 0;
442 if (vkey
>= 'a' && vkey
<= 'z')
444 retval
= ( (WORD
)(QueueKeyStateTable
[vkey
] & 0x80) << 8 ) |
445 (WORD
)(QueueKeyStateTable
[vkey
] & 0x01);
447 /* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
451 /**********************************************************************
452 * GetKeyboardState (USER.222)(USER32.254)
454 * An application calls the GetKeyboardState function in response to a
455 * keyboard-input message. This function retrieves the state of the keyboard
456 * at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
458 VOID WINAPI
GetKeyboardState(LPBYTE lpKeyState
)
460 TRACE(key
, "(%p)\n", lpKeyState
);
461 if (lpKeyState
!= NULL
) {
462 QueueKeyStateTable
[VK_LBUTTON
] = MouseButtonsStates
[0] ? 0x80 : 0;
463 QueueKeyStateTable
[VK_MBUTTON
] = MouseButtonsStates
[1] ? 0x80 : 0;
464 QueueKeyStateTable
[VK_RBUTTON
] = MouseButtonsStates
[2] ? 0x80 : 0;
465 memcpy(lpKeyState
, QueueKeyStateTable
, 256);
469 /**********************************************************************
470 * SetKeyboardState (USER.223)(USER32.484)
472 VOID WINAPI
SetKeyboardState(LPBYTE lpKeyState
)
474 TRACE(key
, "(%p)\n", lpKeyState
);
475 if (lpKeyState
!= NULL
) {
476 memcpy(QueueKeyStateTable
, lpKeyState
, 256);
477 MouseButtonsStates
[0] = (QueueKeyStateTable
[VK_LBUTTON
] != 0);
478 MouseButtonsStates
[1] = (QueueKeyStateTable
[VK_MBUTTON
] != 0);
479 MouseButtonsStates
[2] = (QueueKeyStateTable
[VK_RBUTTON
] != 0);
483 /**********************************************************************
484 * GetAsyncKeyState32 (USER32.207)
486 * Determine if a key is or was pressed. retval has high-order
487 * bit set to 1 if currently pressed, low-order bit set to 1 if key has
490 * This uses the variable AsyncMouseButtonsStates and
491 * AsyncKeyStateTable (set in event.c) which have the mouse button
492 * number or key number (whichever is applicable) set to true if the
493 * mouse or key had been depressed since the last call to
496 WORD WINAPI
GetAsyncKeyState(INT nKey
)
502 retval
= (AsyncMouseButtonsStates
[0] ? 0x0001 : 0) |
503 (MouseButtonsStates
[0] ? 0x8000 : 0);
506 retval
= (AsyncMouseButtonsStates
[1] ? 0x0001 : 0) |
507 (MouseButtonsStates
[1] ? 0x8000 : 0);
510 retval
= (AsyncMouseButtonsStates
[2] ? 0x0001 : 0) |
511 (MouseButtonsStates
[2] ? 0x8000 : 0);
514 retval
= AsyncKeyStateTable
[nKey
] |
515 ((InputKeyStateTable
[nKey
] & 0x80) ? 0x8000 : 0);
519 /* all states to false */
520 memset( AsyncMouseButtonsStates
, 0, sizeof(AsyncMouseButtonsStates
) );
521 memset( AsyncKeyStateTable
, 0, sizeof(AsyncKeyStateTable
) );
523 TRACE(key
, "(%x) -> %x\n", nKey
, retval
);
527 /**********************************************************************
528 * GetAsyncKeyState16 (USER.249)
530 WORD WINAPI
GetAsyncKeyState16(INT16 nKey
)
532 return GetAsyncKeyState(nKey
);
535 /**********************************************************************
536 * KBD_translate_accelerator
538 * FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
540 static BOOL
KBD_translate_accelerator(HWND hWnd
,LPMSG msg
,
541 BYTE fVirt
,WORD key
,WORD cmd
)
543 BOOL sendmsg
= FALSE
;
545 if(msg
->wParam
== key
)
547 if (msg
->message
== WM_CHAR
) {
548 if ( !(fVirt
& FALT
) && !(fVirt
& FVIRTKEY
) )
550 TRACE(accel
,"found accel for WM_CHAR: ('%c')\n",
555 if(fVirt
& FVIRTKEY
) {
557 TRACE(accel
,"found accel for virt_key %04x (scan %04x)\n",
558 msg
->wParam
,0xff & HIWORD(msg
->lParam
));
559 if(GetKeyState(VK_SHIFT
) & 0x8000) mask
|= FSHIFT
;
560 if(GetKeyState(VK_CONTROL
) & 0x8000) mask
|= FCONTROL
;
561 if(GetKeyState(VK_MENU
) & 0x8000) mask
|= FALT
;
562 if(mask
== (fVirt
& (FSHIFT
| FCONTROL
| FALT
)))
565 TRACE(accel
,", but incorrect SHIFT/CTRL/ALT-state\n");
569 if (!(msg
->lParam
& 0x01000000)) /* no special_key */
571 if ((fVirt
& FALT
) && (msg
->lParam
& 0x20000000))
572 { /* ^^ ALT pressed */
573 TRACE(accel
,"found accel for Alt-%c\n", msg
->wParam
&0xff);
580 if (sendmsg
) /* found an accelerator, but send a message... ? */
582 INT16 iSysStat
,iStat
,mesg
=0;
585 if (msg
->message
== WM_KEYUP
|| msg
->message
== WM_SYSKEYUP
)
591 if (!IsWindowEnabled(hWnd
))
595 WND
* wndPtr
= WIN_FindWndPtr(hWnd
);
597 hMenu
= (wndPtr
->dwStyle
& WS_CHILD
) ? 0 : (HMENU
)wndPtr
->wIDmenu
;
598 iSysStat
= (wndPtr
->hSysMenu
) ? GetMenuState(GetSubMenu16(wndPtr
->hSysMenu
, 0),
599 cmd
, MF_BYCOMMAND
) : -1 ;
600 iStat
= (hMenu
) ? GetMenuState(hMenu
,
601 cmd
, MF_BYCOMMAND
) : -1 ;
603 WIN_ReleaseWndPtr(wndPtr
);
607 if (iSysStat
& (MF_DISABLED
|MF_GRAYED
))
620 if (iStat
& (MF_DISABLED
|MF_GRAYED
))
630 if ( mesg
==WM_COMMAND
|| mesg
==WM_SYSCOMMAND
)
632 TRACE(accel
,", sending %s, wParam=%0x\n",
633 mesg
==WM_COMMAND
? "WM_COMMAND" : "WM_SYSCOMMAND",
635 SendMessageA(hWnd
, mesg
, cmd
, 0x00010000L
);
639 /* some reasons for NOT sending the WM_{SYS}COMMAND message:
640 * #0: unknown (please report!)
641 * #1: for WM_KEYUP,WM_SYSKEYUP
642 * #2: mouse is captured
643 * #3: window is disabled
644 * #4: it's a disabled system menu option
645 * #5: it's a menu option, but window is iconic
646 * #6: it's a menu option, but disabled
648 TRACE(accel
,", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg
);
650 ERR(accel
, " unknown reason - please report!");
658 /**********************************************************************
659 * TranslateAccelerator32 (USER32.551)(USER32.552)(USER32.553)
661 INT WINAPI
TranslateAccelerator(HWND hWnd
, HACCEL hAccel
, LPMSG msg
)
664 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
667 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
);
669 if (hAccel
== 0 || msg
== NULL
||
670 (msg
->message
!= WM_KEYDOWN
&&
671 msg
->message
!= WM_KEYUP
&&
672 msg
->message
!= WM_SYSKEYDOWN
&&
673 msg
->message
!= WM_SYSKEYUP
&&
674 msg
->message
!= WM_CHAR
)) {
675 WARN(accel
, "erraneous input parameters\n");
676 SetLastError(ERROR_INVALID_PARAMETER
);
680 TRACE(accel
, "TranslateAccelerators hAccel=%04x, hWnd=%04x,"
681 "msg->hwnd=%04x, msg->message=%04x\n",
682 hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
687 if (KBD_translate_accelerator(hWnd
,msg
,lpAccelTbl
[i
].fVirt
,
688 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
690 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
691 WARN(accel
, "couldn't translate accelerator key\n");
695 /**********************************************************************
696 * TranslateAccelerator16 (USER.178)
698 INT16 WINAPI
TranslateAccelerator16(HWND16 hWnd
, HACCEL16 hAccel
, LPMSG16 msg
)
700 LPACCEL16 lpAccelTbl
= (LPACCEL16
)LockResource16(hAccel
);
704 if (hAccel
== 0 || msg
== NULL
||
705 (msg
->message
!= WM_KEYDOWN
&&
706 msg
->message
!= WM_KEYUP
&&
707 msg
->message
!= WM_SYSKEYDOWN
&&
708 msg
->message
!= WM_SYSKEYUP
&&
709 msg
->message
!= WM_CHAR
)) {
710 WARN(accel
, "erraneous input parameters\n");
711 SetLastError(ERROR_INVALID_PARAMETER
);
715 TRACE(accel
, "TranslateAccelerators hAccel=%04x, hWnd=%04x,\
716 msg->hwnd=%04x, msg->message=%04x\n", hAccel
,hWnd
,msg
->hwnd
,msg
->message
);
717 STRUCT32_MSG16to32(msg
,&msg32
);
723 if (KBD_translate_accelerator(hWnd
,&msg32
,lpAccelTbl
[i
].fVirt
,
724 lpAccelTbl
[i
].key
,lpAccelTbl
[i
].cmd
))
726 } while ((lpAccelTbl
[i
++].fVirt
& 0x80) == 0);
727 WARN(accel
, "couldn't translate accelerator key\n");
732 /**********************************************************************
733 * VkKeyScanA (USER32.573)
735 WORD WINAPI
VkKeyScanA(CHAR cChar
)
737 return VkKeyScan16(cChar
);
740 /******************************************************************************
741 * VkKeyScanW (USER32.576)
743 WORD WINAPI
VkKeyScanW(WCHAR cChar
)
745 return VkKeyScanA((CHAR
)cChar
); /* FIXME: check unicode */
748 /******************************************************************************
749 * GetKeyboardType32 (USER32.255)
751 INT WINAPI
GetKeyboardType(INT nTypeFlag
)
753 return GetKeyboardType16(nTypeFlag
);
756 /******************************************************************************
757 * MapVirtualKey32A (USER32.383)
759 UINT WINAPI
MapVirtualKeyA(UINT code
, UINT maptype
)
761 return MapVirtualKey16(code
,maptype
);
764 /******************************************************************************
765 * MapVirtualKey32W (USER32.385)
767 UINT WINAPI
MapVirtualKeyW(UINT code
, UINT maptype
)
769 return MapVirtualKey16(code
,maptype
);
772 /******************************************************************************
773 * MapVirtualKeyEx32A (USER32.384)
775 UINT WINAPI
MapVirtualKeyEx32A(UINT code
, UINT maptype
, HKL hkl
)
778 FIXME(keyboard
,"(%d,%d,0x%08lx), hkl unhandled!\n",code
,maptype
,(DWORD
)hkl
);
779 return MapVirtualKey16(code
,maptype
);
782 /****************************************************************************
783 * GetKBCodePage32 (USER32.246)
785 UINT WINAPI
GetKBCodePage(void)
787 return GetKBCodePage16();
790 /****************************************************************************
791 * GetKeyboardLayoutName16 (USER.477)
793 INT16 WINAPI
GetKeyboardLayoutName16(LPSTR pwszKLID
)
795 return GetKeyboardLayoutNameA(pwszKLID
);
798 /***********************************************************************
799 * GetKeyboardLayout (USER32.250)
801 * FIXME: - device handle for keyboard layout defaulted to
802 * the language id. This is the way Windows default works.
803 * - the thread identifier (dwLayout) is also ignored.
805 HKL WINAPI
GetKeyboardLayout(DWORD dwLayout
)
808 layout
= GetSystemDefaultLCID(); /* FIXME */
809 layout
|= (layout
<<16); /* FIXME */
810 TRACE(keyboard
,"returning %08x\n",layout
);
814 /****************************************************************************
815 * GetKeyboardLayoutName32A (USER32.252)
817 INT WINAPI
GetKeyboardLayoutNameA(LPSTR pwszKLID
)
819 sprintf(pwszKLID
, "%08x",GetKeyboardLayout(0));
823 /****************************************************************************
824 * GetKeyboardLayoutName32W (USER32.253)
826 INT WINAPI
GetKeyboardLayoutNameW(LPWSTR pwszKLID
)
828 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
829 int res
= GetKeyboardLayoutNameA(buf
);
830 lstrcpyAtoW(pwszKLID
,buf
);
831 HeapFree( GetProcessHeap(), 0, buf
);
835 /****************************************************************************
836 * GetKeyNameText32A (USER32.247)
838 INT WINAPI
GetKeyNameTextA(LONG lParam
, LPSTR lpBuffer
, INT nSize
)
840 return GetKeyNameText16(lParam
,lpBuffer
,nSize
);
843 /****************************************************************************
844 * GetKeyNameText32W (USER32.248)
846 INT WINAPI
GetKeyNameTextW(LONG lParam
, LPWSTR lpBuffer
, INT nSize
)
848 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, nSize
);
849 int res
= GetKeyNameTextA(lParam
,buf
,nSize
);
851 lstrcpynAtoW(lpBuffer
,buf
,nSize
);
852 HeapFree( GetProcessHeap(), 0, buf
);
856 /****************************************************************************
857 * ToAscii32 (USER32.546)
859 INT WINAPI
ToAscii( UINT virtKey
,UINT scanCode
,LPBYTE lpKeyState
,
860 LPWORD lpChar
,UINT flags
)
862 return ToAscii16(virtKey
,scanCode
,lpKeyState
,lpChar
,flags
);
865 /**********************************************************************
866 * ActivateKeyboardLayout32 (USER32.1)
868 * Call ignored. WINE supports only system default keyboard layout.
870 HKL WINAPI
ActivateKeyboardLayout(HKL hLayout
, UINT flags
)
872 TRACE(keyboard
, "(%d, %d)\n", hLayout
, flags
);
873 ERR(keyboard
,"Only default system keyboard layout supported. Call ignored.\n");
878 /***********************************************************************
879 * GetKeyboardLayoutList (USER32.251)
881 * FIXME: Supports only the system default language and layout and
882 * returns only 1 value.
884 * Return number of values available if either input parm is
885 * 0, per MS documentation.
888 INT WINAPI
GetKeyboardLayoutList(INT nBuff
,HKL
*layouts
)
890 TRACE(keyboard
,"(%d,%p)\n",nBuff
,layouts
);
891 if (!nBuff
|| !layouts
)
894 layouts
[0] = GetKeyboardLayout(0);
899 /***********************************************************************
900 * RegisterHotKey (USER32.433)
902 BOOL WINAPI
RegisterHotKey(HWND hwnd
,INT id
,UINT modifiers
,UINT vk
) {
903 FIXME(keyboard
,"(0x%08x,%d,0x%08x,%d): stub\n",hwnd
,id
,modifiers
,vk
);
907 /***********************************************************************
908 * UnregisterHotKey (USER32.565)
910 BOOL WINAPI
UnregisterHotKey(HWND hwnd
,INT id
) {
911 FIXME(keyboard
,"(0x%08x,%d): stub\n",hwnd
,id
);
916 /***********************************************************************
917 * ToUnicode32 (USER32.548)
919 INT WINAPI
ToUnicode(
927 FIXME(keyboard
,": stub\n");
931 /***********************************************************************
932 * LoadKeyboardLayout32A (USER32.367)
933 * Call ignored. WINE supports only system default keyboard layout.
935 HKL WINAPI
LoadKeyboardLayoutA(LPCSTR pwszKLID
, UINT Flags
)
937 TRACE(keyboard
, "(%s, %d)\n", pwszKLID
, Flags
);
938 ERR(keyboard
,"Only default system keyboard layout supported. Call ignored.\n");
942 /***********************************************************************
943 * LoadKeyboardLayout32W (USER32.368)
945 HKL WINAPI
LoadKeyboardLayoutW(LPCWSTR pwszKLID
, UINT Flags
)
947 LPSTR buf
= HEAP_xalloc( GetProcessHeap(), 0, strlen("00000409")+1);
949 lstrcpynWtoA(buf
,pwszKLID
,8);
951 res
= LoadKeyboardLayoutA(buf
, Flags
);
952 HeapFree( GetProcessHeap(), 0, buf
);