More code moved to the X11 driver (bitmap and palette and misc).
[wine] / windows / mouse.c
1 /*
2  * MOUSE driver
3  * 
4  * Copyright 1998 Ulrich Weigand
5  * 
6  */
7
8 #include "debug.h"
9 #include "mouse.h"
10 #include "monitor.h"
11 #include "winuser.h"
12
13 /**********************************************************************/
14
15 MOUSE_DRIVER *MOUSE_Driver = NULL;
16
17 static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
18
19 /***********************************************************************
20  *           MOUSE_Inquire                       (MOUSE.1)
21  */
22 WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
23 {
24     mouseInfo->msExist = TRUE;
25     mouseInfo->msRelative = FALSE;
26     mouseInfo->msNumButtons = 2;
27     mouseInfo->msRate = 34;  /* the DDK says so ... */
28     mouseInfo->msXThreshold = 0;
29     mouseInfo->msYThreshold = 0;
30     mouseInfo->msXRes = 0;
31     mouseInfo->msYRes = 0;
32     mouseInfo->msMouseCommPort = 0;
33
34     return sizeof(MOUSEINFO);
35 }
36
37 /***********************************************************************
38  *           MOUSE_Enable                        (MOUSE.2)
39  */
40 VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
41 {
42     DefMouseEventProc = lpMouseEventProc;
43 }
44
45 /***********************************************************************
46  *           MOUSE_Disable                       (MOUSE.3)
47  */
48 VOID WINAPI MOUSE_Disable(VOID)
49 {
50     DefMouseEventProc = 0;
51 }
52
53 /***********************************************************************
54  *           MOUSE_SendEvent
55  */
56 void MOUSE_SendEvent( DWORD mouseStatus, DWORD posX, DWORD posY, 
57                       DWORD keyState, DWORD time, HWND hWnd )
58 {
59     int width  = MONITOR_GetWidth (&MONITOR_PrimaryMonitor);
60     int height = MONITOR_GetHeight(&MONITOR_PrimaryMonitor);
61     WINE_MOUSEEVENT wme;
62     BOOL bOldWarpPointer;
63
64     if ( !DefMouseEventProc ) return;
65
66     TRACE( event, "(%04lX,%ld,%ld)\n", mouseStatus, posX, posY );
67
68     mouseStatus |= MOUSEEVENTF_ABSOLUTE;
69     posX = (((long)posX << 16) + width-1)  / width;
70     posY = (((long)posY << 16) + height-1) / height;
71
72     wme.magic    = WINE_MOUSEEVENT_MAGIC;
73     wme.keyState = keyState;
74     wme.time     = time;
75     wme.hWnd     = hWnd;
76
77     bOldWarpPointer = MOUSE_Driver->pEnableWarpPointer(FALSE);
78     DefMouseEventProc( mouseStatus, posX, posY, 0, (DWORD)&wme );
79     MOUSE_Driver->pEnableWarpPointer(bOldWarpPointer);
80 }