74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/xf86OSmouse.h,v 1.20 2002/12/17 20:55:23 dawes Exp $ */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/*
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * Copyright (c) 1997-1999 by The XFree86 Project, Inc.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/* Public interface to OS-specific mouse support. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#ifndef _XF86OSMOUSE_H_
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define _XF86OSMOUSE_H_
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#include "xf86Xinput.h"
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/* Mouse interface classes */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_NONE 0x00
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_SERIAL 0x01 /* serial port */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_BUS 0x02 /* old bus mouse */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_PS2 0x04 /* standard read-only PS/2 */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_XPS2 0x08 /* extended PS/2 */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_AUTO 0x10 /* auto-detect (PnP) */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_MISC 0x20 /* The OS layer will identify the
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * specific protocol names that are
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * supported for this class. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsyncstruct _MouseDevRec;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef int (*GetInterfaceTypesProc)(void);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef const char **(*BuiltinNamesProc)(void);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef Bool (*CheckProtocolProc)(const char *protocol);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol,
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int flags);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef const char *(*DefaultProtocolProc)(void);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate,
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int res);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef void (*checkMovementsProc)(InputInfoPtr,int, int);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef Bool (*dataGoodProc)(struct _MouseDevRec *);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/*
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * OSMouseInfoRec is used to pass information from the OSMouse layer to the
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * OS-independent mouse driver.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef struct {
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync GetInterfaceTypesProc SupportedInterfaces;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync BuiltinNamesProc BuiltinNames;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync CheckProtocolProc CheckProtocol;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync BuiltinPreInitProc PreInit;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync DefaultProtocolProc DefaultProtocol;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync SetupAutoProc SetupAuto;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync SetResProc SetPS2Res;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync SetResProc SetBMRes;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync SetResProc SetMiscRes;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync} OSMouseInfoRec, *OSMouseInfoPtr;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/*
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * SupportedInterfaces: Returns the mouse interface types that the OS support.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * If MSE_MISC is returned, then the BuiltinNames and
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * CheckProtocol should be set.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * BuiltinNames: Returns the names of the protocols that are fully handled
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * in the OS-specific code. These are names that don't appear
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * directly in the main "mouse" driver.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * CheckProtocol: Checks if the protocol name given is supported by the
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * OS. It should return TRUE for both "builtin" protocols and
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * protocols of type MSE_MISC that are supported by the OS.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * PreInit: The PreInit function for protocols that are builtin. This
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * function is passed the protocol name.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * DefaultProtocol: Returns the name of a default protocol that should be used
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * for the OS when none has been supplied in the config file.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * This should only be set when there is a reasonable default.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * SetupAuto: This function can be used to do OS-specific protocol
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * auto-detection. It returns the name of the detected protocol,
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * or NULL when detection fails. It may also adjust one or more
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * of the "protoPara" values for the detected protocol by setting
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * then to something other than -1.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * protocol types.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync *
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsyncextern OSMouseInfoPtr xf86OSMouseInit(int flags);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/*
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * Mouse device record. This is shared by the mouse driver and the OSMouse
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * layer.
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons,
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int dx, int dy, int dz, int dw);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef void (*MouseCommonOptProc)(InputInfoPtr pInfo);
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsynctypedef struct _MouseDevRec {
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync PtrCtrlProcPtr Ctrl;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync PostMseEventProc PostEvent;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync MouseCommonOptProc CommonOptions;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync DeviceIntPtr device;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync const char * mseDevice;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync const char * protocol;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int protocolID;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int oldProtocolID; /* hack */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int class;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int mseModel;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int baudRate;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int oldBaudRate;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int sampleRate;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int lastButtons;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int threshold; /* acceleration */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int num;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int den;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int buttons; /* # of buttons */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int emulateState; /* automata state for 2 button mode */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync Bool emulate3Buttons;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync Bool emulate3ButtonsSoft;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int emulate3Timeout;/* Timeout for 3 button emulation */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync Bool chordMiddle;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync Bool flipXY;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int invX;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int invY;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int mouseFlags; /* Flags to Clear after opening
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * mouse dev */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int truebuttons; /* (not used)
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * Arg to maintain before
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync * emulate3buttons timer callback */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int resolution;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int negativeZ; /* button mask */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int positiveZ; /* button mask */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int negativeW; /* button mask */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int positiveW; /* button mask */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync pointer buffer; /* usually an XISBuffer* */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int protoBufTail;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync unsigned char protoBuf[8];
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync unsigned char protoPara[8];
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync unsigned char inSync; /* driver in sync with datastream */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync pointer mousePriv; /* private area */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync InputInfoPtr pInfo;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int origProtocolID;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync const char * origProtocol;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync Bool emulate3Pending;/* timer waiting */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync CARD32 emulate3Expires;/* time to fire emulation code */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync Bool emulateWheel;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int wheelInertia;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int wheelButtonMask;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int negativeX; /* Button values. Unlike the Z and */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int positiveX; /* W equivalents, these are button */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int negativeY; /* values rather than button masks. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int positiveY;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int wheelYDistance;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int wheelXDistance;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync Bool autoProbe;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync checkMovementsProc checkMovements;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync autoProbeProc autoProbeMouse;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync collectDataProc collectData;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync dataGoodProc dataGood;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync int angleOffset;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync pointer pDragLock; /* drag lock area */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync} MouseDevRec, *MouseDevPtr;
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/* Z axis mapping */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_NOZMAP 0
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_MAPTOX -1
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_MAPTOY -2
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_MAPTOZ -3
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_MAPTOW -4
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync/* Generalize for other axes. */
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_NOAXISMAP MSE_NOZMAP
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_MAXBUTTONS 12
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#define MSE_DFLTBUTTONS 3
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync
74fe172698ba936102e120dae998c9ebd09cfbdfvboxsync#endif /* _XF86OSMOUSE_H_ */