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 411450c749Smrg#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) < 18 421450c749Smrg#define LogMessageVerbSigSafe LogMessageVerb 431450c749Smrg#endif 44dd4cbfe8Smrg 45dd4cbfe8Smrg/* Mouse interface classes */ 461450c749Smrg#define MSE_NONE 0x00 471450c749Smrg#define MSE_SERIAL 0x01 /* serial port */ 481450c749Smrg#define MSE_BUS 0x02 /* old bus mouse */ 491450c749Smrg#define MSE_PS2 0x04 /* standard read-only PS/2 */ 501450c749Smrg#define MSE_XPS2 0x08 /* extended PS/2 */ 511450c749Smrg#define MSE_AUTO 0x10 /* auto-detect (PnP) */ 521450c749Smrg#define MSE_MISC 0x20 /* The OS layer will identify the 531450c749Smrg * specific protocol names that are 541450c749Smrg * supported for this class. */ 55dd4cbfe8Smrg 56dd4cbfe8Smrg/* Mouse Protocol IDs. */ 57dd4cbfe8Smrgtypedef enum { 58dd4cbfe8Smrg PROT_UNKNOWN = -2, 591450c749Smrg PROT_UNSUP = -1, /* protocol is not supported */ 60dd4cbfe8Smrg PROT_MS = 0, 61dd4cbfe8Smrg PROT_MSC, 62dd4cbfe8Smrg PROT_MM, 63dd4cbfe8Smrg PROT_LOGI, 64dd4cbfe8Smrg PROT_LOGIMAN, 65dd4cbfe8Smrg PROT_MMHIT, 66dd4cbfe8Smrg PROT_GLIDE, 67dd4cbfe8Smrg PROT_IMSERIAL, 68dd4cbfe8Smrg PROT_THINKING, 69dd4cbfe8Smrg PROT_ACECAD, 70dd4cbfe8Smrg PROT_VALUMOUSESCROLL, 71dd4cbfe8Smrg PROT_PS2, 72dd4cbfe8Smrg PROT_GENPS2, 73dd4cbfe8Smrg PROT_IMPS2, 74dd4cbfe8Smrg PROT_EXPPS2, 75dd4cbfe8Smrg PROT_THINKPS2, 76dd4cbfe8Smrg PROT_MMPS2, 77dd4cbfe8Smrg PROT_GLIDEPS2, 78dd4cbfe8Smrg PROT_NETPS2, 79dd4cbfe8Smrg PROT_NETSCPS2, 80dd4cbfe8Smrg PROT_BM, 81dd4cbfe8Smrg PROT_AUTO, 82dd4cbfe8Smrg PROT_SYSMOUSE, 83dd4cbfe8Smrg PROT_WSMOUSE, 84dd4cbfe8Smrg PROT_VUID, 851450c749Smrg PROT_NUMPROTOS /* This must always be last. */ 86dd4cbfe8Smrg} MouseProtocolID; 87dd4cbfe8Smrg 88dd4cbfe8Smrgstruct _MouseDevRec; 89dd4cbfe8Smrg 90dd4cbfe8Smrgtypedef int (*GetInterfaceTypesProc)(void); 91dd4cbfe8Smrgtypedef const char **(*BuiltinNamesProc)(void); 92dd4cbfe8Smrgtypedef Bool (*CheckProtocolProc)(const char *protocol); 93dd4cbfe8Smrgtypedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol, 941450c749Smrg int flags); 95dd4cbfe8Smrgtypedef const char *(*DefaultProtocolProc)(void); 96dd4cbfe8Smrgtypedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara); 97dd4cbfe8Smrgtypedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate, 981450c749Smrg int res); 99dd4cbfe8Smrgtypedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol, 1001450c749Smrg int flags); 101dd4cbfe8Smrgtypedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags); 102dd4cbfe8Smrg 103dd4cbfe8Smrg/* 104dd4cbfe8Smrg * OSMouseInfoRec is used to pass information from the OSMouse layer to the 105dd4cbfe8Smrg * OS-independent mouse driver. 106dd4cbfe8Smrg */ 107dd4cbfe8Smrgtypedef struct { 1081450c749Smrg GetInterfaceTypesProc SupportedInterfaces; 1091450c749Smrg BuiltinNamesProc BuiltinNames; 1101450c749Smrg CheckProtocolProc CheckProtocol; 1111450c749Smrg BuiltinPreInitProc PreInit; 1121450c749Smrg DefaultProtocolProc DefaultProtocol; 1131450c749Smrg SetupAutoProc SetupAuto; 1141450c749Smrg SetResProc SetPS2Res; 1151450c749Smrg SetResProc SetBMRes; 1161450c749Smrg SetResProc SetMiscRes; 1171450c749Smrg FindDeviceProc FindDevice; 1181450c749Smrg GuessProtocolProc GuessProtocol; 119dd4cbfe8Smrg} OSMouseInfoRec, *OSMouseInfoPtr; 120dd4cbfe8Smrg 121dd4cbfe8Smrg/* 122dd4cbfe8Smrg * SupportedInterfaces: Returns the mouse interface types that the OS support. 1231450c749Smrg * If MSE_MISC is returned, then the BuiltinNames and 1241450c749Smrg * CheckProtocol should be set. 125dd4cbfe8Smrg * 126dd4cbfe8Smrg * BuiltinNames: Returns the names of the protocols that are fully handled 1271450c749Smrg * in the OS-specific code. These are names that don't appear 1281450c749Smrg * directly in the main "mouse" driver. 129dd4cbfe8Smrg * 130dd4cbfe8Smrg * CheckProtocol: Checks if the protocol name given is supported by the 1311450c749Smrg * OS. It should return TRUE for both "builtin" protocols and 1321450c749Smrg * protocols of type MSE_MISC that are supported by the OS. 133dd4cbfe8Smrg * 1341450c749Smrg * PreInit: The PreInit function for protocols that are builtin. This 1351450c749Smrg * function is passed the protocol name. 136dd4cbfe8Smrg * 137dd4cbfe8Smrg * DefaultProtocol: Returns the name of a default protocol that should be used 1381450c749Smrg * for the OS when none has been supplied in the config file. 1391450c749Smrg * This should only be set when there is a reasonable default. 140dd4cbfe8Smrg * 1411450c749Smrg * SetupAuto: This function can be used to do OS-specific protocol 1421450c749Smrg * auto-detection. It returns the name of the detected protocol, 1431450c749Smrg * or NULL when detection fails. It may also adjust one or more 1441450c749Smrg * of the "protoPara" values for the detected protocol by setting 1451450c749Smrg * then to something other than -1. SetupAuto gets called in two 1461450c749Smrg * ways. The first is before any devices have been opened. This 1471450c749Smrg * can be used when the protocol "Auto" always maps to a single 1481450c749Smrg * protocol type. The second is with the device open, allowing 1491450c749Smrg * OS-specific probing to be done. 150dd4cbfe8Smrg * 1511450c749Smrg * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2 1521450c749Smrg * protocol types. 153dd4cbfe8Smrg * 1541450c749Smrg * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types. 155dd4cbfe8Smrg * 1561450c749Smrg * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types. 157dd4cbfe8Smrg * 1581450c749Smrg * FindDevice: This function gets called when no Device has been specified 1591450c749Smrg * in the config file. OS-specific methods may be used to guess 1601450c749Smrg * which input device to use. This function is called after the 1611450c749Smrg * pre-open attempts at protocol discovery are done, but before 1621450c749Smrg * the device is open. I.e., after the first SetupAuto() call, 1631450c749Smrg * after the DefaultProtocol() call, but before the PreInit() 1641450c749Smrg * call. Available protocol information may be used in locating 1651450c749Smrg * the default input device. 166dd4cbfe8Smrg * 167dd4cbfe8Smrg * GuessProtocol: A last resort attempt at guessing the mouse protocol by 1681450c749Smrg * whatever OS-specific means might be available. OS-independent 1691450c749Smrg * things should be in the mouse driver. This function gets 1701450c749Smrg * called after the mouse driver's OS-independent methods have 1711450c749Smrg * failed. 172dd4cbfe8Smrg */ 173dd4cbfe8Smrg 174dd4cbfe8Smrgextern OSMouseInfoPtr OSMouseInit(int flags); 175dd4cbfe8Smrg 176dd4cbfe8Smrg/* Z axis mapping */ 1771450c749Smrg#define MSE_NOZMAP 0 1781450c749Smrg#define MSE_MAPTOX -1 1791450c749Smrg#define MSE_MAPTOY -2 1801450c749Smrg#define MSE_MAPTOZ -3 1811450c749Smrg#define MSE_MAPTOW -4 182dd4cbfe8Smrg 183dd4cbfe8Smrg/* Generalize for other axes. */ 1841450c749Smrg#define MSE_NOAXISMAP MSE_NOZMAP 185dd4cbfe8Smrg 1861450c749Smrg#define MSE_MAXBUTTONS 24 1871450c749Smrg#define MSE_DFLTBUTTONS 3 188dd4cbfe8Smrg 189dd4cbfe8Smrg/* 190dd4cbfe8Smrg * Mouse device record. This is shared by the mouse driver and the OSMouse 191dd4cbfe8Smrg * layer. 192dd4cbfe8Smrg */ 193dd4cbfe8Smrg 194dd4cbfe8Smrgtypedef void (*checkMovementsProc)(InputInfoPtr,int, int); 195dd4cbfe8Smrgtypedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool); 196dd4cbfe8Smrgtypedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char); 197dd4cbfe8Smrgtypedef Bool (*dataGoodProc)(struct _MouseDevRec *); 198dd4cbfe8Smrg 199dd4cbfe8Smrgtypedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons, 2001450c749Smrg int dx, int dy, int dz, int dw); 201dd4cbfe8Smrgtypedef void (*MouseCommonOptProc)(InputInfoPtr pInfo); 202dd4cbfe8Smrg 203dd4cbfe8Smrgtypedef struct _MouseDevRec { 2041450c749Smrg PtrCtrlProcPtr Ctrl; 2051450c749Smrg PostMseEventProc PostEvent; 2061450c749Smrg MouseCommonOptProc CommonOptions; 2071450c749Smrg DeviceIntPtr device; 2081450c749Smrg const char * protocol; 2091450c749Smrg MouseProtocolID protocolID; 2101450c749Smrg MouseProtocolID oldProtocolID; /* hack */ 2111450c749Smrg int class; 2121450c749Smrg int mseModel; 2131450c749Smrg int baudRate; 2141450c749Smrg int oldBaudRate; 2151450c749Smrg int sampleRate; 2161450c749Smrg int lastButtons; 2171450c749Smrg int buttons; /* # of buttons */ 2181450c749Smrg int emulateState; /* automata state for 2 button mode */ 2191450c749Smrg Bool emulate3Buttons; 2201450c749Smrg Bool emulate3ButtonsSoft; 2211450c749Smrg int emulate3Timeout;/* Timeout for 3 button emulation */ 2221450c749Smrg Bool chordMiddle; 223dd4cbfe8Smrg Bool flipXY; 224dd4cbfe8Smrg int invX; 225dd4cbfe8Smrg int invY; 2261450c749Smrg int resolution; 2271450c749Smrg int negativeZ; /* button mask */ 2281450c749Smrg int positiveZ; /* button mask */ 2291450c749Smrg int negativeW; /* button mask */ 2301450c749Smrg int positiveW; /* button mask */ 2311450c749Smrg pointer buffer; /* usually an XISBuffer* */ 2321450c749Smrg int protoBufTail; 2331450c749Smrg unsigned char protoBuf[8]; 2341450c749Smrg unsigned char protoPara[8]; 2351450c749Smrg unsigned char inSync; /* driver in sync with datastream */ 2361450c749Smrg pointer mousePriv; /* private area */ 2371450c749Smrg InputInfoPtr pInfo; 2381450c749Smrg Bool emulate3Pending;/* timer waiting */ 2391450c749Smrg CARD32 emulate3Expires;/* time to fire emulation code */ 2401450c749Smrg Bool emulateWheel; 2411450c749Smrg int wheelInertia; 2421450c749Smrg int wheelButton; 2431450c749Smrg int negativeX; /* Button values. Unlike the Z and */ 2441450c749Smrg int positiveX; /* W equivalents, these are button */ 2451450c749Smrg int negativeY; /* values rather than button masks. */ 2461450c749Smrg int positiveY; 2471450c749Smrg int wheelYDistance; 2481450c749Smrg int wheelXDistance; 2491450c749Smrg Bool autoProbe; 250dd4cbfe8Smrg checkMovementsProc checkMovements; 2511450c749Smrg autoProbeProc autoProbeMouse; 2521450c749Smrg collectDataProc collectData; 2531450c749Smrg dataGoodProc dataGood; 2541450c749Smrg int angleOffset; 2551450c749Smrg pointer pDragLock; /* drag lock area */ 2561450c749Smrg int xisbscale; /* buffer size for 1 event */ 2571450c749Smrg int wheelButtonTimeout;/* Timeout for the wheel button emulation */ 2581450c749Smrg CARD32 wheelButtonExpires; 2591450c749Smrg int doubleClickSourceButtonMask; 2601450c749Smrg int doubleClickTargetButton; 2611450c749Smrg int doubleClickTargetButtonMask; 2621450c749Smrg int doubleClickOldSourceState; 2631450c749Smrg int lastMappedButtons; 2641450c749Smrg int buttonMap[MSE_MAXBUTTONS]; 265216a823bSjmcneill int autoCalibrate; 266216a823bSjmcneill int lastScreenWidth; 267216a823bSjmcneill int lastScreenHeight; 268216a823bSjmcneill int screenNo; 269216a823bSjmcneill int minX; 270216a823bSjmcneill int minY; 271216a823bSjmcneill int maxX; 272216a823bSjmcneill int maxY; 273216a823bSjmcneill int translateAbs; 274dd4cbfe8Smrg} MouseDevRec, *MouseDevPtr; 275dd4cbfe8Smrg 276dd4cbfe8Smrg#endif /* _XF86OSMOUSE_H_ */ 277