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