How do I fix very slow scrolling USB wheel mouse (after waking from suspend) which started after upgrade to 19.04?

6,729

Solution 1

ResetMsMice

A special program has been released to reset Microsoft Mice when dual booting Windows and Linux experiences insanely fast scrolling. It has just been confirmed to work for Ubuntu 19.04 suspend/resume problem of insanely slow scrolling.

Go to this site: https://sourceforge.net/projects/resetmsmice/

Click the link for: resetmsmice_1.1.3_amd64.deb

It is instantly downloaded to your ~/Downloads folder.

To install it use:

sudo dpkg -i ~/Downloads/resetmsmice_1.1.3_amd64.deb
rm -f ~/Downloads/resetmsmice_1.1.3_amd64.deb

The program automatically runs during boot but you can also call it from the terminal at any time with:

resetmsmice

To automatically call it after resuming you need to create a script with gedit.

Use sudo -H gedit /lib/systemd/system-sleep/resetmsmice

Copy these lines into the editor:

#!/bin/bash
case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
        ;;
  post/*)
    echo "$0: Waking up from $2..."
    resetmsmice
        ;;
esac

The echo statements help you locate your program in system logs, eg grep resetmsmice Save the file and exit the editor. Then use:

sudo chmod a+x /lib/systemd/system-sleep/resetmsmice

Original Answer

You can power off the USB mouse during suspend and power it on during resume. This will simulate a reboot.

Use sudo -H gedit /lib/systemd/system-sleep/custom-xhci_hcd

Copy these lines into the editor:

#!/bin/bash

# Original script was using /bin/sh but shellcheck reporting warnings.

# NAME: custom-xhci_hcd
# PATH: /lib/systemd/system-sleep
# CALL: Called from SystemD automatically
# DESC: Suspend broken for USB3.0 as of Oct 25/2018 various kernels all at once

# DATE: Oct 28 2018.

# NOTE: From comment #61 at: https://bugs.launchpad.net/ubuntu/+source/linux/+bug/522998

TMPLIST=/tmp/xhci-dev-list

# Original script was: case "${1}" in hibernate|suspend)

case $1/$2 in
  pre/*)
    echo "$0: Going to $2..."
    echo -n '' > $TMPLIST
          for i in `ls /sys/bus/pci/drivers/xhci_hcd/ | egrep '[0-9a-z]+\:[0-9a-z]+\:.*$'`; do
              # Unbind xhci_hcd for first device XXXX:XX:XX.X:
               echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/unbind
           echo "$i" >> $TMPLIST
          done
        ;;
  post/*)
    echo "$0: Waking up from $2..."
    for i in `cat $TMPLIST`; do
              # Bind xhci_hcd for first device XXXX:XX:XX.X:
              echo -n "$i" | tee /sys/bus/pci/drivers/xhci_hcd/bind
    done
    rm $TMPLIST
        ;;
esac

Save the file and exit the editor. Then use:

sudo chmod a+x /lib/systemd/system-sleep/custom-xhci_hcd

Ubuntu 19.04 upgrade delivers the new Linux 5.0 kernel with new drivers. After future upgrades are done, deactivate the script to see if the problem has been fixed in new kernels.

Solution 2

Turn off and on the mouse or unplug and plug in the cable.

Share:
6,729

Related videos on Youtube

Dennis
Author by

Dennis

Just a typical computer user that gets to bang on the keyboard most of the day. Primarily data collection in a CAD environment. Since I like to poke around and read up on things that interest me I end up getting most of the support calls in the friends and family circle. Windows at work, Ubuntu at home (main accomplishment has been switching wife and several kids, friends, boss to full time open source use), Python for fun and work with it embedded in our CAD system. Wish I had grown up to be a developer since "garbage collection" in my first programing environment meant picking up your punch cards if you weren't careful.

Updated on September 18, 2022

Comments

  • Dennis
    Dennis almost 2 years

    This morning before I upgraded when I rolled the scroll wheel any active program would scroll as long as the wheel was turning. After upgrade to 19.04 after waking from suspend (closing the laptop) when I roll the wheel the view scrolls a few lines then stops, it won't scroll again until I spin the scroll wheel a few more times.

    Microsoft Wireless Mobile Mouse 4000

    It happens in every program including a virtual-box boot up of Windows, and only seems to be after waking from suspend. Unplugging the USB receiver and plugging it back in restores the sensitivity but to me that isn't a fix, jsut a work around.

    How do I stop whatever system behavior in suspend which is disrupting the mouse settings? How do I restore it without physical intervention (automatically on wake up if possible)

    And why did the upgrade break it, or could it be that much of a coincidence?

  • Dennis
    Dennis about 5 years
    Tried it and double checked everything to the best of my ability but I don't see any difference. Is there a way I can check what I'm doing.
  • WinEunuuchs2Unix
    WinEunuuchs2Unix about 5 years
    @Dennis Sure. Do a suspend and resume. Then use journalctl -xe which will bring you to end of system messages then page up. You'll see the system suspend and resume messages. Look for custom-xhci_hcd and you should see USB devices being turn off during suspend and turned on during resume. If there is an error message instead (or it doesn't appear) let me know. If you need more clarification I'll update answer with example of reading system log.
  • Dennis
    Dennis about 5 years
    There is a reference to the custom-xhci_hcd with no errors near it, several lines that look like usb 2-1.2: reset full-speed USB device number 6 using ehci-pci prior to the reference to it. The mouse works fine in every respect except the speed of the scroll wheel until I re-insert the receiver.
  • WinEunuuchs2Unix
    WinEunuuchs2Unix about 5 years
    @Dennis Turns out there are many bugs reported with Microsoft Mice when dual booting and when resuming. There are also many fixes published. Here is one that might be inserted into the script I posted above: sourceforge.net/projects/resetmsmice Also a related problem with Microsoft Mouse and 19.04 was posted today: askubuntu.com/questions/1140117/…
  • Dennis
    Dennis about 5 years
    Yes that post sounds like mine. Though I don't dual boot the resetmsmice does solve the problem and can be run from the command line. Running at each resume is necessary for me because the "on boot" setting doesn't do anything for resume, but at least I don't have to unplug it each time. If you want to at that as an "if the script doesn't work, try...." in your answer I'll accept that as the best available option.
  • WinEunuuchs2Unix
    WinEunuuchs2Unix about 5 years
    @Dennis I added resetmsmice to the top of the answer.
  • scopchanov
    scopchanov over 3 years
    Is this an issue, or a solution?