I'm unfamiliar with the Marte engine, but using only slick code, I have been able to track the location of two simultaneous touches by having a Vector2f variable for each. This Vector2f is initialized when a mousePressed event is called, and set to that location. When mouseMoved is called, the Vector2f that matches the old position is moved to the new position. When mouseReleased is called, the Vector2f matching that location is set to null, indicating that there is no touch for this vector. From there you can have a circular area that counts as a control stick, and if a touch is within that area, you can compute it's distance from the center and use that as your input. Is this what you needed?
code from gearbie:
Code:
public class PlayState extends BasicGameState...{
...
...
/**track fingers*/
Vector2f touchA=null;
Vector2f touchB=null;
...
...
@Override
public void enter(GameContainer container, StateBasedGame game)
throws SlickException {
...
...
touchA=null;
touchB=null;
}
...
...
@Override
public void mousePressed(int button, int x, int y) {
if (touchA==null){
touchA=new Vector2f(x,y);
}else if (touchB==null){
touchB=new Vector2f(x,y);
}else{
//if you get a third touch
//assume something is wrong and reset touches
touchA=null;
touchB=null;
}
}
@Override
public void mouseReleased(int button, int x, int y) {
if (touchA!=null&&touchA.distanceSquared(new Vector2f(x,y))<9){
touchA=null;
}else if (touchB!=null&&touchB.distanceSquared(new Vector2f(x,y))<9){
touchB=null;
}
}
@Override
public void mouseDragged(int oldx, int oldy, int newx, int newy) {
//if oldx,oldy is within three pixels of touchA,
//assume touchA is the one moving (same for touchB)
if (touchA!=null&&touchA.distanceSquared(new Vector2f(oldx,oldy))<9){
touchA=new Vector2f(newx,newy);
}else if (touchB!=null&&touchB.distanceSquared(new Vector2f(oldx,oldy))<9){
touchB=new Vector2f(newx,newy);
}
}