public override bool OnTouchEvent(MotionEvent e) { MotionEventActions action = e.ActionMasked; switch (action) { case MotionEventActions.Down: _startX = e.GetX(); _startY = e.GetY(); break; case MotionEventActions.Up: float endX = e.GetX(); float endY = e.GetY(); if (_startX - endX > 100.0f) { Left(); } else if (endX - _startX > 100.0f) { Right(); } else if (Math.Abs(endY - _startY) > 50.0f && Math.Abs(endX - _startX) < 50.0f) { Scale(); } break; } return(true); }
//@Override public override bool OnTouchEvent(MotionEvent mevent) { MotionEventActions action = mevent.Action; switch (action) { case MotionEventActions.Down: case MotionEventActions.Move: int x = (int)mevent.GetX(); int y = (int)mevent.GetY(); int cx = x - Width / 2; int cy = y - Height / 2; double d = Math.Sqrt(cx * cx + cy * cy); if (d <= colorWheelRadius) { colorHSV[0] = (float)(Math.ToDegrees(Math.Atan2(cy, cx)) + 180f); colorHSV[1] = Math.Max(0f, Math.Min(1f, (float)(d / colorWheelRadius))); Invalidate(); } else if (x >= Width / 2 && d >= innerWheelRadius) { colorHSV[2] = (float)Math.Max(0, Math.Min(1, Math.Atan2(cy, cx) / Math.Pi + 0.5f)); Invalidate(); } return(true); } return(base.OnTouchEvent(mevent)); }
private MotionEvent ObtainMotionEvent(MotionEvent source, MotionEventActions action) { MotionEvent ev = MotionEvent.ObtainNoHistory(source); ev.Action = action; return(ev); }
void _recyclerView_Touch(object sender, TouchEventArgs e) { Console.WriteLine("ExtendedWebViewRenderer_Touch"); var ev = e.Event; MotionEventActions action = ev.Action & MotionEventActions.Mask; switch (action) { case MotionEventActions.Down: _startEventY = ev.GetY(); _heightChange = 0; Element.RaiseOnStartScroll(); // Console.WriteLine ("START start ", _startEventY); break; case MotionEventActions.Move: float delta = (ev.GetY() + _heightChange) - _startEventY; Element.RaiseOnScroll(delta, _recyclerView.GetVerticalScrollOffset()); // Console.WriteLine ("scrolling delta is {0}, change {1}, start {2}", delta, _heightChange, _startEventY); // Console.WriteLine ("SCROLLY {0},", _recyclerView.GetVerticalScrollOffset ()); break; case MotionEventActions.Up: Element.RaiseOnStopScroll(); break; } e.Handled = false; }
public bool SetState(float x, float y, MotionEventActions mea) { if (Math.Sqrt((X1 - x) * (X1 - x) + (Y1 - y) * (Y1 - y)) < 50) { if (mea == MotionEventActions.Down) { state = State.In1; } else { state = State.Out; } return(true); } else { if (Math.Sqrt((X2 - x) * (X2 - x) + (Y2 - y) * (Y2 - y)) < 50) { if (mea == MotionEventActions.Down) { state = State.In2; } else { state = State.Out; } return(true); } else { state = State.Out; return(false); } } }
public static int GetPointerIndex(MotionEventActions action) { if ((int)Android.OS.Build.VERSION.SdkInt >= (int)Android.OS.Build.VERSION_CODES.Honeycomb) return GetPointerIndexHoneyComb(action); else return GetPointerIndexEclair(action); }
public override bool DispatchTouchEvent(MotionEvent ev) { float x = ev.GetX(); float y = ev.GetY(); MotionEventActions action = ev.Action; if (action == MotionEventActions.Down && mTouchTarget == null && mPinnedSection != null && isPinnedViewTouched(mPinnedSection.view, x, y)) // create touch target // user touched pinned view { mTouchTarget = mPinnedSection.view; mTouchPoint.X = x; mTouchPoint.Y = y; // copy down event for eventually be used later mDownEvent = MotionEvent.Obtain(ev); } if (mTouchTarget != null) { if (isPinnedViewTouched(mTouchTarget, x, y)) // forward event to pinned view { mTouchTarget.DispatchTouchEvent(ev); } if (action == MotionEventActions.Up) // perform onClick on pinned view { base.DispatchTouchEvent(ev); performPinnedItemClick(); clearTouchTarget(); } else if (action == MotionEventActions.Cancel) // cancel { clearTouchTarget(); } else if (action == MotionEventActions.Move) { if (Math.Abs(y - mTouchPoint.Y) > mTouchSlop) { // cancel sequence on touch target MotionEvent events = MotionEvent.Obtain(ev); events.Action = MotionEventActions.Cancel; mTouchTarget.DispatchTouchEvent(events); events.Recycle(); // provide correct sequence to super class for further handling base.DispatchTouchEvent(mDownEvent); base.DispatchTouchEvent(ev); clearTouchTarget(); } } return(true); } return(base.DispatchTouchEvent(ev)); }
public override bool OnTouchEvent(MotionEvent evt) { // Get the pointer ID Camera.Parameters cParams = camera.GetParameters(); MotionEventActions action = evt.Action; if (evt.PointerCount > 1) { // handle multi-touch events if (action == MotionEventActions.PointerDown) { dist = getFingerSpacing(evt); } else if ((action == MotionEventActions.Move) && cParams.IsZoomSupported) { camera.CancelAutoFocus(); handleZoom(evt, cParams); } } else { // handle single touch events if (action == MotionEventActions.Up) { handleFocus(evt, cParams); } } return(true); }
public GestureMotionEvent(MotionEvent e) { _cachedAction = e.Action; _cachedX = e.GetX(); _cachedY = e.GetY(); MotionEvent = e; }
private void ProcessTouchEvent(long id, MotionEventActions type, SKPoint location) { switch (type) { case MotionEventActions.Down: case MotionEventActions.Pointer2Down: case MotionEventActions.Pointer1Down: touchDictionary.Add(id, new TouchManipulationInfo { PreviousPoint = location, NewPoint = location }); break; case MotionEventActions.Move: TouchManipulationInfo info = touchDictionary[id]; info.NewPoint = location; Manipulate(); info.PreviousPoint = info.NewPoint; break; case MotionEventActions.Up: case MotionEventActions.Pointer2Up: case MotionEventActions.Pointer1Up: touchDictionary[id].NewPoint = location; //Manipulate(); touchDictionary.Remove(id); break; case MotionEventActions.Cancel: touchDictionary.Remove(id); break; } }
protected internal override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent evt) { switch (actionCode) { case MotionEventActions.Up: case MotionEventActions.Cancel: { mListener.OnMoveEnd(this); ResetState(); break; } case MotionEventActions.Move: { UpdateStateByEvent(evt); // Only accept the event if our relative pressure is within // a certain limit. This can help filter shaky data as a // finger is lifted. if (mCurrPressure / mPrevPressure > PressureThreshold) { bool updatePrevious = mListener.OnMove(this); if (updatePrevious) { mPrevEvent.Recycle(); mPrevEvent = MotionEvent.Obtain(evt); } } break; } } }
public bool SetState(float x, float y, MotionEventActions mea) { if (Math.Sqrt((Current_X - x) * (Current_X - x) + (Current_Y - y) * (Current_Y - y)) < diameter) { if (MotionEventActions.Pointer2Down == mea) { return(true); } if (mea == MotionEventActions.Down) { state = State.In; } else { state = State.Out; } return(true); } else { state = State.Out; return(false); } }
public GestureMotionEvent(MotionEvent e) { _cachedAction = e.Action; _cachedX = e.GetX (); _cachedY = e.GetY (); MotionEvent = e; }
public override bool DispatchTouchEvent(MotionEvent e) { if (isEnable) { MotionEventActions Action = e.ActionMasked; if (e.PointerCount >= 2) { hasMultiTouch = true; } mDetector.OnTouchEvent(e); if (isRotateEnable) { mRotateDetector.onTouchEvent(e); } mScaleDetector.OnTouchEvent(e); if (Action == MotionEventActions.Up || Action == MotionEventActions.Cancel) { onUp(); } return(true); } else { return(base.DispatchTouchEvent(e)); } }
public bool OnTouch(View v, MotionEvent e) { if (e.Action == MotionEventActions.Down) { startClickTime = Calendar.Instance.TimeInMillis; initialX = paramss.X; initialY = paramss.Y; initialTouchX = e.RawX; initialTouchY = e.RawY; return(true); } else if (e.Action == MotionEventActions.Up) { //long clickDuration = Calendar.Instance.TimeInMillis - startClickTime; //if (clickDuration < MAX_CLICK_DURATION) //{ // Intent intent = new Intent(this, typeof(BubbleActivity)); // intent.AddFlags(ActivityFlags.NewTask);//(Intent.FLAG_ACTIVITY_NEW_TASK); // StartActivity(intent); // StopSelf(); // lastAction = e.Action; // return true; //} } else if (e.Action == MotionEventActions.Move) { paramss.X = initialX + (int)(e.RawX - initialTouchX); paramss.Y = initialY + (int)(e.RawY - initialTouchY); mWindowManager.UpdateViewLayout(mChatHeadView, paramss); lastAction = e.Action; return(true); } return(false); }
public bool OnTouch(View v, MotionEvent e) { MotionEventActions ea = e.Action; switch (ea) { case MotionEventActions.Down: v.Parent.RequestDisallowInterceptTouchEvent(true); lastX = (int)e.RawX; lastY = (int)e.RawY; break; case MotionEventActions.Move: int dx = (int)e.RawX - lastX; int dy = (int)e.RawY - lastY; int left = v.Left + dx; int right = v.Right + dx; int top = v.Top; int bottom = v.Bottom; if (left < 0) { left = 0; right = left + v.Width; } if (right > Linear.Width) { right = Linear.Width; left = right - v.Width; } if (top < 0) { top = 0; bottom = top + v.Height; } if (bottom > Linear.Height) { bottom = Linear.Height; top = bottom - v.Height; } v.Layout(left, top, right, bottom); lastX = (int)e.RawX; lastY = (int)e.RawY; v.PostInvalidate(); break; case MotionEventActions.Up: dragAbleBt.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.MatchParent) { Weight = 1 }; v.Parent.RequestDisallowInterceptTouchEvent(false); break; } return(false); }
public override bool OnTouchEvent(MotionEvent ev) { _scaleDetector.OnTouchEvent(ev); MotionEventActions action = ev.Action & MotionEventActions.Mask; int pointerIndex; switch (action) { case MotionEventActions.Down: _lastTouchX = ev.GetX(); _lastTouchY = ev.GetY(); _activePointerId = ev.GetPointerId(0); break; case MotionEventActions.Move: pointerIndex = ev.FindPointerIndex(_activePointerId); float x = ev.GetX(pointerIndex); float y = ev.GetY(pointerIndex); if (!_scaleDetector.IsInProgress) { // Only move the ScaleGestureDetector isn't already processing a gesture. float deltaX = x - _lastTouchX; float deltaY = y - _lastTouchY; _posX += deltaX; _posY += deltaY; Invalidate(); } _lastTouchX = x; _lastTouchY = y; break; case MotionEventActions.Up: case MotionEventActions.Cancel: // This events occur when something cancels the gesture (for example the // activity going in the background) or when the pointer has been lifted up. // We no longer need to keep track of the active pointer. _activePointerId = InvalidPointerId; break; case MotionEventActions.PointerUp: // We only want to update the last touch position if the the appropriate pointer // has been lifted off the screen. pointerIndex = (int)(ev.Action & MotionEventActions.PointerIndexMask) >> (int)MotionEventActions.PointerIndexShift; int pointerId = ev.GetPointerId(pointerIndex); if (pointerId == _activePointerId) { // This was our active pointer going up. Choose a new // action pointer and adjust accordingly int newPointerIndex = pointerIndex == 0 ? 1 : 0; _lastTouchX = ev.GetX(newPointerIndex); _lastTouchY = ev.GetY(newPointerIndex); _activePointerId = ev.GetPointerId(newPointerIndex); } break; } return(true); }
private void Set(/* final */ float pX, /* final */ float pY, /* final int */ MotionEventActions pAction, /* final */ int pPointerID, /* final */ MotionEvent pMotionEvent) { this.mX = pX; this.mY = pY; this.mAction = pAction; this.mPointerID = pPointerID; this.mMotionEvent = pMotionEvent; }
private void SendFakeEvent(MotionEvent e, MotionEventActions forcedAction) { var fake_event = MotionEvent.ObtainNoHistory(e); fake_event.Action = forcedAction; ContentView.ForceHandleTouchEvent(fake_event); fake_event.Recycle(); }
public void HandleTouchEvent(Button b, MotionEventActions action) { var key = Convert.ToInt32(b.Text, 16); keyboardMap[key] = action == MotionEventActions.Down; if (action == MotionEventActions.Down) autoResetEvent.Set(); }
public override bool OnInterceptTouchEvent(MotionEvent ev) { MotionEventActions action = ev.Action; bool intercept = false; switch (action) { case MotionEventActions.Move: if (mTouchState == TOUCH_STATE_HORIZONTAL_SCROLLING) { intercept = true; } else if (mTouchState == TOUCH_STATE_VERTICAL_SCROLLING) { intercept = false; } else { float x = ev.GetX(); int xDiff = (int)Math.Abs(x - mLastMotionX); bool xMoved = xDiff > mTouchSlop; if (xMoved) { mTouchState = TOUCH_STATE_HORIZONTAL_SCROLLING; mLastMotionX = x; } float y = ev.GetY(); int yDiff = (int)Math.Abs(y - mLastMotionY); bool yMoved = yDiff > mTouchSlop; if (yMoved) { mTouchState = TOUCH_STATE_VERTICAL_SCROLLING; } } break; case MotionEventActions.Cancel: mTouchState = TOUCH_STATE_REST; break; case MotionEventActions.Up: mTouchState = TOUCH_STATE_REST; break; case MotionEventActions.Down: mLastMotionX = ev.GetX(); mLastMotionY = ev.GetY(); break; default: break; } return(intercept); }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent e) { if (e.PointerCount > 1) { switch (actionCode) { case MotionEventActions.PointerDown: // At least the second finger is on the screen now. ResetState(); _previousEvent = MotionEvent.Obtain(e); _timeDelta = 0; UpdateStateByEvent(e); // See if we have a sloppy gesture. _sloppyGesture = this.IsSloppyGesture(e); if (!_sloppyGesture) { // No, start gesture now. _gestureInProgress = _listener.OnRotateBegin(this); } break; case MotionEventActions.Move: if (!_sloppyGesture) { break; } // See if we still have a sloppy gesture _sloppyGesture = this.IsSloppyGesture(e); if (!_sloppyGesture) { _gestureInProgress = _listener.OnRotateBegin(this); } break; case MotionEventActions.PointerUp: if (!_sloppyGesture) { break; } break; } } else { // the gesture has to stop! _gestureInProgress = false; _listener.OnRotateEnd(this); ResetState(); } }
public bool OnTouch(View v, MotionEvent e) { var newAction = e.Action; switch (e.Action) { case MotionEventActions.Up: if(this.lastTouch == MotionEventActions.Down) { this.HandleMouseClick(); } break; case MotionEventActions.Down: this.x = (int)e.GetX(); this.y = (int)e.GetY(); break; case MotionEventActions.Pointer1Up: if(this.lastTouch == MotionEventActions.Pointer2Down) { this.HandleMouseRightClick(); } break; case MotionEventActions.Move: float x = e.GetX(); float y = e.GetY(); int newX = (int)x; int newY = (int)y; int dx = newX - this.x; int dY = newY - this.y; newAction = this.lastTouch; if (this.lastTouch == MotionEventActions.Pointer2Down) { break; } if (Math.Abs(dx) > 3 || Math.Abs(dY) > 3) { this.x = newX; this.y = newY; this.client.Send(new CursorAction() { ActionFlags = (uint)CursorAction.MouseEventFlags.MOVE, DX = dx, DY = dY }); newAction = e.Action; } break; } this.lastTouch = newAction; this.actionText.Text = this.lastTouch.ToString(); this.xText.Text = this.x.ToString(); this.yText.Text = this.y.ToString(); return true; }
public override bool OnTouchEvent(MotionEvent ev) { ScaleDetector.OnTouchEvent(ev); MotionEventActions action = ev.Action & MotionEventActions.Mask; int pointerIndex; switch (action) { case MotionEventActions.Down: LastTouchX = ev.GetX(); LastTouchY = ev.GetY(); ActivePointerId = ev.GetPointerId(0); break; case MotionEventActions.Move: pointerIndex = ev.FindPointerIndex(ActivePointerId); float x = ev.GetX(pointerIndex); float y = ev.GetY(pointerIndex); if (!ScaleDetector.IsInProgress) { // Only move the ScaleGestureDetector isn't already processing a gesture. float deltaX = x - LastTouchX; float deltaY = y - LastTouchY; PosX += deltaX; PosY += deltaY; Invalidate(); } LastTouchX = x; LastTouchY = y; break; case MotionEventActions.Up: case MotionEventActions.Cancel: // We no longer need to keep track of the active pointer. ActivePointerId = InvalidPointerId; break; case MotionEventActions.PointerUp: // check to make sure that the pointer that went up is for the gesture we're tracking. pointerIndex = (int)(ev.Action & MotionEventActions.PointerIndexMask) >> (int)MotionEventActions.PointerIndexShift; int pointerId = ev.GetPointerId(pointerIndex); if (pointerId == ActivePointerId) { // This was our active pointer going up. Choose a new // action pointer and adjust accordingly int newPointerIndex = pointerIndex == 0 ? 1 : 0; LastTouchX = ev.GetX(newPointerIndex); LastTouchY = ev.GetY(newPointerIndex); ActivePointerId = ev.GetPointerId(newPointerIndex); } break; } return(true); }
public static int GetPointerIndex(MotionEventActions action) { if ((int)Android.OS.Build.VERSION.SdkInt >= (int)Android.OS.Build.VERSION_CODES.Honeycomb) { return(GetPointerIndexHoneyComb(action)); } else { return(GetPointerIndexEclair(action)); } }
bool MatchesLastMotionEvent(MotionEvent e) { if (e.Action == _lastAction && e.EventTime == _lastEventTime && e.PointerCount == _lastPointerCount) { return(true); } _lastAction = e.Action; _lastEventTime = e.EventTime; _lastPointerCount = e.PointerCount; return(false); }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent (MotionEventActions actionCode, MotionEvent e) { if (e.PointerCount > 1) { switch (actionCode) { case MotionEventActions.PointerDown: // At least the second finger is on the screen now. ResetState(); _previousEvent = MotionEvent.Obtain(e); _timeDelta = 0; UpdateStateByEvent(e); // See if we have a sloppy gesture. _sloppyGesture = this.IsSloppyGesture(e); if (!_sloppyGesture) { // No, start gesture now. _gestureInProgress = _listener.OnRotateBegin(this); } break; case MotionEventActions.Move: if (!_sloppyGesture) { break; } // See if we still have a sloppy gesture _sloppyGesture = this.IsSloppyGesture(e); if (!_sloppyGesture) { _gestureInProgress = _listener.OnRotateBegin(this); } break; case MotionEventActions.PointerUp: if (!_sloppyGesture) { break; } break; } } else { // the gesture has to stop! _gestureInProgress = false; _listener.OnRotateEnd(this); ResetState(); } }
public void HandleTouchEvent(Button b, MotionEventActions action) { var key = Convert.ToInt32(b.Text, 16); keyboardMap[key] = action == MotionEventActions.Down; if (action == MotionEventActions.Down) { autoResetEvent.Set(); } }
public bool OnTouch(View v, MotionEvent e) { MotionEventActions ea = e.Action; switch (ea) { case MotionEventActions.Down: lastX = (int)e.RawX; lastY = (int)e.RawY; break; case MotionEventActions.Move: int dx = (int)e.RawX - lastX; int dy = (int)e.RawY - lastY; int left = v.Left + dx; int right = v.Right + dx; int top = v.Top + dy; int bottom = v.Bottom + dy; if (left < 0) { left = 0; right = left + v.Width; } if (right > screenWidth) { right = screenWidth; left = right - v.Width; } if (top < 0) { top = 0; bottom = top + v.Height; } if (bottom > screenHeight) { bottom = screenHeight; top = bottom - v.Height; } v.Layout(left, top, right, bottom); lastX = (int)e.RawX; lastY = (int)e.RawY; v.PostInvalidate(); break; case MotionEventActions.Up: break; } if (v.Id == Resource.Id.imageView1) { return(true); } return(false); }
private bool OnNativeMotionEvent(PointerRoutedEventArgs args, MotionEventActions action, bool isInView) { // Warning: MotionEvent of other kinds are filtered out in native code (UnoMotionHelper.java) switch (action) { case MotionEventActions.HoverEnter: return(OnNativePointerEnter(args)); case MotionEventActions.HoverExit when !args.Pointer.IsInContact: // When a mouse button is pressed or pen touches the screen (a.k.a. becomes in contact), we receive an HoverExit before the Down. // We validate here if pointer 'isInContact' (which is the case for HoverExit when mouse button pressed / pen touch the screen) // and we ignore them (as on UWP Exit is raised only when pointer moves out of bounds of the control, no matter the pressed state). // As a side effect we will have to update the hover state on each Move in order to handle the case of press -> move out -> release. return(OnNativePointerExited(args)); case MotionEventActions.HoverExit: return(false); // avoid useless logging case MotionEventActions.Down when args.Pointer.PointerDeviceType == PointerDeviceType.Touch: case MotionEventActions.PointerDown when args.Pointer.PointerDeviceType == PointerDeviceType.Touch: return(OnNativePointerEnter(args) | OnNativePointerDown(args)); case MotionEventActions.Down: case MotionEventActions.PointerDown: return(OnNativePointerDown(args)); case MotionEventActions.Up when args.Pointer.PointerDeviceType == PointerDeviceType.Touch: case MotionEventActions.PointerUp when args.Pointer.PointerDeviceType == PointerDeviceType.Touch: return(OnNativePointerUp(args) | OnNativePointerExited(args)); case MotionEventActions.Up: case MotionEventActions.PointerUp: return(OnNativePointerUp(args)); case MotionEventActions.Move: case MotionEventActions.HoverMove: // Note: We use the OnNativePointerMove**WithOverCheck** in order to update the over state in case of press -> move out -> release // where Android won't raise the HoverExit (as it has raised it on press, but we have ignored it cf. HoverExit case.) return(OnNativePointerMoveWithOverCheck(args, isInView)); case MotionEventActions.Cancel: return(OnNativePointerCancel(args, isSwallowedBySystem: true)); default: if (this.Log().IsEnabled(LogLevel.Warning)) { this.Log().Warn($"We receive a native motion event of '{action}', but this is not supported and should have been filtered out in native code."); } return(false); } }
public override bool OnInterceptTouchEvent(MotionEvent ev) { if (mLocked) { return(false); } MotionEventActions action = ev.Action; float x = ev.GetX(); float y = ev.GetY(); Rect frame = mFrame; View handle = mHandle; handle.GetHitRect(frame); if (!mTracking && !frame.Contains((int)x, (int)y)) { return(false); } if (action == MotionEventActions.Down) { mTracking = true; handle.Pressed = true; // Must be called before prepareTracking() prepareContent(); // Must be called after prepareContent() if (mOnDrawerScrollListener != null) { mOnDrawerScrollListener.onScrollStarted(); } if (mVertical) { int top = mHandle.Top; mTouchDelta = (int)y - top; prepareTracking(top); } else { int left = mHandle.Left; mTouchDelta = (int)x - left; prepareTracking(left); } mVelocityTracker.AddMovement(ev); } return(true); }
public bool OnTouch(View v, MotionEvent e) { lock (this) { MotionEventActions action = e.Action & MotionEventActions.Mask; int pointerIndex = e.ActionIndex; int pointerId = e.GetPointerId(pointerIndex); TouchEvent te; switch (action) { case MotionEventActions.Down: case MotionEventActions.PointerDown: te = _touchEventPool.NewObject(); te.type = TouchEvent.TOUCH_DOWN; te.pointer = pointerId; te.x = _touchX[pointerId] = (int)(e.GetX(pointerIndex) * _scaleX); te.y = _touchY[pointerId] = (int)(e.GetY(pointerIndex) * _scaleY); _isTouched[pointerId] = true; _touchEventsBuffer.Add(te); break; case MotionEventActions.Up: case MotionEventActions.PointerUp: case MotionEventActions.Cancel: te = _touchEventPool.NewObject(); te.type = TouchEvent.TOUCH_UP; te.pointer = pointerId; te.x = _touchX[pointerId] = (int)(e.GetX(pointerIndex) * _scaleX); te.y = _touchY[pointerId] = (int)(e.GetY(pointerIndex) * _scaleY); _isTouched[pointerId] = false; _touchEventsBuffer.Add(te); break; case MotionEventActions.Move: int pointerCount = e.PointerCount; for (int i = 0; i < pointerCount; i++) { pointerIndex = i; pointerId = e.GetPointerId(pointerIndex); te = _touchEventPool.NewObject(); te.type = TouchEvent.TOUCH_DRAGGED; te.pointer = pointerId; te.x = _touchX[pointerId] = (int)(e.GetX(pointerIndex) * _scaleX); te.y = _touchY[pointerId] = (int)(e.GetY(pointerIndex) * _scaleY); _touchEventsBuffer.Add(te); } break; } } return(true); }
public static GestureState ToGestureState(this MotionEventActions action) { var actionInternal = action & MotionEventActions.Mask; GestureState result = GestureState.Possible; if (actionInternal == MotionEventActions.Cancel) { result = GestureState.Cancelled; } return(result); }
public override bool OnTouchEvent(MotionEvent motionEvent) { MotionEventActions maskedAction = motionEvent.ActionMasked; switch (maskedAction) { case MotionEventActions.PointerDown: case MotionEventActions.Down: { Vector2 position = Vector2.Zero; position.X = motionEvent.GetX(motionEvent.ActionIndex); position.Y = motionEvent.GetY(motionEvent.ActionIndex); int pointerId = motionEvent.GetPointerId(motionEvent.ActionIndex); TouchPad.Instance.ProcessDown(pointerId, position, DateTime.Now); } return(true); case MotionEventActions.PointerUp: case MotionEventActions.Up: case MotionEventActions.Cancel: { int pointerId = motionEvent.GetPointerId(motionEvent.ActionIndex); TouchPad.Instance.ProcessUp(pointerId, DateTime.Now); } return(true); case MotionEventActions.Move: { int count = motionEvent.PointerCount; for (int idx = 0; idx < count; ++idx) { Vector2 position = Vector2.Zero; position.X = motionEvent.GetX(idx); position.Y = motionEvent.GetY(idx); int pointerId = motionEvent.GetPointerId(idx); TouchPad.Instance.ProcessMove(pointerId, position, DateTime.Now); } } return(true); } return(false); }
protected internal override void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent evt) { switch (actionCode) { case MotionEventActions.PointerDown: { // At least the second finger is on screen now ResetState(); // In case we missed an UP/CANCEL event mPrevEvent = MotionEvent.Obtain(evt); mTimeDelta = 0; UpdateStateByEvent(evt); // See if we have a sloppy gesture mSloppyGesture = IsSloppyGesture(evt); if (!mSloppyGesture) { // No, start gesture now mGestureInProgress = mListener.OnRotateBegin(this); } break; } case MotionEventActions.Move: { if (!mSloppyGesture) { break; } // See if we still have a sloppy gesture mSloppyGesture = IsSloppyGesture(evt); if (!mSloppyGesture) { // No, start normal gesture now mGestureInProgress = mListener.OnRotateBegin(this); } break; } case MotionEventActions.PointerUp: { if (!mSloppyGesture) { break; } break; } } }
/// <summary> /// Called when the current event occurred when NO gesture is in progress /// yet. The handling in this implementation may set the gesture in progress /// or out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">The event.</param> protected override void HandleStartProgressEvent (MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Down: ResetState (); // In case we missed an UP/CANCEL event _previousEvent = MotionEvent.Obtain (e); _timeDelta = 0; UpdateStateByEvent (e); break; case MotionEventActions.Move: _gestureInProgress = _listener.OnMoveBegin(this); break; } }
protected internal override void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent evt) { switch (actionCode) { case MotionEventActions.Down: { ResetState(); // In case we missed an UP/CANCEL event mPrevEvent = MotionEvent.Obtain(evt); mTimeDelta = 0; UpdateStateByEvent(evt); break; } case MotionEventActions.Move: { mGestureInProgress = mListener.OnMoveBegin(this); break; } } }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">The event.</param></param> protected abstract void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent e);
protected internal override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent evt) { switch (actionCode) { case MotionEventActions.PointerUp: { // Gesture ended but UpdateStateByEvent(evt); if (!mSloppyGesture) { mListener.OnRotateEnd(this); } ResetState(); break; } case MotionEventActions.Cancel: { if (!mSloppyGesture) { mListener.OnRotateEnd(this); } ResetState(); break; } case MotionEventActions.Move: { UpdateStateByEvent(evt); // Only accept the event if our relative pressure is within // a certain limit. This can help filter shaky data as a // finger is lifted. if (mCurrPressure / mPrevPressure > PressureThreshold) { bool updatePrevious = mListener.OnRotate(this); if (updatePrevious) { mPrevEvent.Recycle(); mPrevEvent = MotionEvent.Obtain(evt); } } break; } } }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent (MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Up: case MotionEventActions.Cancel: _listener.OnMoveEnd (this); ResetState (); break; case MotionEventActions.Move: UpdateStateByEvent (e); // Only accept the event if our relative pressure is within // a certain limit. This can help filter shaky data as a // finger is lifted. if (_currentPressure / _previousPressure > PressureThreshold) { bool updatePrevious = _listener.OnMove (this); if (updatePrevious) { _previousEvent.Recycle (); _previousEvent = MotionEvent.Obtain (e); } } break; } }
/// <summary> /// Called when the current event occurred when NO gesture is in progress /// yet. The handling in this implementation may set the gesture in progress /// or out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">The event.</param> protected override void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Down: ResetState (); // In case we missed an UP/CANCEL event _firstEventTime = e.EventTime; _previousEvent = MotionEvent.Obtain (e); _timeDelta = 0; _gestureInProgress = true; _x = e.GetX(); _y = e.GetY(); UpdateStateByEvent (e); break; case MotionEventActions.Move: break; } }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Up: case MotionEventActions.Cancel: if (_tapPeriod > (e.EventTime - _firstEventTime)) { _listener.OnTap(this); ResetState(); } break; case MotionEventActions.Move: if (_tapPeriod < (e.EventTime - _firstEventTime)) { ResetState(); } break; } }
private static int GetPointerIndexHoneyComb(MotionEventActions action) { return ((int)action & (int)MotionEventActions.PointerIndexMask) >> (int)MotionEventActions.PointerIndexShift; }
protected internal abstract override void HandleInProgressEvent(MotionEventActions actionCode, MotionEvent evt);
/// <summary> /// Called when the current event occurred when NO gesture is in progress /// yet. /// </summary> /// <remarks> /// Called when the current event occurred when NO gesture is in progress /// yet. The handling in this implementation may set the gesture in progress /// (via mGestureInProgress) or out of progress /// </remarks> /// <param name="actionCode"></param> /// <param name="event"></param> protected internal abstract void HandleStartProgressEvent(MotionEventActions actionCode, MotionEvent evt);
private static int GetPointerIndexEclair(MotionEventActions action) { return ((int)action & (int)MotionEventActions.PointerIdMask) >> (int)MotionEventActions.PointerIdShift; }
public override bool OnTouchEvent(MotionEvent e) { MotionEventActions action = e.Action; if (action == MotionEventActions.Up) { float cx = e.RawX; float cy = e.RawY; int x = (int)cx; int y = (int)cy; foreach (KeyValuePair<string, View> eachItem in this.items) { int[] location = new int[2]; eachItem.Value.GetLocationOnScreen(location); int itemWidth = eachItem.Value.Width; int itemHeight = eachItem.Value.Height; if (x > location[0] && x < (location[0] + itemWidth) && y > location[1] && y < (location[1] + itemHeight)) { if (null != this.ItemSelected) { this.ItemSelected(eachItem.Key, eachItem.Value); }//end if break; }//end if }//end foreach }//end if // TODO: Determine what the last action was this.lastTouchAction = action; return base.OnTouchEvent(e); }
private MotionEvent ObtainMotionEvent(MotionEvent source, MotionEventActions action) { MotionEvent ev = MotionEvent.ObtainNoHistory(source); ev.Action = action; return ev; }
/// <summary> /// Called when the current event occurred when a gesture IS in progress. The /// handling in this implementation may set the gesture out of progress. /// </summary> /// <param name="actionCode">Action code.</param> /// <param name="e">E.</param> protected override void HandleInProgressEvent (MotionEventActions actionCode, MotionEvent e) { switch (actionCode) { case MotionEventActions.Up: case MotionEventActions.Cancel: if (_tapPeriod > (e.EventTime - _firstEventTime) && _xTolerance >= (System.Math.Abs(e.GetX() - _x)) && _yTolerance >= (System.Math.Abs(e.GetY() - _y))) { _listener.OnTap(this); ResetState(); } break; case MotionEventActions.Move: if (_tapPeriod < (e.EventTime - _firstEventTime)) { ResetState(); } break; } }