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 / windows single touch 'workaround'

Author
Message
Zeerun
AGK Developer
18
Years of Service
User Offline
Joined: 28th Aug 2005
Location: United Kingdom
Posted: 18th Oct 2012 12:36
I stress the word workaround probably more of a hack tbh

So I got my ultrabook for the competition and suddenly I find myself in the have to drag 10 pixels to register a touch camp.

I made a workaround for Tier 1, but as the sensor data doesn't work I will have to be going Tier 2 any way.

My Tier 1 fix was to compare the getpointerx and getpointery data, and if there was a small change (<> 0.1) then this was a click, this would not work for multiple fingers I would imagine though.

If it is a help to anyone!

I seek perfection but wear my scars with pride
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 18th Oct 2012 13:22 Edited at: 18th Oct 2012 13:24
If you track each multi-touch event then each time you have a new event you will know you have a click I would imagine but I haven't tried it on a windows touchscreen device.

Here is how I am tracking multi-touch in my current command set (might help):



this.mess = abs(sin(times#))
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 18th Oct 2012 15:58 Edited at: 18th Oct 2012 15:59
Zeerun, so are you checking getpointerx and getpointery in the main game loop, every single frame?
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 18th Oct 2012 15:58
Baxslash i will try to convert your code to T2 and test! Thanks
Auger
12
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 22nd Oct 2012 00:17
Tried this and it is fine if they only use the touchscreen. Problem is if they use a mouse then it'll register clicks when they are not clicking.

Bax , none of the multi touch commands seem to work on windows touchscreens as far as I can tell.

The only way I've been able to get a touch to work is with a double tap or moving it the 10 pixels.

Auger
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 22nd Oct 2012 00:33
Quote: "Problem is if they use a mouse then it'll register clicks when they are not clicking."


Ohhh that is really bad
Auger
12
Years of Service
User Offline
Joined: 21st Aug 2011
Location: Out There
Posted: 22nd Oct 2012 01:31
Yeah, I'm guessing Zeerun's workaround would be fine if you have just a few sprites on the screen and they are a bit apart. But I can have 100 sprites in my app and they are packed together.

I'm saving Getpointer() every frame and then comparing it to the last frames value. If the distance is greater then the width or height of my sprites I register a touch. The only problem is the user can use a mouse and move it really quickly and it'll trigger a touch. It works fine if the user moves the mouse at normal speed.

Here's the code I'm using


Auger
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 22nd Oct 2012 10:04
When will we have the new AppGameKit 108 with the new sensors command working? These might solve all these problems
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 22nd Oct 2012 15:00 Edited at: 22nd Oct 2012 15:01
Doesn't the ultrabook have a touch pad as well as touch screen?

how does AppGameKit differentiate between them?

... and between these and a real mouse plugged in?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 22nd Oct 2012 16:33
Touch screens can normally be detected two ways 1-Using Multi-touch commands and 2-Pointer commands.

Touch pads and mice (although I don't know about multi-touch pads) normally only use the pointer commands.


this.mess = abs(sin(times#))
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Oct 2012 22:36
Quote: " The only problem is the user can use a mouse and move it really quickly and it'll trigger a touch."


I use a routine to do exactly the same. If the pointer changes position twice in a specified time (0.2) I discard the movement as a potential click, and transfer it over to my swipe routine.

If it moves only once in 0.2 seconds then I know it was a click. This is a sturdy piece of code because of the way the "quirk" works. The mouse moves as you take your finger off the screen.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 22nd Oct 2012 22:48
Here you go, this is it in action. The small image shows the exact same code running on the client machine with a mouse. This code is all based on the mouse moving when your finger leaves the screen.



Lavaflyer
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location: Wisconsin, U.S.
Posted: 31st Oct 2012 23:30
Hi All.

Baxslash, none of the raw touch commands seem to work on windows 8 ultrabook as far as I can tell.

Batvink, I am also developing for the ultrabook competition and I watched the video you posted here which is awesome and although I read your post I can’t, for the life of me, quite figure out how you did it. If you could just send me/this forum a quick example or a more detailed explanation that would be great. Thanks!

Ps. Or, if anyone else has an easy way (workaround) of detecting single touches on windows 8 ultrabook that would be great since I'm trying to get my game on AppUp and all, plz post a code snippet
That would be great. Thanks!

Quote: "Here you go, this is it in action. The small image shows the exact same code running on the client machine with a mouse. This code is all based on the mouse moving when your finger leaves the screen.
"
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 1st Nov 2012 00:52
I'll be back with the code soon, I'm totally snowed under right now with newsletter and app submission for another competition ending in...1 hour and 9 minutes

Lavaflyer
11
Years of Service
User Offline
Joined: 2nd Jul 2012
Location: Wisconsin, U.S.
Posted: 3rd Nov 2012 16:09
any update here batvink? I really want to send in my game to intel appup store tonight. Thanks!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 3rd Nov 2012 17:30 Edited at: 3rd Nov 2012 17:31
This works, but you may have to pick the bones out of it to understand it. It's commented but can still be a bit tricky. This does more than just clicks, it also does swipes which are also not registered on an Ultrabook with the current version.

My advice would be to simply call

ret = inputCheck()

each loop, and then check the results in ret, and also the gInput variable.

gInput.WindowTouchMode must be set to 1 for clicks to work.

If anyone can simplify this, please do so and post your improved version here! This one kind of evolved as I tweaked it over time.

You can remove my debug lines, they will stop it compiling.





It also uses this Typed variable:



and these constants:



Plystire
21
Years of Service
User Offline
Joined: 18th Feb 2003
Location: Staring into the digital ether
Posted: 6th Nov 2012 05:50
@BatVink

I was only ever able to get your function to return for a swipe, never a click.


~Plystire

A rose is only a rose until it is held and cherished -- then it becomes a treasure.
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 6th Nov 2012 08:13
Did you do this...

Quote: "gInput.WindowTouchMode must be set to 1 for clicks to work."


bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 15th Nov 2012 23:38
BatVink what is the basic concept of your function?

If AppGameKit does not trigger any Pointer command on 1 touch tap, how can you detect 1 tap?

AGK detects swipes as touches!
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 15th Nov 2012 23:52
Quote: "If AppGameKit does not trigger any Pointer command on 1 touch tap, how can you detect 1 tap?"


You have to use PointerReleased(), which is triggered even on one tap. If the PointerX() / PointerY() jumps significantly, and then does not move again before the pointerReleased() then it is considered a touchscreen tap by the function.

Quote: "AGK detects swipes as touches!"


You need to monitor the PointerX() and PointerY() and make your own conclusions based on distances travelled.

It looks and sounds complex, but it works well. I have not used any AppGameKit swipe commands. One day they will work, but until then this is an alternative solution.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 16th Nov 2012 00:11
batvink, the way you explain it it does not sound too hard to do

i did not know that PointerReleased() is always triggered, that should do the trick i hope

thanks for the essential info
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 16th Nov 2012 00:25
i tap still does not trigger PointerReleased() for me
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 20th Nov 2012 02:28
BatVink, what do you store in g.time and what is that UDT? I think the code you posted needs it.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Nov 2012 14:31
I would guess it's the current value from timer() from looking at the function.


this.mess = abs(sin(times#))
BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 20th Nov 2012 16:16
Quote: "BatVink, what do you store in g.time and what is that UDT? I think the code you posted needs it."


In my post further back, you can see the typed variable.

g.time is indeed the timer(). I grab it at the top of every cycle for performance, and also so that everything in one cycle uses the same time down to the millisecond.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 30th Nov 2012 19:48
Just to close the subject, AppGameKit 1084 (both T1 and T2) now supports 1 touch tap, with no special workarounds

Login to post a reply

Server time is: 2024-05-18 23:51:50
Your offset time is: 2024-05-18 23:51:50