hi all
i implemented an android app that support multitouch event with android.view.View.OnTouchListener implementation.
I can get all the pointer attributes and status with MotionEvent class
[java]
@Override
public boolean onTouch(View v, MotionEvent event) {
// event can say if it is a multitouch event , how many touch event i got, pointerId, pointerCount properties and bla bla…
}
[/java]
so my problem it is to know which is the corresponding object of android.view.View.OnTouchListener in jme3
I tried with com.jme3.input.controls.TouchListener
but with
[java]
@Override
public void onTouch(String name, TouchEvent evt, float tpf)
{
…
}
[/java]
i cannot do the same.I think that jme3 for android does not support multitouch events. If i’m wrong ( I hope so ) how do i manage it?
Please could you suggest me any code that do that?
I looked into it recently and afaik the only multitouch event supported is the scale gesture.
you have to register the TouchListener with the TouchInput.ALL and whatever mapping you want, ant then in the onTouch callback you have to test what kind of event you got (for scale there is SCALE_START, SCALE_MOVE, SCALE_END).
In other words, I don’t think there is a way to do what you want to do at the moment.
Maybe @larynx can shed some light on this
What can i do with scale_start scale move scale_end.I need to create a gamepad in android app with jme3. so i need multitouch.
I ve seen AndroidInput code and it looks like multitouch is managed in this way:
[java]
case MotionEvent.ACTION_DOWN:
if (!dontSendHistory)
{
// Process history
for (int h = 0; h < historySize; h++)
{
// Convert all pointers into events
for (int p = 0; p < pointerCount; p++)
{
touch = getNextFreeTouchEvent();
touch.set(Type.DOWN, event.getHistoricalX(p, h), this.getHeight() - event.getHistoricalY(p, h), 0, 0);
touch.setPointerId(event.getPointerId§);
touch.setTime(event.getHistoricalEventTime(h));
touch.setPressure(event.getHistoricalPressure(p, h));
processEvent(touch);
}
}
}
// Convert all pointers into events
for (int p = 0; p < pointerCount; p++)
{
touch = getNextFreeTouchEvent();
touch.set(Type.DOWN, event.getX§, this.getHeight() - event.getY§, 0, 0);
touch.setPointerId(event.getPointerId§);
touch.setTime(event.getEventTime());
touch.setPressure(event.getPressure§);
processEvent(touch);
}
bWasHandled = true;
break;
…
}
private void processEvent(TouchEvent event)
{
synchronized (eventQueue)
{
eventQueue.push(event);
}
}
[/java]
processEvent is the problem because it is synchronized .What do u think?
according to android’s doc http://developer.android.com/reference/android/view/MotionEvent.html, additional pointers should be triggered on ACTION_POINTER_DOWN event and not ACTION_DOWN.
edit : apparently it’s a TODO
// TODO: implement motion events
case MotionEvent.ACTION_POINTER_UP: