1998-11-08 13:26:36 +01:00
|
|
|
/*
|
|
|
|
* USER Input processing
|
|
|
|
*
|
|
|
|
* Copyright 1993 Bob Amstadt
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
|
|
|
* Copyright 1997 David Faure
|
|
|
|
* Copyright 1998 Morten Welinder
|
|
|
|
* Copyright 1998 Ulrich Weigand
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
1998-11-08 13:26:36 +01:00
|
|
|
#include <ctype.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "wingdi.h"
|
1999-02-22 11:16:00 +01:00
|
|
|
#include "winuser.h"
|
|
|
|
#include "wine/winbase16.h"
|
|
|
|
#include "wine/winuser16.h"
|
1999-02-24 14:05:13 +01:00
|
|
|
#include "wine/keyboard16.h"
|
1998-11-08 13:26:36 +01:00
|
|
|
#include "win.h"
|
|
|
|
#include "heap.h"
|
|
|
|
#include "input.h"
|
|
|
|
#include "keyboard.h"
|
|
|
|
#include "mouse.h"
|
|
|
|
#include "message.h"
|
2000-03-08 19:26:56 +01:00
|
|
|
#include "queue.h"
|
1999-09-20 20:49:02 +02:00
|
|
|
#include "module.h"
|
1998-11-08 13:26:36 +01:00
|
|
|
#include "debugtools.h"
|
|
|
|
#include "struct32.h"
|
|
|
|
#include "winerror.h"
|
1999-02-05 11:37:53 +01:00
|
|
|
#include "task.h"
|
1998-11-08 13:26:36 +01:00
|
|
|
|
2000-02-10 20:03:02 +01:00
|
|
|
DECLARE_DEBUG_CHANNEL(accel);
|
|
|
|
DECLARE_DEBUG_CHANNEL(event);
|
|
|
|
DECLARE_DEBUG_CHANNEL(key);
|
|
|
|
DECLARE_DEBUG_CHANNEL(keyboard);
|
|
|
|
DECLARE_DEBUG_CHANNEL(win);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
static BOOL InputEnabled = TRUE;
|
1999-11-07 22:25:57 +01:00
|
|
|
BOOL SwappedButtons = FALSE;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL MouseButtonsStates[3];
|
|
|
|
BOOL AsyncMouseButtonsStates[3];
|
1998-11-08 13:26:36 +01:00
|
|
|
BYTE InputKeyStateTable[256];
|
|
|
|
BYTE QueueKeyStateTable[256];
|
|
|
|
BYTE AsyncKeyStateTable[256];
|
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
/* Storage for the USER-maintained mouse positions */
|
|
|
|
DWORD PosX, PosY;
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
typedef union
|
|
|
|
{
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
unsigned long count : 16;
|
|
|
|
unsigned long code : 8;
|
|
|
|
unsigned long extended : 1;
|
|
|
|
unsigned long unused : 2;
|
|
|
|
unsigned long win_internal : 2;
|
|
|
|
unsigned long context : 1;
|
|
|
|
unsigned long previous : 1;
|
|
|
|
unsigned long transition : 1;
|
|
|
|
} lp1;
|
|
|
|
unsigned long lp2;
|
|
|
|
} KEYLP;
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* keybd_event (USER32.583)
|
|
|
|
*/
|
|
|
|
void WINAPI keybd_event( BYTE bVk, BYTE bScan,
|
|
|
|
DWORD dwFlags, DWORD dwExtraInfo )
|
|
|
|
{
|
1999-11-07 22:25:57 +01:00
|
|
|
DWORD time, extra;
|
1998-11-08 13:26:36 +01:00
|
|
|
WORD message;
|
|
|
|
KEYLP keylp;
|
|
|
|
keylp.lp2 = 0;
|
|
|
|
|
|
|
|
if (!InputEnabled) return;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* If we are called by the Wine keyboard driver, use the additional
|
|
|
|
* info pointed to by the dwExtraInfo argument.
|
|
|
|
* Otherwise, we need to determine that info ourselves (probably
|
|
|
|
* less accurate, but we can't help that ...).
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_KEYBDEVENT) )
|
1998-11-08 13:26:36 +01:00
|
|
|
&& ((WINE_KEYBDEVENT *)dwExtraInfo)->magic == WINE_KEYBDEVENT_MAGIC )
|
|
|
|
{
|
|
|
|
WINE_KEYBDEVENT *wke = (WINE_KEYBDEVENT *)dwExtraInfo;
|
|
|
|
time = wke->time;
|
|
|
|
extra = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
time = GetTickCount();
|
|
|
|
extra = dwExtraInfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
keylp.lp1.count = 1;
|
|
|
|
keylp.lp1.code = bScan;
|
|
|
|
keylp.lp1.extended = (dwFlags & KEYEVENTF_EXTENDEDKEY) != 0;
|
|
|
|
keylp.lp1.win_internal = 0; /* this has something to do with dialogs,
|
|
|
|
* don't remember where I read it - AK */
|
|
|
|
/* it's '1' under windows, when a dialog box appears
|
|
|
|
* and you press one of the underlined keys - DF*/
|
|
|
|
|
|
|
|
if ( dwFlags & KEYEVENTF_KEYUP )
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL sysKey = (InputKeyStateTable[VK_MENU] & 0x80)
|
1998-11-08 13:26:36 +01:00
|
|
|
&& !(InputKeyStateTable[VK_CONTROL] & 0x80)
|
|
|
|
&& !(dwFlags & KEYEVENTF_WINE_FORCEEXTENDED); /* for Alt from AltGr */
|
|
|
|
|
|
|
|
InputKeyStateTable[bVk] &= ~0x80;
|
|
|
|
keylp.lp1.previous = 1;
|
|
|
|
keylp.lp1.transition = 1;
|
|
|
|
message = sysKey ? WM_SYSKEYUP : WM_KEYUP;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
keylp.lp1.previous = (InputKeyStateTable[bVk] & 0x80) != 0;
|
|
|
|
keylp.lp1.transition = 0;
|
|
|
|
|
|
|
|
if (!(InputKeyStateTable[bVk] & 0x80))
|
|
|
|
InputKeyStateTable[bVk] ^= 0x01;
|
|
|
|
InputKeyStateTable[bVk] |= 0x80;
|
|
|
|
|
|
|
|
message = (InputKeyStateTable[VK_MENU] & 0x80)
|
|
|
|
&& !(InputKeyStateTable[VK_CONTROL] & 0x80)
|
|
|
|
? WM_SYSKEYDOWN : WM_KEYDOWN;
|
|
|
|
}
|
|
|
|
|
|
|
|
if ( message == WM_SYSKEYDOWN || message == WM_SYSKEYUP )
|
|
|
|
keylp.lp1.context = (InputKeyStateTable[VK_MENU] & 0x80) != 0; /* 1 if alt */
|
|
|
|
|
|
|
|
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(key)(" wParam=%04X, lParam=%08lX\n", bVk, keylp.lp2 );
|
|
|
|
TRACE_(key)(" InputKeyState=%X\n", InputKeyStateTable[bVk] );
|
1998-11-08 13:26:36 +01:00
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
hardware_event( message, bVk, keylp.lp2, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-09-20 20:49:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WIN16_keybd_event (USER.289)
|
|
|
|
*/
|
|
|
|
void WINAPI WIN16_keybd_event( CONTEXT86 *context )
|
|
|
|
{
|
|
|
|
DWORD dwFlags = 0;
|
|
|
|
|
|
|
|
if (AH_reg(context) & 0x80) dwFlags |= KEYEVENTF_KEYUP;
|
|
|
|
if (BH_reg(context) & 1 ) dwFlags |= KEYEVENTF_EXTENDEDKEY;
|
|
|
|
|
|
|
|
keybd_event( AL_reg(context), BL_reg(context),
|
|
|
|
dwFlags, MAKELONG(SI_reg(context), DI_reg(context)) );
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* mouse_event (USER32.584)
|
|
|
|
*/
|
|
|
|
void WINAPI mouse_event( DWORD dwFlags, DWORD dx, DWORD dy,
|
|
|
|
DWORD cButtons, DWORD dwExtraInfo )
|
|
|
|
{
|
1999-11-07 22:25:57 +01:00
|
|
|
DWORD time, extra;
|
|
|
|
DWORD keyState;
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
if (!InputEnabled) return;
|
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
if ( dwFlags & MOUSEEVENTF_MOVE )
|
|
|
|
{
|
|
|
|
if ( dwFlags & MOUSEEVENTF_ABSOLUTE )
|
|
|
|
{
|
|
|
|
PosX = (dx * GetSystemMetrics(SM_CXSCREEN)) >> 16;
|
|
|
|
PosY = (dy * GetSystemMetrics(SM_CYSCREEN)) >> 16;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
int width = GetSystemMetrics(SM_CXSCREEN);
|
|
|
|
int height = GetSystemMetrics(SM_CYSCREEN);
|
|
|
|
long posX = (long) PosX, posY = (long) PosY;
|
|
|
|
|
|
|
|
/* dx and dy can be negative numbers for relative movements */
|
|
|
|
posX += (long) dx;
|
|
|
|
posY += (long) dy;
|
|
|
|
|
|
|
|
/* Clip to the current screen size */
|
|
|
|
if (posX < 0) PosX = 0;
|
|
|
|
else if (posX >= width) PosX = width - 1;
|
|
|
|
else PosX = posX;
|
|
|
|
|
|
|
|
if (posY < 0) PosY = 0;
|
|
|
|
else if (posY >= height) PosY = height - 1;
|
|
|
|
else PosY = posY;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/*
|
|
|
|
* If we are called by the Wine mouse driver, use the additional
|
|
|
|
* info pointed to by the dwExtraInfo argument.
|
|
|
|
* Otherwise, we need to determine that info ourselves (probably
|
|
|
|
* less accurate, but we can't help that ...).
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
if ( !IsBadReadPtr( (LPVOID)dwExtraInfo, sizeof(WINE_MOUSEEVENT) )
|
1998-11-08 13:26:36 +01:00
|
|
|
&& ((WINE_MOUSEEVENT *)dwExtraInfo)->magic == WINE_MOUSEEVENT_MAGIC )
|
|
|
|
{
|
|
|
|
WINE_MOUSEEVENT *wme = (WINE_MOUSEEVENT *)dwExtraInfo;
|
|
|
|
time = wme->time;
|
|
|
|
extra = (DWORD)wme->hWnd;
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState = wme->keyState;
|
|
|
|
|
|
|
|
if (keyState != GET_KEYSTATE()) {
|
|
|
|
/* We need to update the keystate with what X provides us */
|
|
|
|
MouseButtonsStates[SwappedButtons ? 2 : 0] = (keyState & MK_LBUTTON ? TRUE : FALSE);
|
|
|
|
MouseButtonsStates[SwappedButtons ? 0 : 2] = (keyState & MK_RBUTTON ? TRUE : FALSE);
|
|
|
|
MouseButtonsStates[1] = (keyState & MK_MBUTTON ? TRUE : FALSE);
|
|
|
|
InputKeyStateTable[VK_SHIFT] = (keyState & MK_SHIFT ? 0x80 : 0);
|
|
|
|
InputKeyStateTable[VK_CONTROL] = (keyState & MK_CONTROL ? 0x80 : 0);
|
|
|
|
}
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
time = GetTickCount();
|
|
|
|
extra = dwExtraInfo;
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState = GET_KEYSTATE();
|
|
|
|
|
|
|
|
if ( dwFlags & MOUSEEVENTF_MOVE )
|
|
|
|
{
|
|
|
|
/* We have to actually move the cursor */
|
|
|
|
SetCursorPos( PosX, PosY );
|
|
|
|
}
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
if ( dwFlags & MOUSEEVENTF_MOVE )
|
|
|
|
{
|
|
|
|
hardware_event( WM_MOUSEMOVE,
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTDOWN : MOUSEEVENTF_RIGHTDOWN) )
|
|
|
|
{
|
|
|
|
MouseButtonsStates[0] = AsyncMouseButtonsStates[0] = TRUE;
|
|
|
|
hardware_event( WM_LBUTTONDOWN,
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_LEFTUP : MOUSEEVENTF_RIGHTUP) )
|
|
|
|
{
|
|
|
|
MouseButtonsStates[0] = FALSE;
|
|
|
|
hardware_event( WM_LBUTTONUP,
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTDOWN : MOUSEEVENTF_LEFTDOWN) )
|
|
|
|
{
|
|
|
|
MouseButtonsStates[2] = AsyncMouseButtonsStates[2] = TRUE;
|
|
|
|
hardware_event( WM_RBUTTONDOWN,
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
if ( dwFlags & (!SwappedButtons? MOUSEEVENTF_RIGHTUP : MOUSEEVENTF_LEFTUP) )
|
|
|
|
{
|
|
|
|
MouseButtonsStates[2] = FALSE;
|
|
|
|
hardware_event( WM_RBUTTONUP,
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
if ( dwFlags & MOUSEEVENTF_MIDDLEDOWN )
|
|
|
|
{
|
|
|
|
MouseButtonsStates[1] = AsyncMouseButtonsStates[1] = TRUE;
|
|
|
|
hardware_event( WM_MBUTTONDOWN,
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
if ( dwFlags & MOUSEEVENTF_MIDDLEUP )
|
|
|
|
{
|
|
|
|
MouseButtonsStates[1] = FALSE;
|
|
|
|
hardware_event( WM_MBUTTONUP,
|
1999-11-07 22:25:57 +01:00
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
2000-04-18 13:56:33 +02:00
|
|
|
if ( dwFlags & MOUSEEVENTF_WHEEL )
|
|
|
|
{
|
|
|
|
hardware_event( WM_MOUSEWHEEL,
|
|
|
|
keyState, 0L, PosX, PosY, time, extra );
|
|
|
|
}
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-09-20 20:49:02 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* WIN16_mouse_event (USER.299)
|
|
|
|
*/
|
|
|
|
void WINAPI WIN16_mouse_event( CONTEXT86 *context )
|
|
|
|
{
|
|
|
|
mouse_event( AX_reg(context), BX_reg(context), CX_reg(context),
|
|
|
|
DX_reg(context), MAKELONG(SI_reg(context), DI_reg(context)) );
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetMouseEventProc (USER.337)
|
|
|
|
*/
|
|
|
|
FARPROC16 WINAPI GetMouseEventProc16(void)
|
|
|
|
{
|
|
|
|
HMODULE16 hmodule = GetModuleHandle16("USER");
|
|
|
|
return NE_GetEntryPoint( hmodule, NE_GetOrdinal( hmodule, "mouse_event" ));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* EnableHardwareInput (USER.331)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL16 WINAPI EnableHardwareInput16(BOOL16 bEnable)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
BOOL16 bOldState = InputEnabled;
|
1999-05-02 16:32:27 +02:00
|
|
|
FIXME_(event)("(%d) - stub\n", bEnable);
|
1998-11-08 13:26:36 +01:00
|
|
|
InputEnabled = bEnable;
|
|
|
|
return bOldState;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SwapMouseButton16 (USER.186)
|
|
|
|
*/
|
|
|
|
BOOL16 WINAPI SwapMouseButton16( BOOL16 fSwap )
|
|
|
|
{
|
|
|
|
BOOL16 ret = SwappedButtons;
|
|
|
|
SwappedButtons = fSwap;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* SwapMouseButton (USER32.537)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI SwapMouseButton( BOOL fSwap )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL ret = SwappedButtons;
|
1998-11-08 13:26:36 +01:00
|
|
|
SwappedButtons = fSwap;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EVENT_Capture
|
|
|
|
*
|
|
|
|
* We need this to be able to generate double click messages
|
|
|
|
* when menu code captures mouse in the window without CS_DBLCLK style.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND EVENT_Capture(HWND hwnd, INT16 ht)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND capturePrev = 0, captureWnd = 0;
|
1999-02-05 11:37:53 +01:00
|
|
|
MESSAGEQUEUE *pMsgQ = 0, *pCurMsgQ = 0;
|
|
|
|
WND* wndPtr = 0;
|
|
|
|
INT16 captureHT = 0;
|
|
|
|
|
|
|
|
/* Get the messageQ for the current thread */
|
1999-02-26 12:11:13 +01:00
|
|
|
if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
|
1999-02-05 11:37:53 +01:00
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
WARN_(win)("\tCurrent message queue not found. Exiting!\n" );
|
1999-02-05 11:37:53 +01:00
|
|
|
goto CLEANUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the current capture window from the perQ data of the current message Q */
|
|
|
|
capturePrev = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData );
|
1998-11-08 13:26:36 +01:00
|
|
|
|
|
|
|
if (!hwnd)
|
|
|
|
{
|
|
|
|
captureWnd = 0L;
|
|
|
|
captureHT = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
1999-02-05 11:37:53 +01:00
|
|
|
wndPtr = WIN_FindWndPtr( hwnd );
|
1998-11-08 13:26:36 +01:00
|
|
|
if (wndPtr)
|
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(win)("(0x%04x)\n", hwnd );
|
1998-11-08 13:26:36 +01:00
|
|
|
captureWnd = hwnd;
|
|
|
|
captureHT = ht;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-05 11:37:53 +01:00
|
|
|
/* Update the perQ capture window and send messages */
|
|
|
|
if( capturePrev != captureWnd )
|
|
|
|
{
|
|
|
|
if (wndPtr)
|
|
|
|
{
|
|
|
|
/* Retrieve the message queue associated with this window */
|
|
|
|
pMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( wndPtr->hmemTaskQ );
|
|
|
|
if ( !pMsgQ )
|
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
WARN_(win)("\tMessage queue not found. Exiting!\n" );
|
1999-02-05 11:37:53 +01:00
|
|
|
goto CLEANUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make sure that message queue for the window we are setting capture to
|
|
|
|
* shares the same perQ data as the current threads message queue.
|
|
|
|
*/
|
|
|
|
if ( pCurMsgQ->pQData != pMsgQ->pQData )
|
|
|
|
goto CLEANUP;
|
|
|
|
}
|
|
|
|
|
|
|
|
PERQDATA_SetCaptureWnd( pCurMsgQ->pQData, captureWnd );
|
|
|
|
PERQDATA_SetCaptureInfo( pCurMsgQ->pQData, captureHT );
|
|
|
|
|
|
|
|
if( capturePrev )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2000-08-07 06:16:43 +02:00
|
|
|
WND* xwndPtr = WIN_FindWndPtr( capturePrev );
|
|
|
|
if( xwndPtr && (xwndPtr->flags & WIN_ISWIN32) )
|
1999-02-26 12:11:13 +01:00
|
|
|
SendMessageA( capturePrev, WM_CAPTURECHANGED, 0L, hwnd);
|
2000-08-07 06:16:43 +02:00
|
|
|
WIN_ReleaseWndPtr(xwndPtr);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
1999-02-05 11:37:53 +01:00
|
|
|
CLEANUP:
|
|
|
|
/* Unlock the queues before returning */
|
|
|
|
if ( pMsgQ )
|
|
|
|
QUEUE_Unlock( pMsgQ );
|
|
|
|
if ( pCurMsgQ )
|
|
|
|
QUEUE_Unlock( pCurMsgQ );
|
|
|
|
|
1999-03-14 18:25:32 +01:00
|
|
|
WIN_ReleaseWndPtr(wndPtr);
|
1999-02-05 11:37:53 +01:00
|
|
|
return capturePrev;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-02-05 11:37:53 +01:00
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* SetCapture16 (USER.18)
|
|
|
|
*/
|
|
|
|
HWND16 WINAPI SetCapture16( HWND16 hwnd )
|
|
|
|
{
|
|
|
|
return (HWND16)EVENT_Capture( hwnd, HTCLIENT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* SetCapture (USER32.464)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND WINAPI SetCapture( HWND hwnd )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return EVENT_Capture( hwnd, HTCLIENT );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ReleaseCapture (USER.19) (USER32.439)
|
|
|
|
*/
|
1999-04-15 18:40:16 +02:00
|
|
|
BOOL WINAPI ReleaseCapture(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-04-15 18:40:16 +02:00
|
|
|
return (EVENT_Capture( 0, 0 ) != 0);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetCapture16 (USER.236)
|
|
|
|
*/
|
|
|
|
HWND16 WINAPI GetCapture16(void)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return (HWND16)GetCapture();
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetCapture (USER32.208)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND WINAPI GetCapture(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-02-05 11:37:53 +01:00
|
|
|
MESSAGEQUEUE *pCurMsgQ = 0;
|
1999-02-26 12:11:13 +01:00
|
|
|
HWND hwndCapture = 0;
|
1999-02-05 11:37:53 +01:00
|
|
|
|
|
|
|
/* Get the messageQ for the current thread */
|
1999-02-26 12:11:13 +01:00
|
|
|
if (!(pCurMsgQ = (MESSAGEQUEUE *)QUEUE_Lock( GetFastQueue16() )))
|
1999-02-05 11:37:53 +01:00
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(win)("GetCapture32: Current message queue not found. Exiting!\n" );
|
1999-02-05 11:37:53 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Get the current capture window from the perQ data of the current message Q */
|
|
|
|
hwndCapture = PERQDATA_GetCaptureWnd( pCurMsgQ->pQData );
|
|
|
|
|
|
|
|
QUEUE_Unlock( pCurMsgQ );
|
|
|
|
return hwndCapture;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetKeyState (USER.106)
|
|
|
|
*/
|
1998-11-08 14:12:49 +01:00
|
|
|
INT16 WINAPI GetKeyState16(INT16 vkey)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return GetKeyState(vkey);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetKeyState (USER32.249)
|
|
|
|
*
|
|
|
|
* An application calls the GetKeyState function in response to a
|
|
|
|
* keyboard-input message. This function retrieves the state of the key
|
|
|
|
* at the time the input message was generated. (SDK 3.1 Vol 2. p 390)
|
|
|
|
*/
|
1999-09-23 13:48:02 +02:00
|
|
|
SHORT WINAPI GetKeyState(INT vkey)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
INT retval;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
|
|
|
switch (vkey)
|
|
|
|
{
|
|
|
|
case VK_LBUTTON : /* VK_LBUTTON is 1 */
|
|
|
|
retval = MouseButtonsStates[0] ? 0x8000 : 0;
|
|
|
|
break;
|
|
|
|
case VK_MBUTTON : /* VK_MBUTTON is 4 */
|
|
|
|
retval = MouseButtonsStates[1] ? 0x8000 : 0;
|
|
|
|
break;
|
|
|
|
case VK_RBUTTON : /* VK_RBUTTON is 2 */
|
|
|
|
retval = MouseButtonsStates[2] ? 0x8000 : 0;
|
|
|
|
break;
|
|
|
|
default :
|
|
|
|
if (vkey >= 'a' && vkey <= 'z')
|
|
|
|
vkey += 'A' - 'a';
|
|
|
|
retval = ( (WORD)(QueueKeyStateTable[vkey] & 0x80) << 8 ) |
|
|
|
|
(WORD)(QueueKeyStateTable[vkey] & 0x01);
|
|
|
|
}
|
|
|
|
/* TRACE(key, "(0x%x) -> %x\n", vkey, retval); */
|
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetKeyboardState (USER.222)(USER32.254)
|
|
|
|
*
|
|
|
|
* An application calls the GetKeyboardState function in response to a
|
|
|
|
* keyboard-input message. This function retrieves the state of the keyboard
|
|
|
|
* at the time the input message was generated. (SDK 3.1 Vol 2. p 387)
|
|
|
|
*/
|
1999-05-08 11:35:37 +02:00
|
|
|
BOOL WINAPI GetKeyboardState(LPBYTE lpKeyState)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(key)("(%p)\n", lpKeyState);
|
1998-11-08 13:26:36 +01:00
|
|
|
if (lpKeyState != NULL) {
|
|
|
|
QueueKeyStateTable[VK_LBUTTON] = MouseButtonsStates[0] ? 0x80 : 0;
|
|
|
|
QueueKeyStateTable[VK_MBUTTON] = MouseButtonsStates[1] ? 0x80 : 0;
|
|
|
|
QueueKeyStateTable[VK_RBUTTON] = MouseButtonsStates[2] ? 0x80 : 0;
|
|
|
|
memcpy(lpKeyState, QueueKeyStateTable, 256);
|
|
|
|
}
|
1999-05-08 11:35:37 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* SetKeyboardState (USER.223)(USER32.484)
|
|
|
|
*/
|
1999-05-08 11:35:37 +02:00
|
|
|
BOOL WINAPI SetKeyboardState(LPBYTE lpKeyState)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(key)("(%p)\n", lpKeyState);
|
1998-11-08 13:26:36 +01:00
|
|
|
if (lpKeyState != NULL) {
|
|
|
|
memcpy(QueueKeyStateTable, lpKeyState, 256);
|
|
|
|
MouseButtonsStates[0] = (QueueKeyStateTable[VK_LBUTTON] != 0);
|
|
|
|
MouseButtonsStates[1] = (QueueKeyStateTable[VK_MBUTTON] != 0);
|
|
|
|
MouseButtonsStates[2] = (QueueKeyStateTable[VK_RBUTTON] != 0);
|
|
|
|
}
|
1999-05-08 11:35:37 +02:00
|
|
|
|
|
|
|
return TRUE;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetAsyncKeyState (USER32.207)
|
1998-11-08 13:26:36 +01:00
|
|
|
*
|
|
|
|
* Determine if a key is or was pressed. retval has high-order
|
|
|
|
* bit set to 1 if currently pressed, low-order bit set to 1 if key has
|
|
|
|
* been pressed.
|
|
|
|
*
|
|
|
|
* This uses the variable AsyncMouseButtonsStates and
|
|
|
|
* AsyncKeyStateTable (set in event.c) which have the mouse button
|
|
|
|
* number or key number (whichever is applicable) set to true if the
|
|
|
|
* mouse or key had been depressed since the last call to
|
|
|
|
* GetAsyncKeyState.
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
WORD WINAPI GetAsyncKeyState(INT nKey)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
short retval;
|
|
|
|
|
|
|
|
switch (nKey) {
|
|
|
|
case VK_LBUTTON:
|
|
|
|
retval = (AsyncMouseButtonsStates[0] ? 0x0001 : 0) |
|
|
|
|
(MouseButtonsStates[0] ? 0x8000 : 0);
|
|
|
|
break;
|
|
|
|
case VK_MBUTTON:
|
|
|
|
retval = (AsyncMouseButtonsStates[1] ? 0x0001 : 0) |
|
|
|
|
(MouseButtonsStates[1] ? 0x8000 : 0);
|
|
|
|
break;
|
|
|
|
case VK_RBUTTON:
|
|
|
|
retval = (AsyncMouseButtonsStates[2] ? 0x0001 : 0) |
|
|
|
|
(MouseButtonsStates[2] ? 0x8000 : 0);
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
retval = AsyncKeyStateTable[nKey] |
|
|
|
|
((InputKeyStateTable[nKey] & 0x80) ? 0x8000 : 0);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* all states to false */
|
|
|
|
memset( AsyncMouseButtonsStates, 0, sizeof(AsyncMouseButtonsStates) );
|
|
|
|
memset( AsyncKeyStateTable, 0, sizeof(AsyncKeyStateTable) );
|
|
|
|
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(key)("(%x) -> %x\n", nKey, retval);
|
1998-11-08 13:26:36 +01:00
|
|
|
return retval;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetAsyncKeyState16 (USER.249)
|
|
|
|
*/
|
|
|
|
WORD WINAPI GetAsyncKeyState16(INT16 nKey)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return GetAsyncKeyState(nKey);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-05-22 21:00:27 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* IsUserIdle (USER.333)
|
|
|
|
*/
|
|
|
|
BOOL16 WINAPI IsUserIdle16(void)
|
|
|
|
{
|
|
|
|
if ( GetAsyncKeyState( VK_LBUTTON ) & 0x8000 )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ( GetAsyncKeyState( VK_RBUTTON ) & 0x8000 )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
if ( GetAsyncKeyState( VK_MBUTTON ) & 0x8000 )
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Should check for screen saver activation here ... */
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* KBD_translate_accelerator
|
|
|
|
*
|
|
|
|
* FIXME: should send some WM_INITMENU or/and WM_INITMENUPOPUP -messages
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
static BOOL KBD_translate_accelerator(HWND hWnd,LPMSG msg,
|
1998-11-08 13:26:36 +01:00
|
|
|
BYTE fVirt,WORD key,WORD cmd)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL sendmsg = FALSE;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
|
|
|
if(msg->wParam == key)
|
|
|
|
{
|
|
|
|
if (msg->message == WM_CHAR) {
|
|
|
|
if ( !(fVirt & FALT) && !(fVirt & FVIRTKEY) )
|
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(accel)("found accel for WM_CHAR: ('%c')\n",
|
1998-11-08 13:26:36 +01:00
|
|
|
msg->wParam&0xff);
|
|
|
|
sendmsg=TRUE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if(fVirt & FVIRTKEY) {
|
1999-02-26 12:11:13 +01:00
|
|
|
INT mask = 0;
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(accel)("found accel for virt_key %04x (scan %04x)\n",
|
1998-11-08 13:26:36 +01:00
|
|
|
msg->wParam,0xff & HIWORD(msg->lParam));
|
1999-02-26 12:11:13 +01:00
|
|
|
if(GetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT;
|
|
|
|
if(GetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL;
|
|
|
|
if(GetKeyState(VK_MENU) & 0x8000) mask |= FALT;
|
1998-11-08 13:26:36 +01:00
|
|
|
if(mask == (fVirt & (FSHIFT | FCONTROL | FALT)))
|
|
|
|
sendmsg=TRUE;
|
|
|
|
else
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(accel)(", but incorrect SHIFT/CTRL/ALT-state\n");
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (!(msg->lParam & 0x01000000)) /* no special_key */
|
|
|
|
{
|
|
|
|
if ((fVirt & FALT) && (msg->lParam & 0x20000000))
|
|
|
|
{ /* ^^ ALT pressed */
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(accel)("found accel for Alt-%c\n", msg->wParam&0xff);
|
1998-11-08 13:26:36 +01:00
|
|
|
sendmsg=TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (sendmsg) /* found an accelerator, but send a message... ? */
|
|
|
|
{
|
|
|
|
INT16 iSysStat,iStat,mesg=0;
|
|
|
|
HMENU16 hMenu;
|
|
|
|
|
|
|
|
if (msg->message == WM_KEYUP || msg->message == WM_SYSKEYUP)
|
|
|
|
mesg=1;
|
|
|
|
else
|
1999-02-26 12:11:13 +01:00
|
|
|
if (GetCapture())
|
1998-11-08 13:26:36 +01:00
|
|
|
mesg=2;
|
|
|
|
else
|
1999-02-26 12:11:13 +01:00
|
|
|
if (!IsWindowEnabled(hWnd))
|
1998-11-08 13:26:36 +01:00
|
|
|
mesg=3;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
WND* wndPtr = WIN_FindWndPtr(hWnd);
|
|
|
|
|
1999-02-26 12:11:13 +01:00
|
|
|
hMenu = (wndPtr->dwStyle & WS_CHILD) ? 0 : (HMENU)wndPtr->wIDmenu;
|
|
|
|
iSysStat = (wndPtr->hSysMenu) ? GetMenuState(GetSubMenu16(wndPtr->hSysMenu, 0),
|
1998-11-08 13:26:36 +01:00
|
|
|
cmd, MF_BYCOMMAND) : -1 ;
|
1999-02-26 12:11:13 +01:00
|
|
|
iStat = (hMenu) ? GetMenuState(hMenu,
|
1998-11-08 13:26:36 +01:00
|
|
|
cmd, MF_BYCOMMAND) : -1 ;
|
|
|
|
|
1999-03-14 18:25:32 +01:00
|
|
|
WIN_ReleaseWndPtr(wndPtr);
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
if (iSysStat!=-1)
|
|
|
|
{
|
|
|
|
if (iSysStat & (MF_DISABLED|MF_GRAYED))
|
|
|
|
mesg=4;
|
|
|
|
else
|
|
|
|
mesg=WM_SYSCOMMAND;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (iStat!=-1)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
if (IsIconic(hWnd))
|
1998-11-08 13:26:36 +01:00
|
|
|
mesg=5;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (iStat & (MF_DISABLED|MF_GRAYED))
|
|
|
|
mesg=6;
|
|
|
|
else
|
|
|
|
mesg=WM_COMMAND;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
mesg=WM_COMMAND;
|
|
|
|
}
|
|
|
|
}
|
2000-03-24 20:46:13 +01:00
|
|
|
if( mesg==WM_COMMAND ) {
|
|
|
|
TRACE_(accel)(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd);
|
|
|
|
SendMessageA(hWnd, mesg, 0x10000 | cmd, 0L);
|
|
|
|
} else if( mesg==WM_SYSCOMMAND ) {
|
|
|
|
TRACE_(accel)(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd);
|
1999-02-26 12:11:13 +01:00
|
|
|
SendMessageA(hWnd, mesg, cmd, 0x00010000L);
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* some reasons for NOT sending the WM_{SYS}COMMAND message:
|
|
|
|
* #0: unknown (please report!)
|
|
|
|
* #1: for WM_KEYUP,WM_SYSKEYUP
|
|
|
|
* #2: mouse is captured
|
|
|
|
* #3: window is disabled
|
|
|
|
* #4: it's a disabled system menu option
|
|
|
|
* #5: it's a menu option, but window is iconic
|
|
|
|
* #6: it's a menu option, but disabled
|
|
|
|
*/
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(accel)(", but won't send WM_{SYS}COMMAND, reason is #%d\n",mesg);
|
1998-11-08 13:26:36 +01:00
|
|
|
if(mesg==0)
|
1999-05-02 16:32:27 +02:00
|
|
|
ERR_(accel)(" unknown reason - please report!");
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* TranslateAccelerator (USER32.551)(USER32.552)(USER32.553)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI TranslateAccelerator(HWND hWnd, HACCEL hAccel, LPMSG msg)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-01-22 18:09:46 +01:00
|
|
|
/* YES, Accel16! */
|
1999-05-29 16:02:28 +02:00
|
|
|
LPACCEL16 lpAccelTbl;
|
1998-11-08 13:26:36 +01:00
|
|
|
int i;
|
|
|
|
|
1999-05-29 16:02:28 +02:00
|
|
|
if (msg == NULL)
|
|
|
|
{
|
|
|
|
WARN_(accel)("msg null; should hang here to be win compatible\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!hAccel || !(lpAccelTbl = (LPACCEL16) LockResource16(hAccel)))
|
|
|
|
{
|
|
|
|
WARN_(accel)("invalid accel handle=%x\n", hAccel);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ((msg->message != WM_KEYDOWN &&
|
1998-11-08 13:26:36 +01:00
|
|
|
msg->message != WM_KEYUP &&
|
|
|
|
msg->message != WM_SYSKEYDOWN &&
|
|
|
|
msg->message != WM_SYSKEYUP &&
|
1999-05-29 16:02:28 +02:00
|
|
|
msg->message != WM_CHAR)) return 0;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(accel)("TranslateAccelerators hAccel=%04x, hWnd=%04x,"
|
1999-05-29 16:02:28 +02:00
|
|
|
"msg->hwnd=%04x, msg->message=%04x, wParam=%08x, lParam=%lx\n",
|
|
|
|
hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam);
|
1998-11-08 13:26:36 +01:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (KBD_translate_accelerator(hWnd,msg,lpAccelTbl[i].fVirt,
|
|
|
|
lpAccelTbl[i].key,lpAccelTbl[i].cmd))
|
|
|
|
return 1;
|
|
|
|
} while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
|
1999-05-02 16:32:27 +02:00
|
|
|
WARN_(accel)("couldn't translate accelerator key\n");
|
1998-11-08 13:26:36 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* TranslateAccelerator16 (USER.178)
|
|
|
|
*/
|
|
|
|
INT16 WINAPI TranslateAccelerator16(HWND16 hWnd, HACCEL16 hAccel, LPMSG16 msg)
|
|
|
|
{
|
1999-05-29 16:02:28 +02:00
|
|
|
LPACCEL16 lpAccelTbl;
|
1998-11-08 13:26:36 +01:00
|
|
|
int i;
|
1999-02-26 12:11:13 +01:00
|
|
|
MSG msg32;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
1999-05-29 16:02:28 +02:00
|
|
|
if (msg == NULL)
|
|
|
|
{
|
|
|
|
WARN_(accel)("msg null; should hang here to be win compatible\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if (!hAccel || !(lpAccelTbl = (LPACCEL16) LockResource16(hAccel)))
|
|
|
|
{
|
|
|
|
WARN_(accel)("invalid accel handle=%x\n", hAccel);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
if ((msg->message != WM_KEYDOWN &&
|
1998-11-08 13:26:36 +01:00
|
|
|
msg->message != WM_KEYUP &&
|
|
|
|
msg->message != WM_SYSKEYDOWN &&
|
|
|
|
msg->message != WM_SYSKEYUP &&
|
1999-05-29 16:02:28 +02:00
|
|
|
msg->message != WM_CHAR)) return 0;
|
1998-11-08 13:26:36 +01:00
|
|
|
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(accel)("TranslateAccelerators hAccel=%04x, hWnd=%04x,\
|
1999-05-29 16:02:28 +02:00
|
|
|
msg->hwnd=%04x, msg->message=%04x, wParam=%04x, lParam=%lx\n", hAccel,hWnd,msg->hwnd,msg->message,msg->wParam,msg->lParam);
|
1998-11-08 13:26:36 +01:00
|
|
|
|
1999-05-29 16:02:28 +02:00
|
|
|
STRUCT32_MSG16to32(msg,&msg32);
|
1998-11-08 13:26:36 +01:00
|
|
|
|
|
|
|
i = 0;
|
|
|
|
do
|
|
|
|
{
|
|
|
|
if (KBD_translate_accelerator(hWnd,&msg32,lpAccelTbl[i].fVirt,
|
|
|
|
lpAccelTbl[i].key,lpAccelTbl[i].cmd))
|
|
|
|
return 1;
|
|
|
|
} while ((lpAccelTbl[i++].fVirt & 0x80) == 0);
|
1999-05-02 16:32:27 +02:00
|
|
|
WARN_(accel)("couldn't translate accelerator key\n");
|
1998-11-08 13:26:36 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* VkKeyScanA (USER32.573)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
WORD WINAPI VkKeyScanA(CHAR cChar)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return VkKeyScan16(cChar);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* VkKeyScanW (USER32.576)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
WORD WINAPI VkKeyScanW(WCHAR cChar)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return VkKeyScanA((CHAR)cChar); /* FIXME: check unicode */
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/**********************************************************************
|
|
|
|
* VkKeyScanExA (USER32.574)
|
|
|
|
*/
|
|
|
|
WORD WINAPI VkKeyScanExA(CHAR cChar, HKL dwhkl)
|
|
|
|
{
|
|
|
|
/* FIXME: complete workaround this is */
|
|
|
|
return VkKeyScan16(cChar);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
|
|
|
* VkKeyScanExW (USER32.575)
|
|
|
|
*/
|
|
|
|
WORD WINAPI VkKeyScanExW(WCHAR cChar, HKL dwhkl)
|
|
|
|
{
|
|
|
|
/* FIXME: complete workaround this is */
|
|
|
|
return VkKeyScanA((CHAR)cChar); /* FIXME: check unicode */
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetKeyboardType (USER32.255)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyboardType(INT nTypeFlag)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return GetKeyboardType16(nTypeFlag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* MapVirtualKeyA (USER32.383)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI MapVirtualKeyA(UINT code, UINT maptype)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return MapVirtualKey16(code,maptype);
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* MapVirtualKeyW (USER32.385)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI MapVirtualKeyW(UINT code, UINT maptype)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return MapVirtualKey16(code,maptype);
|
|
|
|
}
|
|
|
|
|
1999-02-13 09:53:22 +01:00
|
|
|
/******************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* MapVirtualKeyExA (USER32.384)
|
1999-02-13 09:53:22 +01:00
|
|
|
*/
|
2000-03-28 21:31:18 +02:00
|
|
|
UINT WINAPI MapVirtualKeyExA(UINT code, UINT maptype, HKL hkl)
|
1999-02-13 09:53:22 +01:00
|
|
|
{
|
|
|
|
if (hkl)
|
1999-05-02 16:32:27 +02:00
|
|
|
FIXME_(keyboard)("(%d,%d,0x%08lx), hkl unhandled!\n",code,maptype,(DWORD)hkl);
|
1999-02-13 09:53:22 +01:00
|
|
|
return MapVirtualKey16(code,maptype);
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetKBCodePage (USER32.246)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT WINAPI GetKBCodePage(void)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return GetKBCodePage16();
|
|
|
|
}
|
|
|
|
|
1998-11-14 19:26:59 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* GetKeyboardLayoutName16 (USER.477)
|
|
|
|
*/
|
|
|
|
INT16 WINAPI GetKeyboardLayoutName16(LPSTR pwszKLID)
|
|
|
|
{
|
1999-02-26 12:11:13 +01:00
|
|
|
return GetKeyboardLayoutNameA(pwszKLID);
|
1998-11-14 19:26:59 +01:00
|
|
|
}
|
|
|
|
|
1999-02-28 12:13:16 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetKeyboardLayout (USER32.250)
|
|
|
|
*
|
|
|
|
* FIXME: - device handle for keyboard layout defaulted to
|
|
|
|
* the language id. This is the way Windows default works.
|
|
|
|
* - the thread identifier (dwLayout) is also ignored.
|
|
|
|
*/
|
|
|
|
HKL WINAPI GetKeyboardLayout(DWORD dwLayout)
|
|
|
|
{
|
|
|
|
HKL layout;
|
|
|
|
layout = GetSystemDefaultLCID(); /* FIXME */
|
|
|
|
layout |= (layout<<16); /* FIXME */
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(keyboard)("returning %08x\n",layout);
|
1999-02-28 12:13:16 +01:00
|
|
|
return layout;
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/****************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetKeyboardLayoutNameA (USER32.252)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyboardLayoutNameA(LPSTR pwszKLID)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-02-28 12:13:16 +01:00
|
|
|
sprintf(pwszKLID, "%08x",GetKeyboardLayout(0));
|
1998-11-14 19:26:59 +01:00
|
|
|
return 1;
|
1998-11-08 13:26:36 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetKeyboardLayoutNameW (USER32.253)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyboardLayoutNameW(LPWSTR pwszKLID)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2000-04-30 14:22:18 +02:00
|
|
|
char buf[9];
|
1999-02-26 12:11:13 +01:00
|
|
|
int res = GetKeyboardLayoutNameA(buf);
|
1998-11-08 13:26:36 +01:00
|
|
|
lstrcpyAtoW(pwszKLID,buf);
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetKeyNameTextA (USER32.247)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyNameTextA(LONG lParam, LPSTR lpBuffer, INT nSize)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return GetKeyNameText16(lParam,lpBuffer,nSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* GetKeyNameTextW (USER32.248)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyNameTextW(LONG lParam, LPWSTR lpBuffer, INT nSize)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
2000-04-30 14:22:18 +02:00
|
|
|
int res;
|
|
|
|
LPSTR buf = HeapAlloc( GetProcessHeap(), 0, nSize );
|
|
|
|
if(buf == NULL) return 0; /* FIXME: is this the correct failure value?*/
|
|
|
|
res = GetKeyNameTextA(lParam,buf,nSize);
|
1998-11-08 13:26:36 +01:00
|
|
|
|
|
|
|
lstrcpynAtoW(lpBuffer,buf,nSize);
|
|
|
|
HeapFree( GetProcessHeap(), 0, buf );
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* ToAscii (USER32.546)
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI ToAscii( UINT virtKey,UINT scanCode,LPBYTE lpKeyState,
|
|
|
|
LPWORD lpChar,UINT flags )
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
|
|
|
return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags);
|
|
|
|
}
|
|
|
|
|
1999-03-28 15:15:40 +02:00
|
|
|
/****************************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* ToAsciiEx (USER32.547)
|
1999-03-28 15:15:40 +02:00
|
|
|
*/
|
|
|
|
INT WINAPI ToAsciiEx( UINT virtKey, UINT scanCode, LPBYTE lpKeyState,
|
|
|
|
LPWORD lpChar, UINT flags, HKL dwhkl )
|
|
|
|
{
|
|
|
|
/* FIXME: need true implementation */
|
|
|
|
return ToAscii16(virtKey,scanCode,lpKeyState,lpChar,flags);
|
|
|
|
}
|
|
|
|
|
1998-12-10 16:49:22 +01:00
|
|
|
/**********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* ActivateKeyboardLayout (USER32.1)
|
1999-02-28 12:13:16 +01:00
|
|
|
*
|
|
|
|
* Call ignored. WINE supports only system default keyboard layout.
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HKL WINAPI ActivateKeyboardLayout(HKL hLayout, UINT flags)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(keyboard)("(%d, %d)\n", hLayout, flags);
|
|
|
|
ERR_(keyboard)("Only default system keyboard layout supported. Call ignored.\n");
|
1998-12-10 16:49:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
1998-11-08 13:26:36 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetKeyboardLayoutList (USER32.251)
|
1999-02-28 12:13:16 +01:00
|
|
|
*
|
|
|
|
* FIXME: Supports only the system default language and layout and
|
|
|
|
* returns only 1 value.
|
|
|
|
*
|
|
|
|
* Return number of values available if either input parm is
|
|
|
|
* 0, per MS documentation.
|
|
|
|
*
|
1998-11-08 13:26:36 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI GetKeyboardLayoutList(INT nBuff,HKL *layouts)
|
1998-11-08 13:26:36 +01:00
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(keyboard)("(%d,%p)\n",nBuff,layouts);
|
1999-02-28 12:13:16 +01:00
|
|
|
if (!nBuff || !layouts)
|
|
|
|
return 1;
|
1998-11-08 13:26:36 +01:00
|
|
|
if (layouts)
|
|
|
|
layouts[0] = GetKeyboardLayout(0);
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* RegisterHotKey (USER32.433)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI RegisterHotKey(HWND hwnd,INT id,UINT modifiers,UINT vk) {
|
1999-05-02 16:32:27 +02:00
|
|
|
FIXME_(keyboard)("(0x%08x,%d,0x%08x,%d): stub\n",hwnd,id,modifiers,vk);
|
1998-11-08 13:26:36 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UnregisterHotKey (USER32.565)
|
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
BOOL WINAPI UnregisterHotKey(HWND hwnd,INT id) {
|
1999-05-02 16:32:27 +02:00
|
|
|
FIXME_(keyboard)("(0x%08x,%d): stub\n",hwnd,id);
|
1998-11-08 13:26:36 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
1998-12-10 16:49:22 +01:00
|
|
|
|
|
|
|
/***********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* ToUnicode (USER32.548)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
INT WINAPI ToUnicode(
|
|
|
|
UINT wVirtKey,
|
|
|
|
UINT wScanCode,
|
1998-12-10 16:49:22 +01:00
|
|
|
PBYTE lpKeyState,
|
|
|
|
LPWSTR pwszBuff,
|
1999-09-23 13:48:02 +02:00
|
|
|
INT cchBuff,
|
1999-02-26 12:11:13 +01:00
|
|
|
UINT wFlags) {
|
1998-12-10 16:49:22 +01:00
|
|
|
|
1999-05-02 16:32:27 +02:00
|
|
|
FIXME_(keyboard)(": stub\n");
|
1998-12-10 16:49:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* LoadKeyboardLayoutA (USER32.367)
|
1999-02-28 12:13:16 +01:00
|
|
|
* Call ignored. WINE supports only system default keyboard layout.
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HKL WINAPI LoadKeyboardLayoutA(LPCSTR pwszKLID, UINT Flags)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
1999-05-02 16:32:27 +02:00
|
|
|
TRACE_(keyboard)("(%s, %d)\n", pwszKLID, Flags);
|
|
|
|
ERR_(keyboard)("Only default system keyboard layout supported. Call ignored.\n");
|
1998-12-10 16:49:22 +01:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-03-28 21:31:18 +02:00
|
|
|
* LoadKeyboardLayoutW (USER32.368)
|
1998-12-10 16:49:22 +01:00
|
|
|
*/
|
1999-02-26 12:11:13 +01:00
|
|
|
HKL WINAPI LoadKeyboardLayoutW(LPCWSTR pwszKLID, UINT Flags)
|
1998-12-10 16:49:22 +01:00
|
|
|
{
|
2000-04-30 14:22:18 +02:00
|
|
|
char buf[9];
|
|
|
|
|
1999-02-28 12:13:16 +01:00
|
|
|
lstrcpynWtoA(buf,pwszKLID,8);
|
|
|
|
buf[8] = 0;
|
2000-04-30 14:22:18 +02:00
|
|
|
return LoadKeyboardLayoutA(buf, Flags);
|
1998-12-10 16:49:22 +01:00
|
|
|
}
|