openframeworks / openFrameworks

openFrameworks is a community-developed cross platform toolkit for creative coding in C++.
http://openframeworks.cc
Other
9.97k stars 2.55k forks source link

Capture additional touch information in iOS. #5643

Open bakercp opened 7 years ago

bakercp commented 7 years ago

Currently ofxiOSEAGLView doesn't capture all available touch information (and doesn't fill out our ofTouchEventArgs). We're missing information about pressure and size of the touch. Here's an example of a fix. I'm happy to issue a pull request, but I wanted to see if anyone else is working on it already.

ofTouchEventArgs touchArgs;
touchArgs.numTouches = [[event touchesForView:self] count];
touchArgs.x = touchPoint.x;
touchArgs.y = touchPoint.y;
touchArgs.id = touchIndex;

float touchDiameter = [touch majorRadius] * 2;

touchArgs.width = touchDiameter;
touchArgs.height = touchDiameter;
touchArgs.majoraxis = touchDiameter;
touchArgs.minoraxis = touchDiameter;
touchArgs.pressure = [touch force] / [touch maximumPossibleForce];
touchArgs.type = ofTouchEventArgs::move;
ofNotifyEvent(window->events().touchMoved, touchArgs);

A related effort by @borg is here and it seems we should also incorporate that into the next release.

https://github.com/openframeworks/openFrameworks/pull/4801

danoli3 commented 7 years ago

Any headway on this @bakercp ? ofxPointer stuff looked like a great idea

bakercp commented 7 years ago

Definitely. I'm pushing ofxpointer stuff today and just added support for Apple pencil, pressure and angles and coalesced touches on ios. I would love to get it into the core, but haven't submitted much to the core lately because core PRs tend to gather dust without significant backing. If your are interested in helping move it through I'm all for it! Until then, I'm trying to continue improving ofxPointer as a drop in replacement for the core mouse/touch system.

danoli3 commented 7 years ago

Awesome! Yeah get it up and I'll test it and lets get it in

danoli3 commented 6 years ago

Bump :D!

CharlesHolbrow commented 6 years ago

I'd like to see this in core too! Is that still on the table?

sourya-sen commented 5 years ago

Voila, just what I was looking for! @bakercp where does your code need to go for this work? I need to add this in - just realised today that touchEvents is not returning a bunch of stuff I was expecting...

bakercp commented 5 years ago

In the last week, I've significantly updated ofxPointer to fully support all of this stuff (including Apple Pencil features, etc).

It now supports a host of UITouch feature on iOS including coalesced and predicted touches, pressure, tilt, estimated property updates, etc.

https://github.com/bakercp/ofxPointer

ofxPointer for iOS now has two modes -- a compatibility mode which just digests ofTouchEventArgs and one that adds a new view that intercepts all of the touches and dispatches them as a PointerEvents (including all of the richness of coalesced touches, predicted touches, etc etc).

bakercp commented 5 years ago

@arturoc any thoughts on this?

ofTheo commented 5 years ago

I wonder if this could be part of an ofxiOS update?

There are some quite old parts in ofxiOS at the moment and @jvcleave was discussing doing a good cleanup. I would be happy to help with an ofxiOS push to modernize some of the api.

arturoc commented 5 years ago

no idea about iOS, @danoli3 has been usually mantaining that and taking all the decisions on what to do on that part of the code whatever he or anyone else who takes over iOS from now on is ok for me