Java Code Examples for android.view.MotionEvent#getPressure()
The following examples show how to use
android.view.MotionEvent#getPressure() .
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: BaseGestureDetector.java From DiscreteSlider with MIT License | 6 votes |
protected void updateStateByEvent(MotionEvent curr) { final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 2
Source File: BaseGestureDetector.java From OpenMapKitAndroid with BSD 3-Clause "New" or "Revised" License | 6 votes |
protected void updateStateByEvent(MotionEvent curr) { final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 3
Source File: BaseGestureDetector.java From MotionViews-Android with MIT License | 6 votes |
protected void updateStateByEvent(MotionEvent curr) { final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 4
Source File: BaseGestureDetector.java From Nimingban with Apache License 2.0 | 6 votes |
protected void updateStateByEvent(MotionEvent curr) { final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 5
Source File: BaseGestureDetector.java From MoeGallery with GNU General Public License v3.0 | 6 votes |
protected void updateStateByEvent(MotionEvent curr){ final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 6
Source File: BaseGestureDetector.java From AndroidPlayground with MIT License | 6 votes |
protected void updateStateByEvent(MotionEvent curr){ final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 7
Source File: JoystickView.java From Multiwii-Remote with Apache License 2.0 | 6 votes |
private boolean processMoveEvent(MotionEvent ev) { if (pointerId != INVALID_POINTER_ID) { final int pointerIndex = ev.findPointerIndex(pointerId); // Translate touch position to center of view float x = ev.getX(pointerIndex); touchX = x - cX - offsetX; float y = ev.getY(pointerIndex); touchY = y - cY - offsetY; // Log.d(TAG, // String.format("ACTION_MOVE: (%03.0f, %03.0f) => (%03.0f, %03.0f)", // x, y, touchX, touchY)); reportOnMoved(); invalidate(); touchPressure = ev.getPressure(pointerIndex); reportOnPressure(); return true; } return false; }
Example 8
Source File: BaseGestureDetector.java From UltimateAndroid with Apache License 2.0 | 6 votes |
protected void updateStateByEvent(MotionEvent curr){ final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 9
Source File: BaseGestureDetector.java From UltimateAndroid with Apache License 2.0 | 6 votes |
protected void updateStateByEvent(MotionEvent curr){ final MotionEvent prev = mPrevEvent; // Reset mCurrEvent if (mCurrEvent != null) { mCurrEvent.recycle(); mCurrEvent = null; } mCurrEvent = MotionEvent.obtain(curr); // Delta time mTimeDelta = curr.getEventTime() - prev.getEventTime(); // Pressure mCurrPressure = curr.getPressure(curr.getActionIndex()); mPrevPressure = prev.getPressure(prev.getActionIndex()); }
Example 10
Source File: GestureListener.java From input-samples with Apache License 2.0 | 5 votes |
/** * Returns a human-readable string describing the type of touch that triggered a MotionEvent. */ private static String getTouchType(MotionEvent e){ String touchTypeDescription = " "; int touchType = e.getToolType(0); switch (touchType) { case MotionEvent.TOOL_TYPE_FINGER: touchTypeDescription += "(finger)"; break; case MotionEvent.TOOL_TYPE_STYLUS: touchTypeDescription += "(stylus, "; //Get some additional information about the stylus touch float stylusPressure = e.getPressure(); touchTypeDescription += "pressure: " + stylusPressure; if(Build.VERSION.SDK_INT >= 21) { touchTypeDescription += ", buttons pressed: " + getButtonsPressed(e); } touchTypeDescription += ")"; break; case MotionEvent.TOOL_TYPE_ERASER: touchTypeDescription += "(eraser)"; break; case MotionEvent.TOOL_TYPE_MOUSE: touchTypeDescription += "(mouse)"; break; default: touchTypeDescription += "(unknown tool)"; break; } return touchTypeDescription; }
Example 11
Source File: ScaleGestureDetector.java From fanfouapp-opensource with Apache License 2.0 | 5 votes |
private void setContext(final MotionEvent curr) { if (this.mCurrEvent != null) { this.mCurrEvent.recycle(); } this.mCurrEvent = MotionEvent.obtain(curr); this.mCurrLen = -1; this.mPrevLen = -1; this.mScaleFactor = -1; final MotionEvent prev = this.mPrevEvent; final float px0 = prev.getX(0); final float py0 = prev.getY(0); final float px1 = prev.getX(1); final float py1 = prev.getY(1); final float cx0 = curr.getX(0); final float cy0 = curr.getY(0); final float cx1 = curr.getX(1); final float cy1 = curr.getY(1); final float pvx = px1 - px0; final float pvy = py1 - py0; final float cvx = cx1 - cx0; final float cvy = cy1 - cy0; this.mPrevFingerDiffX = pvx; this.mPrevFingerDiffY = pvy; this.mCurrFingerDiffX = cvx; this.mCurrFingerDiffY = cvy; this.mFocusX = cx0 + (cvx * 0.5f); this.mFocusY = cy0 + (cvy * 0.5f); this.mTimeDelta = curr.getEventTime() - prev.getEventTime(); this.mCurrPressure = curr.getPressure(0) + curr.getPressure(1); this.mPrevPressure = prev.getPressure(0) + prev.getPressure(1); }
Example 12
Source File: ScaleGestureDetector.java From YiBo with Apache License 2.0 | 5 votes |
private void setContext(MotionEvent curr) { if (mCurrEvent != null) { mCurrEvent.recycle(); } mCurrEvent = MotionEvent.obtain(curr); mCurrLen = -1; mPrevLen = -1; mScaleFactor = -1; final MotionEvent prev = mPrevEvent; final float px0 = prev.getX(0); final float py0 = prev.getY(0); final float px1 = prev.getX(1); final float py1 = prev.getY(1); final float cx0 = curr.getX(0); final float cy0 = curr.getY(0); final float cx1 = curr.getX(1); final float cy1 = curr.getY(1); final float pvx = px1 - px0; final float pvy = py1 - py0; final float cvx = cx1 - cx0; final float cvy = cy1 - cy0; mPrevFingerDiffX = pvx; mPrevFingerDiffY = pvy; mCurrFingerDiffX = cvx; mCurrFingerDiffY = cvy; mFocusX = cx0 + cvx * 0.5f; mFocusY = cy0 + cvy * 0.5f; mTimeDelta = curr.getEventTime() - prev.getEventTime(); mCurrPressure = curr.getPressure(0) + curr.getPressure(1); mPrevPressure = prev.getPressure(0) + prev.getPressure(1); }
Example 13
Source File: GestureListener.java From android-BasicGestureDetect with Apache License 2.0 | 5 votes |
/** * Returns a human-readable string describing the type of touch that triggered a MotionEvent. */ private static String getTouchType(MotionEvent e){ String touchTypeDescription = " "; int touchType = e.getToolType(0); switch (touchType) { case MotionEvent.TOOL_TYPE_FINGER: touchTypeDescription += "(finger)"; break; case MotionEvent.TOOL_TYPE_STYLUS: touchTypeDescription += "(stylus, "; //Get some additional information about the stylus touch float stylusPressure = e.getPressure(); touchTypeDescription += "pressure: " + stylusPressure; if(Build.VERSION.SDK_INT >= 21) { touchTypeDescription += ", buttons pressed: " + getButtonsPressed(e); } touchTypeDescription += ")"; break; case MotionEvent.TOOL_TYPE_ERASER: touchTypeDescription += "(eraser)"; break; case MotionEvent.TOOL_TYPE_MOUSE: touchTypeDescription += "(mouse)"; break; default: touchTypeDescription += "(unknown tool)"; break; } return touchTypeDescription; }
Example 14
Source File: ForceTouchListener.java From ForceTouch with Apache License 2.0 | 5 votes |
/** * Implemented ForceTouchListener * @param view VIew * @param motionEvent MotionEvent * @return boolean */ @Override public boolean onTouch(View view, MotionEvent motionEvent) { float pressure = motionEvent.getPressure(); checkParam(pressureLimit, millisToVibrate); setPressure(pressure); switch(motionEvent.getAction()){ case MotionEvent.ACTION_DOWN: if(pressure >= pressureLimit && !alreadyExecuted && !isProgressive) { if(isVibrate) { Vibrator vibr = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibr.vibrate(millisToVibrate); } forceTouchExecution.onForceTouch(); alreadyExecuted = true; }else if(isProgressive){ alreadyExecuted = false; progressiveForceTouch(); }else{ alreadyExecuted = false; forceTouchExecution.onNormalTouch(); timer.stop(runnable); } break; case MotionEvent.ACTION_CANCEL: if(isProgressive) { timer.stop(runnable); } alreadyExecuted = false; break; case MotionEvent.ACTION_UP: if(isProgressive) { timer.stop(runnable); } alreadyExecuted = false; break; } return true; }
Example 15
Source File: ForceTouchListener.java From timecat with Apache License 2.0 | 5 votes |
/** * Implemented ForceTouchListener * @param view VIew * @param motionEvent MotionEvent * @return boolean */ @Override public boolean onTouch(View view, MotionEvent motionEvent) { float pressure = motionEvent.getPressure(); checkParam(pressureLimit, millisToVibrate); setPressure(pressure); switch(motionEvent.getAction()){ case MotionEvent.ACTION_DOWN: if(pressure >= pressureLimit && !alreadyExecuted && !isProgressive) { if(isVibrate) { Vibrator vibr = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE); vibr.vibrate(millisToVibrate); } forceTouchExecution.onForceTouch(); alreadyExecuted = true; }else if(isProgressive){ alreadyExecuted = false; progressiveForceTouch(); }else{ alreadyExecuted = false; forceTouchExecution.onNormalTouch(); timer.stop(runnable); } break; case MotionEvent.ACTION_CANCEL: if(isProgressive) { timer.stop(runnable); } alreadyExecuted = false; break; case MotionEvent.ACTION_UP: if(isProgressive) { timer.stop(runnable); } alreadyExecuted = false; break; } return false; }
Example 16
Source File: TouchPoint.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
public static int createTouchPoints(MotionEvent event, TouchPoint[] pts) { int type; int defaultState; switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: type = TOUCH_EVENT_TYPE_START; defaultState = TOUCH_POINT_STATE_PRESSED; break; case MotionEvent.ACTION_MOVE: type = TOUCH_EVENT_TYPE_MOVE; defaultState = TOUCH_POINT_STATE_MOVED; break; case MotionEvent.ACTION_UP: type = TOUCH_EVENT_TYPE_END; defaultState = TOUCH_POINT_STATE_RELEASED; break; case MotionEvent.ACTION_CANCEL: type = TOUCH_EVENT_TYPE_CANCEL; defaultState = TOUCH_POINT_STATE_CANCELLED; break; case MotionEvent.ACTION_POINTER_DOWN: // fall through. case MotionEvent.ACTION_POINTER_UP: type = TOUCH_EVENT_TYPE_MOVE; defaultState = TOUCH_POINT_STATE_STATIONARY; break; default: Log.e("Chromium", "Unknown motion event action: " + event.getActionMasked()); return CONVERSION_ERROR; } for (int i = 0; i < pts.length; ++i) { int state = defaultState; if (defaultState == TOUCH_POINT_STATE_STATIONARY && event.getActionIndex() == i) { // An additional pointer has started or ended. Map this pointer state as // required, and all other pointers as "stationary". state = event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN ? TOUCH_POINT_STATE_PRESSED : TOUCH_POINT_STATE_RELEASED; } pts[i] = new TouchPoint(state, event.getPointerId(i), event.getX(i), event.getY(i), event.getSize(i), event.getPressure(i)); } return type; }
Example 17
Source File: MultiTouchController.java From osmdroid with Apache License 2.0 | 4 votes |
/** Process incoming touch events */ @SuppressWarnings("unused") public boolean onTouchEvent(MotionEvent event) { try { int pointerCount = multiTouchSupported ? (Integer) m_getPointerCount.invoke(event) : 1; if (DEBUG) Log.i("MultiTouch", "Got here 1 - " + multiTouchSupported + " " + mMode + " " + handleSingleTouchEvents + " " + pointerCount); if (mMode == MODE_NOTHING && !handleSingleTouchEvents && pointerCount == 1) // Not handling initial single touch events, just pass them on return false; if (DEBUG) Log.i("MultiTouch", "Got here 2"); // Handle history first (we sometimes get history with ACTION_MOVE events) int action = event.getAction(); int histLen = event.getHistorySize() / pointerCount; for (int histIdx = 0; histIdx <= histLen; histIdx++) { // Read from history entries until histIdx == histLen, then read from current event boolean processingHist = histIdx < histLen; if (!multiTouchSupported || pointerCount == 1) { // Use single-pointer methods -- these are needed as a special case (for some weird reason) even if // multitouch is supported but there's only one touch point down currently -- event.getX(0) etc. throw // an exception if there's only one point down. if (DEBUG) Log.i("MultiTouch", "Got here 3"); xVals[0] = processingHist ? event.getHistoricalX(histIdx) : event.getX(); yVals[0] = processingHist ? event.getHistoricalY(histIdx) : event.getY(); pressureVals[0] = processingHist ? event.getHistoricalPressure(histIdx) : event.getPressure(); } else { // Read x, y and pressure of each pointer if (DEBUG) Log.i("MultiTouch", "Got here 4"); int numPointers = Math.min(pointerCount, MAX_TOUCH_POINTS); if (DEBUG && pointerCount > MAX_TOUCH_POINTS) Log.i("MultiTouch", "Got more pointers than MAX_TOUCH_POINTS"); for (int ptrIdx = 0; ptrIdx < numPointers; ptrIdx++) { int ptrId = (Integer) m_getPointerId.invoke(event, ptrIdx); pointerIds[ptrIdx] = ptrId; // N.B. if pointerCount == 1, then the following methods throw an array index out of range exception, // and the code above is therefore required not just for Android 1.5/1.6 but also for when there is // only one touch point on the screen -- pointlessly inconsistent :( xVals[ptrIdx] = (Float) (processingHist ? m_getHistoricalX.invoke(event, ptrIdx, histIdx) : m_getX.invoke(event, ptrIdx)); yVals[ptrIdx] = (Float) (processingHist ? m_getHistoricalY.invoke(event, ptrIdx, histIdx) : m_getY.invoke(event, ptrIdx)); pressureVals[ptrIdx] = (Float) (processingHist ? m_getHistoricalPressure.invoke(event, ptrIdx, histIdx) : m_getPressure .invoke(event, ptrIdx)); } } // Decode event decodeTouchEvent(pointerCount, xVals, yVals, pressureVals, pointerIds, // /* action = */processingHist ? MotionEvent.ACTION_MOVE : action, // /* down = */processingHist ? true : action != MotionEvent.ACTION_UP // && (action & ((1 << ACTION_POINTER_INDEX_SHIFT) - 1)) != ACTION_POINTER_UP // && action != MotionEvent.ACTION_CANCEL, // processingHist ? event.getHistoricalEventTime(histIdx) : event.getEventTime()); } return true; } catch (Exception e) { // In case any of the introspection stuff fails (it shouldn't) Log.e("MultiTouchController", "onTouchEvent() failed", e); return false; } }
Example 18
Source File: MultiTouchController.java From Androzic with GNU General Public License v3.0 | 4 votes |
/** Process incoming touch events */ public boolean onTouchEvent(MotionEvent event) { try { int pointerCount = multiTouchSupported ? (Integer) m_getPointerCount.invoke(event) : 1; if (DEBUG) Log.i("MultiTouch", "Got here 1 - " + multiTouchSupported + " " + mMode + " " + handleSingleTouchEvents + " " + pointerCount); if (mMode == MODE_NOTHING && !handleSingleTouchEvents && pointerCount == 1) // Not handling initial single touch events, just pass them on return false; if (DEBUG) Log.i("MultiTouch", "Got here 2"); // Handle history first (we sometimes get history with ACTION_MOVE events) int action = event.getAction(); int histLen = event.getHistorySize() / pointerCount; for (int histIdx = 0; histIdx <= histLen; histIdx++) { // Read from history entries until histIdx == histLen, then read from current event boolean processingHist = histIdx < histLen; if (!multiTouchSupported || pointerCount == 1) { // Use single-pointer methods -- these are needed as a special case (for some weird reason) even if // multitouch is supported but there's only one touch point down currently -- event.getX(0) etc. throw // an exception if there's only one point down. if (DEBUG) Log.i("MultiTouch", "Got here 3"); xVals[0] = processingHist ? event.getHistoricalX(histIdx) : event.getX(); yVals[0] = processingHist ? event.getHistoricalY(histIdx) : event.getY(); pressureVals[0] = processingHist ? event.getHistoricalPressure(histIdx) : event.getPressure(); } else { // Read x, y and pressure of each pointer if (DEBUG) Log.i("MultiTouch", "Got here 4"); int numPointers = Math.min(pointerCount, MAX_TOUCH_POINTS); if (DEBUG && pointerCount > MAX_TOUCH_POINTS) Log.i("MultiTouch", "Got more pointers than MAX_TOUCH_POINTS"); for (int ptrIdx = 0; ptrIdx < numPointers; ptrIdx++) { int ptrId = (Integer) m_getPointerId.invoke(event, ptrIdx); pointerIds[ptrIdx] = ptrId; // N.B. if pointerCount == 1, then the following methods throw an array index out of range exception, // and the code above is therefore required not just for Android 1.5/1.6 but also for when there is // only one touch point on the screen -- pointlessly inconsistent :( xVals[ptrIdx] = (Float) (processingHist ? m_getHistoricalX.invoke(event, ptrIdx, histIdx) : m_getX.invoke(event, ptrIdx)); yVals[ptrIdx] = (Float) (processingHist ? m_getHistoricalY.invoke(event, ptrIdx, histIdx) : m_getY.invoke(event, ptrIdx)); pressureVals[ptrIdx] = (Float) (processingHist ? m_getHistoricalPressure.invoke(event, ptrIdx, histIdx) : m_getPressure .invoke(event, ptrIdx)); } } // Decode event decodeTouchEvent(pointerCount, xVals, yVals, pressureVals, pointerIds, // /* action = */processingHist ? MotionEvent.ACTION_MOVE : action, // /* down = */processingHist ? true : action != MotionEvent.ACTION_UP // && (action & ((1 << ACTION_POINTER_INDEX_SHIFT) - 1)) != ACTION_POINTER_UP // && action != MotionEvent.ACTION_CANCEL, // processingHist ? event.getHistoricalEventTime(histIdx) : event.getEventTime()); } return true; } catch (Exception e) { // In case any of the introspection stuff fails (it shouldn't) Log.e("MultiTouchController", "onTouchEvent() failed", e); return false; } }
Example 19
Source File: ScaleGestureDetector.java From PhotoEditor with MIT License | 4 votes |
private void setContext(View view, MotionEvent curr) { if (mCurrEvent != null) { mCurrEvent.recycle(); } mCurrEvent = MotionEvent.obtain(curr); mCurrLen = -1; mPrevLen = -1; mScaleFactor = -1; mCurrSpanVector.set(0.0f, 0.0f); final MotionEvent prev = mPrevEvent; final int prevIndex0 = prev.findPointerIndex(mActiveId0); final int prevIndex1 = prev.findPointerIndex(mActiveId1); final int currIndex0 = curr.findPointerIndex(mActiveId0); final int currIndex1 = curr.findPointerIndex(mActiveId1); if (prevIndex0 < 0 || prevIndex1 < 0 || currIndex0 < 0 || currIndex1 < 0) { mInvalidGesture = true; Log.e(TAG, "Invalid MotionEvent stream detected.", new Throwable()); if (mGestureInProgress) { mListener.onScaleEnd(view, this); } return; } final float px0 = prev.getX(prevIndex0); final float py0 = prev.getY(prevIndex0); final float px1 = prev.getX(prevIndex1); final float py1 = prev.getY(prevIndex1); final float cx0 = curr.getX(currIndex0); final float cy0 = curr.getY(currIndex0); final float cx1 = curr.getX(currIndex1); final float cy1 = curr.getY(currIndex1); final float pvx = px1 - px0; final float pvy = py1 - py0; final float cvx = cx1 - cx0; final float cvy = cy1 - cy0; mCurrSpanVector.set(cvx, cvy); mPrevFingerDiffX = pvx; mPrevFingerDiffY = pvy; mCurrFingerDiffX = cvx; mCurrFingerDiffY = cvy; mFocusX = cx0 + cvx * 0.5f; mFocusY = cy0 + cvy * 0.5f; mTimeDelta = curr.getEventTime() - prev.getEventTime(); mCurrPressure = curr.getPressure(currIndex0) + curr.getPressure(currIndex1); mPrevPressure = prev.getPressure(prevIndex0) + prev.getPressure(prevIndex1); }
Example 20
Source File: TouchPoint.java From android-chromium with BSD 2-Clause "Simplified" License | 4 votes |
public static int createTouchPoints(MotionEvent event, TouchPoint[] pts) { int type; int defaultState; switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: type = TOUCH_EVENT_TYPE_START; defaultState = TOUCH_POINT_STATE_PRESSED; break; case MotionEvent.ACTION_MOVE: type = TOUCH_EVENT_TYPE_MOVE; defaultState = TOUCH_POINT_STATE_MOVED; break; case MotionEvent.ACTION_UP: type = TOUCH_EVENT_TYPE_END; defaultState = TOUCH_POINT_STATE_RELEASED; break; case MotionEvent.ACTION_CANCEL: type = TOUCH_EVENT_TYPE_CANCEL; defaultState = TOUCH_POINT_STATE_CANCELLED; break; case MotionEvent.ACTION_POINTER_DOWN: // fall through. case MotionEvent.ACTION_POINTER_UP: type = TOUCH_EVENT_TYPE_MOVE; defaultState = TOUCH_POINT_STATE_STATIONARY; break; default: Log.e("Chromium", "Unknown motion event action: " + event.getActionMasked()); return CONVERSION_ERROR; } for (int i = 0; i < pts.length; ++i) { int state = defaultState; if (defaultState == TOUCH_POINT_STATE_STATIONARY && event.getActionIndex() == i) { // An additional pointer has started or ended. Map this pointer state as // required, and all other pointers as "stationary". state = event.getActionMasked() == MotionEvent.ACTION_POINTER_DOWN ? TOUCH_POINT_STATE_PRESSED : TOUCH_POINT_STATE_RELEASED; } pts[i] = new TouchPoint(state, event.getPointerId(i), event.getX(i), event.getY(i), event.getSize(i), event.getPressure(i)); } return type; }