xf86-input-mtrack icon indicating copy to clipboard operation
xf86-input-mtrack copied to clipboard

Added ScrollCoastNoBoost and ScrollCoastEase options

Open tarkh opened this issue 3 years ago • 19 comments

Please consider following patch:

  1. Added ScrollCoastNoBoost option, which prevents speed multiplication on subsequent scroll gestures while coasting still running. This behaviour was mentioned in following issues: #99 #59. Boolean value, default false.
  2. Added ScrollCoastEase option, which applying ease effect on coasting movement and creating non-linear slow down. Close to easeInOutCubic logic. Boolean value, default false.

To test this options, please set:

Option "GestureClickTime" "20"
Option "GestureWaitTime" "50"
Option "ScrollSmooth" "true"
Option "ScrollCoastDuration" "1000"
Option "ScrollCoastEnableSpeed" "0.05"
Option "ScrollCoastNoBoost" "true"
Option "ScrollCoastEase" "true"
Option "ScrollDistance" "650"
Option "ScrollClickTime" "5"

* Last two options depends on your touchpad hardware. ** To enable smooth scrolling and coasting controlled by xinput in Firefox, add following env: MOZ_USE_XINPUT2=1

Patch was tested on Arch Linux @ MacBookPro Late 2014.

tarkh avatar Nov 19 '21 19:11 tarkh

This works great for me! I'm so glad I came across this driver when I did, this was a very welcome addition to the inertial scrolling, it feels way more fluid when flick-scrolling.

chuck-r avatar Nov 28 '21 21:11 chuck-r

Hi! This PR is very cool! However: ScrollCoastNoBoost doesn't seem to work. This, combined with the longer coast set to get some nice easing results (700 to 1000) means I get the boost quite often.

Coasting doesn't seem to be very consistent, sometimes I don't get any. I scroll, release my fingers from the trackpad, and scrolling stops right away, especially on scrolling up for some reason. It might be because of my config, though. You can see it below.

In any case, I love the idea for this PR and thank you for working on it.

Here's my config:

Section "InputClass"
        MatchIsTouchpad "on"
        Identifier      "Touchpads"
        MatchDevicePath "/dev/input/event*"
        Driver          "mtrack"
        # The faster you move, the more distance pointer will travel, using "polynomial" profile
        Option          "AccelerationProfile" "2"
        # Tweak cursor movement speed with this
        Option          "Sensitivity" "0.1"
        # Pressure at which a finger is detected as a touch
        Option          "FingerHigh" "5"
        # Pressure at which a finger is detected as a release
        Option          "FingerLow" "5"
        # I often use thumb to press down the physical button, so let's not ignore it
        Option          "IgnoreThumb" "false"
        Option          "ThumbRatio" "70"
        Option          "ThumbSize" "23"
        # Ignore palm, with palm takes up to 30% of your touch pad
        Option          "IgnorePalm" "true"
        Option          "PalmSize" "30"
        # Trigger mouse button when tap: 1 finger - left click, 2 finger - right click, 3 - middle click
        Option          "TapButton1" "1"
        Option          "TapButton2" "3"
        Option          "TapButton3" "2"
        Option          "TapButton4" "0"
        Option          "ClickTime" "50"
        # Disable tap-to-drag, we're using three finger drag instead
        Option          "TapDragEnable" "false"
        # While touching the touch pad with # fingers, press the touchpad physical click button
        Option          "ClickFinger0" "1"
        Option          "ClickFinger1" "1"
        Option          "ClickFinger2" "3"
        Option          "ClickFinger3" "2"
        Option          "ButtonMoveEmulate" "false"
        Option          "ButtonIntegrated" "true"
        # The momentum after scroll fingers released
        Option          "ScrollCoastDuration" "700"
        Option          "ScrollCoastEnableSpeed" ".01"
        Option          "ScrollCoastNoBoost" "true"
        Option          "ScrollCoastEase" "true"
        # Natural scrolling with two fingers
        Option          "ScrollSmooth" "true"
        Option          "ScrollUpButton" "5"
        Option          "ScrollDownButton" "4"
        Option          "ScrollLeftButton" "7"
        Option          "ScrollRightButton" "6"

        # Tweak scroll sensitivity with ScrollDistance, don't touch ScrollSensitivity
        # Option          "ScrollDistance" "650"
        # Option          "ScrollClickTime" "20"
        Option          "ScrollDistance" "270"
        Option          "ScrollClickTime" "1"

        # Three finger swipe
        Option          "SwipeDistance" "700"
        Option          "SwipeLeftButton" "10"
        Option          "SwipeRightButton" "11"
        Option          "SwipeUpButton" "12"
        Option          "SwipeDownButton" "13"
        Option          "SwipeClickTime" "300"
        Option          "SwipeSensitivity" "0"

        # Four finger swipe
        Option          "Swipe4LeftButton" "14"
        Option          "Swipe4RightButton" "15"
        Option          "Swipe4UpButton" "16"
        Option          "Swipe4DownButton" "17"

        # Mouse buttons triggered by 2-finger pinching gesture
        Option          "ScaleDistance" "300"
        Option          "ScaleUpButton" "18"
        Option          "ScaleDownButton" "19"
        # Mouse buttons trigger by 2-finger rotating gesture, disabled to enhance the pinch gesture
        Option          "RotateLeftButton" "0"
        Option          "RotateRightButton" "0"
        Option          "TabDragEnable" "false"
        Option          "GestureClickTime" "1"
        Option          "GestureWaitTime" "0"
EndSection

Vermoot avatar Dec 28 '21 20:12 Vermoot

Hi! This PR is very cool! However: ScrollCoastNoBoost doesn't seem to work. This, combined with the longer coast set to get some nice easing results (700 to 1000) means I get the boost quite often.

Coasting doesn't seem to be very consistent, sometimes I don't get any. I scroll, release my fingers from the trackpad, and scrolling stops right away, especially on scrolling up for some reason. It might be because of my config, though. You can see it below.

In any case, I love the idea for this PR and thank you for working on it.

Hi, thanks for reply! Maybe there is something with hardware specificity of other touchpads... I've only tested it on my MacBookPro machine and on ASUS K55 (both on Arch Linux), where this two options work pretty stable (on MacBookPro obviously better). I was facing some problems with no coasting after two finger up/down gestures in rare cases, but fixed it with setting lower value of ScrollCoastEnableSpeed option. Maybe there is some other config option tweaks needed for your particular hardware. Below is my active working config:

Section "InputClass"
  MatchIsTouchpad "on"
  Identifier "Touchpads"
  MatchDevicePath "/dev/input/event*"
  Driver "mtrack"
  # Physical buttons
  Option "ButtonEnable" "true"
  Option "ButtonIntegrated" "true"
  # Zones
  Option "ButtonZonesEnable" "true"
  Option "FirstZoneButton" "1"
  Option "SecondZoneButton" "2"
  Option "ThirdZoneButton" "3"
  Option "LimitButtonZonesToBottomEdge" "true"
  Option "EdgeBottomSize" "0"
  # Gesture wait time
  Option "GestureWaitTime" "20"
  # The faster you move, the more distance pointer will travel, using "polynomial" profile
  Option "AccelerationProfile" "0"
  # Tweak cursor movement speed with this
  Option "Sensitivity" "0.15"
  # Pressure at which a finger is detected as a touch
  Option "FingerHigh" "8"
  # Pressure at which a finger is detected as a release
  Option "FingerLow" "7"
  # I often use thumb to press down the physical button, so let's not ignore it
  Option "IgnoreThumb" "false"
  Option "ThumbRatio" "70"
  Option "ThumbSize" "25"
  # Ignore palm, with palm takes up to 30% of your touch pad
  Option "IgnorePalm" "true"
  Option "PalmSize" "40"
  # Trigger mouse button when tap: 1 finger - left click, 2 finger - right click, 3 - middle click
  Option "TapButton1" "1"
  Option "TapButton2" "3"
  Option "TapButton3" "2"
  Option "TapButton4" "0"
  Option "ClickTime" "25"
  # Disable tap-to-drag, we're using three finger drag instead
  Option "TapDragEnable" "false"
  # While touching the touch pad with # fingers, press the touchpad physical click button
  Option "ClickFinger1" "1"
  Option "ClickFinger2" "3"
  Option "ClickFinger3" "2"
  Option "ButtonMoveEmulate" "false"
  Option "ButtonIntegrated" "true"
  # The momentum after scroll fingers released
  Option "ScrollCoastDuration" "950"
  Option "ScrollCoastEnableSpeed" "0.05"
  Option "ScrollCoastNoBoost" "true"
  Option "ScrollCoastEase" "true"
  # Natural scrolling with two fingers
  Option "ScrollSmooth" "true"
  Option "ScrollUpButton" "4"
  Option "ScrollDownButton" "5"
  Option "ScrollLeftButton" "7"
  Option "ScrollRightButton" "6"
  # Tweak scroll sensitivity with ScrollDistance, don't touch ScrollSensitivity
  Option "ScrollDistance" "650"
  Option "ScrollClickTime" "20"
  # Three finger drag
  Option "SwipeDistance" "1"
  Option "SwipeLeftButton" "1"
  Option "SwipeRightButton" "1"
  Option "SwipeUpButton" "1"
  Option "SwipeDownButton" "1"
  Option "SwipeClickTime" "0"
  Option "SwipeSensitivity" "1500"
  # Four finger swipe, 8 & 9 are for browsers navigating back and forth respectively
  Option "Swipe4LeftButton" "9"
  Option "Swipe4RightButton" "8"
  # Mouse button >= 10 are not used by Xorg, so we'll map them with xbindkeys and xdotool later
  Option "Swipe4UpButton" "11"
  Option "Swipe4DownButton" "10"
  # Mouse buttons triggered by 2-finger pinching gesture
  Option "ScaleDistance" "300"
  Option "ScaleUpButton" "12"
  Option "ScaleDownButton" "13"
  # Mouse buttons trigger by 2-finger rotating gesture, disabled to enhance the pinch gesture
  Option "RotateLeftButton" "0"
  Option "RotateRightButton" "0"
EndSection

tarkh avatar Dec 29 '21 16:12 tarkh

I'm on a 2014 Macbook Pro and even using the same settings as you are, I still got boost when scrolling while the coasting hasn't finished :thinking:

Vermoot avatar Dec 30 '21 11:12 Vermoot

That's strange... I have same Macbook Pro 2014... Are you sure you deleted the master mtrack from your system and build my particular fork? We need to trace this...

tarkh avatar Dec 30 '21 15:12 tarkh

I am running this on a Macbook Pro 2015 without issue. This branch fixed my scroll issues.

musotec avatar Dec 30 '21 22:12 musotec

I’ll have to check, then, I might have instated it wrong. Though I do have the ScrollCoastEase part working for sure. Doesn’t that mean I’m for sur on the right version of the driver?

Vermoot avatar Dec 30 '21 23:12 Vermoot

Pushed little code optimization for ScrollCoastEase calculation.

@Vermoot ScrollCoastNoBoost must obviously work, there is pretty straightforward fix. To fix coasting consistency try this settings:

Option "GestureClickTime" "20"
Option "GestureWaitTime" "50"
Option "ScrollCoastEnableSpeed" "0.5"

edited

Option "ScrollCoastEnableSpeed" "0.05"

tarkh avatar Dec 31 '21 11:12 tarkh

Coasting is even more difficult to start with these options somehow :thinking:

For reference, here is my whole, up-to-date config again. I did install the driver from your up-to-date scrollCoastingEnhancement branch.

My current config
Section "InputClass"
        MatchIsTouchpad "on"
        Identifier      "Touchpads"
        MatchDevicePath "/dev/input/event*"
        Driver          "mtrack"

        # Tweak cursor movement speed with this
        # The faster you move, the more distance pointer will travel, using "polynomial" profile
        Option          "Sensitivity" "0.1"
        Option          "AccelerationProfile" "2"

        # Pressure at which a finger is detected as a touch
        # Pressure at which a finger is detected as a release
        Option          "FingerHigh" "5"
        Option          "FingerLow" "5"

        # I often use thumb to press down the physical button, so let's not ignore it
        Option          "IgnoreThumb" "false"
        Option          "ThumbRatio" "70"
        Option          "ThumbSize" "23"
        # Ignore palm, with palm takes up to 30% of your touch pad
        Option          "IgnorePalm" "true"
        Option          "PalmSize" "30"

        # Trigger mouse button when tap: 1 finger - left click, 2 finger - right click, 3 - middle click
        Option          "TapButton1" "1"
        Option          "TapButton2" "3"
        Option          "TapButton3" "2"
        Option          "TapButton4" "0"
        Option          "ClickTime" "50"

        # Disable tap-to-drag, we're using three finger drag instead
        Option          "TapDragEnable" "true"

        # While touching the touch pad with # fingers, press the touchpad physical click button
        Option          "ClickFinger0" "1"
        Option          "ClickFinger1" "1"
        Option          "ClickFinger2" "3"
        Option          "ClickFinger3" "2"
        Option          "ButtonMoveEmulate" "false"
        Option          "ButtonIntegrated" "true"

        # The momentum after scroll fingers released
        Option          "ScrollCoastDuration" "950"
        Option          "ScrollCoastEnableSpeed" "0.5"
        Option          "ScrollCoastNoBoost" "true"
        Option          "ScrollCoastEase" "true"

        # Natural scrolling with two fingers
        Option          "ScrollSmooth" "true"
        Option          "ScrollUpButton" "5"
        Option          "ScrollDownButton" "4"
        Option          "ScrollLeftButton" "7"
        Option          "ScrollRightButton" "6"

        # Tweak scroll sensitivity with ScrollDistance, don't touch ScrollSensitivity
        Option          "ScrollDistance" "650"
        Option          "ScrollClickTime" "20"

        # Three finger swipe
        Option          "SwipeDistance" "500"
        Option          "SwipeLeftButton" "10"
        Option          "SwipeRightButton" "11"
        Option          "SwipeUpButton" "12"
        Option          "SwipeDownButton" "13"
        Option          "SwipeClickTime" "300"
        Option          "SwipeSensitivity" "0"

        # Four finger swipe
        Option          "Swipe4Distance" "14"
        Option          "Swipe4LeftButton" "14"
        Option          "Swipe4RightButton" "15"
        Option          "Swipe4UpButton" "16"
        Option          "Swipe4DownButton" "17"

        # Mouse buttons triggered by 2-finger pinching gesture
        Option          "ScaleDistance" "300"
        Option          "ScaleUpButton" "18"
        Option          "ScaleDownButton" "19"
        # Mouse buttons trigger by 2-finger rotating gesture, disabled to enhance the pinch gesture
        Option          "RotateLeftButton" "0"
        Option          "RotateRightButton" "0"
        Option          "TabDragEnable" "false"
        Option          "GestureClickTime" "20"
        Option          "GestureWaitTime" "50"
EndSection

Vermoot avatar Jan 01 '22 12:01 Vermoot

@Vermoot ups, my bad, set ScrollCoastEnableSpeed to 0.05 not 0.5)) For fixing issues with consistency of coasting (while you already scrolling) these options is important:

Option "GestureClickTime" "20"
Option "GestureWaitTime" "50"

Also try to set AccelerationProfile to 0, maybe it causing issues with coasting boost, I never tried this feature...

tarkh avatar Jan 01 '22 13:01 tarkh

Alright, coasting consistency is perfect now, everything works well except for ScrollCoastNoBoost.

Either with or without AccelerationProfile, I still get the boost. I'm not sure what to do now, or what could be relevant.

Vermoot avatar Jan 01 '22 22:01 Vermoot

I just tried plainly copying your config from above, and the boost is still present (And to be clear your config is indeed applied, and I feel like I'm using someone else's computer :smile: )

Vermoot avatar Jan 01 '22 22:01 Vermoot

@Vermoot )) ok, that’s strange… Let’s clear what you mean by accel boost then) So now if you scroll again while it’s still coasting your scroll progress goes crazy and start scrolling multiple times faster? Right? Or it’s something else? Maybe it’s possible to capture screen for demo..

tarkh avatar Jan 02 '22 10:01 tarkh

Yep that's exacty it!

Vermoot avatar Jan 02 '22 10:01 Vermoot

hmm... then I have no idea except that something is not installed... How do you build it? You on Arch linux or another distro? The process is pretty straightforward:

git clone [email protected]:tarkh/xf86-input-mtrack.git
cd xf86-input-mtrack
autoreconf --install
./configure --prefix=/usr
make
sudo make install

tarkh avatar Jan 02 '22 10:01 tarkh

I am on Arch indeed, and build it using ./configure, then make && make install.

I should try and do it all over again, start fresh from your repo (from the scrollCoastingEnhancement branch, right?).

I should probably know this already, but is there any way I can just remove mtrack from my system and be sure to start fresh?

Vermoot avatar Jan 02 '22 10:01 Vermoot

well you can remove mtrack with pacman like sudo pacman -R mtrack if it was installed from this AUR or sudo pacman -R mtrack-git if it was installed from this AUR. If you manually build and installed it straight from this github, then you can try to remove it from your selected location manually.

Pay attention to --prefix, without this option it will be installed in /usr/local/lib/xorg/modules/input/, but with --prefix=/usr in /usr/lib/xorg/modules/input/. And we need second option obviously.

  • reboot after install

tarkh avatar Jan 02 '22 10:01 tarkh

Welp, problem fixed.

I don't know what kind of a frankenstein install I had before, but I started fresh by removing the module from anywhere I could find it (in the paths you mentioned above), restarted X to verify I was on libinput, and then re-cloned, re-installed mtrack following your instructions: everything works as intended.

Thank you very much, both for your awesome contribution to mtrack and for taking the time to help me with my install. My trackpad feels as good as ever.

Vermoot avatar Jan 02 '22 11:01 Vermoot

Hey thanks a lot for this. Scrolling on my 2011 MBP feels really nice now. BTW I also had to reconfigure with --prefix=/usr on Ubuntu 20.04

I hope this PR gets the attention it deserves.

andolivieri avatar Feb 16 '22 11:02 andolivieri

@tarkh Thanks man, merged. You may also consider adding your config to the existing examples.

p2rkw avatar May 21 '23 21:05 p2rkw