Pressure / Force

Howdy everyone,

Hope everyone had a great Christmas and New Years. I was reading the latest update documentation (man, I love how the latest version is looking) and then got very interested in force/pressure.

Can someone explain to me how this works? I mean, if using an iPad and an Apple Pencil, the pressure is measured through the Pencil. So, to use Pressure, is this only applicable for screens that support force? I'm just curious about how this works with OSC.

I'm incredibly interested in this because imagine having a pressure sensitive keyboard so you can suddenly implement Aftertouch. Or 5D Touch meaning we can suddenly have "lift" as a way of inputting data to create performance based instruments.

Very excited. I apologise for ignorance on such matters. Never in my life did I think this could even be a possibility!


Pressure will indeed work only on devices/screens that supports it (I guess most smartphones and tablets do, not sure about desktop touchscreens). The pressure information can only be used with a canvas widget, there's no predefined usage for it in o-s-c, it's up to you to be creative with it :).

Here is a simple example to test it: create a canvas widget with the following touch script and draw script:

// touch
locals.pressure = event.force

if (event.type == 'start') {
  locals.touched = true
} else if (event.type == 'stop') {
  locals.touched = false
  locals.pressure = 0
// draw
var radius = 10 + (width / 2 - 10) * locals.pressure

ctx.arc(width / 2, height / 2, radius, 0, Math.PI * 2)
ctx.fillStyle = cssVars.colorFill

If pressure is supported, you'll get a circle which size depends on how much pressure you put you the widget when touching it.

Ok man, its as I thought. Hmmm, I wish all desktop touch screens supported this. It would be massive.

By the way, loving the Canvas widget. It really is a game changer especially for performance. Thanks so much for implementing that!

Wow, this is amazing !
(I've been waiting and requesting for such a thing in Lemur / touchOSC / Max Mira, ...)
Finally I can use the Apple Pencil pressure to send OSC :grinning: :smiley: :hugs:
Once again, thank you very much Jean-Emmanuel !!

Would you mind adding azimuth angle / tilt , please ?

or PointerEvent.tiltX
(+ tiltY / twist / ...)

PointerEvent.pointerType may be useful as well... to know if the pointer us a touch, a stylus, etc... ?

So many exiting things to explore with this new input :slight_smile:

On iPad, look like when Apple Pencil is used, the touch events are ignored...
is it a setting we could change ? or an iOS limitation ?
I'm pretty sure that there are apps that can use simultaneously pencil + touch...

One more thing :
on iOS devices, touch radius ( radiusX ?) should also be accessible.
I remmener a couple of years ago, developers had to use a forbidden private api to access these data (some apps had some hidden parameters to enable it..) ; then it became officially supported, but with a very low resolution. (Orphion app uses this feature)
Anyway, I guess it would worth giving it a try :wink:



I'm adding these properties in next version, except those tied to the PointerEvent API that would require a partial rewrite of o-s-c touch event implementation.

great !
looking forward exploring these exiting new features :smiley: