1 | /* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.24 2003/11/03 05:11:51 tsi Exp $ */
|
---|
2 | /*
|
---|
3 | * Copyright (c) 1999-2003 by The XFree86 Project, Inc.
|
---|
4 | *
|
---|
5 | * Permission is hereby granted, free of charge, to any person obtaining a
|
---|
6 | * copy of this software and associated documentation files (the "Software"),
|
---|
7 | * to deal in the Software without restriction, including without limitation
|
---|
8 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
---|
9 | * and/or sell copies of the Software, and to permit persons to whom the
|
---|
10 | * Software is furnished to do so, subject to the following conditions:
|
---|
11 | *
|
---|
12 | * The above copyright notice and this permission notice shall be included in
|
---|
13 | * all copies or substantial portions of the Software.
|
---|
14 | *
|
---|
15 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
---|
16 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
---|
17 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
|
---|
18 | * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
|
---|
19 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
|
---|
20 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
---|
21 | * OTHER DEALINGS IN THE SOFTWARE.
|
---|
22 | *
|
---|
23 | * Except as contained in this notice, the name of the copyright holder(s)
|
---|
24 | * and author(s) shall not be used in advertising or otherwise to promote
|
---|
25 | * the sale, use or other dealings in this Software without prior written
|
---|
26 | * authorization from the copyright holder(s) and author(s).
|
---|
27 | */
|
---|
28 |
|
---|
29 | /* Public interface to OS-specific mouse support. */
|
---|
30 |
|
---|
31 | #ifndef _XF86OSMOUSE_H_
|
---|
32 | #define _XF86OSMOUSE_H_
|
---|
33 |
|
---|
34 | #include "xf86Xinput.h"
|
---|
35 |
|
---|
36 | /* Mouse interface classes */
|
---|
37 | #define MSE_NONE 0x00
|
---|
38 | #define MSE_SERIAL 0x01 /* serial port */
|
---|
39 | #define MSE_BUS 0x02 /* old bus mouse */
|
---|
40 | #define MSE_PS2 0x04 /* standard read-only PS/2 */
|
---|
41 | #define MSE_XPS2 0x08 /* extended PS/2 */
|
---|
42 | #define MSE_AUTO 0x10 /* auto-detect (PnP) */
|
---|
43 | #define MSE_MISC 0x20 /* The OS layer will identify the
|
---|
44 | * specific protocol names that are
|
---|
45 | * supported for this class. */
|
---|
46 |
|
---|
47 | /* Mouse Protocol IDs. */
|
---|
48 | typedef enum {
|
---|
49 | PROT_UNKNOWN = -2,
|
---|
50 | PROT_UNSUP = -1, /* protocol is not supported */
|
---|
51 | PROT_MS = 0,
|
---|
52 | PROT_MSC,
|
---|
53 | PROT_MM,
|
---|
54 | PROT_LOGI,
|
---|
55 | PROT_LOGIMAN,
|
---|
56 | PROT_MMHIT,
|
---|
57 | PROT_GLIDE,
|
---|
58 | PROT_IMSERIAL,
|
---|
59 | PROT_THINKING,
|
---|
60 | PROT_ACECAD,
|
---|
61 | PROT_VALUMOUSESCROLL,
|
---|
62 | PROT_PS2,
|
---|
63 | PROT_GENPS2,
|
---|
64 | PROT_IMPS2,
|
---|
65 | PROT_EXPPS2,
|
---|
66 | PROT_THINKPS2,
|
---|
67 | PROT_MMPS2,
|
---|
68 | PROT_GLIDEPS2,
|
---|
69 | PROT_NETPS2,
|
---|
70 | PROT_NETSCPS2,
|
---|
71 | PROT_BM,
|
---|
72 | PROT_AUTO,
|
---|
73 | PROT_SYSMOUSE,
|
---|
74 | PROT_NUMPROTOS /* This must always be last. */
|
---|
75 | } MouseProtocolID;
|
---|
76 |
|
---|
77 | struct _MouseDevRec;
|
---|
78 |
|
---|
79 | typedef int (*GetInterfaceTypesProc)(void);
|
---|
80 | typedef const char **(*BuiltinNamesProc)(void);
|
---|
81 | typedef Bool (*CheckProtocolProc)(const char *protocol);
|
---|
82 | typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol,
|
---|
83 | int flags);
|
---|
84 | typedef const char *(*DefaultProtocolProc)(void);
|
---|
85 | typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara);
|
---|
86 | typedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate,
|
---|
87 | int res);
|
---|
88 | typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol,
|
---|
89 | int flags);
|
---|
90 | typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
|
---|
91 |
|
---|
92 | /*
|
---|
93 | * OSMouseInfoRec is used to pass information from the OSMouse layer to the
|
---|
94 | * OS-independent mouse driver.
|
---|
95 | */
|
---|
96 | typedef struct {
|
---|
97 | GetInterfaceTypesProc SupportedInterfaces;
|
---|
98 | BuiltinNamesProc BuiltinNames;
|
---|
99 | CheckProtocolProc CheckProtocol;
|
---|
100 | BuiltinPreInitProc PreInit;
|
---|
101 | DefaultProtocolProc DefaultProtocol;
|
---|
102 | SetupAutoProc SetupAuto;
|
---|
103 | SetResProc SetPS2Res;
|
---|
104 | SetResProc SetBMRes;
|
---|
105 | SetResProc SetMiscRes;
|
---|
106 | FindDeviceProc FindDevice;
|
---|
107 | GuessProtocolProc GuessProtocol;
|
---|
108 | } OSMouseInfoRec, *OSMouseInfoPtr;
|
---|
109 |
|
---|
110 | /*
|
---|
111 | * SupportedInterfaces: Returns the mouse interface types that the OS support.
|
---|
112 | * If MSE_MISC is returned, then the BuiltinNames and
|
---|
113 | * CheckProtocol should be set.
|
---|
114 | *
|
---|
115 | * BuiltinNames: Returns the names of the protocols that are fully handled
|
---|
116 | * in the OS-specific code. These are names that don't appear
|
---|
117 | * directly in the main "mouse" driver.
|
---|
118 | *
|
---|
119 | * CheckProtocol: Checks if the protocol name given is supported by the
|
---|
120 | * OS. It should return TRUE for both "builtin" protocols and
|
---|
121 | * protocols of type MSE_MISC that are supported by the OS.
|
---|
122 | *
|
---|
123 | * PreInit: The PreInit function for protocols that are builtin. This
|
---|
124 | * function is passed the protocol name.
|
---|
125 | *
|
---|
126 | * DefaultProtocol: Returns the name of a default protocol that should be used
|
---|
127 | * for the OS when none has been supplied in the config file.
|
---|
128 | * This should only be set when there is a reasonable default.
|
---|
129 | *
|
---|
130 | * SetupAuto: This function can be used to do OS-specific protocol
|
---|
131 | * auto-detection. It returns the name of the detected protocol,
|
---|
132 | * or NULL when detection fails. It may also adjust one or more
|
---|
133 | * of the "protoPara" values for the detected protocol by setting
|
---|
134 | * then to something other than -1. SetupAuto gets called in two
|
---|
135 | * ways. The first is before any devices have been opened. This
|
---|
136 | * can be used when the protocol "Auto" always maps to a single
|
---|
137 | * protocol type. The second is with the device open, allowing
|
---|
138 | * OS-specific probing to be done.
|
---|
139 | *
|
---|
140 | * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
|
---|
141 | * protocol types.
|
---|
142 | *
|
---|
143 | * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
|
---|
144 | *
|
---|
145 | * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
|
---|
146 | *
|
---|
147 | * FindDevice: This function gets called when no Device has been specified
|
---|
148 | * in the config file. OS-specific methods may be used to guess
|
---|
149 | * which input device to use. This function is called after the
|
---|
150 | * pre-open attempts at protocol discovery are done, but before
|
---|
151 | * the device is open. I.e., after the first SetupAuto() call,
|
---|
152 | * after the DefaultProtocol() call, but before the PreInit()
|
---|
153 | * call. Available protocol information may be used in locating
|
---|
154 | * the default input device.
|
---|
155 | *
|
---|
156 | * GuessProtocol: A last resort attempt at guessing the mouse protocol by
|
---|
157 | * whatever OS-specific means might be available. OS-independent
|
---|
158 | * things should be in the mouse driver. This function gets
|
---|
159 | * called after the mouse driver's OS-independent methods have
|
---|
160 | * failed.
|
---|
161 | */
|
---|
162 |
|
---|
163 | extern OSMouseInfoPtr xf86OSMouseInit(int flags);
|
---|
164 |
|
---|
165 | /* Adjust this when the mouse interface changes. */
|
---|
166 |
|
---|
167 | /*
|
---|
168 | * History:
|
---|
169 | *
|
---|
170 | * 1.0.0 - Everything up to when versioning was started.
|
---|
171 | * 1.1.0 - FindDevice and GuessProtocol added to OSMouseInfoRec
|
---|
172 | * 1.2.0 - xisbscale added to MouseDevRec
|
---|
173 | *
|
---|
174 | */
|
---|
175 |
|
---|
176 | #define OS_MOUSE_VERSION_MAJOR 1
|
---|
177 | #define OS_MOUSE_VERSION_MINOR 2
|
---|
178 | #define OS_MOUSE_VERSION_PATCH 0
|
---|
179 |
|
---|
180 | #define OS_MOUSE_VERSION_CURRENT \
|
---|
181 | BUILTIN_INTERFACE_VERSION_NUMERIC(OS_MOUSE_VERSION_MAJOR, \
|
---|
182 | OS_MOUSE_VERSION_MINOR, \
|
---|
183 | OS_MOUSE_VERSION_PATCH)
|
---|
184 |
|
---|
185 | #define HAVE_GUESS_PROTOCOL \
|
---|
186 | (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \
|
---|
187 | BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0))
|
---|
188 |
|
---|
189 | #define HAVE_FIND_DEVICE \
|
---|
190 | (xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \
|
---|
191 | BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0))
|
---|
192 |
|
---|
193 | /* Z axis mapping */
|
---|
194 | #define MSE_NOZMAP 0
|
---|
195 | #define MSE_MAPTOX -1
|
---|
196 | #define MSE_MAPTOY -2
|
---|
197 | #define MSE_MAPTOZ -3
|
---|
198 | #define MSE_MAPTOW -4
|
---|
199 |
|
---|
200 | /* Generalize for other axes. */
|
---|
201 | #define MSE_NOAXISMAP MSE_NOZMAP
|
---|
202 |
|
---|
203 | #define MSE_MAXBUTTONS 24
|
---|
204 | #define MSE_DFLTBUTTONS 3
|
---|
205 |
|
---|
206 | /*
|
---|
207 | * Mouse device record. This is shared by the mouse driver and the OSMouse
|
---|
208 | * layer.
|
---|
209 | */
|
---|
210 |
|
---|
211 | typedef void (*checkMovementsProc)(InputInfoPtr,int, int);
|
---|
212 | typedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool);
|
---|
213 | typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char);
|
---|
214 | typedef Bool (*dataGoodProc)(struct _MouseDevRec *);
|
---|
215 |
|
---|
216 | typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons,
|
---|
217 | int dx, int dy, int dz, int dw);
|
---|
218 | typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo);
|
---|
219 |
|
---|
220 | typedef struct _MouseDevRec {
|
---|
221 | PtrCtrlProcPtr Ctrl;
|
---|
222 | PostMseEventProc PostEvent;
|
---|
223 | MouseCommonOptProc CommonOptions;
|
---|
224 | DeviceIntPtr device;
|
---|
225 | const char * mseDevice;
|
---|
226 | const char * protocol;
|
---|
227 | MouseProtocolID protocolID;
|
---|
228 | MouseProtocolID oldProtocolID; /* hack */
|
---|
229 | int class;
|
---|
230 | int mseModel;
|
---|
231 | int baudRate;
|
---|
232 | int oldBaudRate;
|
---|
233 | int sampleRate;
|
---|
234 | int lastButtons;
|
---|
235 | int threshold; /* acceleration */
|
---|
236 | int num;
|
---|
237 | int den;
|
---|
238 | int buttons; /* # of buttons */
|
---|
239 | int emulateState; /* automata state for 2 button mode */
|
---|
240 | Bool emulate3Buttons;
|
---|
241 | Bool emulate3ButtonsSoft;
|
---|
242 | int emulate3Timeout;/* Timeout for 3 button emulation */
|
---|
243 | Bool chordMiddle;
|
---|
244 | Bool flipXY;
|
---|
245 | int invX;
|
---|
246 | int invY;
|
---|
247 | int mouseFlags; /* Flags to Clear after opening
|
---|
248 | * mouse dev */
|
---|
249 | int truebuttons; /* (not used)
|
---|
250 | * Arg to maintain before
|
---|
251 | * emulate3buttons timer callback */
|
---|
252 | int resolution;
|
---|
253 | int negativeZ; /* button mask */
|
---|
254 | int positiveZ; /* button mask */
|
---|
255 | int negativeW; /* button mask */
|
---|
256 | int positiveW; /* button mask */
|
---|
257 | pointer buffer; /* usually an XISBuffer* */
|
---|
258 | int protoBufTail;
|
---|
259 | unsigned char protoBuf[8];
|
---|
260 | unsigned char protoPara[8];
|
---|
261 | unsigned char inSync; /* driver in sync with datastream */
|
---|
262 | pointer mousePriv; /* private area */
|
---|
263 | InputInfoPtr pInfo;
|
---|
264 | int origProtocolID;
|
---|
265 | const char * origProtocol;
|
---|
266 | Bool emulate3Pending;/* timer waiting */
|
---|
267 | CARD32 emulate3Expires;/* time to fire emulation code */
|
---|
268 | Bool emulateWheel;
|
---|
269 | int wheelInertia;
|
---|
270 | int wheelButton;
|
---|
271 | int negativeX; /* Button values. Unlike the Z and */
|
---|
272 | int positiveX; /* W equivalents, these are button */
|
---|
273 | int negativeY; /* values rather than button masks. */
|
---|
274 | int positiveY;
|
---|
275 | int wheelYDistance;
|
---|
276 | int wheelXDistance;
|
---|
277 | Bool autoProbe;
|
---|
278 | checkMovementsProc checkMovements;
|
---|
279 | autoProbeProc autoProbeMouse;
|
---|
280 | collectDataProc collectData;
|
---|
281 | dataGoodProc dataGood;
|
---|
282 | int angleOffset;
|
---|
283 | pointer pDragLock; /* drag lock area */
|
---|
284 | int xisbscale; /* buffer size for 1 event */
|
---|
285 | int wheelButtonTimeout;/* Timeout for the wheel button emulation */
|
---|
286 | CARD32 wheelButtonExpires;
|
---|
287 | int doubleClickSourceButtonMask;
|
---|
288 | int doubleClickTargetButton;
|
---|
289 | int doubleClickTargetButtonMask;
|
---|
290 | int doubleClickOldSourceState;
|
---|
291 | int lastMappedButtons;
|
---|
292 | int buttonMap[MSE_MAXBUTTONS];
|
---|
293 | } MouseDevRec, *MouseDevPtr;
|
---|
294 |
|
---|
295 | #endif /* _XF86OSMOUSE_H_ */
|
---|