openFrameworks icon indicating copy to clipboard operation
openFrameworks copied to clipboard

iOS Add touch majorRadius property

Open julenka opened this issue 11 years ago • 5 comments

As of iOS 8.0, UITouch has a public majorRadius property which communicates the approximate size of the touch. It would be nice to set the majoraxis property of ofTouchEventArgs to majorRadius.

The change is tested, I have used the majorRadius property in a research project already. A patch implementing this change is available at https://gist.github.com/julenka/55dea0263aede105854a.

julenka avatar Dec 14 '14 20:12 julenka

thanks! pinging @openframeworks/ios

bilderbuchi avatar Dec 14 '14 20:12 bilderbuchi

sounds like a useful addition.

have a couple questions, in touchArgs.majoraxis = [touch majorRadius];, i can see you are saving the majorRadius value inside majoraxis... but im not entirely sure what majoraxis is supposed to be used for. there is also minoraxis variable. can anyone advise what these are supposed to be used for? cc @arturoc

it might also be good to use [touch majorRadiusTolerance] to calculate the min and max radius of the touch. what do you think @julenka?

link to apple docs for reference, https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITouch_Class/index.html#//apple_ref/occ/instp/UITouch/majorRadius

julapy avatar Dec 14 '14 22:12 julapy

@julapy I always assumed that majoraxis and minoraxis represented the major and minor radius of the touch. Looking at the class, width and height could also be used. Alternately, width, height, major, and minor could all be set to [touch majorRadius]. If I had to pick, I would prefer to just set majorAxis and leave everything else at zero because otherwise if a person uses width instead of majorRadius, and this later changes to actually be the width of the touch, developers will be confused as to why the behavior of touch width suddenly changed.

Regarding tolerance (good point!), it would be good to add a property majorAxisTolerance, however this would require a change to ofEvents.h just to support something in iOS. My opinion is to leave it out.

julenka avatar Dec 15 '14 05:12 julenka

we could maybe do this, majorAxis = majorRadius + majorRadiusTolerance; minoraxis = majorRadius - majorRadiusTolerance;

but again, not 100% if these variable names would be used correctly. anyone that has a better understanding of this, please jump in.

@bakercp - maybe you have some ideas... how are you treating this in ofxPointer?

julapy avatar Dec 15 '14 05:12 julapy

@julapy That's been my understanding of Apple's docs, and fits the visual sizes I've observed in a test app.

An introspetion of the runtime header (https://github.com/nst/iOS-Runtime-Headers/blob/master/Frameworks/UIKit.framework/UITouch.h) reveals no “minor radius” vars or methods, so majorRadius confusingly see,s to give us the average size, and majorRadius ± Tolerance the max and min.

I'm also observing in 8.1 that majorRadiusTolerance varies linearly with majorRadius such that the calculated min remains roughly ⅓ the size of calculated max. So who knows what Apple's thinking/planning here.

I hope this helps.

capnslipp avatar Mar 28 '15 21:03 capnslipp