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 / Problem with multi-touch

Author
Message
Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 26th Mar 2018 04:06 Edited at: 26th Mar 2018 04:22
I'm trying to improve the multi-touch feature of the game I'm developing.

This is the basic foundation:



1. If you touch your 5 fingers one by one, works fine
2. If you remove all your fingers, works fine
3. After removing all your fingers and touch them again, works fine
4. If you keep all fingers and remove only the last one, and then touch again, works fine
5. Now, if I keep all fingers down and remove only one finger (not the last one) and then touch this same finger again, it doesn't work

Example: touch with your 5 fingers, one by one, starting with your thumb. Remove your index finger. Touch again. Remove again. Touch again. I have no idea how to capture this touch ID.

I'd appreciate your help.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 26th Mar 2018 06:47 Edited at: 26th Mar 2018 06:47
I thought this was a very good example
https://forum.thegamecreators.com/thread/218840
Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 27th Mar 2018 00:10
Hi blink0k thank you for your suggestion, but I haven't see any examples containing GetRawTouchReleased. I'm facing difficulties to identify a touchID when I release one finger and touch again twice, while the other fingers are still touching.

I hope there's some way to detect, but so far I haven't found any. Any ideas?
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 27th Mar 2018 00:27
Sorry. No experience with this unfortunately
PSY
Developer
7
Years of Service
User Offline
Joined: 3rd Jul 2016
Location: Laniakea Supercluster
Posted: 27th Mar 2018 13:31
Yeah,

things like these tend to make your brain go ballistic

Try this:




Didn't test it extensively, but should work

PSY


PSY LABS Games
Coders don't die, they just gosub without return
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 27th Mar 2018 14:59
Hmm, it seems there is something of a bug at play here. I took a different approach, but am encountering very much the same problem so far.

The manual says it is supposed to remove the touch event from it's own internal list, but sometimes when you lift one finger (not the last) and touch the screen again, it can 'copy' any of the existing / active touch events, both in terms of it's event ID, but also in terms of touch event touch time, which is of course something it shouldn't really ever do (unless perhaps you count simultaneous presses as a two-finger touch, but there's time in between these particular touches so it shouldn't count as double-touch so to speak). If you lift and touch that finger again, it won't respond or count the touch.

Now I am wondering though... is this due to the lists of these events not being looped through backwards? If you remove something from a list, it is better to decrease it down to zero so no indexes looped through still containing relevant data are being skipped or resorted.

In fact, this reminds me; it would be nice if we can loop through AppGameKit 2 'for next' loops backwards.


Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 27th Mar 2018 23:43 Edited at: 27th Mar 2018 23:43
Some very interesting insights here. Thank you PSY and Phemox! Yesterday I also figured out that GetRawNextTouchEvent() takes a new ID for every time you run. So in the below example, you'll notice 3 different IDs for each line.



I will try to test some code today and also using iOS, since it's different from Android. Android assigns auto-increment numbers and iOS assigns a monster of digits maybe representing each coordinate (maybe).
Kevin Cross
20
Years of Service
User Offline
Joined: 15th Nov 2003
Location: London, UK
Posted: 28th Mar 2018 14:01 Edited at: 28th Mar 2018 14:03
Quote: "In fact, this reminds me; it would be nice if we can loop through AppGameKit 2 'for next' loops backwards."


You can


Perhaps the help files could be updated to show for next loops running backwards: https://www.appgamekit.com/documentation/principles/3_common.htm
CodeName
7
Years of Service
User Offline
Joined: 30th Dec 2016
Location:
Posted: 3rd Apr 2018 00:43
Android gives you an ID list in an order... and Apple gives you a random ID for every new touch event.

Rick told me this..

In AppGameKit help you will find in the touch commands index an example covering this for use on both Android and Apple.

Take care.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 3rd Apr 2018 17:58
@Kevin Cross ; thanks! I had no idea we could use it like that. Much appreciated!

Quote: "Android gives you an ID list in an order."


@CodeName : True, but it shouldn't really use the same ID for a new touch event like one touch you're still holding. I think that might be a bug. I am not sure if iOS always resets the ID no matter what.
CodeName
7
Years of Service
User Offline
Joined: 30th Dec 2016
Location:
Posted: 4th Apr 2018 03:20
@PHeMoX

Sorry what I meant was in Android if you remove a touch event it will be -1 from the amount activated. Then adding a touch event gives you +1 respectively.

The thing is - likewise - in Android allowing the device to just vibrate you have options on how long its duration is. In Apple you don't have that option, it just vibrates for a short time.

Its all about what each platform really has to offer in the most relative manner.

In this example from the - agk2 help - shows how to find an ID to apply to an orderly set of sprites via a new touch event. Mainly for use on all platforms because Apple differs from Android.



CodeName
7
Years of Service
User Offline
Joined: 30th Dec 2016
Location:
Posted: 4th Apr 2018 03:36 Edited at: 4th Apr 2018 03:39
@PHeMoX

for i = 0 to 9
if GetRawTouchCount(i) > myTouchList.length+1 // GetRawTouchCount() only has 0 to 1 possibilities not 0 to 9.
thisTouch.index=GetRawFirstTouchEvent(i)
myTouchList.Insert(thisTouch)
endif
next i

PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 4th Apr 2018 09:30 Edited at: 4th Apr 2018 09:33
Thanks! Yeah I figured it would do -1 for the ID however it doesn't always do that. It depends on the order of fingers you release from multi touch. I tried setting the touch event value manually (I think we should be able to do so) but did not have time to get it to work.

Quote: "GetRawTouchCount() only has 0 to 1 possibilities not 0 to 9"


Doesn't GetRawTouchCount(i) go as far as the maximum amount of simultaneous touches, which is basically 10 on most platforms. Haven't looked into it.
CodeName
7
Years of Service
User Offline
Joined: 30th Dec 2016
Location:
Posted: 5th Apr 2018 04:24
GetRawTouchCount() "Returns the number of touch events currently taking place. By default the AppGameKit
does not count an event until it knows what type of event it is, e.g. short, long, drag, etc.
To count unknown events as well set bIncludeUnknown to 1. Use 0 to ignore unknown events."

GetRawFirstTouchEvent() // returns the first event - In Android it should be 1 and Apple a random number 1 - 10
GetRawNextTouchEvent() // returns the next touch event - In Android it should be 2 and Apple a random number 1 - 10 but not any other touch event already read.
GetRawNextTouchEvent() // returns the next touch event - in Android it should be 3 and Apple a random number 1 - 10 but not any other touch event already read.
GetRawTouchCount() // returns the amount of fingers activating an event - so that you can put a stop to GetRawNextTouchEvent(). Your ForLoop should not stop at ten unless you have ten active events.


Take Care.
PHeMoX
6
Years of Service
User Offline
Joined: 9th Jan 2018
Location:
Posted: 6th Apr 2018 13:52
Wait, yeah I stand corrected. You're right. I had forgotten about how it can be set to 0 or 1 for taking into account unknown touch events. Thanks.

Actually, it would be neat if we would be able to get an index style read of the total amount of touch events simultaneously going on.
CodeName
7
Years of Service
User Offline
Joined: 30th Dec 2016
Location:
Posted: 7th Apr 2018 05:52 Edited at: 7th Apr 2018 05:54
GetRawTouchCount() , gives you that number.

[href]file:///C:/Program%20Files/Steam/steamapps/common/App%20Game%20Kit%202/Tier%201/Help/Reference/Input-Raw.htm[/href]
Richard_6
7
Years of Service
User Offline
Joined: 3rd Feb 2017
Location:
Posted: 9th Apr 2018 05:33 Edited at: 9th Apr 2018 05:43
I ended up using this which is the best solution I found. Works well for any number of touches and states. I have to say that i don't completely understand how it works though, in special the while part. Since we're touching the screen, I understand that the program should stay inside the while looping. However, if you add any line after the while like print("random(): "+str(Random(1,100))) it will print. So, at each moment it leaves the while even if we're touching and haven't releasing any fingers? Anyways, works pretty well on Android and iOS.

Login to post a reply

Server time is: 2024-03-29 05:24:34
Your offset time is: 2024-03-29 05:24:34