Basic implementation of IStream:Clone.
[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 "mouse.h"
14 #include "windef.h"
15 #include "wingdi.h"
16 #include "winuser.h"
17 #include "wine/winbase16.h"
18
19 DEFAULT_DEBUG_CHANNEL(event);
20
21 #include "pshpack1.h"
22 typedef struct _MOUSEINFO
23 {
24     BYTE msExist;
25     BYTE msRelative;
26     WORD msNumButtons;
27     WORD msRate;
28     WORD msXThreshold;
29     WORD msYThreshold;
30     WORD msXRes;
31     WORD msYRes;
32     WORD msMouseCommPort;
33 } MOUSEINFO, *LPMOUSEINFO;
34 #include "poppack.h"
35
36 /**********************************************************************/
37
38 static LPMOUSE_EVENT_PROC DefMouseEventProc = NULL;
39
40 /***********************************************************************
41  *           Inquire                       (MOUSE.1)
42  */
43 WORD WINAPI MOUSE_Inquire(LPMOUSEINFO mouseInfo)
44 {
45     mouseInfo->msExist = TRUE;
46     mouseInfo->msRelative = FALSE;
47     mouseInfo->msNumButtons = 2;
48     mouseInfo->msRate = 34;  /* the DDK says so ... */
49     mouseInfo->msXThreshold = 0;
50     mouseInfo->msYThreshold = 0;
51     mouseInfo->msXRes = 0;
52     mouseInfo->msYRes = 0;
53     mouseInfo->msMouseCommPort = 0;
54
55     return sizeof(MOUSEINFO);
56 }
57
58 /***********************************************************************
59  *           Enable                        (MOUSE.2)
60  */
61 VOID WINAPI MOUSE_Enable(LPMOUSE_EVENT_PROC lpMouseEventProc)
62 {
63     THUNK_Free( (FARPROC)DefMouseEventProc );
64     DefMouseEventProc = lpMouseEventProc;
65     USER_Driver.pInitMouse( lpMouseEventProc );
66 }
67
68 /**********************************************************************/
69
70 static VOID WINAPI MOUSE_CallMouseEventProc( FARPROC16 proc,
71                                              DWORD dwFlags, DWORD dx, DWORD dy,
72                                              DWORD cButtons, DWORD dwExtraInfo )
73 {
74     CONTEXT86 context;
75
76     memset( &context, 0, sizeof(context) );
77     context.SegCs = SELECTOROF( proc );
78     context.Eip   = OFFSETOF( proc );
79     context.Eax   = (WORD)dwFlags;
80     context.Ebx   = (WORD)dx;
81     context.Ecx   = (WORD)dy;
82     context.Edx   = (WORD)cButtons;
83     context.Esi   = LOWORD( dwExtraInfo );
84     context.Edi   = HIWORD( dwExtraInfo );
85
86     wine_call_to_16_regs_short( &context, 0 );
87 }
88
89 /**********************************************************************/
90
91 VOID WINAPI WIN16_MOUSE_Enable( FARPROC16 proc )
92 {
93     LPMOUSE_EVENT_PROC thunk = 
94       (LPMOUSE_EVENT_PROC)THUNK_Alloc( proc, (RELAY)MOUSE_CallMouseEventProc );
95
96     MOUSE_Enable( thunk );
97 }
98
99 /***********************************************************************
100  *           Disable                       (MOUSE.3)
101  */
102 VOID WINAPI MOUSE_Disable(VOID)
103 {
104     THUNK_Free( (FARPROC)DefMouseEventProc );
105     DefMouseEventProc = 0;
106     USER_Driver.pInitMouse( 0 );
107 }