3 .\" Kazutaka YOKOTA <yokota@zodiac.mech.utsunomiya-u.ac.jp>
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
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.
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.
27 .\" $FreeBSD: src/share/man/man4/mouse.4,v 1.8.2.3 2001/12/17 11:30:12 ru Exp $
34 .Nd mouse and pointing device drivers
44 provide user programs with movement and button state information of the mouse.
45 Currently there are specific device drivers for bus, InPort, PS/2, and USB mice.
46 The serial mouse is not directly supported by a dedicated driver, but
47 it is accessible via the serial device driver or via
52 The user program simply opens a mouse device with a
55 mouse data from the device via
57 Movement and button states are usually encoded in fixed-length data packets.
58 Some mouse devices may send data in variable length of packets.
59 Actual protocol (data format) used by each driver differs widely.
61 The mouse drivers may have ``non-blocking'' attribute which will make
62 the driver return immediately if mouse data is not available.
64 Mouse device drivers often offer several levels of operation.
65 The current operation level can be examined and changed via
68 The level zero is the lowest level at which the driver offers the basic
69 service to user programs.
70 Most drivers provide horizontal and vertical movement of the mouse
71 and state of up to three buttons at this level.
72 At the level one, if supported by the driver, mouse data is encoded
73 in the standard format
74 .Dv MOUSE_PROTO_SYSMOUSE
77 .Bl -tag -width Byte_1 -compact
79 .Bl -tag -width bit_7 -compact
85 Left button status; cleared if pressed, otherwise set.
87 Middle button status; cleared if pressed, otherwise set.
89 if the device does not have the middle button.
91 Right button status; cleared if pressed, otherwise set.
94 The first half of horizontal movement count in two's complement;
97 The first half of vertical movement count in two's complement;
100 The second half of the horizontal movement count in two's complement;
101 -128 through 127. To obtain the full horizontal movement count, add
104 The second half of the vertical movement count in two's complement;
105 -128 through 127. To obtain the full vertical movement count, add
108 The bit 7 is always zero.
109 The lower 7 bits encode the first half of
110 Z axis movement count in two's complement; -64 through 63.
112 The bit 7 is always zero.
113 The lower 7 bits encode the second half of
114 the Z axis movement count in two's complement; -64 through 63.
115 To obtain the full Z axis movement count, add the byte 6 and 7.
117 The bit 7 is always zero.
118 The bits 0 through 6 reflect the state
119 of the buttons 4 through 10.
120 If a button is pressed, the corresponding bit is cleared.
125 The first 5 bytes of this format is compatible with the MouseSystems
127 The additional 3 bytes have their MSBs always set to zero.
128 Thus, if the user program can interpret the MouseSystems data format and
129 tries to find the first byte of the format by detecting the bit pattern
131 it will discard the additional bytes, thus, be able to decode x, y
132 and states of 3 buttons correctly.
134 Device drivers may offer operation levels higher than one.
135 Refer to manual pages of individual drivers for details.
139 commands are defined for the mouse drivers.
140 The degree of support
141 varies from one driver to another.
142 This section gives general
143 description of the commands.
144 Refer to manual pages of individual drivers for specific details.
146 .Bl -tag -width MOUSE -compact
147 .It Dv MOUSE_GETLEVEL Ar int *level
148 .It Dv MOUSE_SETLEVEL Ar int *level
149 These commands manipulate the operation level of the mouse driver.
151 .It Dv MOUSE_GETHWINFO Ar mousehw_t *hw
152 Returns the hardware information of the attached device in the following
155 field, the device driver may not always fill the structure with correct
157 Consult manual pages of individual drivers for details of support.
159 typedef struct mousehw {
160 int buttons; /* number of buttons */
161 int iftype; /* I/F type */
162 int type; /* mouse/track ball/pad... */
163 int model; /* I/F dependent model ID */
164 int hwid; /* I/F dependent hardware ID */
170 field holds the number of buttons detected by the driver.
172 may put an arbitrary value, such as two, in this field, if it cannot
173 determine the exact number.
177 is the type of interface:
178 .Dv MOUSE_IF_SERIAL ,
180 .Dv MOUSE_IF_INPORT ,
183 .Dv MOUSE_IF_SYSMOUSE
185 .Dv MOUSE_IF_UNKNOWN .
189 tells the device type:
191 .Dv MOUSE_TRACKBALL ,
200 .Dv MOUSE_MODEL_GENERIC
207 is the ID value returned by the pointing device.
209 depend on the interface type; refer to the manual page of
210 specific mouse drivers for possible values.
212 .It Dv MOUSE_GETMODE Ar mousemode_t *mode
213 The command reports the current operation parameters of the mouse driver.
215 typedef struct mousemode {
216 int protocol; /* MOUSE_PROTO_XXX */
217 int rate; /* report rate (per sec) */
218 int resolution; /* MOUSE_RES_XXX, -1 if unknown */
219 int accelfactor; /* acceleration factor */
220 int level; /* driver operation level */
221 int packetsize; /* the length of the data packet */
222 unsigned char syncmask[2]; /* sync. bits */
228 field tells the format in which the device status is returned
229 when the mouse data is read by the user program.
236 field is the status report rate (reports/sec) at which the device will send
237 movement reports to the host computer. -1 if unknown or not applicable.
241 field holds a value specifying resolution of the pointing device.
242 It is a positive value or one of
248 field holds a value to control acceleration feature.
249 It must be zero or greater.
250 If it is zero, acceleration is disabled.
254 field tells the length of the fixed-size data packet or the length
255 of the fixed part of the variable-length packet.
256 The size depends on the interface type, the device type and model, the
257 protocol and the operation level of the driver.
261 holds a bit mask and pattern to detect the first byte of the
264 is the bit mask to be ANDed with a byte.
265 If the result is equal to
267 the byte is likely to be the first byte of the data packet.
268 Note that this method of detecting the first byte is not 100% reliable,
269 thus, should be taken only as an advisory measure.
271 .It Dv MOUSE_SETMODE Ar mousemode_t *mode
272 The command changes the current operation parameters of the mouse driver
282 Setting values in the other field does not generate
283 error and has no effect.
285 If you do not want to change the current setting of a field, put -1
287 You may also put zero in
291 and the default value for the fields will be selected.
293 .\" .It Dv MOUSE_GETVARS Ar mousevar_t *vars
294 .\" Get internal variables of the mouse driver.
295 .\" The variables which can be manipulated through these commands
296 .\" are specific to each driver.
297 .\" This command may not be supported by all drivers.
299 .\" typedef struct mousevar {
300 .\" int var[16]; /* internal variables */
304 .\" If the commands are supported, the first element of the array is
305 .\" filled with a signature value.
306 .\" Apart from the signature data, there is currently no standard concerning
307 .\" the other elements of the buffer.
309 .\" .It Dv MOUSE_SETVARS Ar mousevar_t *vars
310 .\" Get internal variables of the mouse driver.
311 .\" The first element of the array must be a signature value.
312 .\" This command may not be supported by all drivers.
314 .It Dv MOUSE_READDATA Ar mousedata_t *data
315 The command reads the raw data from the device.
317 typedef struct mousedata {
318 int len; /* # of data in the buffer */
319 int buf[16]; /* data buffer */
323 The calling process must fill the
325 field with the number of bytes to be read into the buffer.
326 This command may not be supported by all drivers.
328 .It Dv MOUSE_READSTATE Ar mousedata_t *state
329 The command reads the raw state data from the device.
330 It uses the same structure as above.
331 This command may not be supported by all drivers.
333 .It Dv MOUSE_GETSTATUS Ar mousestatus_t *status
334 The command returns the current state of buttons and
335 movement counts in the following structure.
337 typedef struct mousestatus {
338 int flags; /* state change flags */
339 int button; /* button status */
340 int obutton; /* previous button status */
341 int dx; /* x movement */
342 int dy; /* y movement */
343 int dz; /* z movement */
351 fields hold the current and the previous state of the mouse buttons.
352 When a button is pressed, the corresponding bit is set.
353 The mouse drivers may support up to 31 buttons with the bit 0 through 31.
354 Few button bits are defined as
355 .Dv MOUSE_BUTTON1DOWN
357 .Dv MOUSE_BUTTON8DOWN .
358 The first three buttons correspond to left, middle and right buttons.
360 If the state of the button has changed since the last
362 call, the corresponding bit in the
365 If the mouse has moved since the last call, the
369 field will also be set.
371 The other fields hold movement counts since the last
374 The internal counters will be reset after every call to this
378 .Bl -tag -width /dev/sysmouseXX -compact
382 bus and InPort mouse device
399 This manual page was written by
400 .An Kazutaka Yokota Aq yokota@FreeBSD.org .