/// <summary> /// Manages the listener logic /// </summary> /// <param name="gameTime"></param> public void Update(GameTime gameTime) { var touchCollection = TouchPanel.GetState(); foreach (var touchLocation in touchCollection) { switch (touchLocation.State) { case TouchLocationState.Pressed: TouchStarted?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Moved: TouchMoved?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Released: TouchEnded?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Invalid: TouchCancelled?.Invoke(this, new TouchEventArgs(_screenTransformationMatrixProvider, gameTime.TotalGameTime, touchLocation)); break; } } }
public override void Update(GameTime gameTime) { var touchCollection = TouchPanel.GetState(); foreach (var touchLocation in touchCollection) { switch (touchLocation.State) { case TouchLocationState.Pressed: TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Moved: TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Released: TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Invalid: TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; } } }
public override void TouchesMoved(Foundation.NSSet touches, UIEvent evt) { base.TouchesMoved(touches, evt); var touch = touches.AnyObject as UITouch; if (touch != null) { TouchMoved?.Invoke(this, touch); } }
public override void Update(GameTime gameTime) { var touchCollection = TouchPanel.GetState(); if (TouchPanel.IsGestureAvailable) { var gesture = TouchPanel.ReadGesture(); if (gesture.GestureType == GestureType.Tap) { int x = 0; } if (gesture.GestureType == GestureType.DoubleTap) { int y = 0; } } foreach (var touchLocation in touchCollection) { switch (touchLocation.State) { case TouchLocationState.Pressed: TouchStarted?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Moved: TouchMoved?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Released: TouchEnded?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; case TouchLocationState.Invalid: TouchCancelled?.Invoke(this, new TouchEventArgs(ViewportAdapter, gameTime.TotalGameTime, touchLocation)); break; } } }
private void OnDevicePacket() { // WARNING: This is called on a separate thread from the thread // that initialized the object! if (!LoadPacket()) { return; } int fingerState = _packet.FingerState; bool touching = (fingerState & (int)SynFingerFlags.SF_FingerPresent) != 0; if (touching != _touching) { _touching = touching; EventHandler handler = touching ? TouchStarted : TouchEnded; handler?.Invoke(this, EventArgs.Empty); } if (touching) { int x = NormalizeX(_packet.XRaw); int y = NormalizeY(_packet.YRaw); TouchMoved?.Invoke(this, new RawTouchEventArgs(x, y)); } }
/// <summary> /// Check if mouse clicked and call certain events of start, hover and finish of input /// </summary> private void Update() { if (Input.GetMouseButtonDown(0)) { _isTouching = true; TouchEnter?.Invoke(Input.mousePosition); } if (Input.GetMouseButton(0)) { TouchStay?.Invoke(Input.mousePosition); if (Math.Abs(Input.GetAxis("Mouse X")) < MoveDelta && Math.Abs(Input.GetAxis("Mouse Y")) < MoveDelta) { return; } TouchMoved?.Invoke(Input.mousePosition); } if (Input.GetMouseButtonUp(0)) { _isTouching = false; TouchExit?.Invoke(Input.mousePosition); } }
public virtual void OnTouchMoved() { TouchMoved.Invoke(this); }
public virtual void OnTouchMoved() { IsTouchInside = true; TouchMoved.Invoke(this); }
/// <summary> /// Protected overridable handler that raises TouchMoved event. /// </summary> protected virtual void OnTouchMoved(TouchEventArgs args) { TouchMoved?.Invoke(this, args); }
protected void SingleTouchMoved() { TouchMoved?.Invoke(FirstTouch); }
protected virtual void OnTouchMoved(ITouchEventArgs e) => TouchMoved?.Invoke(this, e);