Hacker News new | past | comments | ask | show | jobs | submit login
Mouse scroll wheel acceleration, implemented in user space (github.com/albertz)
75 points by albertzeyer on April 16, 2023 | hide | past | favorite | 54 comments



Ages ago, in my own editor (and missing HP chipmunk physical "paddle wheel" scrolling), I implemented the following mouse scrolling scheme:

    - Integrate the area* enclosed by recent mouse movement
    - Ignore everything under a threshold (this is normal, straight-line, mousing)
    - Scroll according to the sign of the area.
        . naively this would be slow scroll for small circles; fast for large
        . but I found it more intuitive to reverse the action:
            the bigger the gesture, the more controlled the scroll
            (probably closer to scroll-by-radian than scroll-by-area)
It looks like I could use this package to do something similar, only system-wide and portably, but I mention it here as it's the sort of project I'm extremely unlikely to Get Around To (and would therefore be chuffed if someone else were to!)

* https://en.wikipedia.org/wiki/Planimeter


Both Synaptics and ELAN drivers offered circular/chiral scrolling, but it seems this option is not prominently featured (or maybe unavailable) in Windows 10 and above.

IIRC the gesture starts at the edge of the trackpad much like regular edge scrolling, but then you can extend the motion to the entire working area of the trackpad, pretending to spin an imaginary jog wheel.


It was also implemented physically in some mouses

for example, Logtiech G502: " Dual-Mode Hyper-Fast Scroll Wheel

Unlock the scroll wheel for hyper-fast continuous scrolling to spin quickly through long pages, or lock it down for single click precision scrolling. The weighty, metal wheel delivers confident, smooth and satisfying control for either mode. "

https://www.youtube.com/watch?v=aANF2OOVX40 ( Interstellar Mouse ^^ )


This is what I love about the MX Master 3, it's like a hybrid for this where it has precision scrolling when moving it slowly but give it a flick and it will automatically unlock and go into smooth scrolling. https://youtu.be/KTzZui0nrrs

I wish this feature was on more mice


> I wish this feature was on more mice

Logitech owns a patent[0] on this mechanism which prevents it from being incorporated in other products (without licensing it).

[0] https://patents.google.com/patent/US20110227828A1/en

> The present invention generally relates to a control device, such as a mouse, and more particularly relates to multi-mode roller for a control device having a selectable smooth-roller mode and a ratchet-roller mode.


I find this feature annoying and am very unhappy when it randomly activates due to some driver bug (requiring me to open the Logitech software and possibly reboot the mouse).


Yeah I’m addicted to it. I can't use any other mouse since trying the Mx Master 3 scroll wheel.


I switched to an Elecom huge trackball and miss that wheel every single day.

A year ago I figured out I could use a spare button to toggle using the trackball itself for free scroll, total game changer, but still miss that wheel.


MX Anywhere 3 also has this, the only ambidextrous option!


No. It's fake ambidextrous like most of Logitech's mice. It has buttons only usable by the right thumb and a subtle change in shape to accommodate them. The G903 is actually ambidextrous letting you customize whether you want buttons on the left or right side and still has the same sort of scroll wheel (although not automatic but I hate that feature anyways).


I click forward/back with my ring finger, but I guess it depends on your grip how achievable that is.


Until you have an unlocked wheel, you don’t know what you’re missing out on.

On the other hand, gestures in Firefox, specifically “Scroll to Bottom”, have made me miss mine less. Also, unlocked scroll wheels get you banned within seconds on Counter Strike servers for input lag.


My mouse (MX Master) has an unlockable wheel, and an auto-unlock feature. I have both disabled, precision scrolling is much better for my reading style, and it doesn't randomly trigger things.


>unlocked scroll wheels get you banned within seconds on Counter Strike servers for input lag

What's the connection between those two?


I meant to say input spam, sorry!


Sounds like an engine issue to me.


Endless accidental weapon changes


you can just click the scroll wheel


It’s a feature that I rolled my eyes at when I got my mouse, but now use several times a day. Unlock the wheel and spiiiiiiiiiiiiiin until I get far enough down the page. So much more convenient and versatile than clicking and dragging the scroll bar tab.


On Firefox I use ScrollAnywhere extension which I configure to use right-down drag to scroll large amounts with little movement. Helps tremendously with lengthy pages and I miss being able to use it in code editors.


The G502 is a phenomenal mouse


On Win 10 ours randomly changes dpi. The multi-user setup is abysmal; one user can screw up another's settings. It spams notifications when you cause a quick-change-dpi event (you can turn off notifications, it's a weird default). It works very badly without the app running, ie it's a soft-mouse tailored to Windows. There's no Logitech Linux app (though the one I use is superior to the Windows app, IMO, clearer with less cruft -- https://github.com/libratbag/piper). Latest update reverted my dpi settings.

I'm not particularly impressed.


I use mine on Linux but I don't use any application for settings. I set mine under windows using the internal memory on the mouse and I've never had it change anything randomly on me besides unknowingly hitting the physical DPI button by accident


I have one of those at my current job.

I very much dislike it. Probably because I'm not used to it.

Gnome, my DE, has all sorts of 'scroll on hover' tricks. Scroll while hovering an app icon, will "alt tab" between windows of that app. Scroll over the volume icon to up or down it. And so forth.

At least once a day, all my windows get jumbled, or the volume set to 100, because the wheel was spinning while I moved my mouse over something. I did learn of some nice scroll-on-hover features in Gnome this way, though.


I don't like DEs that move stuff around. I disable every gesture and shortcut in settings in my Gnome DEs, then I enable the bare minimum to switch between tabs of the same window, windows on the same virtual desktop and between desktops, scroll with the touchpad and basically that's it.


Just have to get used to it. I hate using other mice after using free spring for years. I lock it maybe a few times a year for the occassional need of discrete scroll wheel steps.


But that’s also a general Linux DEs issue. That windows take focus on hover, this has caused so many unintentional hotkey captures by other apps or as you say scroll capture


There are lots of options (in KDE at least), it's not like you have to have focus on hover, you can have focus-on- click, and IIRC set dwell times before focus kicks in.


I wish there would be a setting that the mouse works normal when locked, but would scroll one pixel at a time when unlocked. It feels very unnatural to scroll with an unlocked mousewheel and not scroll when doing small adjustments.


How would that have acceleration?


I used one of those mice for many years. It doesn't so much "enable acceleration" as it does "disable deceleration."

A button disengages the wheel from the detents that most mouse wheels have, so it acts like a flywheel.


The acceleration macOS has for boring old mice with boring old scroll wheels is atrocious. The first movement of the wheel barely scrolls things, and makes precise scrolling harder. I prefer the Windows behaviour of constant but usually larger (and configurable) distances.


Ah yes, the monday morning little ritual: try to move down a dozen lines, maybe half a page, scroll a bit and realized I moved 3 pixels. Try again scrolling a bit faster and end up zooming by 3 pages. Repeat in the other direction. Use the scroll bar out of desperation after 3 failed attempts.

Gets a bit better once the coffee and the muscle memory kick in, but I really wish Apple would give some love to common old-fashioned rodents instead of letting their users having to rely on community-made apps to have a decent behavior for those. I'm probably not the only one using a laptop provided by an employer with fairly strict rules about the installation of "unnecessary" software.


I'm a first time MacOS user thanks to issued equipment. Three months in and I hate it. Scroll acceleration is definitely in the top five list of reasons why.

The goofy keyboard shortcuts, the crummy window switching (switching between applications is different than switching between instances of an application), and wretched window management (inconsistent behavior around maximizing windows-typically bad-and no half or quarter screen snapping) are also on the list.

I'd be much happier with a Linux or Windows machine.


Funny because I can’t stand alt tab in Windows anymore. Alt tabbing through a bunch of windows just to go back to the other app I want to use. It used to be worse before tab systems collapsed all the window spam.

These days I like the distinction between tabbing through an app vs across apps. Only peeve is that alt tabbing to a minimized app should restore it.


I disable that wherever possible since I find it incredibly annoying. I just never have enough windows to want nested window switching.


Contexts.app (paid software) restores window/Linux alt1tab behavior.

Rectangle.app (OSS) does window snapping and does tiling-lite (which is what I want). I forget the name of the actually tiling WM.

Hammerspoon+custom script off github will get you drag move/resize functionality.


I’d recommend grabbing BetterSnapTool for window snapping. https://folivora.ai/bettersnaptool


I always struggle with the exact opposite problem. Mouse wheel acceleration feels incredibly unnatural to me and I can't turn it off on macOS.


I used to use Steelseries Exactmouse, but now we have https://github.com/linearmouse/linearmouse


After the last major update linear mouse is stuck for me in a kind of an infinite loop. It asks for accessibility permissions, while they are already enabled. I tried everything including reinstalling but it doesn’t work :(


linearmouse is a life-saver for my MX Master 3S, which feels awful on OSX compared to Windows.


Forgive me if I'm incorrect, but doesn't a user space implementation mean it does not understand to reset momentum between window focus events? So if I scroll like crazy in app1 then Alt-Tab to app2, scrolling carries to app2?


Yes that's correct. That's certainly a problem I sometimes actually observe.

Although you could extend it to handle that. But that makes it more platform dependent. E.g. on Linux and MacOS, the scroll events are send to the top-most window under the mouse cursor. It does not matter what window you have focused. I think on Windows it is always send to the focused windows?

PRs are welcome. :)


It could be designed either way; shared memory could allow current velocity etc to be shared between processes, or it could just not be shared. I haven't checked this implementation to see which it would be


Back in the late '90s I hacked a Genius NetMouse[1] to have pressure sensitive resistors under the scroll rocker (plus USB instead of RS232). The harder you pressed the faster it scrolled. It worked great. I need to make another...

[1] http://www.tcocd.de/Pictures/Peripheral/Genius/netmouse.shtm...


While not part of the OS, this has been available in many Windows drivers provided by mouse vendors for ages, e.g Logitech.

Naturally installing them also installs some other junk that the hardware makers always do for product differentiation.


Looks like this is X based, wonder if it could be ported to Wayland.


Looks like it's using pynput[1], which can use uinput[2] (direct kernel API) on Linux.

[1]: https://pynput.readthedocs.io/en/latest/

[2]: https://www.kernel.org/doc/html/latest/input/uinput.html


In the README, I mentioned X11 because an earlier implementation was for X11.

However, this implementation now is platform independent. It uses pynput. It should work on all major desktop environments, like X11, Wayland, MacOS, Windows.


Awesome, thanks for the clarification. Cool project :)


Isn't this exactly what the Mac touchpad and the Apple mouse's touch-scroll-wheel do?


that is exactly what it says in the linked article


Fancy.Lovely.




Join us for AI Startup School this June 16-17 in San Francisco!

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: