]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - share/man/man4/sysmouse.4
Merge r344481:
[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 .Pp
59 .Ss Operation Levels
60 The
61 .Nm
62 driver has two levels of operation.
63 The current operation level can be referred to and changed via ioctl calls.
64 .Pp
65 The level zero, the basic level, is the lowest level at which the driver
66 offers the basic service to user programs.
67 The
68 .Nm
69 driver
70 provides horizontal and vertical movement of the mouse
71 and state of up to three buttons in the
72 .Tn MouseSystems
73 format as follows.
74 .Pp
75 .Bl -tag -width Byte_1 -compact
76 .It Byte 1
77 .Bl -tag -width bit_7 -compact
78 .It bit 7
79 Always one.
80 .It bit 6..3
81 Always zero.
82 .It bit 2
83 Left button status; cleared if pressed, otherwise set.
84 .It bit 1
85 Middle button status; cleared if pressed, otherwise set.
86 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.
100 To obtain the full horizontal movement count, add
101 the byte 2 and 4.
102 .It Byte 5
103 The second half of the vertical movement count in two's complement;
104 \-128 through 127.
105 To obtain the full vertical movement count, add
106 the byte 3 and 5.
107 .El
108 .Pp
109 At the level one, the extended level, mouse data is encoded
110 in the standard format
111 .Dv MOUSE_PROTO_SYSMOUSE
112 as defined in
113 .Xr mouse 4 .
114 .\" .Ss Acceleration
115 .\" The
116 .\" .Nm
117 .\" driver can somewhat `accelerate' the movement of the pointing device.
118 .\" The faster you move the device, the further the pointer
119 .\" travels on the screen.
120 .\" The driver has an internal variable which governs the effect of
121 .\" the acceleration. Its value can be modified via the driver flag
122 .\" or via an ioctl call.
123 .Sh IOCTLS
124 This section describes two classes of
125 .Xr ioctl 2
126 commands:
127 commands for the
128 .Nm
129 driver itself, and commands for the console and the console control drivers.
130 .Ss Sysmouse Ioctls
131 There are a few commands for mouse drivers.
132 General description of the commands is given in
133 .Xr mouse 4 .
134 Following are the features specific to the
135 .Nm
136 driver.
137 .Pp
138 .Bl -tag -width MOUSE -compact
139 .It Dv MOUSE_GETLEVEL Ar int *level
140 .It Dv MOUSE_SETLEVEL Ar int *level
141 These commands manipulate the operation level of the mouse driver.
142 .Pp
143 .It Dv MOUSE_GETHWINFO Ar mousehw_t *hw
144 Returns the hardware information of the attached device in the following
145 structure.
146 Only the
147 .Va iftype
148 field is guaranteed to be filled with the correct value in the current
149 version of the
150 .Nm
151 driver.
152 .Bd -literal
153 typedef struct mousehw {
154     int buttons;    /* number of buttons */
155     int iftype;     /* I/F type */
156     int type;       /* mouse/track ball/pad... */
157     int model;      /* I/F dependent model ID */
158     int hwid;       /* I/F dependent hardware ID */
159 } mousehw_t;
160 .Ed
161 .Pp
162 The
163 .Va buttons
164 field holds the number of buttons detected by the driver.
165 .Pp
166 The
167 .Va iftype
168 is always
169 .Dv MOUSE_IF_SYSMOUSE .
170 .Pp
171 The
172 .Va type
173 tells the device type:
174 .Dv MOUSE_MOUSE ,
175 .Dv MOUSE_TRACKBALL ,
176 .Dv MOUSE_STICK ,
177 .Dv MOUSE_PAD ,
178 or
179 .Dv MOUSE_UNKNOWN .
180 .Pp
181 The
182 .Va model
183 is always
184 .Dv MOUSE_MODEL_GENERIC
185 at the operation level 0.
186 It may be
187 .Dv MOUSE_MODEL_GENERIC
188 or one of
189 .Dv MOUSE_MODEL_XXX
190 constants at higher operation levels.
191 .Pp
192 The
193 .Va hwid
194 is always zero.
195 .Pp
196 .It Dv MOUSE_GETMODE Ar mousemode_t *mode
197 The command gets the current operation parameters of the mouse
198 driver.
199 .Bd -literal
200 typedef struct mousemode {
201     int protocol;    /* MOUSE_PROTO_XXX */
202     int rate;        /* report rate (per sec) */
203     int resolution;  /* MOUSE_RES_XXX, -1 if unknown */
204     int accelfactor; /* acceleration factor */
205     int level;       /* driver operation level */
206     int packetsize;  /* the length of the data packet */
207     unsigned char syncmask[2]; /* sync. bits */
208 } mousemode_t;
209 .Ed
210 .Pp
211 The
212 .Va protocol
213 field tells the format in which the device status is returned
214 when the mouse data is read by the user program.
215 It is
216 .Dv MOUSE_PROTO_MSC
217 at the operation level zero.
218 .Dv MOUSE_PROTO_SYSMOUSE
219 at the operation level one.
220 .Pp
221 The
222 .Va rate
223 is always set to \-1.
224 .Pp
225 The
226 .Va resolution
227 is always set to \-1.
228 .Pp
229 The
230 .Va accelfactor
231 is always 0.
232 .Pp
233 The
234 .Va packetsize
235 field specifies the length of the data packet.
236 It depends on the
237 operation level.
238 .Pp
239 .Bl -tag -width level_0__ -compact
240 .It Em level 0
241 5 bytes
242 .It Em level 1
243 8 bytes
244 .El
245 .Pp
246 The array
247 .Va syncmask
248 holds a bit mask and pattern to detect the first byte of the
249 data packet.
250 .Va syncmask[0]
251 is the bit mask to be ANDed with a byte.
252 If the result is equal to
253 .Va 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, it 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 .Va level
264 may be modifiable.
265 Setting values in the other field does not generate
266 error and has no effect.
267 .Pp
268 .It Dv MOUSE_READDATA Ar mousedata_t *data
269 .It Dv MOUSE_READSTATE Ar mousedata_t *state
270 These commands are not supported by the
271 .Nm
272 driver.
273 .Pp
274 .It Dv MOUSE_GETSTATUS Ar mousestatus_t *status
275 The command returns the current state of buttons and
276 movement counts in the structure as defined in
277 .Xr mouse 4 .
278 .El
279 .Ss Console and Consolectl Ioctls
280 The user process issues console
281 .Fn ioctl
282 calls to the current virtual console in order to control
283 the mouse pointer.
284 The console
285 .Fn ioctl
286 also provides a method for the user process to receive a
287 .Xr signal 3
288 when a button is pressed.
289 .Pp
290 The mouse daemon
291 .Xr moused 8
292 uses
293 .Fn ioctl
294 calls to the console control device
295 .Pa /dev/consolectl
296 to inform the console of mouse actions including mouse movement
297 and button status.
298 .Pp
299 Both classes of
300 .Fn ioctl
301 commands are defined as
302 .Dv CONS_MOUSECTL
303 which takes the following argument.
304 .Bd -literal
305 struct mouse_info {
306     int operation;
307     union {
308         struct mouse_data data;
309         struct mouse_mode mode;
310         struct mouse_event event;
311     } u;
312 };
313 .Ed
314 .Pp
315 .Bl -tag -width operation -compact
316 .It Va operation
317 This can be one of
318 .Pp
319 .Bl -tag -width MOUSE_MOVEABS -compact
320 .It Dv MOUSE_SHOW
321 Enables and displays mouse cursor.
322 .It Dv MOUSE_HIDE
323 Disables and hides mouse cursor.
324 .It Dv MOUSE_MOVEABS
325 Moves mouse cursor to position supplied in
326 .Va u.data .
327 .It Dv MOUSE_MOVEREL
328 Adds position supplied in
329 .Va u.data
330 to current position.
331 .It Dv MOUSE_GETINFO
332 Returns current mouse position in the current virtual console
333 and button status in
334 .Va u.data .
335 .It Dv MOUSE_MODE
336 This sets the
337 .Xr signal 3
338 to be delivered to the current process when a button is pressed.
339 The signal to be delivered is set in
340 .Va u.mode .
341 .El
342 .Pp
343 The above operations are for virtual consoles.
344 The operations defined
345 below are for the console control device and are used by
346 .Xr moused 8
347 to pass mouse data to the console driver.
348 .Pp
349 .Bl -tag -width MOUSE_MOVEABS -compact
350 .It Dv MOUSE_ACTION
351 .It Dv MOUSE_MOTION_EVENT
352 These operations take the information in
353 .Va u.data
354 and act upon it.
355 Mouse data will be sent to the
356 .Nm
357 driver if it is open.
358 .Dv MOUSE_ACTION
359 also processes button press actions and sends signal to the process if
360 requested or performs cut and paste operations
361 if the current console is a text interface.
362 .It Dv MOUSE_BUTTON_EVENT
363 .Va u.data
364 specifies a button and its click count.
365 The console driver will
366 use this information for signal delivery if requested or
367 for cut and paste operations if the console is in text mode.
368 .El
369 .Pp
370 .Dv MOUSE_MOTION_EVENT
371 and
372 .Dv MOUSE_BUTTON_EVENT
373 are newer interface and are designed to be used together.
374 They are intended to replace functions performed by
375 .Dv MOUSE_ACTION
376 alone.
377 .Pp
378 .It Va u
379 This union is one of
380 .Pp
381 .Bl -tag -width data -compact
382 .It Va data
383 .Bd -literal
384 struct mouse_data {
385     int x;
386     int y;
387     int z;
388     int buttons;
389 };
390 .Ed
391 .Pp
392 .Va x , y
393 and
394 .Va z
395 represent movement of the mouse along respective directions.
396 .Va buttons
397 tells the state of buttons.
398 It encodes up to 31 buttons in the bit 0 though
399 the bit 30.
400 If a button is held down, the corresponding bit is set.
401 .Pp
402 .It Va mode
403 .Bd -literal
404 struct mouse_mode {
405     int mode;
406     int signal;
407 };
408 .Ed
409 .Pp
410 The
411 .Va signal
412 field specifies the signal to be delivered to the process.
413 It must be
414 one of the values defined in
415 .In signal.h .
416 The
417 .Va mode
418 field is currently unused.
419 .Pp
420 .It Va event
421 .Bd -literal
422 struct mouse_event {
423     int id;
424     int value;
425 };
426 .Ed
427 .Pp
428 The
429 .Va id
430 field specifies a button number as in
431 .Va u.data.buttons .
432 Only one bit/button is set.
433 The
434 .Va value
435 field
436 holds the click count: the number of times the user has clicked the button
437 successively.
438 .El
439 .El
440 .Sh FILES
441 .Bl -tag -width /dev/consolectl -compact
442 .It Pa /dev/consolectl
443 device to control the console
444 .It Pa /dev/sysmouse
445 virtualized mouse driver
446 .It Pa /dev/ttyv%d
447 virtual consoles
448 .El
449 .Sh SEE ALSO
450 .Xr vidcontrol 1 ,
451 .Xr ioctl 2 ,
452 .Xr signal 3 ,
453 .Xr mouse 4 ,
454 .Xr moused 8
455 .Sh HISTORY
456 The
457 .Nm
458 driver first appeared in
459 .Fx 2.2 .
460 .Sh AUTHORS
461 .An -nosplit
462 This
463 manual page was written by
464 .An John-Mark Gurney Aq Mt jmg@FreeBSD.org
465 and
466 .An Kazutaka Yokota Aq Mt yokota@FreeBSD.org .