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