1
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.24 2003/11/03 05:11:51 tsi Exp $ */
3
* Copyright (c) 1999-2003 by The XFree86 Project, Inc.
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:
12
* The above copyright notice and this permission notice shall be included in
13
* all copies or substantial portions of the Software.
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.
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).
29
/* Public interface to OS-specific mouse support. */
31
#ifndef _XF86OSMOUSE_H_
32
#define _XF86OSMOUSE_H_
34
#include "xf86Xinput.h"
36
/* Mouse interface classes */
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. */
47
/* Mouse Protocol IDs. */
50
PROT_UNSUP = -1, /* protocol is not supported */
74
PROT_NUMPROTOS /* This must always be last. */
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,
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,
88
typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol,
90
typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
93
* OSMouseInfoRec is used to pass information from the OSMouse layer to the
94
* OS-independent mouse driver.
97
GetInterfaceTypesProc SupportedInterfaces;
98
BuiltinNamesProc BuiltinNames;
99
CheckProtocolProc CheckProtocol;
100
BuiltinPreInitProc PreInit;
101
DefaultProtocolProc DefaultProtocol;
102
SetupAutoProc SetupAuto;
103
SetResProc SetPS2Res;
105
SetResProc SetMiscRes;
106
FindDeviceProc FindDevice;
107
GuessProtocolProc GuessProtocol;
108
} OSMouseInfoRec, *OSMouseInfoPtr;
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.
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.
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.
123
* PreInit: The PreInit function for protocols that are builtin. This
124
* function is passed the protocol name.
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.
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.
140
* SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
143
* SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
145
* SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
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.
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
163
extern OSMouseInfoPtr xf86OSMouseInit(int flags);
165
/* Adjust this when the mouse interface changes. */
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
176
#define OS_MOUSE_VERSION_MAJOR 1
177
#define OS_MOUSE_VERSION_MINOR 2
178
#define OS_MOUSE_VERSION_PATCH 0
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)
185
#define HAVE_GUESS_PROTOCOL \
186
(xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \
187
BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0))
189
#define HAVE_FIND_DEVICE \
190
(xf86GetBuiltinInterfaceVersion(BUILTIN_IF_OSMOUSE, 0) >= \
191
BUILTIN_INTERFACE_VERSION_NUMERIC(1, 1, 0))
195
#define MSE_MAPTOX -1
196
#define MSE_MAPTOY -2
197
#define MSE_MAPTOZ -3
198
#define MSE_MAPTOW -4
200
/* Generalize for other axes. */
201
#define MSE_NOAXISMAP MSE_NOZMAP
203
#define MSE_MAXBUTTONS 24
204
#define MSE_DFLTBUTTONS 3
207
* Mouse device record. This is shared by the mouse driver and the OSMouse
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 *);
216
typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons,
217
int dx, int dy, int dz, int dw);
218
typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo);
220
typedef struct _MouseDevRec {
222
PostMseEventProc PostEvent;
223
MouseCommonOptProc CommonOptions;
225
const char * mseDevice;
226
const char * protocol;
227
MouseProtocolID protocolID;
228
MouseProtocolID oldProtocolID; /* hack */
235
int threshold; /* acceleration */
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 */
247
int mouseFlags; /* Flags to Clear after opening
249
int truebuttons; /* (not used)
250
* Arg to maintain before
251
* emulate3buttons timer callback */
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* */
259
unsigned char protoBuf[8];
260
unsigned char protoPara[8];
261
unsigned char inSync; /* driver in sync with datastream */
262
pointer mousePriv; /* private area */
265
const char * origProtocol;
266
Bool emulate3Pending;/* timer waiting */
267
CARD32 emulate3Expires;/* time to fire emulation code */
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. */
278
checkMovementsProc checkMovements;
279
autoProbeProc autoProbeMouse;
280
collectDataProc collectData;
281
dataGoodProc dataGood;
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;
295
#endif /* _XF86OSMOUSE_H_ */