public boolean onTouch(MotionEvent event) {
        if (!isInitialized()) {
            return false;
        }

        boolean bWasHandled = false;
        TouchEvent touch = null;
        //    System.out.println("native : " + event.getAction());
        getAction(event);
        int pointerIndex = getPointerIndex(event);
        int pointerId = getPointerId(event);
        Vector2f lastPos = lastPositions.get(pointerId);
        float jmeX;
        float jmeY;

        numPointers = event.getPointerCount();

        // final int historySize = event.getHistorySize();
        //final int pointerCount = event.getPointerCount();
        switch (getAction(event)) {
            case MotionEvent.ACTION_POINTER_DOWN:
            case MotionEvent.ACTION_DOWN:
                jmeX = getJmeX(event.getX(pointerIndex));
                jmeY = invertY(getJmeY(event.getY(pointerIndex)));
                touch = getFreeTouchEvent();
                touch.set(TouchEvent.Type.DOWN, jmeX, jmeY, 0, 0);
                touch.setPointerId(pointerId);
                touch.setTime(event.getEventTime());
                touch.setPressure(event.getPressure(pointerIndex));

                lastPos = new Vector2f(jmeX, jmeY);
                lastPositions.put(pointerId, lastPos);

                addEvent(touch);
                addEvent(generateMouseEvent(touch));

                bWasHandled = true;
                break;
            case MotionEvent.ACTION_POINTER_UP:
            case MotionEvent.ACTION_CANCEL:
            case MotionEvent.ACTION_UP:
                jmeX = getJmeX(event.getX(pointerIndex));
                jmeY = invertY(getJmeY(event.getY(pointerIndex)));
                touch = getFreeTouchEvent();
                touch.set(TouchEvent.Type.UP, jmeX, jmeY, 0, 0);
                touch.setPointerId(pointerId);
                touch.setTime(event.getEventTime());
                touch.setPressure(event.getPressure(pointerIndex));
                lastPositions.remove(pointerId);

                addEvent(touch);
                addEvent(generateMouseEvent(touch));

                bWasHandled = true;
                break;
            case MotionEvent.ACTION_MOVE:
                // Convert all pointers into events
                for (int p = 0; p < event.getPointerCount(); p++) {
                    jmeX = getJmeX(event.getX(p));
                    jmeY = invertY(getJmeY(event.getY(p)));
                    lastPos = lastPositions.get(event.getPointerId(p));
                    if (lastPos == null) {
                        lastPos = new Vector2f(jmeX, jmeY);
                        lastPositions.put(event.getPointerId(p), lastPos);
                    }

                    float dX = jmeX - lastPos.x;
                    float dY = jmeY - lastPos.y;
                    if (dX != 0 || dY != 0) {
                        touch = getFreeTouchEvent();
                        touch.set(TouchEvent.Type.MOVE, jmeX, jmeY, dX, dY);
                        touch.setPointerId(event.getPointerId(p));
                        touch.setTime(event.getEventTime());
                        touch.setPressure(event.getPressure(p));
                        lastPos.set(jmeX, jmeY);

                        addEvent(touch);
                        addEvent(generateMouseEvent(touch));

                        bWasHandled = true;
                    }
                }
                break;
            case MotionEvent.ACTION_OUTSIDE:
                break;

        }

        // Try to detect gestures
        if (gestureDetector != null) {
            gestureDetector.onTouchEvent(event);
        }
        if (scaleDetector != null) {
            scaleDetector.onTouchEvent(event);
        }

        return bWasHandled;
    }
AndroidTouchInput is the base class that receives touch inputs from the
Android system and creates the TouchEvents for jME.  This class is designed
to handle the base touch events for Android rev 9 (Android 2.3).  This is
extended by other classes to add features that were introduced after
Android rev 9.

@author iwgeric
jme3-android/src/main/java/com/jme3/input/android/AndroidTouchInput.java