Does the MouseInputSource pick up touch pressure on iOS devices? No matter how hard/soft I tap my iPad, the value of “pressure” is always 0. I know my iPad has 3D Touch, as I’m able to use velocity in other music apps, like Garageband.
Any thoughts on this?
So I’m guessing that’s a no. Are there plans to support 3D touch? I’d like to make my iOS synth keys velocity-sensitive to touch.
We do pick up the pressure:
No idea why it wouldn’t get set on your device but you could debug that function and see what’s happening in there.
When Apple introduced this feature in GarageBand, they used the accelerometer of the device to figure out the touch pressure, as the display sensor itself was not able to do this. Nowadays I think they use the pressure sensor in the display (they named it forced touch I think?) to do this. Are you sure your device has this sensor in it?
You’re right. I assumed my device had it since it worked in GB but after digging deeper, apparently Apple has never put 3D Touch into the iPad, only the iPhone.
Along with the accelerometer, I’ve come across a couple other techniques:
Measuring the touch radius, since the harder you press, the more of your finger tip smushes against the screen
Using the mic. The harder the tap, the louder the impact. Though, I imagine this technique would be problematic in a noisy environment.
Time to experiment.
I put together an implementation with room for improvement and posted it at iOS MidiKeyboard Touch Velocity (New thread since this one is more about 3D Touch and Pressure).