1998-11-08 13:21:35 +01:00
|
|
|
/*
|
|
|
|
* MOUSE driver
|
|
|
|
*
|
|
|
|
* Copyright 1998 Ulrich Weigand
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
1999-09-20 20:49:02 +02:00
|
|
|
#include <string.h>
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
#include "debugtools.h"
|
1999-09-20 20:49:02 +02:00
|
|
|
#include "callback.h"
|
|
|
|
#include "builtin16.h"
|
1999-12-06 02:20:00 +01:00
|
|
|
#include "module.h"
|
1999-04-01 10:16:08 +02:00
|
|
|
#include "mouse.h"
|
1999-02-12 13:46:49 +01:00
|
|
|
#include "monitor.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "windef.h"
|
|
|
|
#include "wingdi.h"
|
1999-04-01 10:16:08 +02:00
|
|
|
#include "winuser.h"
|
1999-04-18 11:26:29 +02:00
|
|
|
#include "win.h"
|
1999-12-06 02:20:00 +01:00
|
|
|
#include "wine/winbase16.h"
|
1999-02-04 15:05:38 +01:00
|
|
|
|
1999-04-19 16:56:29 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(event)
|
|
|
|
|
1999-02-04 15:05:38 +01:00
|
|
|
/**********************************************************************/
|
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
MOUSE_DRIVER *MOUSE_Driver = NULL;
|
1998-11-08 13:21:35 +01:00
|
|
|
|
|
|
|
static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MOUSE_Inquire (MOUSE.1)
|
|
|
|
*/
|
|
|
|
WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
|
|
|
|
{
|
|
|
|
mouseInfo->msExist = TRUE;
|
|
|
|
mouseInfo->msRelative = FALSE;
|
|
|
|
mouseInfo->msNumButtons = 2;
|
|
|
|
mouseInfo->msRate = 34; /* the DDK says so ... */
|
|
|
|
mouseInfo->msXThreshold = 0;
|
|
|
|
mouseInfo->msYThreshold = 0;
|
|
|
|
mouseInfo->msXRes = 0;
|
|
|
|
mouseInfo->msYRes = 0;
|
|
|
|
mouseInfo->msMouseCommPort = 0;
|
|
|
|
|
|
|
|
return sizeof(MOUSEINFO);
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MOUSE_Enable (MOUSE.2)
|
|
|
|
*/
|
|
|
|
VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
|
|
|
|
{
|
1999-11-07 22:25:57 +01:00
|
|
|
static BOOL initDone = FALSE;
|
|
|
|
|
1999-09-20 20:49:02 +02:00
|
|
|
THUNK_Free( (FARPROC)DefMouseEventProc );
|
1998-11-08 13:21:35 +01:00
|
|
|
DefMouseEventProc = lpMouseEventProc;
|
1999-11-07 22:25:57 +01:00
|
|
|
|
|
|
|
/* Now initialize the mouse driver */
|
1999-12-06 02:20:00 +01:00
|
|
|
if (initDone == FALSE)
|
|
|
|
{
|
|
|
|
MOUSE_Driver->pInit();
|
|
|
|
initDone = TRUE;
|
|
|
|
}
|
1998-11-08 13:21:35 +01:00
|
|
|
}
|
|
|
|
|
1999-09-20 20:49:02 +02:00
|
|
|
static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
|
|
|
|
DWORD dwFlags, DWORD dx, DWORD dy,
|
|
|
|
DWORD cButtons, DWORD dwExtraInfo )
|
|
|
|
{
|
|
|
|
CONTEXT86 context;
|
|
|
|
|
|
|
|
memset( &context, 0, sizeof(context) );
|
|
|
|
CS_reg(&context) = SELECTOROF( proc );
|
|
|
|
EIP_reg(&context) = OFFSETOF( proc );
|
|
|
|
AX_reg(&context) = (WORD)dwFlags;
|
|
|
|
BX_reg(&context) = (WORD)dx;
|
|
|
|
CX_reg(&context) = (WORD)dy;
|
|
|
|
DX_reg(&context) = (WORD)cButtons;
|
|
|
|
SI_reg(&context) = LOWORD( dwExtraInfo );
|
|
|
|
DI_reg(&context) = HIWORD( dwExtraInfo );
|
|
|
|
|
|
|
|
CallTo16RegisterShort( &context, 0 );
|
|
|
|
}
|
|
|
|
|
|
|
|
VOID WINAPI WIN16_MOUSE_Enable( FARPROC16 proc )
|
|
|
|
{
|
|
|
|
LPMOUSE_EVENT_PROC thunk =
|
|
|
|
(LPMOUSE_EVENT_PROC)THUNK_Alloc( proc, (RELAY)MOUSE_CallMouseEventProc );
|
|
|
|
|
|
|
|
MOUSE_Enable( thunk );
|
|
|
|
}
|
|
|
|
|
1998-11-08 13:21:35 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* MOUSE_Disable (MOUSE.3)
|
|
|
|
*/
|
|
|
|
VOID WINAPI MOUSE_Disable(VOID)
|
|
|
|
{
|
1999-09-20 20:49:02 +02:00
|
|
|
THUNK_Free( (FARPROC)DefMouseEventProc );
|
1998-11-08 13:21:35 +01:00
|
|
|
DefMouseEventProc = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MOUSE_SendEvent
|
|
|
|
*/
|
|
|
|
void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY,
|
1999-02-26 12:11:13 +01:00
|
|
|
DWORD keyState, DWORD time, HWND hWnd )
|
1998-11-08 13:21:35 +01:00
|
|
|
{
|
1999-02-12 13:46:49 +01:00
|
|
|
int width = MONITOR_GetWidth (&MONITOR_PrimaryMonitor);
|
|
|
|
int height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
|
1999-04-03 18:27:53 +02:00
|
|
|
int iWndsLocks;
|
1998-11-08 13:21:35 +01:00
|
|
|
WINE_MOUSEEVENT wme;
|
|
|
|
|
|
|
|
if ( !DefMouseEventProc ) return;
|
|
|
|
|
1999-07-04 18:02:24 +02:00
|
|
|
TRACE("(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
|
1998-11-08 13:21:35 +01:00
|
|
|
|
1999-11-07 22:25:57 +01:00
|
|
|
if (mouseStatus & MOUSEEVENTF_MOVE) {
|
|
|
|
if (mouseStatus & MOUSEEVENTF_ABSOLUTE) {
|
|
|
|
/* Relative mouse movements seems not to be scaled as absolute ones */
|
|
|
|
posX = (((long)posX << 16) + width-1) / width;
|
|
|
|
posY = (((long)posY << 16) + height-1) / height;
|
|
|
|
}
|
|
|
|
}
|
1998-11-08 13:21:35 +01:00
|
|
|
|
|
|
|
wme.magic = WINE_MOUSEEVENT_MAGIC;
|
|
|
|
wme.time = time;
|
|
|
|
wme.hWnd = hWnd;
|
1999-11-07 22:25:57 +01:00
|
|
|
wme.keyState = keyState;
|
|
|
|
|
2000-02-25 21:53:34 +01:00
|
|
|
MOUSE_Driver->pEnableWarpPointer(FALSE);
|
1999-04-03 18:27:53 +02:00
|
|
|
/* To avoid deadlocks, we have to suspend all locks on windows structures
|
|
|
|
before the program control is passed to the mouse driver */
|
|
|
|
iWndsLocks = WIN_SuspendWndsLock();
|
1998-11-08 13:21:35 +01:00
|
|
|
DefMouseEventProc( mouseStatus, posX, posY, 0, (DWORD)&wme );
|
1999-04-03 18:27:53 +02:00
|
|
|
WIN_RestoreWndsLock(iWndsLocks);
|
2000-02-25 21:53:34 +01:00
|
|
|
MOUSE_Driver->pEnableWarpPointer(TRUE);
|
1998-11-08 13:21:35 +01:00
|
|
|
}
|