How to disable a mouse movement input, while leaving mouse buttons enabled?

You can use xinput.

>xinput --list
⎡ Virtual core pointer                      id=2    [master pointer  (3)]
⎜   ↳ Virtual core XTEST pointer            id=4    [slave  pointer  (2)]
⎜   ↳ Mouse0                                id=6    [slave  pointer  (2)]
⎣ Virtual core keyboard                     id=3    [master keyboard (2)]
    ↳ Virtual core XTEST keyboard           id=5    [slave  keyboard (3)]
    ↳ Keyboard0

There you get the name of the mouse in this case Mouse0.

With the following command you slow down the speed of your mouse by a factor of 100000, which is then basically zero.

xinput --set-prop 6 'Device Accel Constant Deceleration' 100000

or

xinput --set-prop Mouse0 'Device Accel Constant Deceleration' 100000

To revert you can use the same

xinput --set-prop Mouse0 'Device Accel Constant Deceleration' 1

My mouse does not have 'Device Accel Constant Deceleration' property. I was still able to disable motion with

xinput set-prop 9 266 -1    
xinput set-prop 9 269 0 1

and reenable it with

xinput set-prop 9 269 1 0
input set-prop 9 266 0.0

I also disabled my buttons with

xinput set-button-map 9 0 0 0

Device 9 being my Mitsumi Electric Apple Optical USB Mouse.

Device list

Device 'Mitsumi Electric Apple Optical USB Mouse':
    Device Enabled (132):   1
    Coordinate Transformation Matrix (134): 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000
    libinput Accel Speed (266):     -1.000000
    libinput Accel Speed Default (267):     0.000000
    libinput Accel Profiles Available (268):        0, 0
    libinput Accel Profile Enabled (269):   0, 1
    libinput Accel Profile Enabled Default (270):   1, 0
    libinput Natural Scrolling Enabled (271):       0
    libinput Natural Scrolling Enabled Default (272):       0
    libinput Send Events Modes Available (250):     1, 0
    libinput Send Events Mode Enabled (251):        0, 0
    libinput Send Events Mode Enabled Default (252):        0, 0
    libinput Left Handed Enabled (273):     0
    libinput Left Handed Enabled Default (274):     0
    libinput Scroll Methods Available (275):        0, 0, 1
    libinput Scroll Method Enabled (276):   0, 0, 0
    libinput Scroll Method Enabled Default (277):   0, 0, 0
    libinput Button Scrolling Button (278): 2
    libinput Button Scrolling Button Default (279): 274
    libinput Middle Emulation Enabled (280):        0
    libinput Middle Emulation Enabled Default (281):        0
    Device Node (253):      "/dev/input/event4"
    Device Product ID (254):        1452, 772
    libinput Drag Lock Buttons (282):       <no items>
    libinput Horizonal Scroll Enabled (255):        1

If I read man 4 mousedrv correctly, you could set, in the CorePointer section of your xorg.conf,

Option "EmulateWheel" true
Option "EmulateWheelButton" 0
Option "EmulateWheelInertia" 10000

which would convert movements into mouse wheel button events, but the inertia setting would make it too insensitive to ever register one. On modern systems, it is evdev instead of mousedrv. This can also be set at runtime using xinput, for example:

xinput --set-prop 17 'Evdev Wheel Emulation' 1
xinput --set-prop 17 'Evdev Wheel Emulation Button' 0
xinput --set-prop 17 'Evdev Wheel Emulation Inertia' 10000

Where 17 should be your own device number. I use a function to get this number by the device name, and store it in $device-id during a startup script.

set_device_id() {
  device_id=$(xinput --list | grep -m 1 "$1")
  device_id=${device_id##*id=}
  device_id=${device_id%%[[:space:]]*}
}

This unfortunately has the side effect of disabling scroll wheel input of the device.

Tags:

X11

Mouse