4 * Copyright 1998 Ulrich Weigand
14 /**********************************************************************/
16 MOUSE_DRIVER
*MOUSE_Driver
= NULL
;
18 static LPMOUSE_EVENT_PROC DefMouseEventProc
= NULL
;
20 /***********************************************************************
21 * MOUSE_Inquire (MOUSE.1)
23 WORD WINAPI
MOUSE_Inquire(LPMOUSEINFO mouseInfo
)
25 mouseInfo
->msExist
= TRUE
;
26 mouseInfo
->msRelative
= FALSE
;
27 mouseInfo
->msNumButtons
= 2;
28 mouseInfo
->msRate
= 34; /* the DDK says so ... */
29 mouseInfo
->msXThreshold
= 0;
30 mouseInfo
->msYThreshold
= 0;
31 mouseInfo
->msXRes
= 0;
32 mouseInfo
->msYRes
= 0;
33 mouseInfo
->msMouseCommPort
= 0;
35 return sizeof(MOUSEINFO
);
38 /***********************************************************************
39 * MOUSE_Enable (MOUSE.2)
41 VOID WINAPI
MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc
)
43 DefMouseEventProc
= lpMouseEventProc
;
46 /***********************************************************************
47 * MOUSE_Disable (MOUSE.3)
49 VOID WINAPI
MOUSE_Disable(VOID
)
51 DefMouseEventProc
= 0;
54 /***********************************************************************
57 void MOUSE_SendEvent( DWORD mouseStatus
, DWORD posX
, DWORD posY
,
58 DWORD keyState
, DWORD time
, HWND hWnd
)
60 int width
= MONITOR_GetWidth (&MONITOR_PrimaryMonitor
);
61 int height
= MONITOR_GetHeight(&MONITOR_PrimaryMonitor
);
66 if ( !DefMouseEventProc
) return;
68 TRACE( event
, "(%04lX,%ld,%ld)\n", mouseStatus
, posX
, posY
);
70 mouseStatus
|= MOUSEEVENTF_ABSOLUTE
;
71 posX
= (((long)posX
<< 16) + width
-1) / width
;
72 posY
= (((long)posY
<< 16) + height
-1) / height
;
74 wme
.magic
= WINE_MOUSEEVENT_MAGIC
;
75 wme
.keyState
= keyState
;
79 bOldWarpPointer
= MOUSE_Driver
->pEnableWarpPointer(FALSE
);
80 /* To avoid deadlocks, we have to suspend all locks on windows structures
81 before the program control is passed to the mouse driver */
82 iWndsLocks
= WIN_SuspendWndsLock();
83 DefMouseEventProc( mouseStatus
, posX
, posY
, 0, (DWORD
)&wme
);
84 WIN_RestoreWndsLock(iWndsLocks
);
85 MOUSE_Driver
->pEnableWarpPointer(bOldWarpPointer
);