Java Code Examples for android.view.MotionEvent#getPointerCoords()

The following examples show how to use android.view.MotionEvent#getPointerCoords() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GameWebView.java    From kcanotify_h5-master with GNU General Public License v3.0 5 votes vote down vote up
private void buildMoveEvent(MotionEvent event){
    MotionEvent.PointerProperties[] pointerProperties = new MotionEvent.PointerProperties[]{new MotionEvent.PointerProperties()};
    event.getPointerProperties(0, pointerProperties[0]);
    MotionEvent.PointerCoords[] pointerCoords = new MotionEvent.PointerCoords[]{new MotionEvent.PointerCoords()};
    event.getPointerCoords(0, pointerCoords[0]);
    pointerProperties[0].toolType = MotionEvent.TOOL_TYPE_MOUSE;
    pointerCoords[0].x -= this.getX();
    pointerCoords[0].y -= this.getY();
    long touchTime = SystemClock.uptimeMillis();
    this.onTouchEvent(MotionEvent.obtain(touchTime, touchTime, MotionEvent.ACTION_MOVE, 1,
            pointerProperties, pointerCoords, 0, 0, 0f, 0f,
            InputDevice.KEYBOARD_TYPE_NON_ALPHABETIC, 0, InputDevice.SOURCE_TOUCHSCREEN, 0));
}
 
Example 2
Source File: ServoPanZoomController.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
private boolean handleMotionEvent(MotionEvent event) {
    if (!mAttached) {
        mQueuedEvents.add(new Pair(EVENT_SOURCE_MOTION, event));
        return false;
    }

    if (event.getPointerCount() <= 0) {
        return false;
    }

    final int action = event.getActionMasked();

    if (action == MotionEvent.ACTION_DOWN) {
        mLastDownTime = event.getDownTime();
    } else if (mLastDownTime != event.getDownTime()) {
        return false;
    }

    final MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
    event.getPointerCoords(0, coords);

    if (action == MotionEvent.ACTION_UP) {
        mSession.click((int) coords.x, (int) coords.y);
    }

    return true;
}
 
Example 3
Source File: ServoPanZoomController.java    From FirefoxReality with Mozilla Public License 2.0 5 votes vote down vote up
private boolean handleScrollEvent(MotionEvent event) {
    if (!mAttached) {
        mQueuedEvents.add(new Pair(EVENT_SOURCE_SCROLL, event));
        return false;
    }

    if (event.getPointerCount() <= 0) {
        return false;
    }

    final MotionEvent.PointerCoords coords = new MotionEvent.PointerCoords();
    event.getPointerCoords(0, coords);

    mSession.getSurfaceBounds(mTempRect);
    final float x = coords.x - mTempRect.left;
    final float y = coords.y - mTempRect.top;

    final float hScroll = event.getAxisValue(MotionEvent.AXIS_HSCROLL) * mPointerScrollFactor;
    final float vScroll = event.getAxisValue(MotionEvent.AXIS_VSCROLL) * mPointerScrollFactor;

    if (!mIsScrolling) {
        mSession.scrollStart((int) hScroll, (int) vScroll, (int) x, (int) y);
    } else {
        mSession.scroll((int) hScroll, (int) vScroll, (int) x, (int) y);
    }
    mIsScrolling = true;
    return true;
}
 
Example 4
Source File: StickyGridHeadersGridView.java    From o2oa with GNU Affero General Public License v3.0 5 votes vote down vote up
private static MotionEvent.PointerCoords[] getPointerCoords(MotionEvent e) {
    int n = e.getPointerCount();
    MotionEvent.PointerCoords[] r = new MotionEvent.PointerCoords[n];
    for (int i = 0; i < n; i++) {
        r[i] = new MotionEvent.PointerCoords();
        e.getPointerCoords(i, r[i]);
    }
    return r;
}
 
Example 5
Source File: MotionEventHelper.java    From ViewSupport with Apache License 2.0 5 votes vote down vote up
private static PointerCoords[] getPointerCoords(MotionEvent e) {
    int n = e.getPointerCount();
    PointerCoords[] r = new PointerCoords[n];
    for (int i = 0; i < n; i++) {
        r[i] = new PointerCoords();
        e.getPointerCoords(i, r[i]);
    }
    return r;
}
 
Example 6
Source File: StickyGridHeadersGridView.java    From UltimateAndroid with Apache License 2.0 5 votes vote down vote up
private static MotionEvent.PointerCoords[] getPointerCoords(MotionEvent e) {
    int n = e.getPointerCount();
    MotionEvent.PointerCoords[] r = new MotionEvent.PointerCoords[n];
    for (int i = 0; i < n; i++) {
        r[i] = new MotionEvent.PointerCoords();
        e.getPointerCoords(i, r[i]);
    }
    return r;
}
 
Example 7
Source File: StickyGridHeadersGridView.java    From StickyGridHeaders with Apache License 2.0 5 votes vote down vote up
private static MotionEvent.PointerCoords[] getPointerCoords(MotionEvent e) {
    int n = e.getPointerCount();
    MotionEvent.PointerCoords[] r = new MotionEvent.PointerCoords[n];
    for (int i = 0; i < n; i++) {
        r[i] = new MotionEvent.PointerCoords();
        e.getPointerCoords(i, r[i]);
    }
    return r;
}