How to set mouse sensitivity, not just mouse acceleration

kdemousex11xinput

I can't find a single desktop environment that supports setting both mouse acceleration AND mouse sensitivity. I don't want any mouse acceleration, but I want to increase the speed of my mouse. That means that if I move the mouse the same distance, the pointer will move the same distance every time, no matter how quickly I move the mouse.

KDE will let me set mouse acceleration to 1x, but the mouse moves too slow then, and I can't figure out how to increase the speed. I am willing to accept a CLI solution, but I have only been able to get xinput to change acceleration. I don't recall having much luck with xset, either.

Best Answer

Just force the pointer to skip pixels, here's how:

First list input devices:

$ xinput list
⎡ Virtual core pointer                          id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer                id=4    [slave  pointer  (2)]
⎜   ↳ PixArt USB Optical Mouse                  id=10   [slave  pointer  (2)]
⎜   ↳ ETPS/2 Elantech Touchpad                  id=15   [slave  pointer  (2)]
⎣ Virtual core keyboard                         id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard               id=5    [slave  keyboard (3)]
    ↳ Power Button                              id=6    [slave  keyboard (3)]
    ↳ Video Bus                                 id=7    [slave  keyboard (3)]
    ↳ Sleep Button                              id=8    [slave  keyboard (3)]
    ↳ USB2.0 UVC 2M WebCam                      id=9    [slave  keyboard (3)]
    ↳ Asus Laptop extra buttons                 id=13   [slave  keyboard (3)]
    ↳ AT Translated Set 2 keyboard              id=14   [slave  keyboard (3)]
    ↳   USB Keyboard                            id=11   [slave  keyboard (3)]
    ↳   USB Keyboard                            id=12   [slave  keyboard (3)]

In the example we see the mouse is PixArt USB Optical Mouse. Next list its properties:

$ xinput list-props "PixArt USB Optical Mouse"
Device 'PixArt USB Optical Mouse':
        Device Enabled (140):   1
        Coordinate Transformation Matrix (142): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
        Device Accel Profile (265):     0
        Device Accel Constant Deceleration (266):       1.000000
        Device Accel Adaptive Deceleration (267):       1.000000
        Device Accel Velocity Scaling (268):    10.000000
        Device Product ID (260):        2362, 9488
        Device Node (261):      "/dev/input/event5"
        Evdev Axis Inversion (269):     0, 0
        Evdev Axes Swap (271):  0
        Axis Labels (272):      "Rel X" (150), "Rel Y" (151), "Rel Vert Wheel" (264)
        Button Labels (273):    "Button Left" (143), "Button Middle" (144), "Button Right" (145), "Button Wheel Up" (146), "Button Wheel Down" (147), "Button Horiz Wheel Left" (148), "Button Horiz Wheel Right" (149)
        Evdev Middle Button Emulation (274):    0
        Evdev Middle Button Timeout (275):      50
        Evdev Third Button Emulation (276):     0
        Evdev Third Button Emulation Timeout (277):     1000
        Evdev Third Button Emulation Button (278):      3
        Evdev Third Button Emulation Threshold (279):   20
        Evdev Wheel Emulation (280):    0
        Evdev Wheel Emulation Axes (281):       0, 0, 4, 5
        Evdev Wheel Emulation Inertia (282):    10
        Evdev Wheel Emulation Timeout (283):    200
        Evdev Wheel Emulation Button (284):     4
        Evdev Drag Lock Buttons (285):  0

By changing "Coordinate Transformation Matrix" property we can increase the pointer speed. Documentation says it is used to calculate a pointer movement. Quoting:

By default, the CTM for every input device in X is the identity matrix. As an example, lets say you touch a touchscreen at point (400, 197) on the screen:

⎡ 1 0 0 ⎤   ⎡ 400 ⎤   ⎡ 400 ⎤
⎜ 0 1 0 ⎥ · ⎜ 197 ⎥ = ⎜ 197 ⎥
⎣ 0 0 1 ⎦   ⎣  1  ⎦   ⎣  1  ⎦

The X and Y coordinates of the device event are input in the second matrix of the calculation. The result of the calculation is where the X and Y coordinates of the event are mapped to the screen. As shown, the identity matrix maps the device coordinates to the screen coordinates without any changes.

So, we want to increase X and Y values, leaving the rest unchanged. An example from my PC:


$ xinput set-prop "PixArt USB Optical Mouse" "Coordinate Transformation Matrix" 2.4 0 0 0 2.4 0 0 0 1

Play a bit with this until you're satisfied with the speed.

thanks go to Simon Thum from Xorg mailing list for giving a hint about the matrix.

UPD: note, some Windows games running in Wine may start exhibiting odd pointer behavior (e.g. it was noted that crosshair in Counter Strike 1.6 declines down until it stares the floor no matter how you move the mouse), in this case just reset X and Y of CTM back to 1 before running the game.

Related Question