Merged msacm and msacm32 dlls.
[wine] / dlls / user / mouse.c
1 /*
2  * MOUSE driver
3  * 
4  * Copyright 1998 Ulrich Weigand
5  * 
6  */
7
8 #include <string.h>
9
10 #include "debugtools.h"
11 #include "callback.h"
12 #include "builtin16.h"
13 #include "module.h"
14 #include "mouse.h"
15 #include "windef.h"
16 #include "wingdi.h"
17 #include "winuser.h"
18 #include "wine/winbase16.h"
19
20 DEFAULT_DEBUG_CHANNEL(event);
21
22 #include "pshpack1.h"
23 typedef struct _MOUSEINFO
24 {
25     BYTE msExist;
26     BYTE msRelative;
27     WORD msNumButtons;
28     WORD msRate;
29     WORD msXThreshold;
30     WORD msYThreshold;
31     WORD msXRes;
32     WORD msYRes;
33     WORD msMouseCommPort;
34 } MOUSEINFO, *LPMOUSEINFO;
35 #include "poppack.h"
36
37 /**********************************************************************/
38
39 static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
40
41 /***********************************************************************
42  *           MOUSE_Inquire                       (MOUSE.1)
43  */
44 WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
45 {
46     mouseInfo->msExist = TRUE;
47     mouseInfo->msRelative = FALSE;
48     mouseInfo->msNumButtons = 2;
49     mouseInfo->msRate = 34;  /* the DDK says so ... */
50     mouseInfo->msXThreshold = 0;
51     mouseInfo->msYThreshold = 0;
52     mouseInfo->msXRes = 0;
53     mouseInfo->msYRes = 0;
54     mouseInfo->msMouseCommPort = 0;
55
56     return sizeof(MOUSEINFO);
57 }
58
59 /***********************************************************************
60  *           MOUSE_Enable                        (MOUSE.2)
61  */
62 VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
63 {
64     THUNK_Free( (FARPROC)DefMouseEventProc );
65     DefMouseEventProc = lpMouseEventProc;
66     USER_Driver->pInitMouse( lpMouseEventProc );
67 }
68
69 static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
70                                              DWORD dwFlags, DWORD dx, DWORD dy,
71                                              DWORD cButtons, DWORD dwExtraInfo )
72 {
73     CONTEXT86 context;
74
75     memset( &context, 0, sizeof(context) );
76     CS_reg(&context)  = SELECTOROF( proc );
77     EIP_reg(&context) = OFFSETOF( proc );
78     AX_reg(&context)  = (WORD)dwFlags;
79     BX_reg(&context)  = (WORD)dx;
80     CX_reg(&context)  = (WORD)dy;
81     DX_reg(&context)  = (WORD)cButtons;
82     SI_reg(&context)  = LOWORD( dwExtraInfo );
83     DI_reg(&context)  = HIWORD( dwExtraInfo );
84
85     CallTo16RegisterShort( &context, 0 );
86 }
87
88 VOID WINAPI WIN16_MOUSE_Enable( FARPROC16 proc )
89 {
90     LPMOUSE_EVENT_PROC thunk = 
91       (LPMOUSE_EVENT_PROC)THUNK_Alloc( proc, (RELAY)MOUSE_CallMouseEventProc );
92
93     MOUSE_Enable( thunk );
94 }
95
96 /***********************************************************************
97  *           MOUSE_Disable                       (MOUSE.3)
98  */
99 VOID WINAPI MOUSE_Disable(VOID)
100 {
101     THUNK_Free( (FARPROC)DefMouseEventProc );
102     DefMouseEventProc = 0;
103     USER_Driver->pInitMouse( 0 );
104 }