Q3 Linux touchpad update: Multitouch gesture test packages now ready
I&#x27;ve never been a fan of Linux on laptops as I feel its DE is just not there yet and prefer to stick to the terminal or the desktop, but I switched my laptop to Linux about six months ago to re-assess and ran into a number of big issues, the most unexpected of which was the poor state of basic touchpad support, not to mention multitouch input support - I genuinely thought it would be a solved problem by now, but I can&#x27;t blame anyone but myself given that it&#x27;s open source and anyone is free to contribute a fix (read on).<p>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&#x27;re not allowed to ask for synaptics support because all distro and project maintainers will lecture you about &quot;upgrading&quot; to libinput which has &quot;superior&quot; touch and multitouch support... except libinput absolutely does not, even if it is theoretically architectured in a way that <i>would</i> enable superior touch&#x2F;multitouch support <i>someday</i>.<p>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&#x2F;profiles for input devices [0], it is hubris to think you can throw it all away and expect to still have a superior product.<p>Anyway, long story short, if you&#x27;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&#x27;s not to say the drivers don&#x27;t have multitouch support: they do, and they accurately report all motions, but only as raw events.<p>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&#x2F;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&#x27;t sufficiently motivated to clean it up anytime soon so decided to just upload it as-is.<p>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&#x27;t currently configurable. (It&#x27;s all very easy to change even if you don&#x27;t know rust, as all it does is spawn a program with certain arguments in response to each motion.) I&#x27;ll throw an MIT license in the repo as soon as I get a chance.<p>The utility is pretty bulletproof, even though the heuristic is fairly simple (the rationale behind the consensus algorithm is documented in the comments). It&#x27;s extremely fast (don&#x27;t have a reliable way to measure lag, but I&#x27;m extremely sensitive to it and don&#x27;t detect any) and has low memory usage (CPU usage is basically zero except for the duration of a gesture, if you&#x27;re polling at a high-enough frequency to pick up on that).<p>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?) &quot;circle gesture&quot; that can be apparently be used for weird things.<p>[0]: <a href="https:&#x2F;&#x2F;www.microsoft.com&#x2F;buxtoncollection&#x2F;detail.aspx?id=60" rel="nofollow">https:&#x2F;&#x2F;www.microsoft.com&#x2F;buxtoncollection&#x2F;detail.aspx?id=60</a><p>[1]: <a href="https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;v4.18&#x2F;input&#x2F;multi-touch-protocol.html" rel="nofollow">https:&#x2F;&#x2F;www.kernel.org&#x2F;doc&#x2F;html&#x2F;v4.18&#x2F;input&#x2F;multi-touch-prot...</a><p>[2]: <a href="https:&#x2F;&#x2F;github.com&#x2F;mqudsi&#x2F;syngesture" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;mqudsi&#x2F;syngesture</a>