Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / Detecting the SIZE of your touch? (fake pressure sensitivity)

Author
Message
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 14th Jan 2013 04:27
Hi, fairly new to AppGameKit, but I had a question about whether or not there might be a way to detect the size of the touch point, whether it be actual commands, or a workaround.

If you've ever used Sketchbook on your 'i' or Android device, you'll know there is an option for pressure sensitivity. Most Android devices and 'i' devices don't have true pressure sensitivity, but Sketchbook uses a trick to capture how squashed your fingertip or stylus is and use the size of your touch to determine your pen pressure while drawing.

I'm hoping someone has a clever idea on how this might be accomplished. If it's not possible currently, it would be great to get a comment from the devs on a possibility of looking into such a feature.

Thanks!
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 14th Jan 2013 08:39
AGK itself doesn't provide that functionality, nor any of iDevices does (some android devices have stilo-induced pressure sensitivity). However, "pressure" sensitivity can be processed as detection of touch "hardness" with accelerometer, and this can be implemented both with agk tier1 and tier2.

Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 14th Jan 2013 09:09
You could use an average size initially and incorporate a calibration option;

The user is asked to touch the screen with two fingers as close together as they are able.

The distance between these points should give a good approximation of finger width.
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 14th Jan 2013 12:10
I wouldn't be positive on this as AppGameKit recognizes single touch as a point but not area. Thus, one finger touch will always return zero distance. Even with native XCode environment it's not possible to access touch area data, not sure about Android and others but should be the same.

Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 15th Jan 2013 06:08
Well, somehow it's done in the Sketchbook Mobile applications on 'i' devices and some Android devices. I'm not sure how, of course, but it would be great if there was a way to determine touch area in AGK. My thoughts are to have a dual virtual stick FPS, where you fire by pressing a bit harder on the right stick so you can fluidly aim and fire without having to lift your thumb to select the fire button. . Seems like a logical next step in the genre for on-screen virtual controls. I'd love to explore the idea.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jan 2013 08:13 Edited at: 15th Jan 2013 08:15
It's possible that the sketchbook app is using distance moved over time rather than an area but I haven't used it so I can't be sure. I know when I've done drawing using AppGameKit it sometimes looks like pressure is being detected just because a number of sprites overlay each other. This might also be the effect you are seeing. I'm not aware of any actual pressure sensitivity on touch screen devices so it's more likely it is faked using gesture algorithms.

Edit: here is an example of one of the above suggestions; http://stackoverflow.com/questions/5179426/tap-pressure-strength-detection-using-accelerometer


this.mess = abs(sin(times#))
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 15th Jan 2013 08:21
Quote: "somehow it's done in the Sketchbook Mobile applications on 'i' devices"

Quote: "It's possible that the sketchbook app is using distance moved over time"

+100 baxslash, it's a "fake" pressure sensitivity, when brush stroke is just tapered at both ends.

I will try to do some workaround on accelerometer input

Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 15th Jan 2013 14:31
You're right, it is faked, but it's not faked by tapering the ends of each stroke. It doesn't detect pressure, but rather the area of the screen you are touching. If you press harder your finger tip will flatten and cover a larger surface area. That's how it detects "pressure" this would not work at all if you used a solid tipped stylus, but it will work with the typical soft stylii we see being used with touch devices.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 15th Jan 2013 14:36
As far as I am aware the area being touched can only be taken from a private method in UItouch. This would not be accepted in an App Store application as you are not allowed to use private API methods: http://stackoverflow.com/questions/2103447/is-there-any-way-at-all-that-i-can-tell-how-hard-the-screen-is-being-pressed/2103715#2103715


this.mess = abs(sin(times#))
tornado
19
Years of Service
User Offline
Joined: 21st Jul 2005
Location:
Posted: 15th Jan 2013 20:18
Quote: "It doesn't detect pressure, but rather the area of the screen you are touching. "


sorry, i couldn't get such an effect in sketchbook mobile for iOS.

Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 16th Jan 2013 05:16
Quote: "sorry, i couldn't get such an effect in sketchbook mobile for iOS."


No problem, it worked for me on iPad2, but I know there are different versions of Sketchbook, some have more features than others I believe. Also, it may vary between models. Perhaps only new 'i' devices support it. I don't know.

This whole idea is sadly probably pretty far fetched and a bit much to be asking of AGK. It's not necessary to my projects, but would have been a nice experiment!
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 16th Jan 2013 14:10
Using a capacities pen (i.e. a stick with a squidgy rubber bit) you can get pleasure senitive style strokes on the iPad. But it's far from perfect, my lines tend to wobble. It hardly works at all with my finger.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Jan 2013 14:12
oops, typo... funny one though thanks for the chuckle Daniel


this.mess = abs(sin(times#))
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 16th Jan 2013 15:50
I'm sure that someone was making, or made a stylus that plugs into the mic input of a tablet, then uses that to transmit the touch pressure. This might have been on the Nintendo DS, but it's a novel idea I think - wish someone would make an iPad version. I wish someone would make a decent stylus as well - imagine having a wacom style stylus with touch sensitivity, through mic input or bluetooth or anything. Art packages on the iPad would benefit hugely. The only stylus I've seen use capacitive material and a fat blister on the end - not exactly accurate enough for art. If we had a real stylus, we'd have neat little intuos style art tablets, would be awesome.

The accel method is probably not ideal for an art package, it's more for Garageband drums and stuff like that - unless you paint like a mad man, bashing the screen - typically an art package won't be bashed enough to really register on the accelorometer.

As a stand-in, I'd maybe have a sliding bar for pressure, so at least the user can specify the pressure with their other hand - with some practice it might work out alright... better than nothing.

I got a fever, and the only prescription, is more memes.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 16th Jan 2013 15:58 Edited at: 16th Jan 2013 15:59
I still think using velocity would be easiest. If you are moving slowly it's likely you intend more pressure.

Something like this psuedocode:



this.mess = abs(sin(times#))
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 16th Jan 2013 16:18
My intentions were for an alternative to the lift thumb and press fire button in a dual virtual joystick shooter, not for an art package, however those are all great ideas for an art package, definitely. Based on research, it sounds like the method I described will only work on iOS devices at best anyhow.
Daniel TGC
Retired Moderator
17
Years of Service
User Offline
Joined: 19th Feb 2007
Location: TGC
Posted: 17th Jan 2013 18:24
Apple should just add pressure sensitivity already I've got a Pentium II based RM Tablet from 2002 that does 255 levels of pressure. Why can decades old tech do this but iPad not? Seems a big oversight!
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 18th Jan 2013 14:30 Edited at: 18th Jan 2013 14:32
So, I went through my Android developer options in the settings menu on my Galaxy S3 loaded with the AOKP Jellybean rom, and if I turn on touch data options, it will show me the statistics of pertinent touch data. One of the parameters is "size". Surely enough if I pressed covered more of the phone's surface with my thumb, the size data increased. It decreased as I lifted my thumb off the device.

So, at least one handset, the Galaxy S3, is able to detect touch size. If that is an available variable that can be pulled from the OS, I think it should be an available option in AGK's touch command set.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Jan 2013 14:35
Quote: "I think it should be an available option in AGK's touch command set."

I agree it would be a great feature to use even if it was only available on some devices for now. Perhaps it's available on a lot of Android devices... [checks his phone] couldn't find it on my Samsung GT-S5570


this.mess = abs(sin(times#))
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 18th Jan 2013 15:43
I am running a custom rom, so that developer feature may have been part of that, however the OS and handset still have the capability of delivering that data.

Having a getTouchSizeAvailable() to check if that feature is available on the device and a getTouchSize() to return the touch size data would be wonderfully handy.
Marl
13
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 18th Jan 2013 19:27 Edited at: 18th Jan 2013 19:28
I'm pretty sure the menu option appeared in Android 4 - I got it with ICS on my S2, but the data was available in earlier version since apps on earlier versions used it.

They had to be getting it from somewhere.

I think getTouchSizeAvailable() and getTouchSize() is a brilliant idea and certainly in line with the other sensor data commands.

To be absolutely future proof though it might be an idea to consider getTouchWidth() and getTouchHeight()

Hmmm - a flat bladed stylus to get that fountain pen look to your text.
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 21st Jan 2013 05:57
That would be fantastic
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 22nd Jan 2013 02:02
I did a quick test on some Android devices and they do have size and pressure values for their touch events. However pressure just seems to be a function of the size since placing the thumb lightly on the screen produces a large pressure value as well as a large size value. The Nexus 7 worked, but the Kindle Fire didn't, it just produced a fixed value no matter what I did, so I don't know how well supported this function is, and I can't find it at all on iOS. So maybe something to add when we run out of other ideas
Agent Dink
20
Years of Service
User Offline
Joined: 30th Mar 2004
Location:
Posted: 25th Jan 2013 22:32
Thank you for looking into it! Hopefully it becomes a more developed functionality over time in Android and iOS (or perhaps hardware companies could just add true pressure sensitivity. Wouldn't that be nice?)

Login to post a reply

Server time is: 2024-11-24 06:03:06
Your offset time is: 2024-11-24 06:03:06