Difference between revisions of "Mouse acceleration"

From ArchWiki
Jump to navigation Jump to search
m (→‎with libinput: Minor update to use template formatting)
 
(94 intermediate revisions by 51 users not shown)
Line 1: Line 1:
Mouse acceleration settings typically can be configured using tools provided by your desktop environment. Alternatively, Xorg supplies similar methods more directly, using the '''xset''' command. Along with sensitivity, your mouse speed is controlled by acceleration and threshold levels. The command synopsis is <code>xset m acceleration threshold</code>.
+
[[Category:Mice]]
 +
[[Category:X server]]
 +
[[ja:マウスのアクセラレーション]]
 +
[[zh-hans:Mouse acceleration]]
 +
{{Related articles start}}
 +
{{Related|Mouse buttons}}
 +
{{Related|Mouse polling rate}}
 +
{{Related articles end}}
  
For example:
+
{{Accuracy|Configuration depends on the input driver, libinput can be used in [[Xorg]]. Each subsection should explicitly state which driver is assumed.}}
<pre>
 
xset m 4 1
 
</pre>
 
<br>
 
''Acceleration'' defines how many times faster the cursor will move than the default speed, when the cursor moves more than ''threshold'' pixels in a short time. ''Acceleration'' can be a fraction, so if you want to slow down the mouse you can use 1/2, and if 3 is slightly too fast, but 2 is too slow, you can use 5/2. You effectively disable the threshold by setting it to 1, that way the cursor will always move the same speed. To get the default settings back, type <code>xset m default</code>.  
 
  
===Disabling mouse acceleration===
+
Setting the mouse acceleration depends on the windowing protocol you are using: either [[Xorg]] or [[Wayland]].
Mouse acceleration can be disabled using:
 
xset m 0 0
 
  
===Query currently used settings===
+
* On [[Xorg]], there are several ways of setting mouse acceleration
The current acceleration/threshold settings can be checked using:
+
:* by editing Xorg configuration files
 +
:* {{Pkg|xorg-xset}} and {{Pkg|xorg-xinput}} which provide ''xset'' and ''xinput'' respectively
 +
:* and configuration interfaces common in [[desktop environments]].
  
xset q | grep -A 1 ^Pointer
+
* If you are using [[Wayland]], the events are controlled via [[libinput]]. It is the compositor's job to expose the settings brought by libinput. There is currently no standard way to change settings across compositors.[https://www.reddit.com/r/gnome/comments/3upay2/wayland_where_are_the_mouse_acceleration_options/]
 +
* [[GNOME]] manages mouse acceleration by itself. A choice between "adaptive" and "flat" profiles can be chosen by installing {{Pkg|dconf-editor}} and editing the value in org/gnome/desktop/peripherals/mouse/acceleration-profile. Alternatively, {{Pkg|gnome-tweaks}} can also be used to edit the org/gnome/desktop/peripherals/mouse/acceleration-profile.
  
==Making changes permanent==
+
== Mouse acceleration with libinput ==
You can add the xset command to your ~/.xinitrc to get the desired mouse speed every time X starts.
 
  
For more info see <code>man xset</code>.
+
When using the adaptive pointer acceleration profile, [[libinput]] calculates the mouse acceleration depending on the DPI and the parameter {{ic|Acceleration Speed}} [https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html]. libinput relies on the resolution reported by [[evdev]] [https://wayland.freedesktop.org/libinput/doc/latest/motion_normalization.html]. Feedback settings set with {{ic|xset m}} are effectively ignored. When using the flat pointer acceleration profile, the acceleration factor is constant regardless of the velocity of the pointer. This provides 1:1 movement between the device and the pointer on-screen.
  
[[Category:X Server (English)]]
+
=== Changing the acceleration ===
[[Category:HOWTOs (English)]]
+
 
[[Category:Mouse]]
+
Find the id of your device with {{ic|xinput list}} and set the acceleration speed with the following command. Note that the acceleration speed has to be in the range of [-1,1]. Check [https://wayland.freedesktop.org/libinput/doc/latest/pointer-acceleration.html#ptraccel-linear this plot] to see the impact of different acceleration speed values.
 +
 
 +
$ xinput --set-prop <device id> 'libinput Accel Speed' <acceleration factor>
 +
 
 +
Confirm your changes with the following:
 +
 
 +
$ xinput --list-props <device id>
 +
 
 +
=== Persistent configuration ===
 +
 
 +
libinput does not store configuration options, it is up to the caller to manage these. Under Wayland configuration is restored by the desktop environment. Under X {{Pkg|xf86-input-libinput}} reads the xorg config files and applies the options [https://wayland.freedesktop.org/libinput/doc/latest/faqs.html#how-do-i-configure-my-device-on-x]. To make changes persistent under X create a file like this:
 +
 
 +
{{hc|/etc/X11/xorg.conf.d/99-libinput-custom-config.conf|
 +
Section "InputClass"
 +
  Identifier "<something to identify this snippet>"
 +
  MatchDriver "libinput"
 +
  MatchProduct "<substring of the device name>"
 +
  Option "AccelSpeed" "<e.g. 0.3>"
 +
EndSection
 +
}}
 +
 
 +
For further options see {{man|4|libinput}}.
 +
 
 +
== Setting mouse acceleration ==
 +
 
 +
=== In Xorg configuration ===
 +
 
 +
{{Style|Don't use comments in code blocks, provide more description in the wiki text instead.}}
 +
 
 +
See {{man|5|xorg.conf}} for details.
 +
 
 +
Examples:
 +
 
 +
{{hc|/etc/X11/xorg.conf.d/50-mouse-acceleration.conf|2=
 +
Section "InputClass"
 +
Identifier "My Mouse"
 +
MatchIsPointer "yes"
 +
# set the following to 1 1 0 respectively to disable acceleration.
 +
Option "AccelerationNumerator" "2"
 +
Option "AccelerationDenominator" "1"
 +
Option "AccelerationThreshold" "4"
 +
EndSection
 +
}}
 +
 
 +
{{hc|/etc/X11/xorg.conf.d/50-mouse-deceleration.conf|2=
 +
Section "InputClass"
 +
Identifier "My Mouse"
 +
MatchIsPointer "yes"
 +
# some curved deceleration
 +
# Option "AdaptiveDeceleration" "2"
 +
# linear deceleration (mouse speed reduction)
 +
Option "ConstantDeceleration" "2"
 +
EndSection
 +
}}
 +
 
 +
You can also assign settings to specific hardware by using "MatchProduct", "MatchVendor" and other matches inside class sections. Run {{ic|lsusb}} to find out the product name and vendor to match:
 +
 +
$ lsusb -v | grep -e idProduct -e idVendor
 +
 
 +
If you are unable to identify your device, try running {{ic|xinput list}}. Some devices the use Logitech Unifying Recceiver share the same USB connection therefore, the mouse don't appear using {{ic|lsusb}}
 +
 
 +
=== Using xset ===
 +
 
 +
{{Note|xset does not use libinput.}}
 +
 
 +
To get the current values, use:
 +
 
 +
$ xset q | grep -A 1 Pointer
 +
 
 +
To set new values, type:
 +
 
 +
$ xset m ''acceleration'' ''threshold''
 +
 
 +
where ''acceleration'' defines how many times faster the cursor will move than the default speed. ''threshold'' is the velocity required for acceleration to become effective, usually measured in device units per 10ms. ''acceleration'' can be a fraction, so if you want to slow down the mouse you can use 1/2, 1/3, 1/4, ... if you want to make it faster you can use 2/1, 3/1, 4/1, ...
 +
 
 +
''Threshold'' defines the point at which acceleration should occur in pixels per 10 ms. If threshold is zero, e.g. if you use:
 +
 
 +
$ xset m 3/2 0
 +
 
 +
as suggested in the man page, then acceleration is treated as "the exponent of a more natural and continuous formula."
 +
 
 +
To get the default settings back:
 +
 
 +
$ xset m default
 +
 
 +
For more info see {{man|1|xset}}.
 +
 
 +
Commands may be stored in [[Xinitrc]] or [[Xprofile]]. Alternatively, create a [[Desktop entry]] in {{ic|.config/autostart}}:
 +
 
 +
[Desktop Entry]
 +
Name=Disable mouse acceleration
 +
Exec=xset m 0 0
 +
Type=Application
 +
 
 +
This technique may be more desirable than employing the xorg configuration technique described above; latter may interfere with setting mouse speed in a display manager.
 +
 
 +
=== Using xinput ===
 +
 
 +
First, get a list of devices plugged in (ignore any virtual pointers):
 +
 
 +
$ xinput list
 +
 
 +
Take note of the ID. You may also use the full name in commands if the ID is prone to changing.
 +
 
 +
Get a list of available properties and their current values available for modification with
 +
 
 +
$ xinput list-props 9
 +
 
 +
where {{ic|9}} is the ID of the device you wish to use. Or
 +
 
 +
$ xinput list-props ''mouse brand''
 +
 
 +
where ''mouse brand'' is the name of your mouse given by {{ic|$ xinput list}}
 +
 
 +
Example, changing the property of {{ic|Constant Deceleration}} to 2:
 +
 
 +
{{hc|$ xinput list-props 9|
 +
Device &#39;''mouse brand''&#39;:
 +
      Device Enabled (121):  1
 +
      Device Accel Profile (240):    0
 +
      Device Accel Constant Deceleration (241):      1.000000
 +
      Device Accel Adaptive Deceleration (243):      1.000000
 +
      Device Accel Velocity Scaling (244):   10.000000
 +
}}
 +
$ xinput --set-prop &#39;''mouse brand''&#39; 'Device Accel Constant Deceleration' 2
 +
 
 +
To make it permanent, edit xorg configuration (see above) or add commands to [[xprofile]]. The latter won't affect speed in a [[Display manager]].
 +
 
 +
=== Configuration example ===
 +
 
 +
You may need to resort to using more than one method to achieve your desired mouse settings. Here's what I did to configure a generic optical mouse:
 +
First, slow down the default movement speed 3 times so that it's more precise.
 +
 
 +
$ xinput --set-prop 9 'Device Accel Constant Deceleration' 3 &
 +
 
 +
Then, enable acceleration and make it 3 times faster after moving past 6 units.
 +
 
 +
$ xset mouse 3 6 &
 +
 
 +
If you are satisfied of the results, store the preceding commands in {{ic|~/.xinitrc}}.
 +
 
 +
== Disabling mouse acceleration ==
 +
 
 +
Mouse acceleration has changed dramatically in recent X server versions; using {{Ic|xset}} to disable acceleration doesn't work as it used to and is not recommended anymore. Recent changes on {{ic|PointerAcceleration}} can be read [http://xorg.freedesktop.org/wiki/Development/Documentation/PointerAcceleration#Introduction here].
 +
 
 +
Disabling the mouse acceleration means that a linear function will be used to map from physical to virtual mouse movements. The mouse speed setting controls the inclination of this linear function.
 +
 
 +
To completely disable any sort of acceleration/deceleration, create the following file:
 +
{{hc|/etc/X11/xorg.conf.d/50-mouse-acceleration.conf|2=
 +
Section "InputClass"
 +
Identifier "My Mouse"
 +
MatchIsPointer "yes"
 +
Option "AccelerationProfile" "-1"
 +
Option "AccelerationScheme" "none"
 +
Option "AccelSpeed" "-1"
 +
EndSection
 +
}}
 +
and restart X.
 +
 
 +
=== with libinput ===
 +
 
 +
Alternatively, since {{Pkg|libinput}}-1.1.0-1 and {{Pkg|xf86-input-libinput}}-0.15.0-1 you can use a flat acceleration profile. To enable it create the following file:
 +
 
 +
{{hc|/etc/X11/xorg.conf.d/50-mouse-acceleration.conf|2=
 +
Section "InputClass"
 +
Identifier "My Mouse"
 +
Driver "libinput"
 +
MatchIsPointer "yes"
 +
Option "AccelProfile" "flat"
 +
Option "AccelSpeed" "0"
 +
EndSection
 +
}}
 +
and restart X. Notice that under certain conditions (for example if you have a different {{Ic|Pointer Speed}} value for your mouse in Plasma 5.13) your desktop environment may try to override some of these values even if you have this X configuration file.
 +
 
 +
 
 +
Another option is this command:
 +
 
 +
$ xinput --set-prop <device id> 'libinput Accel Profile Enabled' 0, 1
 +
 
 +
Which doesn't need an X restart, but isn't persistent. Although it can be set up to run automatically with [[Autostarting]].
 +
 
 +
To confirm that acceleration has been disabled, enter the following:
 +
 
 +
$ xinput list-props {1..50} 2>/dev/null | fgrep 'libinput Accel Profile Enabled ('
 +
 
 +
The profile should read {{ic|0, 1}}.

Latest revision as of 08:32, 9 July 2019

Tango-inaccurate.pngThe factual accuracy of this article or section is disputed.Tango-inaccurate.png

Reason: Configuration depends on the input driver, libinput can be used in Xorg. Each subsection should explicitly state which driver is assumed. (Discuss in Talk:Mouse acceleration#)

Setting the mouse acceleration depends on the windowing protocol you are using: either Xorg or Wayland.

  • On Xorg, there are several ways of setting mouse acceleration
  • If you are using Wayland, the events are controlled via libinput. It is the compositor's job to expose the settings brought by libinput. There is currently no standard way to change settings across compositors.[1]
  • GNOME manages mouse acceleration by itself. A choice between "adaptive" and "flat" profiles can be chosen by installing dconf-editor and editing the value in org/gnome/desktop/peripherals/mouse/acceleration-profile. Alternatively, gnome-tweaks can also be used to edit the org/gnome/desktop/peripherals/mouse/acceleration-profile.

Mouse acceleration with libinput

When using the adaptive pointer acceleration profile, libinput calculates the mouse acceleration depending on the DPI and the parameter Acceleration Speed [2]. libinput relies on the resolution reported by evdev [3]. Feedback settings set with xset m are effectively ignored. When using the flat pointer acceleration profile, the acceleration factor is constant regardless of the velocity of the pointer. This provides 1:1 movement between the device and the pointer on-screen.

Changing the acceleration

Find the id of your device with xinput list and set the acceleration speed with the following command. Note that the acceleration speed has to be in the range of [-1,1]. Check this plot to see the impact of different acceleration speed values.

$ xinput --set-prop <device id> 'libinput Accel Speed' <acceleration factor>

Confirm your changes with the following:

$ xinput --list-props <device id>

Persistent configuration

libinput does not store configuration options, it is up to the caller to manage these. Under Wayland configuration is restored by the desktop environment. Under X xf86-input-libinput reads the xorg config files and applies the options [4]. To make changes persistent under X create a file like this:

/etc/X11/xorg.conf.d/99-libinput-custom-config.conf
Section "InputClass"
  Identifier "<something to identify this snippet>"
  MatchDriver "libinput"
  MatchProduct "<substring of the device name>"
  Option "AccelSpeed" "<e.g. 0.3>"
EndSection

For further options see libinput(4).

Setting mouse acceleration

In Xorg configuration

Tango-edit-clear.pngThis article or section needs language, wiki syntax or style improvements. See Help:Style for reference.Tango-edit-clear.png

Reason: Don't use comments in code blocks, provide more description in the wiki text instead. (Discuss in Talk:Mouse acceleration#)

See xorg.conf(5) for details.

Examples:

/etc/X11/xorg.conf.d/50-mouse-acceleration.conf
Section "InputClass"
	Identifier "My Mouse"
	MatchIsPointer "yes"
# set the following to 1 1 0 respectively to disable acceleration.
	Option "AccelerationNumerator" "2"
	Option "AccelerationDenominator" "1"
	Option "AccelerationThreshold" "4"
EndSection
/etc/X11/xorg.conf.d/50-mouse-deceleration.conf
Section "InputClass"
	Identifier "My Mouse"
	MatchIsPointer "yes"
# some curved deceleration
#	Option "AdaptiveDeceleration" "2"
# linear deceleration (mouse speed reduction)
	Option "ConstantDeceleration" "2"
EndSection

You can also assign settings to specific hardware by using "MatchProduct", "MatchVendor" and other matches inside class sections. Run lsusb to find out the product name and vendor to match:

$ lsusb -v | grep -e idProduct -e idVendor

If you are unable to identify your device, try running xinput list. Some devices the use Logitech Unifying Recceiver share the same USB connection therefore, the mouse don't appear using lsusb

Using xset

Note: xset does not use libinput.

To get the current values, use:

$ xset q | grep -A 1 Pointer

To set new values, type:

$ xset m acceleration threshold

where acceleration defines how many times faster the cursor will move than the default speed. threshold is the velocity required for acceleration to become effective, usually measured in device units per 10ms. acceleration can be a fraction, so if you want to slow down the mouse you can use 1/2, 1/3, 1/4, ... if you want to make it faster you can use 2/1, 3/1, 4/1, ...

Threshold defines the point at which acceleration should occur in pixels per 10 ms. If threshold is zero, e.g. if you use:

$ xset m 3/2 0

as suggested in the man page, then acceleration is treated as "the exponent of a more natural and continuous formula."

To get the default settings back:

$ xset m default

For more info see xset(1).

Commands may be stored in Xinitrc or Xprofile. Alternatively, create a Desktop entry in .config/autostart:

[Desktop Entry]
Name=Disable mouse acceleration
Exec=xset m 0 0
Type=Application

This technique may be more desirable than employing the xorg configuration technique described above; latter may interfere with setting mouse speed in a display manager.

Using xinput

First, get a list of devices plugged in (ignore any virtual pointers):

$ xinput list

Take note of the ID. You may also use the full name in commands if the ID is prone to changing.

Get a list of available properties and their current values available for modification with

$ xinput list-props 9

where 9 is the ID of the device you wish to use. Or

$ xinput list-props mouse brand

where mouse brand is the name of your mouse given by $ xinput list

Example, changing the property of Constant Deceleration to 2:

$ xinput list-props 9
Device 'mouse brand':
       Device Enabled (121):   1
       Device Accel Profile (240):     0
       Device Accel Constant Deceleration (241):       1.000000
       Device Accel Adaptive Deceleration (243):       1.000000
       Device Accel Velocity Scaling (244):    10.000000
$ xinput --set-prop 'mouse brand' 'Device Accel Constant Deceleration' 2

To make it permanent, edit xorg configuration (see above) or add commands to xprofile. The latter won't affect speed in a Display manager.

Configuration example

You may need to resort to using more than one method to achieve your desired mouse settings. Here's what I did to configure a generic optical mouse: First, slow down the default movement speed 3 times so that it's more precise.

$ xinput --set-prop 9 'Device Accel Constant Deceleration' 3 &

Then, enable acceleration and make it 3 times faster after moving past 6 units.

$ xset mouse 3 6 &

If you are satisfied of the results, store the preceding commands in ~/.xinitrc.

Disabling mouse acceleration

Mouse acceleration has changed dramatically in recent X server versions; using xset to disable acceleration doesn't work as it used to and is not recommended anymore. Recent changes on PointerAcceleration can be read here.

Disabling the mouse acceleration means that a linear function will be used to map from physical to virtual mouse movements. The mouse speed setting controls the inclination of this linear function.

To completely disable any sort of acceleration/deceleration, create the following file:

/etc/X11/xorg.conf.d/50-mouse-acceleration.conf
Section "InputClass"
	Identifier "My Mouse"
	MatchIsPointer "yes"
	Option "AccelerationProfile" "-1"
	Option "AccelerationScheme" "none"
	Option "AccelSpeed" "-1"
EndSection

and restart X.

with libinput

Alternatively, since libinput-1.1.0-1 and xf86-input-libinput-0.15.0-1 you can use a flat acceleration profile. To enable it create the following file:

/etc/X11/xorg.conf.d/50-mouse-acceleration.conf
Section "InputClass"
	Identifier "My Mouse"
	Driver "libinput"
	MatchIsPointer "yes"
	Option "AccelProfile" "flat"
	Option "AccelSpeed" "0"
EndSection

and restart X. Notice that under certain conditions (for example if you have a different Pointer Speed value for your mouse in Plasma 5.13) your desktop environment may try to override some of these values even if you have this X configuration file.


Another option is this command:

$ xinput --set-prop <device id> 'libinput Accel Profile Enabled' 0, 1

Which doesn't need an X restart, but isn't persistent. Although it can be set up to run automatically with Autostarting.

To confirm that acceleration has been disabled, enter the following:

$ xinput list-props {1..50} 2>/dev/null | fgrep 'libinput Accel Profile Enabled ('

The profile should read 0, 1.