Multitouch v1.6.0: Resting thumb rejection
Multitouch v1.6.0 is now available for download! The main feature here is new “resting” thumb detection and rejection. As mentioned in previous posts, the move to using Apple’s private framework for trackpad gestures in v1.4.0 meant foregoing Apple’s thumb rejection algorithm. I’ve been working on getting the thumb rejection back in place with my own algorithm for a few weeks now, and I’ll share some interesting (to me at least, haha) takeaways from the experience.
First, it’s worth mentioning that thumb rejection is something that is really easy to take for granted in macOS. There are research papers devoted to algorithms for palm rejection for tablets and thumb rejection is a pretty similar endeavor. The Apple engineers that worked on the trackpad stack did some fine work that feels really transparent to anyone using Apple’s trackpads. To that end, I put a lot of effort into trying to figure out what Apple might have done for this.
There’s not really an easy way to know all the facets of Apple’s thumb rejection algorithm since we have no way to see their source code, but we can create an event tap and look at resulting NSTouches and their phases (began, moved, ended, etc). I pretty much just tried a ton of different touch movements with multiple fingers and my resting thumb, and noted some interesting results. I won’t bore with the details, but the craziest thing I found was that there was a lot of inconsistency. Sometimes a thumb was rightfully ignored and other times it was detected when I didn’t expect it to be. For all normal finger/thumb movement on the trackpad, though, Apple’s algorithms were spot on for when to ignore the thumb.
When writing the thumb rejection algorithm, it was immensely helpful to visually see what the raw trackpad input looks like. For this I used the excellent FingerMgmt open source application. At this point, it’s pretty old and it took a little bit of finagling to get it to work, but it produces nice visuals for what’s going on. BetterTouchTool also has a really similar view, but that one shows the trackpad input after it was processed by the application. FingerMgmt shows the raw data that comes in from Apple’s private multitouch framework. I’ll push my working fork of FingerMgmt up to GitHub when I get a chance.
My algorithm is definitely different from Apple’s, but there are a lot of pieces of it that behave the same. Some quick considerations I looked at in my design were
- What is the touch’s height to width ratio?
- Where is the touch, and is it moving?
- How many touches are there, and are they moving?
- What is the “weight” and “density” of the touch?
From the perspective of those questions, this problem may seem to be rather trivial. Piecing the answers to all of these questions together proved to be a good deal more complex.
Feel free to let me know if version 1.6.0 works for you or not. You can always send me feedback at firstname.lastname@example.org.
One last thing. If you actually preferred not having resting thumb detection, it can be disabled by running the following command in Terminal, and restarting Multitouch.
defaults write com.brassmonkery.Multitouch disableThumbRejection -bool YES