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