.\" SPDX-License-Identifier: BSD-4-Clause .\" .\" Copyright (c) 1996 Mike Pritchard .\" All rights reserved. .\" .\" Redistribution and use in source and binary forms, with or without .\" modification, are permitted provided that the following conditions .\" are met: .\" 1. Redistributions of source code must retain the above copyright .\" notice, this list of conditions and the following disclaimer. .\" 2. Redistributions in binary form must reproduce the above copyright .\" notice, this list of conditions and the following disclaimer in the .\" documentation and/or other materials provided with the distribution. .\" 3. All advertising materials mentioning features or use of this software .\" must display the following acknowledgement: .\" This product includes software developed by Mike Pritchard. .\" 4. Neither the name of the author nor the names of its contributors .\" may be used to endorse or promote products derived from this software .\" without specific prior written permission. .\" .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE .\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF .\" SUCH DAMAGE. .\" .Dd June 14, 2025 .Dt MOUSED 8 .Os .Sh NAME .Nm moused .Nd pass mouse data to the console driver .Sh SYNOPSIS .Nm .Op Fl dfg .Op Fl I Ar file .Op Fl F Ar rate .Op Fl r Ar resolution .Op Fl VH Op Fl U Ar distance Fl L Ar distance .Op Fl A Ar exp Ns Op , Ns Ar offset .Op Fl a Ar X Ns Op , Ns Ar Y .Op Fl C Ar threshold .Op Fl m Ar N=M .Op Fl w Ar N .Op Fl z Ar target .Op Fl t Ar interfacetype .Op Fl l Ar level .Op Fl 3 Op Fl E Ar timeout .Op Fl T Ar distance Ns Op , Ns Ar time Ns Op , Ns Ar after .Fl p Ar port .Pp .Nm .Op Fl d .Fl p Ar port .Fl i Ar info .Sh DESCRIPTION The .Nm utility and the console driver work together to support mouse operation in the text console and user programs. They virtualize the mouse and provide user programs with mouse data in the standard format (see .Xr sysmouse 4 ) . .Pp The mouse daemon listens to the specified port for mouse data, interprets and then passes it via ioctls to the console driver. Supported data interfaces are .Qq input event device AKA evdev and .Xr sysmouse 4 level 1. The mouse daemon reports translation movement, button press/release events and movement of the roller or the wheel if available. The roller/wheel movement is reported as .Dq Z axis movement. .Pp The console driver will display the mouse pointer on the screen and provide cut and paste functions if the mouse pointer is enabled in the virtual console via .Xr vidcontrol 1 . If .Xr sysmouse 4 is opened by the user program, the console driver also passes the mouse data to the device so that the user program will see it. .Pp If the mouse daemon receives the signal .Dv SIGHUP , it will reopen the mouse port and reinitialize itself. Useful if the mouse is attached/detached while the system is suspended. .Pp If the mouse daemon receives the signal .Dv SIGUSR1 , it will stop passing mouse events. Sending the signal .Dv SIGUSR1 again will resume passing mouse events. Useful if your typing on a laptop is interrupted by accidentally touching the mouse pad. .Pp The following options are available: .Bl -tag -width indent .It Fl 3 Emulate the third (middle) button for 2-button mice. It is emulated by pressing the left and right physical buttons simultaneously. .It Fl C Ar threshold Set double click speed as the maximum interval in msec between button clicks. Without this option, the default value of 500 msec will be assumed. This option will have effect only on the cut and paste operations in the text mode console. The user program which is reading mouse data via .Xr sysmouse 4 will not be affected. .It Fl E Ar timeout When the third button emulation is enabled (see above), the .Nm utility waits .Ar timeout msec at most before deciding whether two buttons are being pressed simultaneously. The default timeout is 100 msec. .It Fl F Ar rate Only for .Xr sysmouse 4 interface. Set the report rate (reports/sec) of the device if supported. .It Fl L Ar distance When .Dq Virtual Scrolling is enabled, the .Fl L option can be used to set the .Ar distance (in pixels) that the mouse must move before a scroll event is generated. This effectively controls the scrolling speed. The default .Ar distance is 2 pixels. .It Fl H Enable .Dq Horizontal Virtual Scrolling . With this option set, holding the middle mouse button down will cause motion to be interpreted as horizontal scrolling. Use the .Fl U option to set the distance the mouse must move before the scrolling mode is activated and the .Fl L option to set the scrolling speed. This option may be used with or without the .Fl V option. .It Fl I Ar file Write the process id of the .Nm utility in the specified file. Without this option, the process id will be stored in .Pa /var/run/moused.pid . .It Fl T Ar distance Ns Op , Ns Ar time Ns Op , Ns Ar after Terminate drift. Use this option if mouse pointer slowly wanders when mouse is not moved. Movements up to .Ar distance (for example 4) pixels (X+Y) in .Ar time msec (default 500) are ignored, except during .Ar after msec (default 4000) since last real mouse movement. .It Fl V Enable .Dq Virtual Scrolling . With this option set, holding the middle mouse button down will cause motion to be interpreted as scrolling. Use the .Fl U option to set the distance the mouse must move before the scrolling mode is activated and the .Fl L option to set the scrolling speed. .It Fl U Ar distance When .Dq Virtual Scrolling is enabled, the .Fl U option can be used to set the .Ar distance (in pixels) that the mouse must move before the scrolling mode is activated. The default .Ar distance is 3 pixels. .It Fl A Ar exp Ns Op , Ns Ar offset Apply exponential (dynamic) acceleration to mouse movements: the faster you move the mouse, the more it will be accelerated. That means that small mouse movements are not accelerated, so they are still very accurate, while a faster movement will drive the pointer quickly across the screen. .Pp The .Ar exp value specifies the exponent, which is basically the amount of acceleration. Useful values are in the range 1.1 to 2.0, but it depends on your mouse hardware and your personal preference. A value of 1.0 means no exponential acceleration. A value of 2.0 means squared acceleration (i.e. if you move the mouse twice as fast, the pointer will move four times as fast on the screen). Values beyond 2.0 are possible but not recommended. A good value to start is probably 1.5. .Pp The optional .Ar offset value specifies the distance at which the acceleration begins. The default is 1.0, which means that the acceleration is applied to movements larger than one unit. If you specify a larger value, it takes more speed for the acceleration to kick in, i.e. the speed range for small and accurate movements is wider. Usually the default should be sufficient, but if you're not satisfied with the behaviour, try a value of 2.0. .Pp Note that the .Fl A option interacts badly with the X server's own acceleration, which doesn't work very well anyway. Therefore it is recommended to switch it off if necessary: .Dq xset m 1 . .It Fl a Ar X Ns Op , Ns Ar Y Accelerate or decelerate the mouse input. This is a linear acceleration only. Values less than 1.0 slow down movement, values greater than 1.0 speed it up. Specifying only one value sets the acceleration for both axes. .Pp You can use the .Fl a and .Fl A options at the same time to have the combined effect of linear and exponential acceleration. .It Fl d Enable debugging messages. .It Fl f Do not become a daemon and instead run as a foreground process. Useful for testing and debugging. .It Fl g Only for evdev interface. Become the sole recipient of all incoming input events. This prevents other processes from getting input events on the device. .It Fl i Ar info Print specified information and quit. Available pieces of information are: .Pp .Bl -tag -compact -width modelxxx .It Ar port Port (device file) name, i.e.\& .Pa /dev/input/event0 , .Pa /dev/ums0 and .Pa /dev/psm0 . .It Ar if Interface type: .Dq evdev or .Dq sysmouse . .It Ar type Device type: .Dq mouse or .Dq touchpad . .It Ar model Mouse model. .It Ar all All of the above items. Print port, type and model in this order in one line. .El .Pp If the .Nm utility cannot determine the requested information, it prints .Dq Li unknown or .Dq Li generic . .It Fl l Ar level Ignored. Used for compatibility with legacy .Nm . .It Fl m Ar N=M Assign the physical button .Ar M to the logical button .Ar N . You may specify as many instances of this option as you like. More than one physical button may be assigned to a logical button at the same time. In this case the logical button will be down, if either of the assigned physical buttons is held down. Do not put space around .Ql = . .It Fl p Ar port Use .Ar port to communicate with the mouse. .It Fl r Ar resolution Only for .Xr sysmouse 4 interface. Set the resolution of the device; in Dots Per Inch, or .Ar low , .Ar medium-low , .Ar medium-high or .Ar high . This option may not be supported by all the device. .It Fl t Ar type Force the interface type of the mouse attached to the port. You may explicitly specify a type listed below, or use .Ar auto to let the .Nm utility automatically select an appropriate protocol for the given character device. If you entirely omit this option in the command line, .Fl t Ar auto is assumed. .Pp Valid types for this option are listed below. .Bl -tag -compact -width systemmouse .It Ar evdev Input event device usualy residing in .Pa /dev/input . .It Ar sysmouse Traditional protocol used by e.g. .Xr ums 4 and .Xr psm 4 drivers. .El .Pp Note that this option restricts usage of the given port rather then gives a hint. .It Fl q Ar config Path to configuration file. .It Fl Q Ar quirks Path to quirks directory. .It Fl w Ar N Make the physical button .Ar N act as the wheel mode button. While this button is pressed, X and Y axis movement is reported to be zero and the Y axis movement is mapped to Z axis. You may further map the Z axis movement to virtual buttons by the .Fl z option below. .It Fl z Ar target Map Z axis (roller/wheel) movement to another axis or to virtual buttons. Valid .Ar target maybe: .Bl -tag -compact -width x__ .It Ar x .It Ar y X or Y axis movement will be reported when the Z axis movement is detected. .It Ar N Report down events for the virtual buttons .Ar N and .Ar N+1 respectively when negative and positive Z axis movement is detected. There do not need to be physical buttons .Ar N and .Ar N+1 . Note that mapping to logical buttons is carried out after mapping from the Z axis movement to the virtual buttons is done. .It Ar N1 N2 Report down events for the virtual buttons .Ar N1 and .Ar N2 respectively when negative and positive Z axis movement is detected. .It Ar N1 N2 N3 N4 This is useful for the mouse with two wheels of which the second wheel is used to generate horizontal scroll action, and for the mouse which has a knob or a stick which can detect the horizontal force applied by the user. .Pp The motion of the second wheel will be mapped to the buttons .Ar N3 , for the negative direction, and .Ar N4 , for the positive direction. If the buttons .Ar N3 and .Ar N4 actually exist in this mouse, their actions will not be detected. .Pp Note that horizontal movement or second roller/wheel movement may not always be detected, because there appears to be no accepted standard as to how it is encoded. .Pp Note also that some mice think left is the negative horizontal direction; others may think otherwise. Moreover, there are some mice whose two wheels are both mounted vertically, and the direction of the second vertical wheel does not match the first one. .El .Ss Multiple Mice The .Nm utility may operate in 2 different modes depending on the value of .Fl p option. When started with .Fl p Ar auto option specified the .Nm handles all recognized pointing devices in a single instance. Device hotplug is supported through .Xr devd 8 . Only evdev interface is available in this mode. When started with .Fl p Ar option specified the .Nm handles single device located at .Ar . Both evdev and .Xr sysmouse 4 level 1 interfaces are available in this mode. Multiple .Nm instances may be run simultaneously. .Sh FILES .Bl -tag -width /var/run/moused.pid -compact .It Pa /dev/consolectl device to control the console .It Pa /dev/input/event%d Input event device .It Pa /dev/psm%d PS/2 mouse driver .It Pa /dev/sysmouse virtualized mouse driver .It Pa /dev/ums%d USB mouse driver .It Pa /var/run/moused.pid process id of the currently running .Nm utility .El .Sh EXAMPLES .Bd -literal -offset indent moused -p auto vidcontrol -m on .Ed .Pp Start .Nm utility to handle all evdev pointing devices automatically with hotplug support. And enable the mouse pointer in the text console after than. The daemon can be started without the .Fl p option as well. .Pp .Dl "moused -f -d -g -p /dev/input/event0" .Ed .Pp Start the mouse daemon on the .Pa /dev/input/event0 in the exclusive foreground debug mode. Exclusive mode may disable mouse in Xorg session. .Pp .Dl "moused -p /dev/input/event0 -m 1=3 -m 3=1" .Pp Assign the physical button 3 (right button) to the logical button 1 (logical left) and the physical button 1 (left) to the logical button 3 (logical right). This will effectively swap the left and right buttons. .Pp .Dl "moused -p /dev/input/event0 -z 4" .Pp Report negative Z axis movement (i.e., mouse wheel) as the button 4 pressed and positive Z axis movement (i.e., mouse wheel) as the button 5 pressed. .Pp If you add .Pp .Dl "ALL ALL = NOPASSWD: /usr/bin/killall -USR1 moused" .Pp to your .Pa /usr/local/etc/sudoers file, and bind .Pp .Dl "killall -USR1 moused" .Pp to a key in your window manager, you can suspend mouse events on your laptop if you keep brushing over the mouse pad while typing. .Sh SEE ALSO .Xr moused.conf 5 , .Xr kill 1 , .Xr vidcontrol 1 , .Xr xset 1 , .Xr keyboard 4 , .Xr psm 4 , .Xr sysmouse 4 , .Xr ums 4 , .Xr devd 8 .Sh HISTORY The .Nm utility first appeared in .Fx 2.2 . It was rewritten to support multiple input event devices in .Fx 15.0 . .Sh AUTHORS .An -nosplit The .Nm utility was originally written by .An Michael Smith Aq Mt msmith@FreeBSD.org . This manual page was written by .An Mike Pritchard Aq Mt mpp@FreeBSD.org . The command and manual page have since been updated by .An Kazutaka Yokota Aq Mt yokota@FreeBSD.org . Multiple input event devices support was added by .An Vladimir Kondratyev Aq Mt wulf@FreeBSD.org . .Sh CAVEATS Cut and paste functions in the virtual console assume that there are three buttons on the mouse. The logical button 1 (logical left) selects a region of text in the console and copies it to the cut buffer. The logical button 3 (logical right) extends the selected region. The logical button 2 (logical middle) pastes the selected text at the text cursor position. If the mouse has only two buttons, the middle, `paste' button is not available. To obtain the paste function, use the .Fl 3 option to emulate the middle button, or use the .Fl m option to assign the physical right button to the logical middle button: .Dq Fl m Li 2=3 .