Hi, I fixed this by combining the GestureListener and
getPointerCount():
public boolean onTouchEvent(MotionEvent e) {
if(e.getPointerCount()>1){
mode = ZOOM;
}
detector.onTouchEvent(e);
float x = e.getX();
float y = e.getY();
switch (e.getAction()) {
/*case MotionEvent.ACTION_POINTER_DOWN:
oldDist = spacing(e);
if (oldDist >= 10f) {
mode = ZOOM;
Log.d(TAG, "Zoom Mode");
}
break;*/
case MotionEvent.ACTION_MOVE:
/*if (mode == ZOOM) {
float newDist = spacing(e);
if(newDist >= 10f){
float scale = newDist / oldDist;
Log.d(TAG,"Scale is: " + scale);
}
}*/
if(mode != ZOOM){
float dx = x - mPreviousX;
float dy = y - mPreviousY;
mRenderer.mAngleX += dx * TOUCH_SCALE_FACTOR;
mRenderer.mAngleY += dy * TOUCH_SCALE_FACTOR;
}
break;
case MotionEvent.ACTION_POINTER_UP:
mode = NONE;
Log.d(TAG, "Restoring mode");
break;
case MotionEvent.ACTION_UP:
mode = NONE;
break;
}
mPreviousX = x;
mPreviousY = y;
requestRender();
return true;
}
At least it's working now :)
On May 23, 1:56 pm, Vinicius Carvalho <[email protected]>
wrote:
> Hi there! I have a GLSurfaceView, and I'm trying to listen to multi
> touch events. Basically I want to use x/y move to rotate the model
> (just like the touchrotate example) but also the pinch gesture to zoom
> in/out.
>
> The problem is that it seems that the view is not sending all the
> fingers pressed to the MotionEvent.
>
> This code:
>
> public boolean onTouchEvent(MotionEvent e) {
> switch (e.getAction()) {
> case MotionEvent.ACTION_POINTER_DOWN:
> break;
>
> }
> }
>
> Does not gets called at all. Only after using 6 or more
> fingers ... ????
>
> I also tried to use the gesturelistener, which worked like a charm :
>
> this.detector = new ScaleGestureDetector(context, new
> ScaleListener());
> public boolean onTouchEvent(MotionEvent e) {
> detector.onTouchEvent(e);
>
> }
>
> The problem now, is that I do detect the scale, but when it hapens,
> the model is being rotated on both axis at the same time. I'd like to
> detect a multiple input to avoid rotating the model and let the user
> only zoom, but as I said, the motionevent never returns more than one
> finger pressed at the same time.
>
> How can I solve this?
>
> Regards
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en