xf86OSmouse.h 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  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. /* Public interface to OS-specific mouse support. */
  28. #ifndef _XF86OSMOUSE_H_
  29. #define _XF86OSMOUSE_H_
  30. #include "xf86Xinput.h"
  31. /* Mouse interface classes */
  32. #define MSE_NONE 0x00
  33. #define MSE_SERIAL 0x01 /* serial port */
  34. #define MSE_BUS 0x02 /* old bus mouse */
  35. #define MSE_PS2 0x04 /* standard read-only PS/2 */
  36. #define MSE_XPS2 0x08 /* extended PS/2 */
  37. #define MSE_AUTO 0x10 /* auto-detect (PnP) */
  38. #define MSE_MISC 0x20 /* The OS layer will identify the
  39. * specific protocol names that are
  40. * supported for this class. */
  41. /* Mouse Protocol IDs. */
  42. typedef enum {
  43. PROT_UNKNOWN = -2,
  44. PROT_UNSUP = -1, /* protocol is not supported */
  45. PROT_MS = 0,
  46. PROT_MSC,
  47. PROT_MM,
  48. PROT_LOGI,
  49. PROT_LOGIMAN,
  50. PROT_MMHIT,
  51. PROT_GLIDE,
  52. PROT_IMSERIAL,
  53. PROT_THINKING,
  54. PROT_ACECAD,
  55. PROT_VALUMOUSESCROLL,
  56. PROT_PS2,
  57. PROT_GENPS2,
  58. PROT_IMPS2,
  59. PROT_EXPPS2,
  60. PROT_THINKPS2,
  61. PROT_MMPS2,
  62. PROT_GLIDEPS2,
  63. PROT_NETPS2,
  64. PROT_NETSCPS2,
  65. PROT_BM,
  66. PROT_AUTO,
  67. PROT_SYSMOUSE,
  68. PROT_NUMPROTOS /* This must always be last. */
  69. } MouseProtocolID;
  70. struct _MouseDevRec;
  71. typedef int (*GetInterfaceTypesProc)(void);
  72. typedef const char **(*BuiltinNamesProc)(void);
  73. typedef Bool (*CheckProtocolProc)(const char *protocol);
  74. typedef Bool (*BuiltinPreInitProc)(InputInfoPtr pInfo, const char *protocol,
  75. int flags);
  76. typedef const char *(*DefaultProtocolProc)(void);
  77. typedef const char *(*SetupAutoProc)(InputInfoPtr pInfo, int *protoPara);
  78. typedef void (*SetResProc)(InputInfoPtr pInfo, const char* protocol, int rate,
  79. int res);
  80. typedef const char *(*FindDeviceProc)(InputInfoPtr pInfo, const char *protocol,
  81. int flags);
  82. typedef const char *(*GuessProtocolProc)(InputInfoPtr pInfo, int flags);
  83. /*
  84. * OSMouseInfoRec is used to pass information from the OSMouse layer to the
  85. * OS-independent mouse driver.
  86. */
  87. typedef struct {
  88. GetInterfaceTypesProc SupportedInterfaces;
  89. BuiltinNamesProc BuiltinNames;
  90. CheckProtocolProc CheckProtocol;
  91. BuiltinPreInitProc PreInit;
  92. DefaultProtocolProc DefaultProtocol;
  93. SetupAutoProc SetupAuto;
  94. SetResProc SetPS2Res;
  95. SetResProc SetBMRes;
  96. SetResProc SetMiscRes;
  97. FindDeviceProc FindDevice;
  98. GuessProtocolProc GuessProtocol;
  99. } OSMouseInfoRec, *OSMouseInfoPtr;
  100. /*
  101. * SupportedInterfaces: Returns the mouse interface types that the OS support.
  102. * If MSE_MISC is returned, then the BuiltinNames and
  103. * CheckProtocol should be set.
  104. *
  105. * BuiltinNames: Returns the names of the protocols that are fully handled
  106. * in the OS-specific code. These are names that don't appear
  107. * directly in the main "mouse" driver.
  108. *
  109. * CheckProtocol: Checks if the protocol name given is supported by the
  110. * OS. It should return TRUE for both "builtin" protocols and
  111. * protocols of type MSE_MISC that are supported by the OS.
  112. *
  113. * PreInit: The PreInit function for protocols that are builtin. This
  114. * function is passed the protocol name.
  115. *
  116. * DefaultProtocol: Returns the name of a default protocol that should be used
  117. * for the OS when none has been supplied in the config file.
  118. * This should only be set when there is a reasonable default.
  119. *
  120. * SetupAuto: This function can be used to do OS-specific protocol
  121. * auto-detection. It returns the name of the detected protocol,
  122. * or NULL when detection fails. It may also adjust one or more
  123. * of the "protoPara" values for the detected protocol by setting
  124. * then to something other than -1. SetupAuto gets called in two
  125. * ways. The first is before any devices have been opened. This
  126. * can be used when the protocol "Auto" always maps to a single
  127. * protocol type. The second is with the device open, allowing
  128. * OS-specific probing to be done.
  129. *
  130. * SetPS2Res: Set the resolution and sample rate for MSE_PS2 and MSE_XPS2
  131. * protocol types.
  132. *
  133. * SetBMRes: Set the resolution and sample rate for MSE_BM protocol types.
  134. *
  135. * SetMiscRes: Set the resolution and sample rate for MSE_MISC protocol types.
  136. *
  137. * FindDevice: This function gets called when no Device has been specified
  138. * in the config file. OS-specific methods may be used to guess
  139. * which input device to use. This function is called after the
  140. * pre-open attempts at protocol discovery are done, but before
  141. * the device is open. I.e., after the first SetupAuto() call,
  142. * after the DefaultProtocol() call, but before the PreInit()
  143. * call. Available protocol information may be used in locating
  144. * the default input device.
  145. *
  146. * GuessProtocol: A last resort attempt at guessing the mouse protocol by
  147. * whatever OS-specific means might be available. OS-independent
  148. * things should be in the mouse driver. This function gets
  149. * called after the mouse driver's OS-independent methods have
  150. * failed.
  151. */
  152. extern OSMouseInfoPtr xf86OSMouseInit(int flags);
  153. /* Adjust this when the mouse interface changes. */
  154. /*
  155. * History:
  156. *
  157. * 1.0.0 - Everything up to when versioning was started.
  158. * 1.1.0 - FindDevice and GuessProtocol added to OSMouseInfoRec
  159. * 1.2.0 - xisbscale added to MouseDevRec
  160. *
  161. */
  162. /* Z axis mapping */
  163. #define MSE_NOZMAP 0
  164. #define MSE_MAPTOX -1
  165. #define MSE_MAPTOY -2
  166. #define MSE_MAPTOZ -3
  167. #define MSE_MAPTOW -4
  168. /* Generalize for other axes. */
  169. #define MSE_NOAXISMAP MSE_NOZMAP
  170. #define MSE_MAXBUTTONS 24
  171. #define MSE_DFLTBUTTONS 3
  172. /*
  173. * Mouse device record. This is shared by the mouse driver and the OSMouse
  174. * layer.
  175. */
  176. typedef void (*checkMovementsProc)(InputInfoPtr,int, int);
  177. typedef void (*autoProbeProc)(InputInfoPtr, Bool, Bool);
  178. typedef Bool (*collectDataProc)(struct _MouseDevRec *, unsigned char);
  179. typedef Bool (*dataGoodProc)(struct _MouseDevRec *);
  180. typedef void (*PostMseEventProc)(InputInfoPtr pInfo, int buttons,
  181. int dx, int dy, int dz, int dw);
  182. typedef void (*MouseCommonOptProc)(InputInfoPtr pInfo);
  183. typedef struct _MouseDevRec {
  184. PtrCtrlProcPtr Ctrl;
  185. PostMseEventProc PostEvent;
  186. MouseCommonOptProc CommonOptions;
  187. DeviceIntPtr device;
  188. const char * mseDevice;
  189. const char * protocol;
  190. MouseProtocolID protocolID;
  191. MouseProtocolID oldProtocolID; /* hack */
  192. int class;
  193. int mseModel;
  194. int baudRate;
  195. int oldBaudRate;
  196. int sampleRate;
  197. int lastButtons;
  198. int threshold; /* acceleration */
  199. int num;
  200. int den;
  201. int buttons; /* # of buttons */
  202. int emulateState; /* automata state for 2 button mode */
  203. Bool emulate3Buttons;
  204. Bool emulate3ButtonsSoft;
  205. int emulate3Timeout;/* Timeout for 3 button emulation */
  206. Bool chordMiddle;
  207. Bool flipXY;
  208. int invX;
  209. int invY;
  210. int mouseFlags; /* Flags to Clear after opening
  211. * mouse dev */
  212. int truebuttons; /* (not used)
  213. * Arg to maintain before
  214. * emulate3buttons timer callback */
  215. int resolution;
  216. int negativeZ; /* button mask */
  217. int positiveZ; /* button mask */
  218. int negativeW; /* button mask */
  219. int positiveW; /* button mask */
  220. pointer buffer; /* usually an XISBuffer* */
  221. int protoBufTail;
  222. unsigned char protoBuf[8];
  223. unsigned char protoPara[8];
  224. unsigned char inSync; /* driver in sync with datastream */
  225. pointer mousePriv; /* private area */
  226. InputInfoPtr pInfo;
  227. int origProtocolID;
  228. const char * origProtocol;
  229. Bool emulate3Pending;/* timer waiting */
  230. CARD32 emulate3Expires;/* time to fire emulation code */
  231. Bool emulateWheel;
  232. int wheelInertia;
  233. int wheelButton;
  234. int negativeX; /* Button values. Unlike the Z and */
  235. int positiveX; /* W equivalents, these are button */
  236. int negativeY; /* values rather than button masks. */
  237. int positiveY;
  238. int wheelYDistance;
  239. int wheelXDistance;
  240. Bool autoProbe;
  241. checkMovementsProc checkMovements;
  242. autoProbeProc autoProbeMouse;
  243. collectDataProc collectData;
  244. dataGoodProc dataGood;
  245. int angleOffset;
  246. pointer pDragLock; /* drag lock area */
  247. int xisbscale; /* buffer size for 1 event */
  248. int wheelButtonTimeout;/* Timeout for the wheel button emulation */
  249. CARD32 wheelButtonExpires;
  250. int doubleClickSourceButtonMask;
  251. int doubleClickTargetButton;
  252. int doubleClickTargetButtonMask;
  253. int doubleClickOldSourceState;
  254. int lastMappedButtons;
  255. int buttonMap[MSE_MAXBUTTONS];
  256. } MouseDevRec, *MouseDevPtr;
  257. #endif /* _XF86OSMOUSE_H_ */