Finger Area to ofTouchEventArgs.pressure


Hi there,
I just managed to get this working and thought I’d share. Some of you may know about the developer Rob Fielding, maker of Mugician and more recently Geo Synthesizer. In his non-AppStore apps he always uses finger area to control various parameters and has many posts scattered around the internet regarding how to get this. Apparently this is not allowed in store apps even though it is part of the official API so if you are planning on submitting to the store don’t use this :slight_smile: (FYI Fantastick ships with this on somehow). For the rest of you:

This requires you to modify in the ofxiPhone source, either directly or by copying it and including your version. Inside the touchesBegan/Moved/Ended (and Canceled if you feel like it) methods before where if defines ofTouchEventArgs add this:

float vf = 10.0;

id valFloat = [touch valueForKey: [NSString stringWithUTF8String:“pathMajorRadius”] ];

if(valFloat != nil) { vf = [valFloat floatValue]; }

Then when adding the values to ofTouchEventArgs add this:

touchArgs.pressure = vf;

Now touch.pressure will register continuous changes in how much finger is touching the screen. The values are somewhat unpredictable: typically from around 7.0 up to 17.0 but can be more or less depending on how big your fingers are. It is also important to initialize the value as some default (hence the if statement) since this won’t always be available and you don’t want your code to break if it’s not.

Hope some of you find this useful!



Thanks for this! Giving it a try now. I’m curious if apple is becoming more lenient on its use since another music app was just accepted with this on. I think it’s working submitting with it on. If they don’t accept it you can always remove it.