]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/mouse.4
This commit was generated by cvs2svn to compensate for changes in r52746,
[FreeBSD/FreeBSD.git] / share / man / man4 / mouse.4
1 .\"
2 .\" Copyright (c) 1997
3 .\" Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
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 as
11 .\"    the first lines of this file unmodified.
12 .\" 2. Redistributions in binary form must reproduce the above copyright
13 .\"    notice, this list of conditions and the following disclaimer in the
14 .\"    documentation and/or other materials provided with the distribution.
15 .\"
16 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
17 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21 .\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 .\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 .\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
25 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 .\"
27 .\" $FreeBSD$
28 .\"
29 .Dd December 3, 1997
30 .Dt MOUSE 4 i386
31 .Os FreeBSD
32 .Sh NAME
33 .Nm mouse
34 .Nd mouse and pointing device drivers
35 .Sh SYNOPSIS
36 .Fd #include <machine/mouse.h>
37 .Sh DESCRIPTION
38 The mouse drivers
39 .Xr mse 4 ,
40 .Xr psm 4
41 and
42 .Xr sysmouse 4
43 provide user programs with movement and button state information of the mouse.
44 Currently there are specific device drivers for bus, InPort and PS/2 mice.
45 The serial mouse is not directly supported by a dedicated driver, but
46 it is accessible via the serial device driver or via
47 .Xr moused 8 
48 and
49 .Xr sysmouse 4 .
50 .Pp
51 The user program simply opens a mouse device with a
52 .Xr open 2
53 call and reads
54 mouse data from the device via
55 .Xr read 2 .
56 Movement and button states are usually encoded in fixed-length data packets.
57 Some mouse devices may send data in variable length of packets.
58 Actual protocol (data format) used by each driver differs widely. 
59 .Pp
60 The mouse drivers may have ``non-blocking'' attribute which will make
61 the driver return immediately if mouse data is not available.
62 .Pp
63 Mouse device drivers often offer several levels of operation.
64 The current operation level can be examined and changed via
65 .Xr ioctl 2
66 commands.
67 The level zero is the lowest level at which the driver offers the basic
68 service to user programs. 
69 Most drivers provide horizontal and vertical movement of the mouse
70 and state of up to three buttons at this level.
71 At the level one, if supported by the driver, mouse data is encoded
72 in the standard format 
73 .Dv MOUSE_PROTO_SYSMOUSE 
74 as follows:
75 .Pp
76 .Bl -tag -width Byte_1 -compact
77 .It Byte 1 
78 .Bl -tag -width bit_7 -compact
79 .It bit 7
80 Always one.
81 .It bit 6..3
82 Always zero.
83 .It bit 2
84 Left button status; cleared if pressed, otherwise set.
85 .It bit 1
86 Middle button status; cleared if pressed, otherwise set. Always one,
87 if the device does not have the middle button.
88 .It bit 0
89 Right button status; cleared if pressed, otherwise set.
90 .El
91 .It Byte 2
92 The first half of horizontal movement count in two's complement; 
93 -128 through 127.
94 .It Byte 3
95 The first half of vertical movement count in two's complement; 
96 -128 through 127.
97 .It Byte 4
98 The second half of the horizontal movement count in two's complement; 
99 -128 through 127. To obtain the full horizontal movement count, add
100 the byte 2 and 4.
101 .It Byte 5
102 The second half of the vertical movement count in two's complement; 
103 -128 through 127. To obtain the full vertical movement count, add
104 the byte 3 and 5.
105 .It Byte 6
106 The bit 7 is always zero. The lower 7 bits encode the first half of 
107 Z axis movement count in two's complement; -64 through 63.
108 .It Byte 7
109 The bit 7 is always zero. The lower 7 bits encode the second half of 
110 the Z axis movement count in two's complement; -64 through 63.
111 To obtain the full Z axis movement count, add the byte 6 and 7.
112 .It Byte 8
113 The bit 7 is always zero. The bits 0 through 6 reflect the state
114 of the buttons 4 through 10.
115 If a button is pressed, the corresponding bit is cleared. Otherwise
116 the bit is set.
117 .El
118 .Pp
119 The first 5 bytes of this format is compatible with the MouseSystems
120 format. The additional 3 bytes have their MSBs always set to zero. 
121 Thus, if the user program can interpret the MouseSystems data format and
122 tries to find the first byte of the format by detecting the bit pattern
123 10000xxxb, 
124 it will discard the additional bytes, thus, be able to decode x, y 
125 and states of 3 buttons correctly.
126 .Pp
127 Device drivers may offer operation levels higher than one.
128 Refer to manual pages of individual drivers for details.
129 .Sh IOCTLS
130 The following
131 .Xr ioctl 2
132 commands are defined for the mouse drivers. The degree of support
133 varies from one driver to another. This section gives general 
134 description of the commands.
135 Refer to manual pages of individual drivers for specific details.
136 .Pp
137 .Bl -tag -width MOUSE -compact
138 .It Dv MOUSE_GETLEVEL Ar int *level
139 .It Dv MOUSE_SETLEVEL Ar int *level
140 These commands manipulate the operation level of the mouse driver.
141 .Pp
142 .It Dv MOUSE_GETHWINFO Ar mousehw_t *hw
143 Returns the hardware information of the attached device in the following 
144 Except for the
145 .Dv iftype
146 field, the device driver may not always fill the structure with correct
147 values.
148 Consult manual pages of individual drivers for details of support.
149 .Bd -literal
150 typedef struct mousehw {
151     int buttons;    /* number of buttons */
152     int iftype;     /* I/F type */
153     int type;       /* mouse/track ball/pad... */
154     int model;      /* I/F dependent model ID */
155     int hwid;       /* I/F dependent hardware ID */
156 } mousehw_t;
157 .Ed
158 .Pp
159 The
160 .Dv buttons
161 field holds the number of buttons detected by the driver. The driver
162 may put an arbitrary value, such as two, in this field, if it cannot
163 determine the exact number.
164 .Pp
165 The
166 .Dv iftype
167 is the type of interface:
168 .Dv MOUSE_IF_SERIAL ,
169 .Dv MOUSE_IF_BUS ,
170 .Dv MOUSE_IF_INPORT ,
171 .Dv MOUSE_IF_PS2 ,
172 .Dv MOUSE_IF_SYSMOUSE
173 or
174 .Dv MOUSE_IF_UNKNOWN .
175 .Pp
176 The
177 .Dv type
178 tells the device type:
179 .Dv MOUSE_MOUSE ,
180 .Dv MOUSE_TRACKBALL ,
181 .Dv MOUSE_STICK ,
182 .Dv MOUSE_PAD ,
183 or
184 .Dv MOUSE_UNKNOWN .
185 .Pp
186 The
187 .Dv model
188 may be 
189 .Dv MOUSE_MODEL_GENERIC
190 or one of 
191 .Dv MOUSE_MODEL_XXX
192 constants.
193 .Pp
194 The
195 .Dv hwid
196 is the ID value returned by the pointing device. It
197 depend on the interface type; refer to the manual page of 
198 specific mouse drivers for possible values.
199 .Pp
200 .It Dv MOUSE_GETMODE Ar mousemode_t *mode
201 The command reports the current operation parameters of the mouse driver.
202 .Bd -literal
203 typedef struct mousemode {
204     int protocol;    /* MOUSE_PROTO_XXX */
205     int rate;        /* report rate (per sec) */
206     int resolution;  /* MOUSE_RES_XXX, -1 if unknown */
207     int accelfactor; /* acceleration factor */
208     int level;       /* driver operation level */
209     int packetsize;  /* the length of the data packet */
210     unsigned char syncmask[2]; /* sync. bits */
211 } mousemode_t;
212 .Ed
213 .Pp
214 The
215 .Dv protocol
216 field tells the format in which the device status is returned 
217 when the mouse data is read by the user program.
218 It is one of 
219 .Dv MOUSE_PROTO_XXX
220 constants.
221 .Pp
222 The
223 .Dv rate
224 field is the status report rate (reports/sec) at which the device will send 
225 movement reports to the host computer. -1 if unknown or not applicable.
226 .Pp
227 The
228 .Dv resolution
229 field holds a value specifying resolution of the pointing device.
230 It is a positive value or one of 
231 .Dv MOUSE_RES_XXX
232 constants.
233 .Pp
234 The
235 .Dv accelfactor
236 field holds a value to control acceleration feature.
237 It must be zero or greater.
238 If it is zero, acceleration is disabled.
239 .Pp
240 The
241 .Dv packetsize
242 field tells the length of the fixed-size data packet or the length
243 of the fixed part of the variable-length packet.
244 The size depends on the interface type, the device type and model, the
245 protocol and the operation level of the driver.
246 .Pp
247 The array
248 .Dv syncmask
249 holds a bit mask and pattern to detect the first byte of the
250 data packet.
251 .Dv syncmask[0]
252 is the bit mask to be ANDed with a byte. If the result is equal to
253 .Dv syncmask[1] ,
254 the byte is likely to be the first byte of the data packet.
255 Note that this method of detecting the first byte is not 100% reliable,
256 thus, should be taken only as an advisory measure.
257 .Pp
258 .It Dv MOUSE_SETMODE Ar mousemode_t *mode
259 The command changes the current operation parameters of the mouse driver
260 as specified in
261 .Ar mode .
262 Only
263 .Dv rate ,
264 .Dv resolution ,
265 .Dv level 
266 and 
267 .Dv accelfactor
268 may be modifiable. Setting values in the other field does not generate
269 error and has no effect.
270 .Pp
271 If you do not want to change the current setting of a field, put -1
272 there.
273 You may also put zero in 
274 .Dv resolution
275 and
276 .Dv rate ,
277 and the default value for the fields will be selected.
278 .\" .Pp
279 .\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
280 .\" Get internal variables of the mouse driver. 
281 .\" The variables which can be manipulated through these commands
282 .\" are specific to each driver. 
283 .\" This command may not be supported by all drivers.
284 .\" .Bd -literal
285 .\" typedef struct mousevar {
286 .\"     int var[16];    /* internal variables */
287 .\" } mousevar_t;
288 .\" .Ed
289 .\" .Pp
290 .\" If the commands are supported, the first element of the array is
291 .\" filled with a signature value. 
292 .\" Apart from the signature data, there is currently no standard concerning 
293 .\" the other elements of the buffer.
294 .\" .Pp
295 .\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
296 .\" Get internal variables of the mouse driver. 
297 .\" The first element of the array must be a signature value.
298 .\" This command may not be supported by all drivers.
299 .Pp
300 .It Dv MOUSE_READDATA Ar mousedata_t *data
301 The command reads the raw data from the device.
302 .Bd -literal
303 typedef struct mousedata {
304     int len;        /* # of data in the buffer */
305     int buf[16];    /* data buffer */
306 } mousedata_t;
307 .Ed
308 .Pp
309 The calling process must fill the
310 .Dv len
311 field with the number of bytes to be read into the buffer.
312 This command may not be supported by all drivers.
313 .Pp
314 .It Dv MOUSE_READSTATE Ar mousedata_t *state
315 The command reads the raw state data from the device.
316 It uses the same structure as above.
317 This command may not be supported by all drivers.
318 .Pp
319 .It Dv MOUSE_GETSTATE Ar mousestatus_t *status
320 The command returns the current state of buttons and 
321 movement counts in the following structure.
322 .Bd -literal
323 typedef struct mousestatus {
324     int flags;      /* state change flags */
325     int button;     /* button status */
326     int obutton;    /* previous button status */
327     int dx;         /* x movement */
328     int dy;         /* y movement */
329     int dz;         /* z movement */
330 } mousestatus_t;
331 .Ed
332 .Pp
333 The
334 .Dv button
335 and
336 .Dv obutton
337 fields hold the current and the previous state of the mouse buttons.
338 When a button is pressed, the corresponding bit is set.
339 The mouse drivers may support up to 31 buttons with the bit 0 through 31.
340 Few button bits are defined as 
341 .Dv MOUSE_BUTTON1DOWN
342 through 
343 .Dv MOUSE_BUTTON8DOWN .
344 The first three buttons correspond to left, middle and right buttons.
345 .Pp
346 If the state of the button has changed since the last 
347 .Dv MOUSE_GETSTATE
348 call, the corresponding bit in the
349 .Dv flags
350 field will be set. 
351 If the mouse has moved since the last call, the
352 .Dv MOUSE_POSCHANGED
353 bit in the
354 .Dv flags
355 field will also be set.
356 .Pp
357 The other fields hold movement counts since the last 
358 .Dv MOUSE_GETSTATE
359 call. The internal counters will be reset after every call to this
360 command.
361 .El
362 .Sh FILES
363 .Bl -tag -width /dev/sysmouseXX -compact
364 .It Pa /dev/cuaa%d
365 serial ports
366 .It Pa /dev/mse%d
367 bus and InPort mouse device
368 .It Pa /dev/psm%d
369 PS/2 mouse device
370 .It Pa /dev/sysmouse
371 virtual mouse device
372 .El
373 .Sh SEE ALSO
374 .Xr ioctl 2 ,
375 .Xr mse 4 ,
376 .Xr psm 4 ,
377 .Xr sysmouse 4 ,
378 .Xr moused 8
379 .\".Sh HISTORY
380 .Sh AUTHORS
381 This manual page was written by
382 .An Kazutaka Yokota Aq yokota@FreeBSD.org .