Dual booting: every time Windows boots, it increases the scrolling speed of the mouse on Ubuntu

Reset mouse

Windows has a habit of leaving devices in an unusual state when it reboots. It works fine when you reboot from Windows into Windows but there are problems rebooting from Windows into Grub and then into Ubuntu.

The OP's question is just one example where the mouse has incorrect scrolling speed. Other examples include Windows powering off Audio Cards, WiFi or Network adapters can also occur.


Here is a new script I've tested and doesn't lock up the mouse/keyboard like the first script did.

Add this script to /usr/local/bin/reset-usb:

#!/bin/bash

# NAME: /usr/local/bin/reset-usb
# DATE: August 17, 2018.
# DESC: Written for Ask Ubuntu Question:
#       https://askubuntu.com/questions/1061754
#       Reboots / resets all USB devices including mouse & WiFi

if [[ $(id -u) != 0 ]]; then # root powers needed to call this script
    echo $0 must be called with sudo powers
    exit 1
fi

for i in /sys/bus/pci/drivers/[uoex]hci_hcd/*:*; do
  [ -e "$i" ] || continue
  echo "${i##*/}" > "${i%/*}/unbind"
  echo "${i##*/}" > "${i%/*}/bind"
done

systemctl restart NetworkManager.service

exit 0

Mark the file as executable with:

sudo chmod +x /usr/local/bin/reset-usb

Edit the file /etc/rc.local and insert these lines before the last line that says exit 0:

# Reboot / reset all USB devices
/usr/local/bin/reset-usb

Credit: How do you reset a USB device from the command line?


NOTE: When internal USB devices are reset the WiFi / Bluetooth are reinitialized so systemctl restart NetworkManager.


Obviously, the KISS (Keep It Simply Stupid) answer is:

  • Shut down Windows
  • Press the power button to boot into Ubuntu.

Why?

The Windows driver leaves the mouse in an unstable state and none of the really smart answers seem to work, which leads me to the conclusion that Ubuntu cannot solve this Windows problem.

You can still file a bug to the developers of the driver (which is off-topic here), but this is a side-effect and notoriously difficult to debug. Expect to spend a lot of time on this if you go that way


The mouse must have DPI setting that windows modified when it starts up. Normally for best response, the system will disable software mouse acceleration and set the mouse DPI to a value that provide the desire movement speed.

When you reboot back to Ubuntu without power cycle the mouse the DPI setting is still at the level that is set by Windows. However, Ubuntu by default have mouse accerelartion set to more than x 1 speed, and hence you experience the faster motion.

You can remove mouse acceleration in Ubuntu so that you can switch between Windows and Ubuntu to get similar mouse movement speed but you may get a very slow mouse motion if you power on to Ubuntu directly unless your mouse support DPI setting memory that doesn't change over power cycle.

Remove mouse acceleration in Ubuntu, create the following file:

sudo nano /usr/share/X11/xorg.conf.d/50-mouse-accel-disable.conf

Content of the file:

Section "InputClass"
    Identifier "Microsoft Mouse"
    MatchIsPointer "yes"
    Option "AccelerationProfile" "-1"
    Option "AccelerationScheme" "none"
    Option "AccelSpeed" "-1"
EndSection

Restart your session for this change to take into use (i.e., logout/login)