1998-11-08 13:21:35 +01:00
|
|
|
/*
|
|
|
|
* MOUSE driver
|
|
|
|
*
|
|
|
|
* Copyright 1998 Ulrich Weigand
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "debug.h"
|
1999-04-01 10:16:08 +02:00
|
|
|
#include "mouse.h"
|
1999-02-12 13:46:49 +01:00
|
|
|
#include "monitor.h"
|
1999-04-01 10:16:08 +02:00
|
|
|
#include "winuser.h"
|
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)
|
|
|
|
{
|
|
|
|
DefMouseEventProc = lpMouseEventProc;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* MOUSE_Disable (MOUSE.3)
|
|
|
|
*/
|
|
|
|
VOID WINAPI MOUSE_Disable(VOID)
|
|
|
|
{
|
|
|
|
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;
|
1999-04-01 10:16:08 +02:00
|
|
|
BOOL bOldWarpPointer;
|
1998-11-08 13:21:35 +01:00
|
|
|
|
|
|
|
if ( !DefMouseEventProc ) return;
|
|
|
|
|
|
|
|
TRACE( event, "(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
|
|
|
|
|
|
|
|
mouseStatus |= MOUSEEVENTF_ABSOLUTE;
|
1999-02-12 13:46:49 +01:00
|
|
|
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.keyState = keyState;
|
|
|
|
wme.time = time;
|
|
|
|
wme.hWnd = hWnd;
|
|
|
|
|
1999-04-01 10:16:08 +02:00
|
|
|
bOldWarpPointer = 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);
|
1999-04-01 10:16:08 +02:00
|
|
|
MOUSE_Driver->pEnableWarpPointer(bOldWarpPointer);
|
1998-11-08 13:21:35 +01:00
|
|
|
}
|