Multi-Touch Issue with Move Event

While debugging some mutli-touch code, I noticed that the MOVE event was only firing with the first touch pointer, not the second. While looking through AndroidInput, I think there is a problem with the for loop that goes through the active pointers. Patch file below. @nehon can you look at the attached patch file and see if it is correct and commit it? Thanks.



[java]

This patch file was generated by NetBeans IDE

Following Index: paths are relative to: D:UserspotterecDocumentsjMonkeyProjectsjME3srcandroidcomjme3inputandroid

This patch can be applied using context Tools: Patch action on respective folder.

It uses platform neutral UTF-8 encoding and n newlines.

Above lines and this line are ignored by the patching process.

Index: AndroidInput.java

— AndroidInput.java Base (BASE)

+++ AndroidInput.java Locally Modified (Based On LOCAL)

@@ -264,18 +264,18 @@



// Convert all pointers into events

for (int p = 0; p < event.getPointerCount(); p++) {

  •                Vector2f lastPos = lastPositions.get(pointerIndex);<br />
    
  •                Vector2f lastPos = lastPositions.get(p);<br />
    

if (lastPos == null) {

  •                    lastPos = new Vector2f(event.getX(pointerIndex), this.getHeight() - event.getY(pointerIndex));<br />
    
  •                    lastPositions.put(pointerId, lastPos);<br />
    
  •                    lastPos = new Vector2f(event.getX(p), this.getHeight() - event.getY(p));<br />
    
  •                    lastPositions.put(event.getPointerId(p), lastPos);<br />
    

}

touch = getNextFreeTouchEvent();

  •                touch.set(Type.MOVE, event.getX(pointerIndex), this.getHeight() - event.getY(pointerIndex), event.getX(pointerIndex) - lastPos.x, this.getHeight() - event.getY(pointerIndex) - lastPos.y);<br />
    
  •                touch.setPointerId(pointerId);<br />
    
  •                touch.set(Type.MOVE, event.getX(p), this.getHeight() - event.getY(p), event.getX(p) - lastPos.x, this.getHeight() - event.getY(p) - lastPos.y);<br />
    
  •                touch.setPointerId(p);<br />
    

touch.setTime(event.getEventTime());

  •                touch.setPressure(event.getPressure(pointerIndex));<br />
    
  •                touch.setPressure(event.getPressure(p));<br />
    

processEvent(touch);

  •                lastPos.set(event.getX(pointerIndex), this.getHeight() - event.getY(pointerIndex));<br />
    
  •                lastPos.set(event.getX(p), this.getHeight() - event.getY(p));<br />
    

}

bWasHandled = true;

break;



[/java]

2 Likes

Just a friendly bump to make sure this doesn’t get lost.

@iwgeric sorry i missed this post…the strange thing is that I didn’t get any mail from the nehon mention…



anyway, I’ll check and commit your patch thanks.

1 Like

Just a friendly bump to make sure it doesn’t get lost.

I think he’s diablo 3’ing all the time XD

@androlo said:
I think he's diablo 3'ing all the time XD

How dare you??? I was on a humanitarian trip, and while crossing the dessert my camel got stuck in moving sands and.....yeah...ok ...I was playing Diablo 3....

Anyway back to business
@iwgeric, i tried your patch but it does not seem to work. No matter what i do the pointerId is always 0.
I even tried to change this line
[java]
touch.setPointerId(p);
[/java]
to
[java]
touch.setPointerId(event.getPointerId(p));
[/java]
but it's still the same.
Did you manage to make it work on your side?

ok…that’s embarrassing. My mom always told me video games would get me dumb and she was right in the end.



I was not testing against the good JME3-android.jar…

I applied your change, it works pretty well.

It’s in last SVN



Thanks once again and sorry for the delay.

3 Likes

You had me worried for a minute. I’ve been caught by that as well, both for Android and for Native Bullet. Glad it worked.



Thanks for committing it.

2 Likes