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