Search in sources :

Example 31 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android_frameworks_base by ResurrectionRemix.

the class MagnificationGestureHandler method getTempPointerPropertiesWithMinSize.

private PointerProperties[] getTempPointerPropertiesWithMinSize(int size) {
    final int oldSize = (mTempPointerProperties != null) ? mTempPointerProperties.length : 0;
    if (oldSize < size) {
        PointerProperties[] oldTempPointerProperties = mTempPointerProperties;
        mTempPointerProperties = new PointerProperties[size];
        if (oldTempPointerProperties != null) {
            System.arraycopy(oldTempPointerProperties, 0, mTempPointerProperties, 0, oldSize);
        }
    }
    for (int i = oldSize; i < size; i++) {
        mTempPointerProperties[i] = new PointerProperties();
    }
    return mTempPointerProperties;
}
Also used : PointerProperties(android.view.MotionEvent.PointerProperties)

Example 32 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android_frameworks_base by ResurrectionRemix.

the class EdgeGestureInputFilter method getTempPointerPropertiesWithMinSizeLocked.

private PointerProperties[] getTempPointerPropertiesWithMinSizeLocked(int size) {
    final int oldSize = mTempPointerProperties.length;
    if (oldSize < size) {
        PointerProperties[] oldTempPointerProperties = mTempPointerProperties;
        mTempPointerProperties = new PointerProperties[size];
        System.arraycopy(oldTempPointerProperties, 0, mTempPointerProperties, 0, oldSize);
    }
    for (int i = oldSize; i < size; i++) {
        mTempPointerProperties[i] = new PointerProperties();
    }
    return mTempPointerProperties;
}
Also used : PointerProperties(android.view.MotionEvent.PointerProperties)

Example 33 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android_frameworks_base by crdroidandroid.

the class TouchExplorer method offsetEvent.

/**
     * Offsets all pointers in the given event by adding the specified X and Y
     * offsets.
     *
     * @param event The event to offset.
     * @param offsetX The X offset.
     * @param offsetY The Y offset.
     * @return An event with the offset pointers or the original event if both
     *         offsets are zero.
     */
private MotionEvent offsetEvent(MotionEvent event, int offsetX, int offsetY) {
    if (offsetX == 0 && offsetY == 0) {
        return event;
    }
    final int remappedIndex = event.findPointerIndex(mLongPressingPointerId);
    final int pointerCount = event.getPointerCount();
    PointerProperties[] props = PointerProperties.createArray(pointerCount);
    PointerCoords[] coords = PointerCoords.createArray(pointerCount);
    for (int i = 0; i < pointerCount; i++) {
        event.getPointerProperties(i, props[i]);
        event.getPointerCoords(i, coords[i]);
        if (i == remappedIndex) {
            coords[i].x += offsetX;
            coords[i].y += offsetY;
        }
    }
    return MotionEvent.obtain(event.getDownTime(), event.getEventTime(), event.getAction(), event.getPointerCount(), props, coords, event.getMetaState(), event.getButtonState(), 1.0f, 1.0f, event.getDeviceId(), event.getEdgeFlags(), event.getSource(), event.getFlags());
}
Also used : PointerCoords(android.view.MotionEvent.PointerCoords) PointerProperties(android.view.MotionEvent.PointerProperties) Point(android.graphics.Point)

Example 34 with PointerProperties

use of android.view.MotionEvent.PointerProperties in project android_frameworks_base by crdroidandroid.

the class TouchExplorer method onDoubleTap.

@Override
public boolean onDoubleTap(MotionEvent event, int policyFlags) {
    // Ignore the event if we aren't touch exploring.
    if (mCurrentState != STATE_TOUCH_EXPLORING) {
        return false;
    }
    // Remove pending event deliveries.
    mSendHoverEnterAndMoveDelayed.cancel();
    mSendHoverExitDelayed.cancel();
    if (mSendTouchExplorationEndDelayed.isPending()) {
        mSendTouchExplorationEndDelayed.forceSendAndRemove();
    }
    if (mSendTouchInteractionEndDelayed.isPending()) {
        mSendTouchInteractionEndDelayed.forceSendAndRemove();
    }
    final int pointerIndex = event.getActionIndex();
    final int pointerId = event.getPointerId(pointerIndex);
    Point clickLocation = mTempPoint;
    final int result = computeClickLocation(clickLocation);
    if (result == CLICK_LOCATION_NONE) {
        // consumed.
        return true;
    }
    // Do the click.
    PointerProperties[] properties = new PointerProperties[1];
    properties[0] = new PointerProperties();
    event.getPointerProperties(pointerIndex, properties[0]);
    PointerCoords[] coords = new PointerCoords[1];
    coords[0] = new PointerCoords();
    coords[0].x = clickLocation.x;
    coords[0].y = clickLocation.y;
    MotionEvent click_event = MotionEvent.obtain(event.getDownTime(), event.getEventTime(), MotionEvent.ACTION_DOWN, 1, properties, coords, 0, 0, 1.0f, 1.0f, event.getDeviceId(), 0, event.getSource(), event.getFlags());
    final boolean targetAccessibilityFocus = (result == CLICK_LOCATION_ACCESSIBILITY_FOCUS);
    sendActionDownAndUp(click_event, policyFlags, targetAccessibilityFocus);
    click_event.recycle();
    return true;
}
Also used : PointerCoords(android.view.MotionEvent.PointerCoords) Point(android.graphics.Point) PointerProperties(android.view.MotionEvent.PointerProperties) Point(android.graphics.Point) MotionEvent(android.view.MotionEvent)

Aggregations

PointerProperties (android.view.MotionEvent.PointerProperties)34 PointerCoords (android.view.MotionEvent.PointerCoords)26 MotionEvent (android.view.MotionEvent)16 Point (android.graphics.Point)15 Rect (android.graphics.Rect)5 GesturePoint (android.gesture.GesturePoint)1