xref: /freebsd/usr.sbin/moused/moused.8 (revision 23f282aa31e9b6fceacd449020e936e98d6f2298)
1.\" Copyright (c) 1996
2.\"	Mike Pritchard <mpp@FreeBSD.org>.  All rights reserved.
3.\"
4.\" Redistribution and use in source and binary forms, with or without
5.\" modification, are permitted provided that the following conditions
6.\" are met:
7.\" 1. Redistributions of source code must retain the above copyright
8.\"    notice, this list of conditions and the following disclaimer.
9.\" 2. Redistributions in binary form must reproduce the above copyright
10.\"    notice, this list of conditions and the following disclaimer in the
11.\"    documentation and/or other materials provided with the distribution.
12.\" 3. All advertising materials mentioning features or use of this software
13.\"    must display the following acknowledgement:
14.\"	This product includes software developed by Mike Pritchard.
15.\" 4. Neither the name of the author nor the names of its contributors
16.\"    may be used to endorse or promote products derived from this software
17.\"    without specific prior written permission.
18.\"
19.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
20.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
23.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29.\" SUCH DAMAGE.
30.\"
31.\" $FreeBSD$
32.\"
33.Dd April 1, 2000
34.Dt MOUSED 8
35.Os FreeBSD
36.Sh NAME
37.Nm moused
38.Nd pass mouse data to the console driver
39.Sh SYNOPSIS
40.Nm
41.Op Fl DPRcdfs
42.Op Fl I Ar file
43.Op Fl F Ar rate
44.Op Fl r Ar resolution
45.Op Fl S Ar baudrate
46.Op Fl C Ar threshold
47.Op Fl m Ar N=M
48.Op Fl w Ar N
49.Op Fl z Ar target
50.Op Fl t Ar mousetype
51.Op Fl 3 Op Fl E Ar timeout
52.Fl p Ar port
53.Pp
54.Nm
55.Op Fl Pd
56.Fl p Ar port
57.Fl i Ar info
58.Sh DESCRIPTION
59The mouse daemon
60.Nm
61and the console driver work together to support
62mouse operation in the text console and user programs.
63They virtualize the mouse and provide user programs with mouse data
64in the standard format
65.Pq see Xr sysmouse 4 .
66.Pp
67The mouse daemon listens to the specified port for mouse data,
68interprets and then passes it via ioctls to the console driver.
69The mouse daemon
70reports translation movement, button press/release
71events and movement of the roller or the wheel if available.
72The roller/wheel movement is reported as ``Z'' axis movement.
73.Pp
74The console driver will display the mouse pointer on the screen
75and provide cut and paste functions if the mouse pointer is enabled
76in the virtual console via
77.Xr vidcontrol 1 .
78If
79.Xr sysmouse 4
80is opened by the user program, the console driver also passes the mouse
81data to the device so that the user program will see it.
82.Pp
83If the mouse daemon receives the signal
84.Dv SIGHUP ,
85it will reopen the mouse port and reinitializes itself.
86Useful if
87the mouse is attached/detached while the system is suspended.
88.Pp
89The following options are available:
90.Bl -tag -width indent
91.It Fl 3
92Emulate the third (middle) button for 2-button mice.
93It is emulated
94by pressing the left and right physical buttons simultaneously.
95.It Fl C Ar threshold
96Set double click speed as the maximum interval in msec between button clicks.
97Without this option, the default value of 500 msec will be assumed.
98This option will have effect only on the cut and paste operations
99in the text mode console.
100The user program which is reading mouse data
101via
102.Xr sysmouse 4
103will not be affected.
104.It Fl D
105Lower DTR on the serial port.
106This option is valid only if
107.Ar mousesystems
108is selected as the protocol type.
109The DTR line may need to be dropped for a 3-button mouse
110to operate in the
111.Ar mousesystems
112mode.
113.It Fl E Ar timeout
114When the third button emulation is enabled
115.Pq see above ,
116the
117.Nm
118daemon waits
119.Ar timeout
120msec at most before deciding whether two buttons are being pressed
121simultaneously.
122The default timeout is 100 msec.
123.It Fl F Ar rate
124Set the report rate (reports/sec) of the device if supported.
125.It Fl I Ar file
126Write the process id of the
127.Nm
128daemon in the specified file.
129Without this option, the process id will be stored in
130.Pa /var/run/moused.pid .
131.It Fl P
132Do not start the Plug and Play COM device enumeration procedure
133when identifying the serial mouse.
134If this option is given together with the
135.Fl i
136option, the
137.Nm
138command will not be able to print useful information for the serial mouse.
139.It Fl R
140Lower RTS on the serial port.
141This option is valid only if
142.Ar mousesystems
143is selected as the protocol type by the
144.Fl t
145option below.
146It is often used with the
147.Fl D
148option above.
149Both RTS and DTR lines may need to be dropped for
150a 3-button mouse to operate in the
151.Ar mousesystems
152mode.
153.It Fl S Ar baudrate
154Select the baudrate for the serial port (1200 to 9600).
155Not all serial mice support this option.
156.It Fl c
157Some mice report middle button down events
158as if the left and right buttons are being pressed.
159This option handles this.
160.It Fl d
161Enable debugging messages.
162.It Fl f
163Do not become a daemon and instead run as a foreground process.
164Useful for testing and debugging.
165.It Fl i Ar info
166Print specified information and quit.  Available pieces of
167information are:
168.Pp
169.Bl -tag -compact -width modelxxx
170.It Ar port
171Port (device file) name, i.e.
172.Pa /dev/cuaa0 ,
173.Pa /dev/mse0
174and
175.Pa /dev/psm0 .
176.It Ar if
177Interface type: serial, bus, inport or ps/2.
178.It Ar type
179Protocol type.
180It is one of the types listed under the
181.Fl t
182option below or
183.Ar sysmouse
184if the driver supports the
185.Ar sysmouse
186data format standard.
187.It Ar model
188Mouse model.  The
189.Nm
190command may not always be able to identify the model.
191.It Ar all
192All of the above items.  Print port, interface, type and model in this order
193in one line.
194.El
195.Pp
196If the
197.Nm
198command cannot determine the requested information, it prints ``unknown''
199or ``generic''.
200.It Fl m Ar N=M
201Assign the physical button
202.Ar M
203to the logical button
204.Ar N.
205You may specify as many instances of this option as you like.
206More than one physical button may be assigned to a logical button at the
207same time.
208In this case the logical button will be down,
209if either of the assigned physical buttons is held down.
210Do not put space around `='.
211.It Fl p Ar port
212Use
213.Ar port
214to communicate with the mouse.
215.It Fl r Ar resolution
216Set the resolution of the device; in Dots Per Inch, or
217.Ar low ,
218.Ar medium-low ,
219.Ar medium-high
220or
221.Ar high .
222This option may not be supported by all the device.
223.It Fl s
224Select a baudrate of 9600 for the serial line.
225Not all serial mice support this option.
226.It Fl t Ar type
227Specify the protocol type of the mouse attached to the port.
228You may explicitly specify a type listed below, or use
229.Ar auto
230to let the
231.Nm
232command to automatically select an appropriate protocol for the given
233mouse.
234If you entirely ommit this options in the command line,
235.Fl t Ar auto
236is assumed.
237Under normal circumstances,
238you need to use this option only if the
239.Nm
240command is not able to detect the protocol automatically
241.Pq see the Sx Configuring Mouse Daemon .
242.Pp
243Note that if a protocol type is specified with this option, the
244.Fl P
245option above is implied and Plug and Play COM device enumeration
246procedure will be disabled.
247.Pp
248Also note that if your mouse is attached to the PS/2 mouse port, you should
249always choose
250.Ar auto
251or
252.Ar ps/2 ,
253regardless of the brand and model of the mouse.  Likewise, if your
254mouse is attached to the bus mouse port, choose
255.Ar auto
256or
257.Ar busmouse .
258Serial mouse protocols will not work with these mice.
259.Pp
260For the USB mouse, the protocol must be
261.Ar auto .
262No other protocol will work with the USB mouse.
263.Pp
264Valid types for this option are
265listed below.
266.Pp
267For the serial mouse:
268.Bl -tag -compact -width mousesystemsxxx
269.It Ar microsoft
270Microsoft serial mouse protocol.  Most 2-button serial mice use this protocol.
271.It Ar intellimouse
272Microsoft IntelliMouse protocol.  Genius NetMouse, ASCII Mie Mouse,
273Logitech MouseMan+ and FirstMouse+ use this protocol too.
274Other mice with a roller/wheel may be compatible with this protocol.
275.It Ar mousesystems
276MouseSystems 5-byte protocol.  3-button mice may use this protocol.
277.It Ar mmseries
278MM Series mouse protocol.
279.It Ar logitech
280Logitech mouse protocol.  Note that this is for old Logitech models.
281.Ar mouseman
282or
283.Ar intellimouse
284should be specified for newer models.
285.It Ar mouseman
286Logitech MouseMan and TrackMan protocol.  Some 3-button mice may be compatible
287with this protocol.  Note that MouseMan+ and FirstMouse+ use
288.Ar intellimouse
289protocol rather than this one.
290.It Ar glidepoint
291ALPS GlidePoint protocol.
292.It Ar thinkingmouse
293Kensington ThinkingMouse protocol.
294.It Ar mmhitab
295Hitachi tablet protocol.
296.It Ar x10mouseremote
297X10 MouseRemote.
298.It Ar kidspad
299Genius Kidspad and Easypad protocol.
300.It Ar versapad
301Interlink VersaPad protocol.
302.El
303.Pp
304For the bus and InPort mouse:
305.Bl -tag -compact -width mousesystemsxxx
306.It Ar busmouse
307This is the only protocol type available for
308the bus and InPort mouse and should be specified for any bus mice
309and InPort mice, regardless of the brand.
310.El
311.Pp
312For the PS/2 mouse:
313.Bl -tag -compact -width mousesystemsxxx
314.It Ar ps/2
315This is the only protocol type available for the PS/2 mouse
316and should be specified for any PS/2 mice, regardless of the brand.
317.El
318.Pp
319For the USB mouse,
320.Ar auto
321is the only protocol type available for the USB mouse
322and should be specified for any USB mice, regardless of the brand.
323.It Fl w Ar N
324Make the physical button
325.Ar N
326act as the wheel mode button.
327While this button is pressed, X and Y axis movement is reported to be zero
328and the Y axis movement is mapped to Z axis.
329You may further map the Z axis movement to virtual buttons by the
330.Fl z
331option below.
332.It Fl z Ar target
333Map Z axis (roller/wheel) movement to another axis or to virtual buttons.
334Valid
335.Ar target
336maybe:
337.Bl -tag -compact -width x__
338.It Ar x
339.It Ar y
340X or Y axis movement will be reported when the Z axis movement is detected.
341.It Ar N
342Report down events for the virtual buttons
343.Ar N
344and
345.Ar N+1
346respectively when negative and positive Z axis movement
347is detected.
348There do not need to be physical buttons
349.Ar N
350and
351.Ar N+1 .
352Note that mapping to logical buttons is carried out after mapping
353from the Z axis movement to the virtual buttons is done.
354.It Ar N1 N2
355Report down events for the virtual buttons
356.Ar N1
357and
358.Ar N2
359respectively when negative and positive Z axis movement
360is detected.
361.It Ar N1 N2 N3 N4
362This is useful for the mouse with two wheels of which
363the second wheel is used to generate horizontal scroll action,
364and for the mouse which has a knob or a stick which can detect
365the horizontal force applied by the user.
366.Pp
367The motion of the second wheel will be mapped to the buttons
368.Ar N3 ,
369for the negative direction, and
370.Ar N4 ,
371for the positive direction.
372If the buttons
373.Ar N3
374and
375.Ar N4
376actually exist in this mouse, their actions will not be detected.
377.Pp
378Note that horizontal movement or second roller/wheel movement may not
379always be detected,
380because there appears to be no accepted standard as to how it is encoded.
381.Pp
382Note also that some mice think left is the negative horizontal direction,
383others may think otherwise.
384Moreover, there are some mice whose two wheels are both mounted vertically,
385and the direction of the second vertical wheel does not match the
386first one's.
387.El
388.El
389.Ss Configuring Mouse Daemon
390The first thing you need to know is the interface type
391of the mouse you are going to use.
392It can be determined by looking at the connector of the mouse.
393The serial mouse has a D-Sub female 9- or 25-pin connector.
394The bus and InPort mice have either a D-Sub male 9-pin connector
395or a round DIN 9-pin connector.
396The PS/2 mouse is equipped with a small, round DIN 6-pin connector.
397Some mice come with adapters with which the connector can
398be converted to another.  If you are to use such an adapter,
399remember the connector at the very end of the mouse/adapter pair is
400what matters.
401The USB mouse has a flat rectangular connector.
402.Pp
403The next thing to decide is a port to use for the given interface.
404For the bus, InPort and PS/2 mice, there is little choice:
405the bus and InPort mice always use
406.Pa /dev/mse0 ,
407and the PS/2 mouse is always at
408.Pa /dev/psm0 .
409There may be more than one serial port to which the serial
410mouse can be attached.  Many people often assign the first, built-in
411serial port
412.Pa /dev/cuaa0
413to the mouse.
414You can attach multiple USB mice to your system or to your USB hub.
415They are accessible as
416.Pa /dev/ums0, /dev/ums1,
417and so on.
418.Pa
419You may want to create a symbolic link
420.Pa /dev/mouse
421pointing to the real port to which the mouse is connected, so that you
422can easily distinguish which is your ``mouse'' port later.
423.Pp
424The next step is to guess the appropriate protocol type for the mouse.
425The
426.Nm
427command may be able to automatically determine the protocol type.
428Run the
429.Nm
430command with the
431.Fl i
432option and see what it says.  If the command can identify
433the protocol type, no further investigation is necessary on your part.
434You may start the daemon without explicitly specifying a protocol type
435.Pq see Sx EXAMPLE .
436.Pp
437The command may print
438.Ar sysmouse
439if the mouse driver supports this protocol type.
440.Pp
441Note that the
442.Dv type
443and
444.Dv model
445printed by the
446.Fl i
447option do not necessarily match the product name of the pointing device
448in question, but they may give the name of the device with which it is
449compatible.
450.Pp
451If the
452.Fl i
453option yields nothing, you need to specify a protocol type to the
454.Nm
455command by the
456.Fl t
457option.
458You have to make a guess and try.
459There is rule of thumb:
460.Pp
461.Bl -tag -compact -width 1.X
462.It 1.
463The bus and InPort mice always use
464.Ar busmouse
465protocol regardless of the brand of the mouse.
466.It 2.
467The
468.Ar ps/2
469protocol should always be specified for the PS/2 mouse
470regardless of the brand of the mouse.
471.It 3.
472You must specify the
473.Ar auto
474protocol for the USB mouse.
475.It 4.
476Most 2-button serial mice support the
477.Ar microsoft
478protocol.
479.It 5.
4803-button serial mice may work with the
481.Ar mousesystems
482protocol.
483If it does not, it may work with the
484.Ar microsoft
485protocol although
486the third (middle) button will not function.
4873-button serial mice may also work with the
488.Ar mouseman
489protocol under which the third button may function as expected.
490.It 6.
4913-button serial mice may have a small switch to choose between ``MS''
492and ``PC'', or ``2'' and ``3''.
493``MS'' or ``2'' usually mean the
494.Ar microsoft
495protocol.
496``PC'' or ``3'' will choose the
497.Ar mousesystems
498protocol.
499.It 7.
500If the mouse has a roller or a wheel, it may be compatible with the
501.Ar intellimouse
502protocol.
503.El
504.Pp
505To test if the selected protocol type is correct for the given mouse,
506enable the mouse pointer in the current virtual console,
507.Pp
508.Dl vidcontrol -m on
509.Pp
510start the mouse daemon in the foreground mode,
511.Pp
512.Dl moused -f -p Ar _selected_port_ -t Ar _selected_protocol_
513.Pp
514and see if the mouse pointer travels correctly
515according to the mouse movement.
516Then try cut & paste features by
517clicking the left, right and middle buttons.
518Type ^C to stop
519the command.
520.Ss Multiple Mice
521As many instances of the mouse daemon as the number of mice attached to
522the system may be run simultaneously; one
523instance for each mouse.
524This is useful if the user wants to use the built-in PS/2 pointing device
525of a laptop computer while on the road, but wants to use a serial
526mouse when s/he attaches the system to the docking station in the office.
527Run two mouse daemons and tell the application program
528.Pq such as the X Window System
529to use
530.Xr sysmouse ,
531then the application program will always see mouse data from either mice.
532When the serial mouse is not attached, the corresponding mouse daemon
533will not detect any movement or button state change and the application
534program will only see mouse data coming from the daemon for the
535PS/2 mouse.
536In contrast when both mice are attached and both of them
537are moved at the same time in this configuration,
538the mouse pointer will travel across the screen just as if movement of
539the mice is combined all together.
540.Sh FILES
541.Bl -tag -width /dev/consolectl -compact
542.It Pa /dev/consolectl
543device to control the console
544.It Pa /dev/mse%d
545bus and InPort mouse driver
546.It Pa /dev/psm%d
547PS/2 mouse driver
548.It Pa /dev/sysmouse
549virtualized mouse driver
550.It Pa /dev/ttyv%d
551virtual consoles
552.It Pa /dev/ums%d
553USB mouse driver
554.It Pa /var/run/moused.pid
555process id of the currently running
556.Nm
557daemon
558.It Pa /var/run/MouseRemote
559UNIX-domain stream socket for X10 MouseRemote events
560.El
561.Sh EXAMPLE
562.Pp
563.Dl moused -p /dev/cuaa0 -i type
564.Pp
565Let the
566.Nm
567command determine the protocol type of the mouse at the serial port
568.Pa /dev/cuaa0 .
569If successful, the command will print the type, otherwise it will say
570``unknown''.
571.Pp
572.Dl moused -p /dev/cuaa0
573.Dl vidcontrol -m on
574.Pp
575If the
576.Nm
577command is able to identify the protocol type of the mouse at the specified
578port automatically, you can start the daemon without the
579.Fl t
580option and enable the mouse pointer in the text console as above.
581.Pp
582.Dl moused -p /dev/mouse -t microsoft
583.Dl vidcontrol -m on
584.Pp
585Start the mouse daemon on the serial port
586.Pa /dev/mouse .
587The protocol type
588.Ar microsoft
589is explicitly specified by the
590.Fl t
591option.
592.Pp
593.Dl moused -p /dev/mouse -m 1=3 -m 3=1
594.Pp
595Assign the physical button 3 (right button) to the logical button 1
596(logical left) and the physical button 1 (left) to the logical
597button 3 (logical right).
598This will effectively swap the left and right buttons.
599.Pp
600.Dl moused -p /dev/mouse -t intellimouse -z 4
601.Pp
602Report negative Z axis (roller) movement as the button 4 pressed
603and positive Z axis movement as the button 5 pressed.
604.Sh CAVEATS
605The
606.Nm
607command does not currently work with the alternative console driver
608.Xr pcvt 4 .
609.Pp
610Many pad devices behave as if the first (left) button were pressed if
611the user `taps' the surface of the pad.
612In contrast, some ALPS GlidePoint and Interlink VersaPad models
613treat the tapping action
614as fourth button events.
615Use the option ``-m 1=4'' for these models
616to obtain the same effect as the other pad devices.
617.Pp
618Cut and paste functions in the virtual console assume that there
619are three buttons on the mouse.
620The logical button 1 (logical left) selects a region of text in the
621console and copies it to the cut buffer.
622The logical button 3 (logical right) extends the selected region.
623The logical button 2 (logical middle) pastes the selected text
624at the text cursor position.
625If the mouse has only two buttons, the middle, `paste' button
626is not available.
627To obtain the paste function, use the
628.Fl 3
629option to emulate the middle button, or use the
630.Fl m
631option to assign the physical right button to the logical middle button:
632``-m 2=3''.
633.Sh SEE ALSO
634.Xr kill 1 ,
635.Xr vidcontrol 1 ,
636.Xr keyboard 4 ,
637.Xr mse 4 ,
638.Xr pcvt 4 ,
639.Xr psm 4 ,
640.Xr screen 4 ,
641.Xr sysmouse 4 ,
642.Xr ums 4
643.Sh STANDARD
644The
645.Nm
646command partially supports
647.Dq Plug and Play External COM Device Specification
648in order to support PnP serial mice.
649However, due to various degrees of conformance to the specification by
650existing serial mice, it does not strictly follow the version 1.0 of the
651standard.
652Even with this less strict approach,
653it may not always determine an appropriate protocol type
654for the given serial mouse.
655.Sh AUTHORS
656The
657.Nm
658command was written by
659.An Michael Smith Aq msmith@FreeBSD.org .
660This manual page was written by
661.An Mike Pritchard Aq mpp@FreeBSD.org .
662The command and manual page have since been updated by
663.An Kazutaka Yokota Aq yokota@FreeBSD.org .
664.Sh HISTORY
665The
666.Nm
667command first appeared in
668.Fx 2.2 .
669