xref: /dragonfly/sys/sys/mouse.h (revision a162a738)
1 /*-
2  * Copyright (c) 1992, 1993 Erik Forsberg.
3  * Copyright (c) 1996, 1997 Kazutaka YOKOTA
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  * 1. Redistributions of source code must retain the above copyright
10  *    notice, this list of conditions and the following disclaimer.
11  *
12  * THIS SOFTWARE IS PROVIDED BY ``AS IS'' AND ANY EXPRESS OR IMPLIED
13  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
14  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN
15  * NO EVENT SHALL I BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
16  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
17  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
18  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
19  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
21  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
22  *
23  * $FreeBSD: src/sys/i386/include/mouse.h,v 1.15.2.2 2002/04/15 00:52:08 will Exp $
24  *  $FreeBSD: stable/11/sys/sys/mouse.h 307576 2016-10-18 20:17:57Z gonzo $
25  */
26 
27 #ifndef _SYS_MOUSE_H_
28 #define _SYS_MOUSE_H_
29 
30 #include <sys/types.h>
31 #include <sys/ioccom.h>
32 
33 /* ioctls */
34 #define MOUSE_GETSTATUS		_IOR('M', 0, mousestatus_t)
35 #define MOUSE_GETHWINFO		_IOR('M', 1, mousehw_t)
36 #define MOUSE_GETMODE		_IOR('M', 2, mousemode_t)
37 #define MOUSE_SETMODE		_IOW('M', 3, mousemode_t)
38 #define MOUSE_GETLEVEL		_IOR('M', 4, int)
39 #define MOUSE_SETLEVEL		_IOW('M', 5, int)
40 #define MOUSE_READSTATE		_IOWR('M', 8, mousedata_t)
41 #define MOUSE_READDATA		_IOWR('M', 9, mousedata_t)
42 
43 #if 0 /* notyet */
44 #define MOUSE_SETRESOLUTION	_IOW('M', 10, int)
45 #define MOUSE_SETSCALING	_IOW('M', 11, int)
46 #define MOUSE_SETRATE		_IOW('M', 12, int)
47 #define MOUSE_GETHWID		_IOR('M', 13, int)
48 #endif
49 
50 #define MOUSE_SYN_GETHWINFO	_IOR('M', 100, synapticshw_t)
51 
52 /* mouse status block */
53 typedef struct mousestatus {
54     int     flags;		/* state change flags */
55     int     button;		/* button status */
56     int     obutton;		/* previous button status */
57     int     dx;			/* x movement */
58     int     dy;			/* y movement */
59     int     dz;			/* z movement */
60 } mousestatus_t;
61 
62 /* button */
63 #define MOUSE_BUTTON1DOWN	0x0001	/* left */
64 #define MOUSE_BUTTON2DOWN	0x0002	/* middle */
65 #define MOUSE_BUTTON3DOWN	0x0004	/* right */
66 #define MOUSE_BUTTON4DOWN	0x0008
67 #define MOUSE_BUTTON5DOWN	0x0010
68 #define MOUSE_BUTTON6DOWN	0x0020
69 #define MOUSE_BUTTON7DOWN	0x0040
70 #define MOUSE_BUTTON8DOWN	0x0080
71 #define MOUSE_MAXBUTTON		31
72 #define MOUSE_STDBUTTONS	0x0007		/* buttons 1-3 */
73 #define MOUSE_EXTBUTTONS	0x7ffffff8	/* the others (28 of them!) */
74 #define MOUSE_BUTTONS		(MOUSE_STDBUTTONS | MOUSE_EXTBUTTONS)
75 
76 /* flags */
77 #define MOUSE_STDBUTTONSCHANGED	MOUSE_STDBUTTONS
78 #define MOUSE_EXTBUTTONSCHANGED	MOUSE_EXTBUTTONS
79 #define MOUSE_BUTTONSCHANGED	MOUSE_BUTTONS
80 #define MOUSE_POSCHANGED	0x80000000
81 
82 typedef struct mousehw {
83 	int buttons;		/* -1 if unknown */
84 	int iftype;		/* MOUSE_IF_XXX */
85 	int type;		/* mouse/track ball/pad... */
86 	int model;		/* I/F dependent model ID: MOUSE_MODEL_XXX */
87 	int hwid;		/* I/F dependent hardware ID
88 				 * for the PS/2 mouse, it will be PSM_XXX_ID
89 				 */
90 } mousehw_t;
91 
92 typedef struct synapticshw {
93 	int infoMajor;
94 	int infoMinor;
95 	int infoRot180;
96 	int infoPortrait;
97 	int infoSensor;
98 	int infoHardware;
99 	int infoNewAbs;
100 	int capPen;
101 	int infoSimplC;
102 	int infoGeometry;
103 	int capExtended;
104 	int capSleep;
105 	int capFourButtons;
106 	int capMultiFinger;
107 	int capPalmDetect;
108 	int capPassthrough;
109 	int capMiddle;
110 	int capLowPower;
111 	int capMultiFingerReport;
112 	int capBallistics;
113 	int nExtendedButtons;
114 	int nExtendedQueries;
115 	int capClickPad;
116 	int capDeluxeLEDs;
117 	int noAbsoluteFilter;
118 	int capReportsV;
119 	int capUniformClickPad;
120 	int capReportsMin;
121 	int capInterTouch;
122 	int capReportsMax;
123 	int capClearPad;
124 	int capAdvancedGestures;
125 	int multiFingerMode;
126 	int capCoveredPad;
127 	int verticalScroll;
128 	int horizontalScroll;
129 	int verticalWheel;
130 	int capEWmode;
131 	int minimumXCoord;
132 	int minimumYCoord;
133 	int maximumXCoord;
134 	int maximumYCoord;
135 	int infoXupmm;
136 	int infoYupmm;
137 	int forcePad;
138 	int topButtonPad;
139 } synapticshw_t;
140 
141 /* iftype */
142 #define MOUSE_IF_UNKNOWN	(-1)
143 #define MOUSE_IF_SERIAL		0
144 #define MOUSE_IF_BUS		1
145 #define MOUSE_IF_INPORT		2
146 #define MOUSE_IF_PS2		3
147 #define MOUSE_IF_SYSMOUSE	4
148 #define MOUSE_IF_USB		5
149 
150 /* type */
151 #define MOUSE_UNKNOWN		(-1)	/* should be treated as a mouse */
152 #define MOUSE_MOUSE		0
153 #define MOUSE_TRACKBALL		1
154 #define MOUSE_STICK		2
155 #define MOUSE_PAD		3
156 
157 /* model */
158 #define MOUSE_MODEL_UNKNOWN		(-1)
159 #define MOUSE_MODEL_GENERIC		0
160 #define MOUSE_MODEL_GLIDEPOINT		1
161 #define MOUSE_MODEL_NETSCROLL		2
162 #define MOUSE_MODEL_NET			3
163 #define MOUSE_MODEL_INTELLI		4
164 #define MOUSE_MODEL_THINK		5
165 #define MOUSE_MODEL_EASYSCROLL		6
166 #define MOUSE_MODEL_MOUSEMANPLUS	7
167 #define MOUSE_MODEL_KIDSPAD		8
168 #define MOUSE_MODEL_VERSAPAD		9
169 #define MOUSE_MODEL_EXPLORER		10
170 #define MOUSE_MODEL_4D			11
171 #define MOUSE_MODEL_4DPLUS		12
172 #define MOUSE_MODEL_SYNAPTICS		13
173 #define MOUSE_MODEL_TRACKPOINT		14
174 #define MOUSE_MODEL_ELANTECH		15
175 
176 typedef struct mousemode {
177 	int protocol;		/* MOUSE_PROTO_XXX */
178 	int rate;		/* report rate (per sec), -1 if unknown */
179 	int resolution;		/* MOUSE_RES_XXX, -1 if unknown */
180 	int accelfactor;	/* accelation factor (must be 1 or greater) */
181 	int level;		/* driver operation level */
182 	int packetsize;		/* the length of the data packet */
183 	unsigned char syncmask[2]; /* sync. data bits in the header byte */
184 } mousemode_t;
185 
186 /* protocol */
187 /*
188  * Serial protocols:
189  *   Microsoft, MouseSystems, Logitech, MM series, MouseMan, Hitachi Tablet,
190  *   GlidePoint, IntelliMouse, Thinking Mouse, MouseRemote, Kidspad,
191  *   VersaPad
192  * Bus mouse protocols:
193  *   bus, InPort
194  * PS/2 mouse protocol:
195  *   PS/2
196  */
197 #define MOUSE_PROTO_UNKNOWN	(-1)
198 #define MOUSE_PROTO_MS		0	/* Microsoft Serial, 3 bytes */
199 #define MOUSE_PROTO_MSC		1	/* Mouse Systems, 5 bytes */
200 #define MOUSE_PROTO_LOGI	2	/* Logitech, 3 bytes */
201 #define MOUSE_PROTO_MM		3	/* MM series, 3 bytes */
202 #define MOUSE_PROTO_LOGIMOUSEMAN 4	/* Logitech MouseMan 3/4 bytes */
203 #define MOUSE_PROTO_BUS		5	/* MS/Logitech bus mouse */
204 #define MOUSE_PROTO_INPORT	6	/* MS/ATI InPort mouse */
205 #define MOUSE_PROTO_PS2		7	/* PS/2 mouse, 3 bytes */
206 #define MOUSE_PROTO_HITTAB	8	/* Hitachi Tablet 3 bytes */
207 #define MOUSE_PROTO_GLIDEPOINT	9	/* ALPS GlidePoint, 3/4 bytes */
208 #define MOUSE_PROTO_INTELLI	10	/* MS IntelliMouse, 4 bytes */
209 #define MOUSE_PROTO_THINK	11	/* Kensignton Thinking Mouse, 3/4 bytes */
210 #define MOUSE_PROTO_SYSMOUSE	12	/* /dev/sysmouse */
211 #define MOUSE_PROTO_X10MOUSEREM	13	/* X10 MouseRemote, 3 bytes */
212 #define MOUSE_PROTO_KIDSPAD	14	/* Genius Kidspad */
213 #define MOUSE_PROTO_VERSAPAD	15	/* Interlink VersaPad, 6 bytes */
214 #define	MOUSE_PROTO_JOGDIAL	16	/* Vaio's JogDial */
215 #define MOUSE_PROTO_GTCO_DIGIPAD        17
216 
217 #define MOUSE_RES_UNKNOWN	(-1)
218 #define MOUSE_RES_DEFAULT	0
219 #define MOUSE_RES_LOW		(-2)
220 #define MOUSE_RES_MEDIUMLOW	(-3)
221 #define MOUSE_RES_MEDIUMHIGH	(-4)
222 #define MOUSE_RES_HIGH		(-5)
223 
224 typedef struct mousedata {
225 	int len;		/* # of data in the buffer */
226 	int buf[16];		/* data buffer */
227 } mousedata_t;
228 
229 /* Synaptics Touchpad */
230 #define MOUSE_SYNAPTICS_PACKETSIZE 6	/* '3' works better */
231 
232 /* Elantech Touchpad */
233 #define MOUSE_ELANTECH_PACKETSIZE       6
234 
235 /* Microsoft Serial mouse data packet */
236 #define MOUSE_MSS_PACKETSIZE	3
237 #define MOUSE_MSS_SYNCMASK	0x40
238 #define MOUSE_MSS_SYNC		0x40
239 #define MOUSE_MSS_BUTTONS	0x30
240 #define MOUSE_MSS_BUTTON1DOWN	0x20	/* left */
241 #define MOUSE_MSS_BUTTON2DOWN	0x00	/* no middle button */
242 #define MOUSE_MSS_BUTTON3DOWN	0x10	/* right */
243 
244 /* Logitech MouseMan data packet (M+ protocol) */
245 #define MOUSE_LMAN_BUTTON2DOWN	0x20	/* middle button, the 4th byte */
246 
247 /* ALPS GlidePoint extention (variant of M+ protocol) */
248 #define MOUSE_ALPS_BUTTON2DOWN	0x20	/* middle button, the 4th byte */
249 #define MOUSE_ALPS_TAP		0x10	/* `tapping' action, the 4th byte */
250 
251 /* Kinsington Thinking Mouse extention (variant of M+ protocol) */
252 #define MOUSE_THINK_BUTTON2DOWN 0x20	/* lower-left button, the 4th byte */
253 #define MOUSE_THINK_BUTTON4DOWN 0x10	/* lower-right button, the 4th byte */
254 
255 /* MS IntelliMouse (variant of MS Serial) */
256 #define MOUSE_INTELLI_PACKETSIZE 4
257 #define MOUSE_INTELLI_BUTTON2DOWN 0x10	/* middle button in the 4th byte */
258 
259 /* Mouse Systems Corp. mouse data packet */
260 #define MOUSE_MSC_PACKETSIZE	5
261 #define MOUSE_MSC_SYNCMASK	0xf8
262 #define MOUSE_MSC_SYNC		0x80
263 #define MOUSE_MSC_BUTTONS	0x07
264 #define MOUSE_MSC_BUTTON1UP	0x04	/* left */
265 #define MOUSE_MSC_BUTTON2UP	0x02	/* middle */
266 #define MOUSE_MSC_BUTTON3UP	0x01	/* right */
267 #define MOUSE_MSC_MAXBUTTON	3
268 
269 /* MM series mouse data packet */
270 #define MOUSE_MM_PACKETSIZE	3
271 #define MOUSE_MM_SYNCMASK	0xe0
272 #define MOUSE_MM_SYNC		0x80
273 #define MOUSE_MM_BUTTONS	0x07
274 #define MOUSE_MM_BUTTON1DOWN	0x04	/* left */
275 #define MOUSE_MM_BUTTON2DOWN	0x02	/* middle */
276 #define MOUSE_MM_BUTTON3DOWN	0x01	/* right */
277 #define MOUSE_MM_XPOSITIVE	0x10
278 #define MOUSE_MM_YPOSITIVE	0x08
279 
280 /* PS/2 mouse data packet */
281 #define MOUSE_PS2_PACKETSIZE	3
282 #define MOUSE_PS2_SYNCMASK	0xc8
283 #define MOUSE_PS2_SYNC		0x08
284 #define MOUSE_PS2_BUTTONS	0x07	/* 0x03 for 2 button mouse */
285 #define MOUSE_PS2_BUTTON1DOWN	0x01	/* left */
286 #define MOUSE_PS2_BUTTON2DOWN	0x04	/* middle */
287 #define MOUSE_PS2_BUTTON3DOWN	0x02	/* right */
288 #define MOUSE_PS2_TAP		MOUSE_PS2_SYNC /* GlidePoint (PS/2) `tapping'
289 					        * Yes! this is the same bit
290 						* as SYNC!
291 						*/
292 
293 #define MOUSE_PS2_XNEG		0x10
294 #define MOUSE_PS2_YNEG		0x20
295 #define MOUSE_PS2_XOVERFLOW	0x40
296 #define MOUSE_PS2_YOVERFLOW	0x80
297 
298 /* Logitech MouseMan+ (PS/2) data packet (PS/2++ protocol) */
299 #define MOUSE_PS2PLUS_SYNCMASK	0x48
300 #define MOUSE_PS2PLUS_SYNC	0x48
301 #define MOUSE_PS2PLUS_ZNEG	0x08	/* sign bit */
302 #define MOUSE_PS2PLUS_BUTTON4DOWN 0x10	/* 4th button on MouseMan+ */
303 #define MOUSE_PS2PLUS_BUTTON5DOWN 0x20
304 
305 /* IBM ScrollPoint (PS/2) also uses PS/2++ protocol */
306 #define MOUSE_SPOINT_ZNEG	0x80	/* sign bits */
307 #define MOUSE_SPOINT_WNEG	0x08
308 
309 /* MS IntelliMouse (PS/2) data packet */
310 #define MOUSE_PS2INTELLI_PACKETSIZE 4
311 /* some compatible mice have additional buttons */
312 #define MOUSE_PS2INTELLI_BUTTON4DOWN 0x40
313 #define MOUSE_PS2INTELLI_BUTTON5DOWN 0x80
314 
315 /* MS IntelliMouse Explorer (PS/2) data packet (variation of IntelliMouse) */
316 #define MOUSE_EXPLORER_ZNEG	0x08	/* sign bit */
317 /* IntelliMouse Explorer has additional button data in the fourth byte */
318 #define MOUSE_EXPLORER_BUTTON4DOWN 0x10
319 #define MOUSE_EXPLORER_BUTTON5DOWN 0x20
320 
321 /* Interlink VersaPad (serial I/F) data packet */
322 #define MOUSE_VERSA_PACKETSIZE	6
323 #define MOUSE_VERSA_IN_USE	0x04
324 #define MOUSE_VERSA_SYNCMASK	0xc3
325 #define MOUSE_VERSA_SYNC	0xc0
326 #define MOUSE_VERSA_BUTTONS	0x30
327 #define MOUSE_VERSA_BUTTON1DOWN	0x20	/* left */
328 #define MOUSE_VERSA_BUTTON2DOWN	0x00	/* middle */
329 #define MOUSE_VERSA_BUTTON3DOWN	0x10	/* right */
330 #define MOUSE_VERSA_TAP		0x08
331 
332 /* Interlink VersaPad (PS/2 I/F) data packet */
333 #define MOUSE_PS2VERSA_PACKETSIZE	6
334 #define MOUSE_PS2VERSA_IN_USE		0x10
335 #define MOUSE_PS2VERSA_SYNCMASK		0xe8
336 #define MOUSE_PS2VERSA_SYNC		0xc8
337 #define MOUSE_PS2VERSA_BUTTONS		0x05
338 #define MOUSE_PS2VERSA_BUTTON1DOWN	0x04	/* left */
339 #define MOUSE_PS2VERSA_BUTTON2DOWN	0x00	/* middle */
340 #define MOUSE_PS2VERSA_BUTTON3DOWN	0x01	/* right */
341 #define MOUSE_PS2VERSA_TAP		0x02
342 
343 /* A4 Tech 4D Mouse (PS/2) data packet */
344 #define MOUSE_4D_PACKETSIZE		3
345 #define MOUSE_4D_WHEELBITS		0xf0
346 
347 /* A4 Tech 4D+ Mouse (PS/2) data packet */
348 #define MOUSE_4DPLUS_PACKETSIZE		3
349 #define MOUSE_4DPLUS_ZNEG		0x04	/* sign bit */
350 #define MOUSE_4DPLUS_BUTTON4DOWN	0x08
351 
352 /* sysmouse extended data packet */
353 /*
354  * /dev/sysmouse sends data in two formats, depending on the protocol
355  * level.  At the level 0, format is exactly the same as MousSystems'
356  * five byte packet.  At the level 1, the first five bytes are the same
357  * as at the level 0.  There are additional three bytes which shows
358  * `dz' and the states of additional buttons.  `dz' is expressed as the
359  * sum of the byte 5 and 6 which contain signed seven bit values.
360  * The states of the button 4 though 10 are in the bit 0 though 6 in
361  * the byte 7 respectively: 1 indicates the button is up.
362  */
363 #define MOUSE_SYS_PACKETSIZE	8
364 #define MOUSE_SYS_SYNCMASK	0xf8
365 #define MOUSE_SYS_SYNC		0x80
366 #define MOUSE_SYS_BUTTON1UP	0x04	/* left, 1st byte */
367 #define MOUSE_SYS_BUTTON2UP	0x02	/* middle, 1st byte */
368 #define MOUSE_SYS_BUTTON3UP	0x01	/* right, 1st byte */
369 #define MOUSE_SYS_BUTTON4UP	0x0001	/* 7th byte */
370 #define MOUSE_SYS_BUTTON5UP	0x0002
371 #define MOUSE_SYS_BUTTON6UP	0x0004
372 #define MOUSE_SYS_BUTTON7UP	0x0008
373 #define MOUSE_SYS_BUTTON8UP	0x0010
374 #define MOUSE_SYS_BUTTON9UP	0x0020
375 #define MOUSE_SYS_BUTTON10UP	0x0040
376 #define MOUSE_SYS_MAXBUTTON	10
377 #define MOUSE_SYS_STDBUTTONS	0x07
378 #define MOUSE_SYS_EXTBUTTONS	0x7f	/* the others */
379 
380 /* Mouse remote socket */
381 #define _PATH_MOUSEREMOTE	"/var/run/MouseRemote"
382 
383 #endif /* !_SYS_MOUSE_H_ */
384