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.\" $Id: moused.8,v 1.15 1998/06/14 20:05:26 ahasty Exp $ 32.\" 33.Dd December 3, 1997 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 3DPRcdfs 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 z Ar target 49.Op Fl t Ar mousetype 50.Fl p Ar port 51.Pp 52.Nm 53.Op Fl Pd 54.Fl p Ar port 55.Fl i Ar info 56.Sh DESCRIPTION 57The mouse daemon 58.Nm 59and the console driver work together to support 60mouse operation in the text console and user programs. 61They virtualize the mouse and provide user programs with mouse data 62in the standard format 63.Pq see Xr sysmouse 4 . 64.Pp 65The mouse daemon listens to the specified port for mouse data, 66interprets and then passes it via ioctls to the console driver. 67The mouse daemon 68reports translation movement, button press/release 69events and movement of the roller or the wheel if available. 70The roller/wheel movement is reported as ``Z'' axis movement. 71.Pp 72The console driver will display the mouse pointer on the screen 73and provide cut and paste functions if the mouse pointer is enabled 74in the virtual console via 75.Xr vidcontrol 4 . 76If 77.Xr sysmouse 4 78is opened by the user program, the console driver also passes the mouse 79data to the device so that the user program will see it. 80.Pp 81If the mouse daemon receives the signal 82.Dv SIGHUP , 83it will reopen the mouse port and reinitializes itself. Useful if 84the mouse is attached/detached while the system is suspended. 85.Pp 86The following options are available: 87.Bl -tag -width indent 88.It Fl 3 89Emulate the third (middle) button for 2-button mice. It is emulated 90by pressing the left and right physical buttons simultaneously. 91.It Fl C Ar threshold 92Set double click speed as the maximum interval in msec between button clicks. 93Without this option, the default value of 500 msec will be assumed. 94This option will have effect only on the cut and paste operations 95in the text mode console. The user program which is reading mouse data 96via 97.Xr sysmouse 4 98won't be affected. 99.It Fl D 100Lower DTR on the serial port. 101This option is valid only if 102.Ar mousesystems 103is selected as the protocol type. 104The DTR line may need to be dropped for a 3-button mouse 105to operate in the 106.Ar mousesystems 107mode. 108.It Fl F Ar rate 109Set the report rate (reports/sec) of the device if supported. 110.It Fl I Ar file 111Write the process id of the 112.Nm 113daemon in the specified file. 114Without this option, the process id will be stored in 115.Pa /var/run/moused.pid . 116.It Fl P 117Do not start the Plug and Play COM device enumeration procedure 118when identifying the serial mouse. 119If this option is given together with the 120.Fl i 121option, the 122.Nm 123command won't be able to print useful information for the serial mouse. 124.It Fl R 125Lower RTS on the serial port. 126This option is valid only if 127.Ar mousesystems 128is selected as the protocol type by the 129.Fl t 130option below. It is often used with the 131.Fl D 132option above. Both RTS and DTR lines may need to be dropped for 133a 3-button mouse to operate in the 134.Ar mousesystems 135mode. 136.It Fl S Ar baudrate 137Select the baudrate for the serial port (1200 to 9600). 138Not all serial mice support this option. 139.It Fl c 140Some mice report middle button down events 141as if the left and right buttons are pressed. This option handles this. 142.It Fl d 143Enable debugging messages. 144.It Fl f 145Do not become a daemon and instead run as a foreground process. 146Useful for testing and debugging. 147.It Fl i Ar info 148Print specified information and quit. Available pieces of 149information are: 150.Pp 151.Bl -tag -compact -width modelxxx 152.It Ar port 153Port (device file) name, i.e. 154.Pa /dev/cuaa0 , 155.Pa /dev/mse0 156and 157.Pa /dev/psm0 . 158.It Ar if 159Interface type: serial, bus, inport or ps/2. 160.It Ar type 161Protocol type. It is one of the types listed under the 162.Fl t 163option below or 164.Ar sysmouse 165if the driver supports the 166.Ar sysmouse 167data format standard. 168.It Ar model 169Mouse model. The 170.Nm 171command may not always be able to identify the model. 172.It Ar all 173All of the above items. Print port, interface, type and model in this order 174in one line. 175.El 176.Pp 177If the 178.Nm 179command cannot determine the requested information, it prints ``unknown'' 180or ``generic''. 181.It Fl m Ar N=M 182Assign the physical button 183.Ar M 184to the logical button 185.Ar N. 186You may specify as many instances of this option as you like. 187More than one physical button may be assigned to a logical button at the 188same time. In this case the logical button will be down, 189if either of the assigned physical buttons is held down. 190Do not put space around `='. 191.It Fl p Ar port 192Use 193.Ar port 194to communicate with the mouse. 195.It Fl r Ar resolution 196Set the resolution of the device; in Dots Per Inch, or 197.Ar low , 198.Ar medium-low , 199.Ar medium-high 200or 201.Ar high . 202This option may not be supported by all the device. 203.It Fl s 204Select a baudrate of 9600 for the serial line. 205Not all serial mice support this option. 206.It Fl t Ar type 207Specify the protocol type of the mouse attached to the port. 208You may explicitly specify a type listed below, or use 209.Ar auto 210to let the 211.Nm 212command to automatically select an appropriate protocol for the given 213mouse. 214If you entirely ommit this options in the command line, 215.Fl t Ar auto 216is assumed. 217Under normal circumstances, 218you need to use this option only if the 219.Nm 220command is not able to detect the protocol automatically 221.Pq see the Sx Configuring Mouse Daemon . 222.Pp 223Also note that if a protocol type is specified with this option, the 224.Fl P 225option above is implied and Plug and Play COM device enumeration 226procedure will be disabled. 227.Pp 228Valid types for this option are 229listed below. 230.Pp 231For the serial mouse: 232.Bl -tag -compact -width mousesystemsxxx 233.It Ar microsoft 234Microsoft serial mouse protocol. Most 2-button serial mice use this protocol. 235.It Ar intellimouse 236Microsoft IntelliMouse protocol. Genius NetMouse, ASCII Mie Mouse, 237Logitech MouseMan+ and FirstMouse+ use this protocol too. 238Other mice with a roller/wheel may be compatible with this protocol. 239.It Ar mousesystems 240MouseSystems 5-byte protocol. 3-button mice may use this protocol. 241.It Ar mmseries 242MM Series mouse protocol. 243.It Ar logitech 244Logitech mouse protocol. Note that this is for old Logitech models. 245.Ar mouseman 246or 247.Ar intellimouse 248should be specified for newer models. 249.It Ar mouseman 250Logitech MouseMan and TrackMan protocol. Some 3-button mice may be compatible 251with this protocol. Note that MouseMan+ and FirstMouse+ use 252.Ar intellimouse 253protocol rather than this one. 254.It Ar glidepoint 255ALPS GlidePoint protocol. 256.It Ar thinkingmouse 257Kensington ThinkingMouse protocol. 258.It Ar mmhitab 259Hitachi tablet protocol. 260.It Ar x10mouseremote 261X10 MouseRemote. 262.El 263.Pp 264For the bus and InPort mouse: 265.Bl -tag -compact -width mousesystemsxxx 266.It Ar busmouse 267This is the only protocol type available for 268the bus and InPort mouse and should be specified for any bus mice 269and InPort mice, regardless of the brand. 270.El 271.Pp 272For the PS/2 mouse: 273.Bl -tag -compact -width mousesystemsxxx 274.It Ar ps/2 275This is the only protocol type available for the PS/2 mouse 276and should be specified for any PS/2 mice, regardless of the brand. 277.El 278.It Fl z Ar target 279Map Z axis (roller/wheel) movement to another axis or to virtual buttons. 280Valid 281.Ar target 282maybe: 283.Bl -tag -compact -width x__ 284.It Ar x 285.It Ar y 286X or Y axis movement will be reported when the Z axis movement is detected. 287.It Ar N 288Report the virtual buttons 289.Ar N 290and 291.Ar N+1 292down events respectively when negative and positive Z axis movement 293is detected. There doesn't need to be physical buttons 294.Ar N 295and 296.Ar N+1 . 297Note that mapping to logical buttons is carried out after mapping 298from the Z axis movement to the virtual buttons is done. 299.El 300.El 301.Ss Configuring Mouse Daemon 302The first thing you need to know is the interface type 303of the mouse you are going to use. 304It can be determined by looking at the connector of the mouse. 305The serial mouse has a D-Sub female 9- or 25-pin connector. 306The bus and InPort mice have either a D-Sub male 9-pin connector 307or a round DIN 9-pin connector. 308The PS/2 mouse is equipped with a small, round DIN 6-pin connector. 309Some mice come with adapters with which the connector can 310be converted to another. If you are to use such an adapter, 311remember the connector at the very end of the mouse/adapter pair is 312what matters. 313.Pp 314The next thing to decide is a port to use for the given interface. 315For the bus, InPort and PS/2 mice, there is little choice: 316the bus and InPort mice always use 317.Pa /dev/mse0 , 318and the PS/2 mouse is always at 319.Pa /dev/psm0 . 320There may be more than one serial port to which the serial 321mouse can be attached. Many people often assign the first, built-in 322serial port 323.Pa /dev/cuaa0 324to the mouse. 325You may want to create a symbolic link 326.Pa /dev/mouse 327pointing to the real port to which the mouse is connected, so that you 328can easily distinguish which is your ``mouse'' port later. 329.Pp 330The next step is to guess the appropriate protocol type for the mouse. 331The 332.Nm 333command may be able to automatically determine the protocol type. 334Run the 335.Nm 336command with the 337.Fl i 338option and see what it says. If the command can identify 339the protocol type, no further investigation is necessary on your part. 340You may start the daemon without explicitly specifying a protocol type 341.Pq see Sx EXAMPLE . 342.Pp 343The command may print 344.Ar sysmouse 345if the mouse driver supports this protocol type. 346.Pp 347Note that the 348.Dv type 349and 350.Dv model 351printed by the 352.Fl i 353option do not necessarily match the product name of the pointing device 354in question, but they may give the name of the device with which it is 355compatible. 356.Pp 357If the 358.Fl i 359option yields nothing, you need to specify a protocol type to the 360.Nm 361command by the 362.Fl t 363option. You have to make a guess and try. 364There is rule of thumb: 365.Pp 366.Bl -tag -compact -width 1.X 367.It 1. 368The bus and InPort mice always use 369.Ar busmouse 370protocol regardless of the brand of the mouse. 371.It 2. 372The 373.Ar ps/2 374protocol should always be specified for the PS/2 mouse 375regardless of the brand of the mouse. 376.It 3. 377Most 2-button serial mice support the 378.Ar microsoft 379protocol. 380.It 4. 3813-button serial mice may work with the 382.Ar mousesystems 383protocol. If it doesn't, it may work with the 384.Ar microsoft 385protocol although 386the third (middle) button won't function. 3873-button serial mice may also work with the 388.Ar mouseman 389protocol under which the third button may function as expected. 390.It 5. 3913-button serial mice may have a small switch to choose between ``MS'' 392and ``PC'', or ``2'' and ``3''. 393``MS'' or ``2'' usually mean the 394.Ar microsoft 395protocol. 396``PC'' or ``3'' will choose the 397.Ar mousesystems 398protocol. 399.It 6. 400If the mouse has a roller or a wheel, it may be compatible with the 401.Ar intellimouse 402protocol. 403.El 404.Pp 405To test if the selected protocol type is correct for the given mouse, 406enable the mouse pointer in the current virtual console, 407.Pp 408.Dl vidcontrol -m on 409.Pp 410start the mouse daemon in the foreground mode, 411.Pp 412.Dl moused -f -p Ar _selected_port_ -t Ar _selected_protocol_ 413.Pp 414and see if the mouse pointer travels correctly 415according to the mouse movement. Then try cut & paste features by 416clicking the left, right and middle buttons. Type ^C to stop 417the command. 418.Ss Multiple Mice 419As many instances of the mouse daemon as the number of mice attached to 420the system may be run simultaneously; one 421instance for each mouse. 422This is useful if the user wants to use the built-in PS/2 pointing device 423of a laptop computer while on the road, but wants to use a serial 424mouse when s/he attaches the system to the docking station in the office. 425Run two mouse daemons and tell the application program 426.Pq such as the X Window System 427to use 428.Xr sysmouse , 429then the application program will always see mouse data from either mice. 430When the serial mouse is not attached, the corresponding mouse daemon 431won't detect any movement or button state change and the application 432program will only see mouse data coming from the daemon for the 433PS/2 mouse. In contrast when both mice are attached and both of them 434are moved at the same time in this configuration, 435the mouse pointer will travel across the screen just as if movement of 436the mice is combined all together. 437.Sh FILES 438.Bl -tag -width /dev/consolectl -compact 439.It Pa /dev/consolectl 440device to control the console 441.It Pa /dev/mse%d 442bus and InPort mouse driver 443.It Pa /dev/psm%d 444PS/2 mouse driver 445.It Pa /dev/sysmouse 446virtualized mouse driver 447.It Pa /dev/ttyv%d 448virtual consoles 449.It Pa /var/run/moused.pid 450process id of the currently running 451.Nm 452daemon 453.It Pa /var/run/MouseRemote 454UNIX-domain stream socket for X10 MouseRemote events 455.El 456.Sh EXAMPLE 457.Pp 458.Dl moused -p /dev/cuaa0 -i type 459.Pp 460Let the 461.Nm 462command determine the protocol type of the mouse at the serial port 463.Pa /dev/cuaa0 . 464If successful, the command will print the type, otherwise it will say 465``unknown''. 466.Pp 467.Dl moused -p /dev/cuaa0 468.Dl vidcontrol -m on 469.Pp 470If the 471.Nm 472command is able to identify the protocol type of the mouse at the specified 473port automatically, you can start the daemon without the 474.Fl t 475option and enable the mouse pointer in the text console as above. 476.Pp 477.Dl moused -p /dev/mouse -t microsoft 478.Dl vidcontrol -m on 479.Pp 480Start the mouse daemon on the serial port 481.Pa /dev/mouse . 482The protocol type 483.Ar microsoft 484is explicitly specified by the 485.Fl t 486option. 487.Pp 488.Dl moused -p /dev/mouse -m 1=3 -m 3=1 489.Pp 490Assign the physical button 3 (right button) to the logical button 1 491(logical left) and the physical button 1 (left) to the logical 492button 3 (logical right). 493This will effectively swap the left and right buttons. 494.Pp 495.Dl moused -p /dev/mouse -t intellimouse -z 4 496.Pp 497Report negative Z axis (roller) movement as the button 4 pressed 498and positive Z axis movement as the button 5 pressed. 499.Sh CAVEATS 500The 501.Nm 502command does not currently work with the alternative console driver 503.Xr pcvt 4 . 504.Pp 505Many pad devices behave as if the first (left) button were pressed if 506the user `taps' the surface of the pad. 507In contrast, some ALPS GlidePoint pad models treat the tapping action 508as fourth button events. Use the option ``-m 1=4'' for these models 509to obtain the same effect as the other pad devices. 510.Pp 511Cut and paste functions in the virtual console assume that there 512are three buttons on the mouse. 513The logical button 1 (logical left) selects a region of text in the 514console and copies it to the cut buffer. 515The logical button 3 (logical right) extends the selected region. 516The logical button 2 (logical middle) pastes the selected text 517at the text cursor position. 518If the mouse has only two buttons, the middle, `paste' button 519is not available. 520To obtain the paste function, use the 521.Fl 3 522option to emulate the middle button, or use the 523.Fl m 524option to assign the physical right button to the logical middle button: 525``-m 2=3''. 526.Sh SEE ALSO 527.Xr kill 1 , 528.Xr vidcontrol 1 , 529.Xr keyboard 4 , 530.Xr mse 4 , 531.Xr pcvt 4 , 532.Xr psm 4 , 533.Xr screen 4 , 534.Xr sysmouse 4 535.Sh STANDARD 536The 537.Nm 538command partially supports ``Plag and Play External COM Device Specification'' 539in order to support PnP serial mice. 540However, due to various degrees of conformance to the specification by 541existing serial mice, it does not strictly follow the version 1.0 of the 542standard. Even with this less strict approach, 543it may not always determine an appropriate protocol type 544for the given serial mouse. 545.Sh AUTHORS 546The 547.Nm 548command was written by 549.An Michael Smith Aq msmith@FreeBSD.org . 550This manual page was written by 551.An Mike Pritchard Aq mpp@FreeBSD.org . 552The command and manual page have since been updated by 553.An Kazutaka Yokota Aq yokota@FreeBSD.org . 554.Sh HISTORY 555The 556.Nm 557command first appeared in 558.Fx 2.2 . 559