GLSurfaceView queueEvent and onTouchEvent seams broken!!!

What a title, I know but thats exactly what it is.

This issue is happening on Android 1.6 so it might already been fixed. Just as per documentation i have implemented my GLSurfaceView as GameGLSurfaceView and overridden public boolean onTouchEvent(final MotionEvent event) method as so.

/**
	 * Capture touch event and delegate it to our renderer
	 */
	public boolean onTouchEvent(final MotionEvent event) {
		// This method will be called on the rendering thread
		Log.i(TAG, "GOT EVENT : "+event.getAction());
		//mRenderer.onTouchEvent(event);
		queueEvent(new Runnable(){
			public void run() {
				mRenderer.onTouchEvent(event);
		}});
		return true;
	}

and in my renderer I simply print that I received the event.

06-09 15:16:37.456: INFO/GameSurfaceView(14749): GOT EVENT : 0
06-09 15:16:37.466: INFO/GameSurfaceView(14749): GOT EVENT : 2
06-09 15:16:37.486: DEBUG/com.fivebrothers.engine.scene.AbstractRenderer(14749): RECIVED EVENT : 2
06-09 15:16:37.486: DEBUG/com.fivebrothers.engine.scene.AbstractRenderer(14749): RECIVED EVENT : 2
06-09 15:16:37.506: INFO/GameSurfaceView(14749): GOT EVENT : 2
06-09 15:16:37.506: INFO/GameSurfaceView(14749): GOT EVENT : 1
06-09 15:16:37.566: DEBUG/com.fivebrothers.engine.scene.AbstractRenderer(14749): RECIVED EVENT : 1
06-09 15:16:37.566: DEBUG/com.fivebrothers.engine.scene.AbstractRenderer(14749): RECIVED EVENT : 1

As you can see we have never recived event that MotionEvent.ACTION_DOWN have fired. So I really don’t know what might be the problem here.

One solution I have found is to call directly as so

        /**
	 * Capture touch event and delegate it to our renderer
	 */
	public boolean onTouchEvent(final MotionEvent event) {	
		return mRenderer.onTouchEvent(event);
	}

this does work but is it correct ?

2 thoughts on “GLSurfaceView queueEvent and onTouchEvent seams broken!!!”

  1. I found the cause of this. It’s because there are too many queued events. Try to find a way to reduce the number of events and it will work better.

    Hope this helps
    Ash

Leave a Comment

Your email address will not be published. Required fields are marked *