Uses the force sensor from Mac Trackpad to weigh items!
How I made it
Going into this, I already knew that the mac trackpad was not a regular trackpad, but a force sensor paired with really good haptics. Naturally, I thought it could be possible to extract this data.
In the past, I would have spent days googling to see if this was even possible, but the idea was pretty much derisked with a couple ChatGPT Deep Research calls on the subway. It threw a bunch of repos at me that I got to read through, while weighing out the pros and cons.
Options
Webkit This exposes a normalized 0 → 1 force after clicking on the trackpad. The great part is that it’s available on the web, but only Safari.
The problem with this is that weighing things wouldn’t work if you had to balance your finger at some pressure that is just over the click threshold.
NSEvents You can also extract pressure from NSEvents in a Swift app, but it struggles with the same issue as above.
Multitouch Support This is a private undocumented API that Apple uses for things like the signature functionality on preview. It was found a long time ago when people were trying to reverse engineer drivers to make Asahi Linux, but it was before the force trackpad actually came out! Developers found a field in the data packet that was always 0, and they marked it as an unknown field and went on with their day.
Later on, when the force trackpads came out, they noticed that it was an actual pressure value. More modern wrappers of this API included it in their data frames.
The great part about this is that it pretty much gives you the raw information from the firmware, and works before a user clicks, as long as there is an object with a finger like capacitance on the trackpad (more on this later).
public var id: Int32
public var position: OMSPosition
public var total: Float
public var pressure: Float
public var axis: OMSAxis
public var angle: Float
public var density: Float
public var state: OMSState
public var timestamp: String
Testing
Cool, so I just cloned the repo above and started printing out values. The pressure values seemed unbounded and not really normalized. So I put my laptop on a food scale and began pushing. The values printed out and the values on the scale were similar.
After testing a bunch more I realized that it was just outputting weight in grams, and any difference was a calibration/user issue. I believe I’m the first person in the world to discover this!
The Flow
I’m still not set on this one. Currently I instruct the user to do the following:
- Open the scale
- Rest your finger on the trackpad
- While maintaining finger contact, put your object on the trackpad
- Try to put as little pressure on the trackpad while still maintaining contact. This is the weight of your object
This works, but requires the user to not flicker their finger on the trackpad (otherwise the reading will go down).
I’ve also experimented with a more guided approach, that goes step by step and waits for a stable reading. My friends still don’t understand how to use it. I’d appreciate any algorithmic help to figure out a better UX for this.
Limitations
- You have to touch your finger (or a similar capacitance object) on the trackpad to weigh. This is the only thing that makes the weight inaccurate.
- Metalic objects often trigger a touch, but because its not a similar capacitance, it often “decays” the pressure to 0 by simulating a bunch of onset and offsets
Fun Facts
- In South Korea’s bitter 2010 winter, people discovered that using snack sausages (often still in their plastic wrappers) allowed them to operate capacitive touchscreens while wearing gloves. Sales of some sausages even spiked by 40% that season, as commuters realized these meat sticks mimicked a finger’s electrical properties
Media
A collection of all the places I’ve seen this
My tweets
- https://x.com/KrishRShah/status/1947186835811193330
- https://x.com/KrishRShah/status/1947684172660908444
- https://x.com/KrishRShah/status/1947322024071778496
- https://x.com/KrishRShah/status/1946789013962277266
Youtube
- https://youtube.com/shorts/Yd89SMjfOhE?si=uiq7hkC7e4fwQfU_
- https://youtube.com/shorts/QeO1sEZWBb4?si=luiNCb5Ndnl_fce3