]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - sys/sys/mouse.h
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / sys / sys / mouse.h
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$
24  */
25
26 #ifndef _SYS_MOUSE_H_
27 #define _SYS_MOUSE_H_
28
29 #include <sys/types.h>
30 #include <sys/ioccom.h>
31
32 /* ioctls */
33 #define MOUSE_GETSTATUS         _IOR('M', 0, mousestatus_t)
34 #define MOUSE_GETHWINFO         _IOR('M', 1, mousehw_t)
35 #define MOUSE_GETMODE           _IOR('M', 2, mousemode_t)
36 #define MOUSE_SETMODE           _IOW('M', 3, mousemode_t)
37 #define MOUSE_GETLEVEL          _IOR('M', 4, int)
38 #define MOUSE_SETLEVEL          _IOW('M', 5, int)
39 #define MOUSE_GETVARS           _IOR('M', 6, mousevar_t)
40 #define MOUSE_SETVARS           _IOW('M', 7, mousevar_t)
41 #define MOUSE_READSTATE         _IOWR('M', 8, mousedata_t)
42 #define MOUSE_READDATA          _IOWR('M', 9, mousedata_t)
43
44 #ifdef notyet
45 #define MOUSE_SETRESOLUTION     _IOW('M', 10, int)
46 #define MOUSE_SETSCALING        _IOW('M', 11, int)
47 #define MOUSE_SETRATE           _IOW('M', 12, int)
48 #define MOUSE_GETHWID           _IOR('M', 13, int)
49 #endif
50
51 #define MOUSE_SYN_GETHWINFO     _IOR('M', 100, synapticshw_t)
52
53 /* mouse status block */
54 typedef struct mousestatus {
55     int     flags;              /* state change flags */
56     int     button;             /* button status */
57     int     obutton;            /* previous button status */
58     int     dx;                 /* x movement */
59     int     dy;                 /* y movement */
60     int     dz;                 /* z movement */
61 } mousestatus_t;
62
63 /* button */
64 #define MOUSE_BUTTON1DOWN       0x0001  /* left */
65 #define MOUSE_BUTTON2DOWN       0x0002  /* middle */
66 #define MOUSE_BUTTON3DOWN       0x0004  /* right */
67 #define MOUSE_BUTTON4DOWN       0x0008
68 #define MOUSE_BUTTON5DOWN       0x0010
69 #define MOUSE_BUTTON6DOWN       0x0020
70 #define MOUSE_BUTTON7DOWN       0x0040
71 #define MOUSE_BUTTON8DOWN       0x0080
72 #define MOUSE_MAXBUTTON         31
73 #define MOUSE_STDBUTTONS        0x0007          /* buttons 1-3 */
74 #define MOUSE_EXTBUTTONS        0x7ffffff8      /* the others (28 of them!) */
75 #define MOUSE_BUTTONS           (MOUSE_STDBUTTONS | MOUSE_EXTBUTTONS)
76
77 /* flags */
78 #define MOUSE_STDBUTTONSCHANGED MOUSE_STDBUTTONS
79 #define MOUSE_EXTBUTTONSCHANGED MOUSE_EXTBUTTONS
80 #define MOUSE_BUTTONSCHANGED    MOUSE_BUTTONS
81 #define MOUSE_POSCHANGED        0x80000000
82
83 typedef struct mousehw {
84         int buttons;            /* -1 if unknown */
85         int iftype;             /* MOUSE_IF_XXX */
86         int type;               /* mouse/track ball/pad... */
87         int model;              /* I/F dependent model ID: MOUSE_MODEL_XXX */
88         int hwid;               /* I/F dependent hardware ID
89                                  * for the PS/2 mouse, it will be PSM_XXX_ID 
90                                  */
91 } mousehw_t;
92
93 typedef struct synapticshw {
94         int infoMajor;
95         int infoMinor;
96         int infoRot180;
97         int infoPortrait;
98         int infoSensor;
99         int infoHardware;
100         int infoNewAbs;
101         int capPen;
102         int infoSimplC;
103         int infoGeometry;
104         int capExtended;
105         int capSleep;
106         int capFourButtons;
107         int capMultiFinger;
108         int capPalmDetect;
109         int capPassthrough;
110         int capMiddle;
111         int nExtendedButtons;
112         int nExtendedQueries;
113 } synapticshw_t;
114
115 /* iftype */
116 #define MOUSE_IF_UNKNOWN        (-1)
117 #define MOUSE_IF_SERIAL         0
118 #define MOUSE_IF_BUS            1
119 #define MOUSE_IF_INPORT         2
120 #define MOUSE_IF_PS2            3
121 #define MOUSE_IF_SYSMOUSE       4
122 #define MOUSE_IF_USB            5
123
124 /* type */
125 #define MOUSE_UNKNOWN           (-1)    /* should be treated as a mouse */
126 #define MOUSE_MOUSE             0
127 #define MOUSE_TRACKBALL         1
128 #define MOUSE_STICK             2
129 #define MOUSE_PAD               3
130
131 /* model */
132 #define MOUSE_MODEL_UNKNOWN             (-1)
133 #define MOUSE_MODEL_GENERIC             0
134 #define MOUSE_MODEL_GLIDEPOINT          1
135 #define MOUSE_MODEL_NETSCROLL           2
136 #define MOUSE_MODEL_NET                 3
137 #define MOUSE_MODEL_INTELLI             4
138 #define MOUSE_MODEL_THINK               5
139 #define MOUSE_MODEL_EASYSCROLL          6
140 #define MOUSE_MODEL_MOUSEMANPLUS        7
141 #define MOUSE_MODEL_KIDSPAD             8
142 #define MOUSE_MODEL_VERSAPAD            9
143 #define MOUSE_MODEL_EXPLORER            10
144 #define MOUSE_MODEL_4D                  11
145 #define MOUSE_MODEL_4DPLUS              12
146 #define MOUSE_MODEL_SYNAPTICS           13
147 #define MOUSE_MODEL_TRACKPOINT          14
148
149 typedef struct mousemode {
150         int protocol;           /* MOUSE_PROTO_XXX */
151         int rate;               /* report rate (per sec), -1 if unknown */
152         int resolution;         /* MOUSE_RES_XXX, -1 if unknown */
153         int accelfactor;        /* accelation factor (must be 1 or greater) */
154         int level;              /* driver operation level */
155         int packetsize;         /* the length of the data packet */
156         unsigned char syncmask[2]; /* sync. data bits in the header byte */
157 } mousemode_t;
158
159 /* protocol */
160 /*
161  * Serial protocols:
162  *   Microsoft, MouseSystems, Logitech, MM series, MouseMan, Hitachi Tablet,
163  *   GlidePoint, IntelliMouse, Thinking Mouse, MouseRemote, Kidspad,
164  *   VersaPad
165  * Bus mouse protocols:
166  *   bus, InPort
167  * PS/2 mouse protocol:
168  *   PS/2
169  */
170 #define MOUSE_PROTO_UNKNOWN     (-1)
171 #define MOUSE_PROTO_MS          0       /* Microsoft Serial, 3 bytes */
172 #define MOUSE_PROTO_MSC         1       /* Mouse Systems, 5 bytes */
173 #define MOUSE_PROTO_LOGI        2       /* Logitech, 3 bytes */
174 #define MOUSE_PROTO_MM          3       /* MM series, 3 bytes */
175 #define MOUSE_PROTO_LOGIMOUSEMAN 4      /* Logitech MouseMan 3/4 bytes */
176 #define MOUSE_PROTO_BUS         5       /* MS/Logitech bus mouse */
177 #define MOUSE_PROTO_INPORT      6       /* MS/ATI InPort mouse */
178 #define MOUSE_PROTO_PS2         7       /* PS/2 mouse, 3 bytes */
179 #define MOUSE_PROTO_HITTAB      8       /* Hitachi Tablet 3 bytes */
180 #define MOUSE_PROTO_GLIDEPOINT  9       /* ALPS GlidePoint, 3/4 bytes */
181 #define MOUSE_PROTO_INTELLI     10      /* MS IntelliMouse, 4 bytes */
182 #define MOUSE_PROTO_THINK       11      /* Kensington Thinking Mouse, 3/4 bytes */
183 #define MOUSE_PROTO_SYSMOUSE    12      /* /dev/sysmouse */
184 #define MOUSE_PROTO_X10MOUSEREM 13      /* X10 MouseRemote, 3 bytes */
185 #define MOUSE_PROTO_KIDSPAD     14      /* Genius Kidspad */
186 #define MOUSE_PROTO_VERSAPAD    15      /* Interlink VersaPad, 6 bytes */
187 #define MOUSE_PROTO_JOGDIAL     16      /* Vaio's JogDial */
188 #define MOUSE_PROTO_GTCO_DIGIPAD        17
189
190 #define MOUSE_RES_UNKNOWN       (-1)
191 #define MOUSE_RES_DEFAULT       0
192 #define MOUSE_RES_LOW           (-2)
193 #define MOUSE_RES_MEDIUMLOW     (-3)
194 #define MOUSE_RES_MEDIUMHIGH    (-4)
195 #define MOUSE_RES_HIGH          (-5)
196
197 typedef struct mousedata {
198         int len;                /* # of data in the buffer */
199         int buf[16];            /* data buffer */
200 } mousedata_t;
201
202 #if (defined(MOUSE_GETVARS))
203
204 typedef struct mousevar {
205         int var[16];
206 } mousevar_t;
207
208 /* magic numbers in var[0] */
209 #define MOUSE_VARS_PS2_SIG      0x00325350      /* 'PS2' */
210 #define MOUSE_VARS_BUS_SIG      0x00535542      /* 'BUS' */
211 #define MOUSE_VARS_INPORT_SIG   0x00504e49      /* 'INP' */
212
213 #endif /* MOUSE_GETVARS */
214
215 /* Synaptics Touchpad */
216 #define MOUSE_SYNAPTICS_PACKETSIZE      6       /* '3' works better */
217
218 /* Microsoft Serial mouse data packet */
219 #define MOUSE_MSS_PACKETSIZE    3
220 #define MOUSE_MSS_SYNCMASK      0x40
221 #define MOUSE_MSS_SYNC          0x40
222 #define MOUSE_MSS_BUTTONS       0x30
223 #define MOUSE_MSS_BUTTON1DOWN   0x20    /* left */
224 #define MOUSE_MSS_BUTTON2DOWN   0x00    /* no middle button */
225 #define MOUSE_MSS_BUTTON3DOWN   0x10    /* right */
226
227 /* Logitech MouseMan data packet (M+ protocol) */
228 #define MOUSE_LMAN_BUTTON2DOWN  0x20    /* middle button, the 4th byte */
229
230 /* ALPS GlidePoint extension (variant of M+ protocol) */
231 #define MOUSE_ALPS_BUTTON2DOWN  0x20    /* middle button, the 4th byte */
232 #define MOUSE_ALPS_TAP          0x10    /* `tapping' action, the 4th byte */
233
234 /* Kinsington Thinking Mouse extension (variant of M+ protocol) */
235 #define MOUSE_THINK_BUTTON2DOWN 0x20    /* lower-left button, the 4th byte */
236 #define MOUSE_THINK_BUTTON4DOWN 0x10    /* lower-right button, the 4th byte */
237
238 /* MS IntelliMouse (variant of MS Serial) */
239 #define MOUSE_INTELLI_PACKETSIZE 4
240 #define MOUSE_INTELLI_BUTTON2DOWN 0x10  /* middle button in the 4th byte */
241
242 /* Mouse Systems Corp. mouse data packet */
243 #define MOUSE_MSC_PACKETSIZE    5
244 #define MOUSE_MSC_SYNCMASK      0xf8
245 #define MOUSE_MSC_SYNC          0x80
246 #define MOUSE_MSC_BUTTONS       0x07
247 #define MOUSE_MSC_BUTTON1UP     0x04    /* left */
248 #define MOUSE_MSC_BUTTON2UP     0x02    /* middle */
249 #define MOUSE_MSC_BUTTON3UP     0x01    /* right */
250 #define MOUSE_MSC_MAXBUTTON     3
251
252 /* MM series mouse data packet */
253 #define MOUSE_MM_PACKETSIZE     3
254 #define MOUSE_MM_SYNCMASK       0xe0
255 #define MOUSE_MM_SYNC           0x80
256 #define MOUSE_MM_BUTTONS        0x07
257 #define MOUSE_MM_BUTTON1DOWN    0x04    /* left */
258 #define MOUSE_MM_BUTTON2DOWN    0x02    /* middle */
259 #define MOUSE_MM_BUTTON3DOWN    0x01    /* right */
260 #define MOUSE_MM_XPOSITIVE      0x10
261 #define MOUSE_MM_YPOSITIVE      0x08
262
263 /* PS/2 mouse data packet */
264 #define MOUSE_PS2_PACKETSIZE    3
265 #define MOUSE_PS2_SYNCMASK      0xc8
266 #define MOUSE_PS2_SYNC          0x08
267 #define MOUSE_PS2_BUTTONS       0x07    /* 0x03 for 2 button mouse */
268 #define MOUSE_PS2_BUTTON1DOWN   0x01    /* left */
269 #define MOUSE_PS2_BUTTON2DOWN   0x04    /* middle */
270 #define MOUSE_PS2_BUTTON3DOWN   0x02    /* right */
271 #define MOUSE_PS2_TAP           MOUSE_PS2_SYNC /* GlidePoint (PS/2) `tapping'
272                                                 * Yes! this is the same bit 
273                                                 * as SYNC!
274                                                 */
275
276 #define MOUSE_PS2_XNEG          0x10
277 #define MOUSE_PS2_YNEG          0x20
278 #define MOUSE_PS2_XOVERFLOW     0x40
279 #define MOUSE_PS2_YOVERFLOW     0x80
280
281 /* Logitech MouseMan+ (PS/2) data packet (PS/2++ protocol) */
282 #define MOUSE_PS2PLUS_SYNCMASK  0x48
283 #define MOUSE_PS2PLUS_SYNC      0x48
284 #define MOUSE_PS2PLUS_ZNEG      0x08    /* sign bit */
285 #define MOUSE_PS2PLUS_BUTTON4DOWN 0x10  /* 4th button on MouseMan+ */
286 #define MOUSE_PS2PLUS_BUTTON5DOWN 0x20
287
288 /* IBM ScrollPoint (PS/2) also uses PS/2++ protocol */
289 #define MOUSE_SPOINT_ZNEG       0x80    /* sign bits */
290 #define MOUSE_SPOINT_WNEG       0x08
291
292 /* MS IntelliMouse (PS/2) data packet */
293 #define MOUSE_PS2INTELLI_PACKETSIZE 4
294 /* some compatible mice have additional buttons */
295 #define MOUSE_PS2INTELLI_BUTTON4DOWN 0x40
296 #define MOUSE_PS2INTELLI_BUTTON5DOWN 0x80
297
298 /* MS IntelliMouse Explorer (PS/2) data packet (variation of IntelliMouse) */
299 #define MOUSE_EXPLORER_ZNEG     0x08    /* sign bit */
300 /* IntelliMouse Explorer has additional button data in the fourth byte */
301 #define MOUSE_EXPLORER_BUTTON4DOWN 0x10
302 #define MOUSE_EXPLORER_BUTTON5DOWN 0x20
303
304 /* Interlink VersaPad (serial I/F) data packet */
305 #define MOUSE_VERSA_PACKETSIZE  6
306 #define MOUSE_VERSA_IN_USE      0x04
307 #define MOUSE_VERSA_SYNCMASK    0xc3
308 #define MOUSE_VERSA_SYNC        0xc0
309 #define MOUSE_VERSA_BUTTONS     0x30
310 #define MOUSE_VERSA_BUTTON1DOWN 0x20    /* left */
311 #define MOUSE_VERSA_BUTTON2DOWN 0x00    /* middle */
312 #define MOUSE_VERSA_BUTTON3DOWN 0x10    /* right */
313 #define MOUSE_VERSA_TAP         0x08
314
315 /* Interlink VersaPad (PS/2 I/F) data packet */
316 #define MOUSE_PS2VERSA_PACKETSIZE       6
317 #define MOUSE_PS2VERSA_IN_USE           0x10
318 #define MOUSE_PS2VERSA_SYNCMASK         0xe8
319 #define MOUSE_PS2VERSA_SYNC             0xc8
320 #define MOUSE_PS2VERSA_BUTTONS          0x05
321 #define MOUSE_PS2VERSA_BUTTON1DOWN      0x04    /* left */
322 #define MOUSE_PS2VERSA_BUTTON2DOWN      0x00    /* middle */
323 #define MOUSE_PS2VERSA_BUTTON3DOWN      0x01    /* right */
324 #define MOUSE_PS2VERSA_TAP              0x02
325
326 /* A4 Tech 4D Mouse (PS/2) data packet */
327 #define MOUSE_4D_PACKETSIZE             3       
328 #define MOUSE_4D_WHEELBITS              0xf0
329
330 /* A4 Tech 4D+ Mouse (PS/2) data packet */
331 #define MOUSE_4DPLUS_PACKETSIZE         3       
332 #define MOUSE_4DPLUS_ZNEG               0x04    /* sign bit */
333 #define MOUSE_4DPLUS_BUTTON4DOWN        0x08
334
335 /* sysmouse extended data packet */
336 /*
337  * /dev/sysmouse sends data in two formats, depending on the protocol
338  * level.  At the level 0, format is exactly the same as MousSystems'
339  * five byte packet.  At the level 1, the first five bytes are the same
340  * as at the level 0.  There are additional three bytes which shows
341  * `dz' and the states of additional buttons.  `dz' is expressed as the
342  * sum of the byte 5 and 6 which contain signed seven bit values.
343  * The states of the button 4 though 10 are in the bit 0 though 6 in 
344  * the byte 7 respectively: 1 indicates the button is up.
345  */
346 #define MOUSE_SYS_PACKETSIZE    8
347 #define MOUSE_SYS_SYNCMASK      0xf8
348 #define MOUSE_SYS_SYNC          0x80
349 #define MOUSE_SYS_BUTTON1UP     0x04    /* left, 1st byte */
350 #define MOUSE_SYS_BUTTON2UP     0x02    /* middle, 1st byte */
351 #define MOUSE_SYS_BUTTON3UP     0x01    /* right, 1st byte */
352 #define MOUSE_SYS_BUTTON4UP     0x0001  /* 7th byte */
353 #define MOUSE_SYS_BUTTON5UP     0x0002
354 #define MOUSE_SYS_BUTTON6UP     0x0004
355 #define MOUSE_SYS_BUTTON7UP     0x0008
356 #define MOUSE_SYS_BUTTON8UP     0x0010
357 #define MOUSE_SYS_BUTTON9UP     0x0020
358 #define MOUSE_SYS_BUTTON10UP    0x0040
359 #define MOUSE_SYS_MAXBUTTON     10
360 #define MOUSE_SYS_STDBUTTONS    0x07
361 #define MOUSE_SYS_EXTBUTTONS    0x7f    /* the others */
362
363 /* Mouse remote socket */
364 #define _PATH_MOUSEREMOTE       "/var/run/MouseRemote"
365
366 #endif /* _SYS_MOUSE_H_ */