I realize that currently there is no built-in support (ie orx types) for dealing with multitouch. Hence, I will start rolling my own solution for this. However, I want to keep this development close to whatever the eventual orx solution will be, so that I can merge to the official branch without too much difficulty. Any do's/dont's/advice before I begin?
Comments
- Implement GestureDetector in java and create a new orx event type for this.
- Keep everything client-side, and have the game keep track of pointer/finger activation. In this case, it would be nice to also receive pressure and timestamp info with each touch event. The timestamp would be used in client-side gesture detection. Alternatively time could be saved at the point of event arrival in client code, but this has obvious drawbacks.
That being said, I don't know the details about the Android implementation of those.
- ScaleBegin
- ScaleChanged
- ScaleEnd
The user will then catch these in their SystemEventHandler. Payload that comes with each of these is:
- X,Y of center of gesture
- % change from last scale (instead of pressure)
The code is up in my orx fork
Also I think we could regroup all gestures under orxSYSTEM_EVENT_GESTURE_BEGIN, _GESTURE_MOVE and _GESTURE_END, using then an enum of type orxSYSTEM_GESTURE_TYPE to get the relevant data within the payload.
Yeah, they could certainly be regrouped, I was going for minimal changes at this point (like highjacking of pressure value for scale storage).
One thing I realize that I did wrong is with the negative numbered enums, as that would mislead EVENT_TOTAL (luckily it is not currently used anywhere). We do need them to stay fixed somehow, as the values are copied in java.
I think the best would be to let iarwain do the iOS implementation (when he has the time).
That way, all the orx events enums, structs and stuff will be there, and ready to be reused for Android.
As I said in your commit, If you are going to contribute to orx Android port, the best would be to fork my repository as iarwain is unable to test Android yet, so I can review and adapt your changes.
It reduce also the risk of conflict when merging from orx upstream.
About orx forks, is there any way to do inverse pull requests? Reason being, is that I already have two copies of orx going - the official and my temp staging area. So it would be really great if there was a way for me to send you my code without making yet another copy of the project. Any suggestions?
Now for the actual pull request feature of bitbucket, I think an easy way to do it would be to remove your current fork (but keep your local clone), fork lydesik's one on bitbucket and set that fork as your default remote repository on your local one.
You can either do that by using a GUI client such as TortoiseHg or by editing the .hg/hgrc file of your local clone. Of course if you use the exact same name as your previous fork (ie. the remote addresse doesn't change), you won't even need to do that editing step, it should work right away with your local clone.
The only thing that I'm still not settled on is the contents of the gesture events. Android's gestures are not a uniform bunch, and callbacks have different parameters. For now, there are two floats for holding whatever comes with the event. Additionally, some gestures don't have a begin and end (such as fling) so it just comes through under gesture_changed.