Re:Q3 Linux touchpad update: Multitouch gesture test package...
by donio on Wednesday October 07, 2020 @12:28AM
(#24705305)
> proprietary synaptics driver
In what way is it proprietary? xf86-input-synaptics is MIT and the kernel driver is GPL.
Re:Q3 Linux touchpad update: Multitouch gesture test package...
by ComputerGuru on Thursday October 08, 2020 @01:02AM
(#24716017)
Today I learned! It makes all the pushback to them all the harder to understand.
Re:Q3 Linux touchpad update: Multitouch gesture test package...
by _slyo on Thursday October 08, 2020 @03:34AM
(#24716809)
Hey, this sounds awesome! Thanks for sharing. Please consider putting all this info in the GitHub readme, it's useful for anyone who wants to pick up the project. Also please consider posting this on relevant mailing lists.
I updated my PopOS packages today. My touchpad accel changed, my two-finger scroll broke, and I am left with a bunch of debugging to do and an urge to switch to Guix full-time. I came back to this HN thread and was delighted to find your post.
Re:Q3 Linux touchpad update: Multitouch gesture test package...
by ComputerGuru on Saturday October 10, 2020 @12:25PM
(#24739996)
Thank you.
> Also please consider posting this on relevant mailing lists.
I’m beginning to accept that I’m terrible when it comes to evangelizing. Suggestions?
IMHO the most egregious offender is libinput because everyone and their pet fish seem to be in a massive hurry to drop the proprietary synaptics driver and replace it with libinput; you're not allowed to ask for synaptics support because all distro and project maintainers will lecture you about "upgrading" to libinput which has "superior" touch and multitouch support... except libinput absolutely does not, even if it is theoretically architectured in a way that would enable superior touch/multitouch support someday.
The biggest problem is that the acceleration curves libinput uses are vastly inferior to those that ship out-of-the-box with other operating systems or the proprietary solutions from the manufacturers. When you read about the TrackPoint and the research that went into developing acceleration curves/profiles for input devices [0], it is hubris to think you can throw it all away and expect to still have a superior product.
Anyway, long story short, if you're using a synaptics or synaptics-compatible trackpad, the old synaptics drivers have the best (by far) acceleration profiles and feel the most natural to use, but they are not supported by multitouch plugins for the desktop environments. That's not to say the drivers don't have multitouch support: they do, and they accurately report all motions, but only as raw events.
I wrote this simple program to read the raw input from the synaptics driver and recognize two-, three-, four-, and five-finger tap and swipe gestures from the raw event stream generated by the synaptics driver per the kernel multi-touch protocol [1]. I initially wrote it in an evening after studying the protocol to get just simple back/forward swipe navigations working with the only actually good touchpad drivers for Linux I could find (the synaptics one), and intended to clean it up before throwing it on GitHub for anyone else that might find it interesting but realized I wasn't sufficiently motivated to clean it up anytime soon so decided to just upload it as-is.
sygesture [2] is written in rust and processes the raw MT protocol events generated by the trackpad in real-time to recognize multitouch gestures. Currently it spawns an `evtest` instance rather than opening the input device directly, that was a hack to not have to deal with translating the binary protocol but adds a dependency on the `evtest` utility (should be in your package manager). The path to device is also hard-coded in `main.rs` (and currently it only supports a single input device), but all that is separated from the actual parsing logic because I planned on making that modular from the start, but never got around to it. The mapping of gesture to action is also hard-coded in `main.rs` and isn't currently configurable. (It's all very easy to change even if you don't know rust, as all it does is spawn a program with certain arguments in response to each motion.) I'll throw an MIT license in the repo as soon as I get a chance.
The utility is pretty bulletproof, even though the heuristic is fairly simple (the rationale behind the consensus algorithm is documented in the comments). It's extremely fast (don't have a reliable way to measure lag, but I'm extremely sensitive to it and don't detect any) and has low memory usage (CPU usage is basically zero except for the duration of a gesture, if you're polling at a high-enough frequency to pick up on that).
Something not accounted for at all in the code is support for non-swipe gestures such as pinch-to-zoom and (has anyone ever used it?) "circle gesture" that can be apparently be used for weird things.
[0]: https://www.microsoft.com/buxtoncollection/detail.aspx?id=60
[1]: https://www.kernel.org/doc/html/v4.18/input/multi-touch-prot...
[2]: https://github.com/mqudsi/syngesture