Example usage for android.view MotionEvent getActionIndex

List of usage examples for android.view MotionEvent getActionIndex

Introduction

In this page you can find the example usage for android.view MotionEvent getActionIndex.

Prototype

public final int getActionIndex() 

Source Link

Document

For #ACTION_POINTER_DOWN or #ACTION_POINTER_UP as returned by #getActionMasked , this returns the associated pointer index.

Usage

From source file:com.google.blockly.android.ui.PendingDrag.java

/**
 * Constructs a new PendingDrag that, if accepted by the DragHandler, begins with the
 * {@code actionDown} event./*from  w w w. j av a 2 s. c  o  m*/
 *
 * @param controller The activity's {@link BlocklyController}.
 * @param touchedView The initial touched {@link BlockView} of the drag.
 * @param actionDown The first {@link MotionEvent#ACTION_DOWN} event.
 */
PendingDrag(@NonNull BlocklyController controller, @NonNull BlockView touchedView,
        @NonNull MotionEvent actionDown) {
    if (actionDown.getAction() != MotionEvent.ACTION_DOWN) {
        throw new IllegalArgumentException();
    }

    mController = controller;
    mHelper = controller.getWorkspaceHelper();

    mLatestEventTime = actionDown.getEventTime();

    mTouchedView = touchedView;

    mPointerId = actionDown.getPointerId(actionDown.getActionIndex());
    int pointerIdx = actionDown.findPointerIndex(mPointerId);
    mTouchDownBlockX = (int) actionDown.getX(pointerIdx);
    mTouchDownBlockY = (int) actionDown.getY(pointerIdx);

    touchedView.getTouchLocationOnScreen(actionDown, mTouchDownScreen);
    mHelper.screenToWorkspaceCoordinates(mTouchDownScreen, mTouchDownWorkspace);

    mGestureDetector = new GestureDetectorCompat(mController.getContext(), new GestureListener());
    mGestureDetector.onTouchEvent(actionDown);
}

From source file:com.github.crvv.wubinput.wubi.dictionary.suggestions.SuggestionStripView.java

@Override
public boolean onInterceptTouchEvent(final MotionEvent me) {
    if (!mMoreSuggestionsView.isShowingInParent()) {
        mLastX = (int) me.getX();
        mLastY = (int) me.getY();
        return mMoreSuggestionsSlidingDetector.onTouchEvent(me);
    }//from   w  w w.  ja  va 2 s  .  c  o m

    final int action = me.getAction();
    final int index = me.getActionIndex();
    final int x = (int) me.getX(index);
    final int y = (int) me.getY(index);
    if (Math.abs(x - mOriginX) >= mMoreSuggestionsModalTolerance
            || mOriginY - y >= mMoreSuggestionsModalTolerance) {
        // Decided to be in the sliding suggestion mode only when the touch point has been moved
        // upward. Further {@link MotionEvent}s will be delivered to
        // {@link #onTouchEvent(MotionEvent)}.
        mNeedsToTransformTouchEventToHoverEvent = AccessibilityUtils.getInstance().isTouchExplorationEnabled();
        mIsDispatchingHoverEventToMoreSuggestions = false;
        return true;
    }

    if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_POINTER_UP) {
        // Decided to be in the modal input mode.
        mMoreSuggestionsView.adjustVerticalCorrectionForModalMode();
    }
    return false;
}

From source file:ch.tutti.android.bottomsheet.ResolverDrawerLayout.java

private void onSecondaryPointerUp(MotionEvent ev) {
    final int pointerIndex = ev.getActionIndex();
    final int pointerId = ev.getPointerId(pointerIndex);
    if (pointerId == mActivePointerId) {
        // This was our active pointer going up. Choose a new
        // active pointer and adjust accordingly.
        final int newPointerIndex = pointerIndex == 0 ? 1 : 0;
        mInitialTouchX = ev.getX(newPointerIndex);
        mInitialTouchY = mLastTouchY = ev.getY(newPointerIndex);
        mActivePointerId = ev.getPointerId(newPointerIndex);
    }/*from w w w. j  a v  a 2  s .  c o m*/
}

From source file:study.com.s_sxl.carelib.pullRefreshView.layout.FlingLayout.java

/******************************************************************/

@Override//from   w  ww .  j  av a 2s  . co  m
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (mPullView != null && !ViewCompat.isNestedScrollingEnabled(mPullView)) {
        float moveY = getMoveY();
        int pointerCount = ev.getPointerCount();
        int pointerIndex = ev.getActionIndex();
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }
        switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            float x = ev.getX(pointerIndex);
            float y = ev.getY(pointerIndex);
            tempY = downY = y;
            tempX = downX = x;
            tempStateType = SCROLL_STATE_TOUCH_SCROLL;
            if (moveY != 0) {
                return true;
            }
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            tempX = ev.getX(pointerIndex);
            tempY = ev.getY(pointerIndex);
            break;
        case MotionEvent.ACTION_MOVE:
            pointerIndex = ev.findPointerIndex(mPointerId);
            float mx;
            float my;
            if (pointerCount > pointerIndex && pointerIndex >= 0) {
                mx = ev.getX(pointerIndex);
                my = ev.getY(pointerIndex);
            } else {
                mx = ev.getX();
                my = ev.getY();
            }
            //?????
            int dataX = (int) (mx - tempX);
            int dataY = (int) (my - tempY);
            tempX = mx;
            tempY = my;
            if (isScrolling || (Math.abs(dataY) > Math.abs(dataX))) {
                isScrolling = true;
                if (moveY == 0) {
                    // 0,0
                    //??
                    if ((dataY < 0 && canPullUp()) || (dataY > 0 && canPullDown())) {
                        moveBy(dataY);
                        return true;
                    }
                } else {
                    //?0,0
                    ev.setAction(MotionEvent.ACTION_CANCEL);//?

                    if ((moveY < 0 && moveY + dataY >= 0) || (moveY > 0 && moveY + dataY <= 0)) {
                        //0,0
                        ev.setAction(MotionEvent.ACTION_DOWN);
                        moveTo(0);
                    } else if ((moveY > 0 && dataY > 0) || (moveY < 0 && dataY < 0)) {
                        //??
                        if (maxDistance == 0 || Math.abs(moveY) < maxDistance) {
                            int ps = 0;
                            int hDataY = dataY / 2;
                            if (maxDistance == 0) {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) MAXDISTANCE) - hDataY;
                            } else {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) maxDistance) - hDataY;
                            }
                            moveBy(ps + dataY);
                        } else if (moveY > maxDistance) {
                            moveTo(maxDistance);
                        } else if (moveY < -maxDistance) {
                            moveTo(-maxDistance);
                        }
                    } else {
                        moveBy(dataY);
                    }
                }
            } else {
                ev.setLocation(mx, downY);
            }
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            startFling();
            isScrolling = false;
            break;
        case MotionEvent.ACTION_POINTER_UP:
            // ??
            int pointerIdLeave = ev.getPointerId(pointerIndex);
            if (mPointerId == pointerIdLeave) {
                // ??????VelocityTracker
                int reIndex = pointerIndex == 0 ? 1 : 0;
                mPointerId = ev.getPointerId(reIndex);
                // ?
                tempY = ev.getY(reIndex);
            }
        }
        return super.dispatchTouchEvent(ev) || isScrolling;
    } else {
        return super.dispatchTouchEvent(ev);
    }

}

From source file:com.leap.mini.widget.pullrefresh.base.layout.FlingLayout.java

/******************************************************************/

@Override// w  ww .ja v a 2s  . c om
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (mPullView != null && !ViewCompat.isNestedScrollingEnabled(mPullView)) {
        float moveY = getMoveY();
        int pointerCount = ev.getPointerCount();
        int pointerIndex = ev.getActionIndex();
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }
        switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            float x = ev.getX(pointerIndex);
            float y = ev.getY(pointerIndex);
            tepmY = downY = y;
            tepmX = downX = x;
            tempStateType = SCROLL_STATE_TOUCH_SCROLL;
            if (moveY != 0) {
                return true;
            }
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            tepmX = ev.getX(pointerIndex);
            tepmY = ev.getY(pointerIndex);
            break;
        case MotionEvent.ACTION_MOVE:
            pointerIndex = ev.findPointerIndex(mPointerId);
            float mx;
            float my;
            if (pointerCount > pointerIndex && pointerIndex >= 0) {
                mx = ev.getX(pointerIndex);
                my = ev.getY(pointerIndex);
            } else {
                mx = ev.getX();
                my = ev.getY();
            }
            // ?????
            int dataX = (int) (mx - tepmX);
            int dataY = (int) (my - tepmY);
            tepmX = mx;
            tepmY = my;
            if (isScrolling || (Math.abs(dataY) > Math.abs(dataX))) {
                isScrolling = true;
                if (moveY == 0) {
                    //  0,0
                    // ??
                    if ((dataY < 0 && canPullUp()) || (dataY > 0 && canPullDown())) {
                        moveBy(dataY);
                        return true;
                    }
                } else {
                    // ?0,0
                    ev.setAction(MotionEvent.ACTION_CANCEL);// ?

                    if ((moveY < 0 && moveY + dataY >= 0) || (moveY > 0 && moveY + dataY <= 0)) {
                        // 0,0
                        ev.setAction(MotionEvent.ACTION_DOWN);
                        moveTo(0);
                    } else if ((moveY > 0 && dataY > 0) || (moveY < 0 && dataY < 0)) {
                        // ??
                        if (maxDistance == 0 || Math.abs(moveY) < maxDistance) {
                            int ps = 0;
                            int hDataY = dataY / 2;
                            if (maxDistance == 0) {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) MAXDISTANCE) - hDataY;
                            } else {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) maxDistance) - hDataY;
                            }
                            moveBy(ps + dataY);
                        } else if (moveY > maxDistance) {
                            moveTo(maxDistance);
                        } else if (moveY < -maxDistance) {
                            moveTo(-maxDistance);
                        }
                    } else {
                        moveBy(dataY);
                    }
                }
            } else {
                ev.setLocation(mx, downY);
            }
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            startFling();
            isScrolling = false;
            break;
        case MotionEvent.ACTION_POINTER_UP:
            // ??
            int pointerIdLeave = ev.getPointerId(pointerIndex);
            if (mPointerId == pointerIdLeave) {
                // ??????VelocityTracker
                int reIndex = pointerIndex == 0 ? 1 : 0;
                mPointerId = ev.getPointerId(reIndex);
                // ?
                tepmY = ev.getY(reIndex);
            }
        }
        return super.dispatchTouchEvent(ev) || isScrolling;
    } else {
        return super.dispatchTouchEvent(ev);
    }

}

From source file:com.ybao.pullrefreshview.layout.FlingLayout.java

/******************************************************************/

@Override/*w  w w  .  j  a v a 2  s .c om*/
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (mPullView != null && !ViewCompat.isNestedScrollingEnabled(mPullView)) {
        float moveY = getMoveY();
        int pointerCount = ev.getPointerCount();
        int pointerIndex = ev.getActionIndex();
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }
        switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            float x = ev.getX(pointerIndex);
            float y = ev.getY(pointerIndex);
            tepmY = downY = y;
            tepmX = downX = x;
            tempStateType = SCROLL_STATE_TOUCH_SCROLL;
            if (moveY != 0) {
                return true;
            }
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            tepmX = ev.getX(pointerIndex);
            tepmY = ev.getY(pointerIndex);
            break;
        case MotionEvent.ACTION_MOVE:
            pointerIndex = ev.findPointerIndex(mPointerId);
            float mx;
            float my;
            if (pointerCount > pointerIndex && pointerIndex >= 0) {
                mx = ev.getX(pointerIndex);
                my = ev.getY(pointerIndex);
            } else {
                mx = ev.getX();
                my = ev.getY();
            }
            //?????
            int dataX = (int) (mx - tepmX);
            int dataY = (int) (my - tepmY);
            tepmX = mx;
            tepmY = my;
            if (isScrolling || (Math.abs(dataY) > Math.abs(dataX))) {
                isScrolling = true;
                if (moveY == 0) {
                    // 0,0
                    //??
                    if ((dataY < 0 && canPullUp()) || (dataY > 0 && canPullDown())) {
                        moveBy(dataY);
                        return true;
                    }
                } else {
                    //?0,0
                    ev.setAction(MotionEvent.ACTION_CANCEL);//?

                    if ((moveY < 0 && moveY + dataY >= 0) || (moveY > 0 && moveY + dataY <= 0)) {
                        //0,0
                        ev.setAction(MotionEvent.ACTION_DOWN);
                        moveTo(0);
                    } else if ((moveY > 0 && dataY > 0) || (moveY < 0 && dataY < 0)) {
                        //??
                        if (maxDistance == 0 || Math.abs(moveY) < maxDistance) {
                            int ps = 0;
                            int hDataY = dataY / 2;
                            if (maxDistance == 0) {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) MAXDISTANCE) - hDataY;
                            } else {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) maxDistance) - hDataY;
                            }
                            moveBy(ps + dataY);
                        } else if (moveY > maxDistance) {
                            moveTo(maxDistance);
                        } else if (moveY < -maxDistance) {
                            moveTo(-maxDistance);
                        }
                    } else {
                        moveBy(dataY);
                    }
                }
            } else {
                ev.setLocation(mx, downY);
            }
            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            startFling();
            isScrolling = false;
            break;
        case MotionEvent.ACTION_POINTER_UP:
            // ??
            int pointerIdLeave = ev.getPointerId(pointerIndex);
            if (mPointerId == pointerIdLeave) {
                // ??????VelocityTracker
                int reIndex = pointerIndex == 0 ? 1 : 0;
                mPointerId = ev.getPointerId(reIndex);
                // ?
                tepmY = ev.getY(reIndex);
            }
        }
        return super.dispatchTouchEvent(ev) || isScrolling;
    } else {
        return super.dispatchTouchEvent(ev);
    }

}

From source file:com.cocarechina.pullrefreshview.layout.FlingLayout.java

/******************************************************************/

@Override//from   w ww. j ava  2  s  .  c om
public boolean dispatchTouchEvent(MotionEvent ev) {
    if (mPullView != null && !ViewCompat.isNestedScrollingEnabled(mPullView)) {
        float moveY = getMoveY();
        int pointerCount = ev.getPointerCount();
        int pointerIndex = ev.getActionIndex();
        if (!mScroller.isFinished()) {
            mScroller.abortAnimation();
        }
        switch (ev.getActionMasked()) {
        case MotionEvent.ACTION_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            float x = ev.getX(pointerIndex);
            float y = ev.getY(pointerIndex);
            tepmY = downY = y;
            tepmX = downX = x;
            tempStateType = SCROLL_STATE_TOUCH_SCROLL;
            if (moveY != 0) {
                return true;
            }
            lastY = ev.getY();
            Log.v("lastY", moveY + "");
            break;
        case MotionEvent.ACTION_POINTER_DOWN:
            mPointerId = ev.getPointerId(pointerIndex);
            tepmX = ev.getX(pointerIndex);
            tepmY = ev.getY(pointerIndex);
            break;
        case MotionEvent.ACTION_MOVE:
            pointerIndex = ev.findPointerIndex(mPointerId);
            float mx;
            float my;
            if (pointerCount > pointerIndex && pointerIndex >= 0) {
                mx = ev.getX(pointerIndex);
                my = ev.getY(pointerIndex);
            } else {
                mx = ev.getX();
                my = ev.getY();
            }
            //?????
            int dataX = (int) (mx - tepmX);
            int dataY = (int) (my - tepmY);
            tepmX = mx;
            tepmY = my;
            if (isScrolling || (Math.abs(dataY) > Math.abs(dataX))) {
                isScrolling = true;
                if (moveY == 0) {
                    // 0,0
                    //??
                    if ((dataY < 0 && canPullUp()) || (dataY > 0 && canPullDown())) {
                        moveBy(dataY);
                        return true;
                    }
                } else {
                    //?0,0
                    ev.setAction(MotionEvent.ACTION_CANCEL);//?

                    if ((moveY < 0 && moveY + dataY >= 0) || (moveY > 0 && moveY + dataY <= 0)) {
                        //0,0
                        ev.setAction(MotionEvent.ACTION_DOWN);
                        moveTo(0);
                    } else if ((moveY > 0 && dataY > 0) || (moveY < 0 && dataY < 0)) {
                        //??
                        if (maxDistance == 0 || Math.abs(moveY) < maxDistance) {
                            int ps = 0;
                            int hDataY = dataY / 2;
                            if (maxDistance == 0) {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) MAXDISTANCE) - hDataY;
                            } else {
                                ps = (int) (-hDataY * Math.abs(moveY) / (float) maxDistance) - hDataY;
                            }
                            moveBy(ps + dataY);
                        } else if (moveY > maxDistance) {

                            moveTo(maxDistance);
                        } else if (moveY < -maxDistance) {
                            moveTo(-maxDistance);
                        }
                    } else {
                        moveBy(dataY);
                    }
                }
            } else {
                ev.setLocation(mx, downY);
            }

            Log.v("flingLayout", "ev.getY()" + ev.getY() + "  ---  lastY " + lastY);
            if (ev.getY() - lastY > 5) {
                if (monScrollHeadListener != null) {
                    monScrollHeadListener.onScrollBottom();
                }
            } else if (ev.getY() - lastY < -10) {
                if (monScrollHeadListener != null) {
                    monScrollHeadListener.onScrollTop();
                }
            }

            break;
        case MotionEvent.ACTION_CANCEL:
        case MotionEvent.ACTION_UP:
            startFling();
            isScrolling = false;
            break;
        case MotionEvent.ACTION_POINTER_UP:
            // ??
            int pointerIdLeave = ev.getPointerId(pointerIndex);
            if (mPointerId == pointerIdLeave) {
                // ??????VelocityTracker
                int reIndex = pointerIndex == 0 ? 1 : 0;
                mPointerId = ev.getPointerId(reIndex);
                // ?
                tepmY = ev.getY(reIndex);
            }
        }
        return super.dispatchTouchEvent(ev) || isScrolling;
    } else {
        return super.dispatchTouchEvent(ev);
    }

}

From source file:com.android.inputmethod.latin.suggestions.SuggestionStripView.java

@Override
public boolean onTouchEvent(final MotionEvent me) {
    if (!mMoreSuggestionsView.isShowingInParent()) {
        // Ignore any touch event while more suggestions panel hasn't been shown.
        // Detecting sliding up is done at {@link #onInterceptTouchEvent}.
        return true;
    }/*from  w  ww .j  av  a2s .  c  om*/
    // In the sliding input mode. {@link MotionEvent} should be forwarded to
    // {@link MoreSuggestionsView}.
    final int index = me.getActionIndex();
    final int x = mMoreSuggestionsView.translateX((int) me.getX(index));
    final int y = mMoreSuggestionsView.translateY((int) me.getY(index));
    me.setLocation(x, y);
    if (!mNeedsToTransformTouchEventToHoverEvent) {
        mMoreSuggestionsView.onTouchEvent(me);
        return true;
    }
    // In sliding suggestion mode with accessibility mode on, a touch event should be
    // transformed to a hover event.
    final int width = mMoreSuggestionsView.getWidth();
    final int height = mMoreSuggestionsView.getHeight();
    final boolean onMoreSuggestions = (x >= 0 && x < width && y >= 0 && y < height);
    if (!onMoreSuggestions && !mIsDispatchingHoverEventToMoreSuggestions) {
        // Just drop this touch event because dispatching hover event isn't started yet and
        // the touch event isn't on {@link MoreSuggestionsView}.
        return true;
    }
    final int hoverAction;
    if (onMoreSuggestions && !mIsDispatchingHoverEventToMoreSuggestions) {
        // Transform this touch event to a hover enter event and start dispatching a hover
        // event to {@link MoreSuggestionsView}.
        mIsDispatchingHoverEventToMoreSuggestions = true;
        hoverAction = MotionEvent.ACTION_HOVER_ENTER;
    } else if (me.getActionMasked() == MotionEvent.ACTION_UP) {
        // Transform this touch event to a hover exit event and stop dispatching a hover event
        // after this.
        mIsDispatchingHoverEventToMoreSuggestions = false;
        mNeedsToTransformTouchEventToHoverEvent = false;
        hoverAction = MotionEvent.ACTION_HOVER_EXIT;
    } else {
        // Transform this touch event to a hover move event.
        hoverAction = MotionEvent.ACTION_HOVER_MOVE;
    }
    me.setAction(hoverAction);
    mMoreSuggestionsView.onHoverEvent(me);
    return true;
}

From source file:com.kerkr.edu.recycleView.SwipeToDismissTouchListener.java

private boolean move(MotionEvent motionEvent) {
    if (mSwipeView == null || mVelocityTracker == null || mPaused) {
        return false;
    }//from   ww  w  .j a  va 2s . c o  m

    mVelocityTracker.addMovement(motionEvent);
    float deltaX = motionEvent.getRawX() - mDownX;
    float deltaY = motionEvent.getRawY() - mDownY;
    if (Math.abs(deltaX) > mSlop && Math.abs(deltaY) < Math.abs(deltaX) / 2) {
        mSwiping = true;
        mSwipingSlop = (deltaX > 0 ? mSlop : -mSlop);
        mSwipeView.setPressed(false);

        MotionEvent cancelEvent = MotionEvent.obtain(motionEvent);
        cancelEvent.setAction(MotionEvent.ACTION_CANCEL
                | (motionEvent.getActionIndex() << MotionEvent.ACTION_POINTER_INDEX_SHIFT));
        mSwipeView.onTouchEvent(cancelEvent);
    }

    //Prevent swipes to disallowed directions
    if ((deltaX < 0 && mAllowedSwipeDirection == SwipeDirection.RIGHT)
            || (deltaX > 0 && mAllowedSwipeDirection == SwipeDirection.LEFT)) {
        resetMotion();
        return false;
    }

    if (mSwiping) {
        mTranslationX = deltaX;
        ViewCompat.setTranslationX(mSwipeView, deltaX - mSwipingSlop);
        ViewCompat.setAlpha(mSwipeView, Math.max(0f, Math.min(1f, 1f - 2f * Math.abs(deltaX) / mViewWidth)));
        return true;
    }
    return false;
}

From source file:org.uoyabause.android.PadButton.java

public boolean onTouch(View v, MotionEvent event) {

    int action = event.getActionMasked();
    int touchCount = event.getPointerCount();

    int pointerIndex = event.getActionIndex();
    int pointerId = event.getPointerId(pointerIndex);
    int posx = (int) event.getX(pointerIndex);
    int posy = (int) event.getY(pointerIndex);

    float hitsize = 15.0f * wscale * base_scale;
    RectF hittest = new RectF((int) (posx - hitsize), (int) (posy - hitsize), (int) (posx + hitsize),
            (int) (posy + hitsize));

    switch (action) {
    case MotionEvent.ACTION_DOWN:
        for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) {
            if (buttons[btnindex].intersects(hittest)) {
                buttons[btnindex].On(pointerId);
            }/*ww  w. ja  v a 2 s .co  m*/
        }

        if (_pad_mode == 1) {
            updatePad(hittest, posx, posy, pointerId);
        }

        break;

    case MotionEvent.ACTION_POINTER_DOWN:
        for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) {
            if (buttons[btnindex].intersects(hittest)) {
                buttons[btnindex].On(pointerId);
            }
        }
        if (_pad_mode == 1) {
            updatePad(hittest, posx, posy, pointerId);
        }

        break;

    case MotionEvent.ACTION_POINTER_UP:
        for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) {
            if (buttons[btnindex].intersects(hittest)) {
                buttons[btnindex].Off();
            }
        }

        if (_pad_mode == 1) {
            releasePad(pointerId);
        }

        break;

    case MotionEvent.ACTION_CANCEL:
    case MotionEvent.ACTION_UP:
        for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) {
            if (buttons[btnindex].intersects(hittest)) {
                buttons[btnindex].Off();
            }
        }

        if (_pad_mode == 1) {
            releasePad(pointerId);
        }

        break;

    case MotionEvent.ACTION_MOVE:

        for (int index = 0; index < touchCount; index++) {

            int eventID2 = event.getPointerId(index);
            float x2 = event.getX(index);
            float y2 = event.getY(index);

            RectF hittest2 = new RectF((int) (x2 - hitsize), (int) (y2 - hitsize), (int) (x2 + hitsize),
                    (int) (y2 + hitsize));

            for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) {
                if (eventID2 == buttons[btnindex].getPointId()) {
                    if (buttons[btnindex].intersects(hittest2) == false) {
                        buttons[btnindex].Off();
                    }
                } else if (buttons[btnindex].intersects(hittest2)) {
                    buttons[btnindex].On(eventID2);
                }
            }

            if (_pad_mode == 1) {
                updatePad(hittest2, (int) x2, (int) y2, eventID2);
            }
        }
        break;
    }

    if (!testmode) {

        if (_pad_mode == 0) {

            for (int btnindex = 0; btnindex < PadEvent.BUTTON_LAST; btnindex++) {
                if (buttons[btnindex].isOn()) {
                    YabauseRunnable.press(btnindex, 0);
                } else {
                    YabauseRunnable.release(btnindex, 0);
                }
            }
        } else {
            for (int btnindex = PadEvent.BUTTON_RIGHT_TRIGGER; btnindex < PadEvent.BUTTON_LAST; btnindex++) {
                if (buttons[btnindex].isOn()) {
                    YabauseRunnable.press(btnindex, 0);
                } else {
                    YabauseRunnable.release(btnindex, 0);
                }
            }
        }
    }

    if (testmode) {
        status = "";
        status += "START:";
        if (buttons[PadEvent.BUTTON_START].isOn())
            status += "ON ";
        else
            status += "OFF ";

        status += "\nUP:";
        if (buttons[PadEvent.BUTTON_UP].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "DOWN:";
        if (buttons[PadEvent.BUTTON_DOWN].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "LEFT:";
        if (buttons[PadEvent.BUTTON_LEFT].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "RIGHT:";
        if (buttons[PadEvent.BUTTON_RIGHT].isOn())
            status += "ON ";
        else
            status += "OFF ";

        status += "\nA:";
        if (buttons[PadEvent.BUTTON_A].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "B:";
        if (buttons[PadEvent.BUTTON_B].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "C:";
        if (buttons[PadEvent.BUTTON_C].isOn())
            status += "ON ";
        else
            status += "OFF ";

        status += "\nX:";
        if (buttons[PadEvent.BUTTON_X].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "Y:";
        if (buttons[PadEvent.BUTTON_Y].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "Z:";
        if (buttons[PadEvent.BUTTON_Z].isOn())
            status += "ON ";
        else
            status += "OFF ";

        status += "\nLT:";
        if (buttons[PadEvent.BUTTON_LEFT_TRIGGER].isOn())
            status += "ON ";
        else
            status += "OFF ";
        status += "RT:";
        if (buttons[PadEvent.BUTTON_RIGHT_TRIGGER].isOn())
            status += "ON ";
        else
            status += "OFF ";

        status += "\nAX:";
        if (_analog_pad.isOn())
            status += "ON " + _axi_x;
        else
            status += "OFF " + _axi_x;
        status += "AY:";
        if (_analog_pad.isOn())
            status += "ON " + _axi_y;
        else
            status += "OFF " + _axi_y;

    }
    if ((listener != null)) {
        listener.onPad(null);
    }
    return true;
}