]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/sysmouse.4
sys/{x86,amd64}: remove one of doubled ;s
[FreeBSD/FreeBSD.git] / share / man / man4 / sysmouse.4
1 .\" Copyright 1997 John-Mark Gurney.  All rights reserved.
2 .\"
3 .\" Redistribution and use in source and binary forms, with or without
4 .\" modification, are permitted provided that the following conditions
5 .\" are met:
6 .\" 1. Redistributions of source code must retain the above copyright
7 .\"    notice, this list of conditions and the following disclaimer.
8 .\" 2. Redistributions in binary form must reproduce the above copyright
9 .\"    notice, this list of conditions and the following disclaimer in the
10 .\"    documentation and/or other materials provided with the distribution.
11 .\"
12 .\" THIS SOFTWARE IS PROVIDED BY John-Mark Gurney AND CONTRIBUTORS ``AS IS'' AND
13 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
14 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
15 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
16 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
17 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
18 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
20 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
21 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
22 .\" SUCH DAMAGE.
23 .\"
24 .\" $FreeBSD$
25 .\"
26 .Dd March 25, 2014
27 .Dt SYSMOUSE 4
28 .Os
29 .Sh NAME
30 .Nm sysmouse
31 .\" .Nd supplies mouse data from syscons for other applications
32 .Nd virtualized mouse driver
33 .Sh SYNOPSIS
34 .In sys/mouse.h
35 .In sys/consio.h
36 .Sh DESCRIPTION
37 The console driver, in conjunction with the mouse daemon
38 .Xr moused 8 ,
39 supplies mouse data to the user process in the standardized way via the
40 .Nm
41 driver.
42 This arrangement makes it possible for the console and the user process
43 (such as the
44 .Tn X\ Window System )
45 to share the mouse.
46 .Pp
47 The user process which wants to utilize mouse operation simply opens
48 .Pa /dev/sysmouse
49 with a
50 .Xr open 2
51 call and reads
52 mouse data from the device via
53 .Xr read 2 .
54 Make sure that
55 .Xr moused 8
56 is running, otherwise the user process will not see any data coming from
57 the mouse.
58 .Ss Operation Levels
59 The
60 .Nm
61 driver has two levels of operation.
62 The current operation level can be referred to and changed via ioctl calls.
63 .Pp
64 The level zero, the basic level, is the lowest level at which the driver
65 offers the basic service to user programs.
66 The
67 .Nm
68 driver
69 provides horizontal and vertical movement of the mouse
70 and state of up to three buttons in the
71 .Tn MouseSystems
72 format as follows.
73 .Pp
74 .Bl -tag -width Byte_1 -compact
75 .It Byte 1
76 .Bl -tag -width bit_7 -compact
77 .It bit 7
78 Always one.
79 .It bit 6..3
80 Always zero.
81 .It bit 2
82 Left button status; cleared if pressed, otherwise set.
83 .It bit 1
84 Middle button status; cleared if pressed, otherwise set.
85 Always one,
86 if the device does not have the middle button.
87 .It bit 0
88 Right button status; cleared if pressed, otherwise set.
89 .El
90 .It Byte 2
91 The first half of horizontal movement count in two's complement;
92 \-128 through 127.
93 .It Byte 3
94 The first half of vertical movement count in two's complement;
95 \-128 through 127.
96 .It Byte 4
97 The second half of the horizontal movement count in two's complement;
98 \-128 through 127.
99 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.
104 To obtain the full vertical movement count, add
105 the byte 3 and 5.
106 .El
107 .Pp
108 At the level one, the extended level, mouse data is encoded
109 in the standard format
110 .Dv MOUSE_PROTO_SYSMOUSE
111 as defined in
112 .Xr mouse 4 .
113 .\" .Ss Acceleration
114 .\" The
115 .\" .Nm
116 .\" driver can somewhat `accelerate' the movement of the pointing device.
117 .\" The faster you move the device, the further the pointer
118 .\" travels on the screen.
119 .\" The driver has an internal variable which governs the effect of
120 .\" the acceleration. Its value can be modified via the driver flag
121 .\" or via an ioctl call.
122 .Sh IOCTLS
123 This section describes two classes of
124 .Xr ioctl 2
125 commands:
126 commands for the
127 .Nm
128 driver itself, and commands for the console and the console control drivers.
129 .Ss Sysmouse Ioctls
130 There are a few commands for mouse drivers.
131 General description of the commands is given in
132 .Xr mouse 4 .
133 Following are the features specific to the
134 .Nm
135 driver.
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 structure.
145 Only the
146 .Va iftype
147 field is guaranteed to be filled with the correct value in the current
148 version of the
149 .Nm
150 driver.
151 .Bd -literal
152 typedef struct mousehw {
153     int buttons;    /* number of buttons */
154     int iftype;     /* I/F type */
155     int type;       /* mouse/track ball/pad... */
156     int model;      /* I/F dependent model ID */
157     int hwid;       /* I/F dependent hardware ID */
158 } mousehw_t;
159 .Ed
160 .Pp
161 The
162 .Va buttons
163 field holds the number of buttons detected by the driver.
164 .Pp
165 The
166 .Va iftype
167 is always
168 .Dv MOUSE_IF_SYSMOUSE .
169 .Pp
170 The
171 .Va type
172 tells the device type:
173 .Dv MOUSE_MOUSE ,
174 .Dv MOUSE_TRACKBALL ,
175 .Dv MOUSE_STICK ,
176 .Dv MOUSE_PAD ,
177 or
178 .Dv MOUSE_UNKNOWN .
179 .Pp
180 The
181 .Va model
182 is always
183 .Dv MOUSE_MODEL_GENERIC
184 at the operation level 0.
185 It may be
186 .Dv MOUSE_MODEL_GENERIC
187 or one of
188 .Dv MOUSE_MODEL_XXX
189 constants at higher operation levels.
190 .Pp
191 The
192 .Va hwid
193 is always zero.
194 .Pp
195 .It Dv MOUSE_GETMODE Ar mousemode_t *mode
196 The command gets the current operation parameters of the mouse
197 driver.
198 .Bd -literal
199 typedef struct mousemode {
200     int protocol;    /* MOUSE_PROTO_XXX */
201     int rate;        /* report rate (per sec) */
202     int resolution;  /* MOUSE_RES_XXX, -1 if unknown */
203     int accelfactor; /* acceleration factor */
204     int level;       /* driver operation level */
205     int packetsize;  /* the length of the data packet */
206     unsigned char syncmask[2]; /* sync. bits */
207 } mousemode_t;
208 .Ed
209 .Pp
210 The
211 .Va protocol
212 field tells the format in which the device status is returned
213 when the mouse data is read by the user program.
214 It is
215 .Dv MOUSE_PROTO_MSC
216 at the operation level zero.
217 .Dv MOUSE_PROTO_SYSMOUSE
218 at the operation level one.
219 .Pp
220 The
221 .Va rate
222 is always set to \-1.
223 .Pp
224 The
225 .Va resolution
226 is always set to \-1.
227 .Pp
228 The
229 .Va accelfactor
230 is always 0.
231 .Pp
232 The
233 .Va packetsize
234 field specifies the length of the data packet.
235 It depends on the
236 operation level.
237 .Pp
238 .Bl -tag -width level_0__ -compact
239 .It Em level 0
240 5 bytes
241 .It Em level 1
242 8 bytes
243 .El
244 .Pp
245 The array
246 .Va syncmask
247 holds a bit mask and pattern to detect the first byte of the
248 data packet.
249 .Va syncmask[0]
250 is the bit mask to be ANDed with a byte.
251 If the result is equal to
252 .Va syncmask[1] ,
253 the byte is likely to be the first byte of the data packet.
254 Note that this method of detecting the first byte is not 100% reliable;
255 thus, it should be taken only as an advisory measure.
256 .Pp
257 .It Dv MOUSE_SETMODE Ar mousemode_t *mode
258 The command changes the current operation parameters of the mouse driver
259 as specified in
260 .Ar mode .
261 Only
262 .Va level
263 may be modifiable.
264 Setting values in the other field does not generate
265 error and has no effect.
266 .Pp
267 .It Dv MOUSE_READDATA Ar mousedata_t *data
268 .It Dv MOUSE_READSTATE Ar mousedata_t *state
269 These commands are not supported by the
270 .Nm
271 driver.
272 .Pp
273 .It Dv MOUSE_GETSTATUS Ar mousestatus_t *status
274 The command returns the current state of buttons and
275 movement counts in the structure as defined in
276 .Xr mouse 4 .
277 .El
278 .Ss Console and Consolectl Ioctls
279 The user process issues console
280 .Fn ioctl
281 calls to the current virtual console in order to control
282 the mouse pointer.
283 The console
284 .Fn ioctl
285 also provides a method for the user process to receive a
286 .Xr signal 3
287 when a button is pressed.
288 .Pp
289 The mouse daemon
290 .Xr moused 8
291 uses
292 .Fn ioctl
293 calls to the console control device
294 .Pa /dev/consolectl
295 to inform the console of mouse actions including mouse movement
296 and button status.
297 .Pp
298 Both classes of
299 .Fn ioctl
300 commands are defined as
301 .Dv CONS_MOUSECTL
302 which takes the following argument.
303 .Bd -literal
304 struct mouse_info {
305     int operation;
306     union {
307         struct mouse_data data;
308         struct mouse_mode mode;
309         struct mouse_event event;
310     } u;
311 };
312 .Ed
313 .Pp
314 .Bl -tag -width operation -compact
315 .It Va operation
316 This can be one of
317 .Pp
318 .Bl -tag -width MOUSE_MOVEABS -compact
319 .It Dv MOUSE_SHOW
320 Enables and displays mouse cursor.
321 .It Dv MOUSE_HIDE
322 Disables and hides mouse cursor.
323 .It Dv MOUSE_MOVEABS
324 Moves mouse cursor to position supplied in
325 .Va u.data .
326 .It Dv MOUSE_MOVEREL
327 Adds position supplied in
328 .Va u.data
329 to current position.
330 .It Dv MOUSE_GETINFO
331 Returns current mouse position in the current virtual console
332 and button status in
333 .Va u.data .
334 .It Dv MOUSE_MODE
335 This sets the
336 .Xr signal 3
337 to be delivered to the current process when a button is pressed.
338 The signal to be delivered is set in
339 .Va u.mode .
340 .El
341 .Pp
342 The above operations are for virtual consoles.
343 The operations defined
344 below are for the console control device and are used by
345 .Xr moused 8
346 to pass mouse data to the console driver.
347 .Pp
348 .Bl -tag -width MOUSE_MOVEABS -compact
349 .It Dv MOUSE_ACTION
350 .It Dv MOUSE_MOTION_EVENT
351 These operations take the information in
352 .Va u.data
353 and act upon it.
354 Mouse data will be sent to the
355 .Nm
356 driver if it is open.
357 .Dv MOUSE_ACTION
358 also processes button press actions and sends signal to the process if
359 requested or performs cut and paste operations
360 if the current console is a text interface.
361 .It Dv MOUSE_BUTTON_EVENT
362 .Va u.data
363 specifies a button and its click count.
364 The console driver will
365 use this information for signal delivery if requested or
366 for cut and paste operations if the console is in text mode.
367 .El
368 .Pp
369 .Dv MOUSE_MOTION_EVENT
370 and
371 .Dv MOUSE_BUTTON_EVENT
372 are newer interface and are designed to be used together.
373 They are intended to replace functions performed by
374 .Dv MOUSE_ACTION
375 alone.
376 .Pp
377 .It Va u
378 This union is one of
379 .Pp
380 .Bl -tag -width data -compact
381 .It Va data
382 .Bd -literal
383 struct mouse_data {
384     int x;
385     int y;
386     int z;
387     int buttons;
388 };
389 .Ed
390 .Pp
391 .Va x , y
392 and
393 .Va z
394 represent movement of the mouse along respective directions.
395 .Va buttons
396 tells the state of buttons.
397 It encodes up to 31 buttons in the bit 0 though
398 the bit 30.
399 If a button is held down, the corresponding bit is set.
400 .Pp
401 .It Va mode
402 .Bd -literal
403 struct mouse_mode {
404     int mode;
405     int signal;
406 };
407 .Ed
408 .Pp
409 The
410 .Va signal
411 field specifies the signal to be delivered to the process.
412 It must be
413 one of the values defined in
414 .In signal.h .
415 The
416 .Va mode
417 field is currently unused.
418 .Pp
419 .It Va event
420 .Bd -literal
421 struct mouse_event {
422     int id;
423     int value;
424 };
425 .Ed
426 .Pp
427 The
428 .Va id
429 field specifies a button number as in
430 .Va u.data.buttons .
431 Only one bit/button is set.
432 The
433 .Va value
434 field
435 holds the click count: the number of times the user has clicked the button
436 successively.
437 .El
438 .El
439 .Sh FILES
440 .Bl -tag -width /dev/consolectl -compact
441 .It Pa /dev/consolectl
442 device to control the console
443 .It Pa /dev/sysmouse
444 virtualized mouse driver
445 .It Pa /dev/ttyv%d
446 virtual consoles
447 .El
448 .Sh SEE ALSO
449 .Xr vidcontrol 1 ,
450 .Xr ioctl 2 ,
451 .Xr signal 3 ,
452 .Xr mouse 4 ,
453 .Xr moused 8
454 .Sh HISTORY
455 The
456 .Nm
457 driver first appeared in
458 .Fx 2.2 .
459 .Sh AUTHORS
460 .An -nosplit
461 This
462 manual page was written by
463 .An John-Mark Gurney Aq Mt jmg@FreeBSD.org
464 and
465 .An Kazutaka Yokota Aq Mt yokota@FreeBSD.org .