protected TouchZone(string name, TouchConfiguration touchConfiguration, int[,] mask) { Name = name; _touchConfiguration = touchConfiguration; Mask = mask; _current = new TouchPoint(); }
public bool IsUnderneath(TouchPoint t) { var tx = t.CenterX; var ty = t.CenterY; return (tx > x && tx < x + w && ty > y && ty < y + h); }
public void TouchMove(object sdr, Type t, TouchDevice touchDevice, TouchPoint touchPoint) { My_Point point = Point_List.UpdatePoint(sdr, t, touchDevice.Id, touchPoint); if (point != null && (t == typeof(Card_Layer))) { ///Show gesture indicator //if (point.Life > STATICS.MIN_GESTURE_LIFE) //{ // FrameworkElement sender = point.Sender as FrameworkElement; // lock (Point_List.TouchPointList) // { // if (!mainWindow.GestureIndicatorLayer.Contain(touchDevice.Id)) // { // mainWindow.GestureIndicatorLayer.Add(touchDevice.Id, touchPoint.Position); // } // else // { // mainWindow.GestureIndicatorLayer.Move(touchDevice.Id, touchPoint.Position); // } // } //} } }
/// <inheritdoc /> protected override void updateOnce(TouchPoint touch) { base.updateOnce(touch); stringBuilder.Length = 0; stringBuilder.Append("Touch id: "); stringBuilder.Append(touch.Id); gameObject.name = stringBuilder.ToString(); if (Text == null) return; if (!ShowTouchId && !ShowTags) return; stringBuilder.Length = 0; if (ShowTouchId) { stringBuilder.Append("Id: "); stringBuilder.Append(touch.Id); } if (ShowTags) { if (stringBuilder.Length > 0) stringBuilder.Append("\n"); stringBuilder.Append("Tags: "); stringBuilder.Append(touch.Tags.ToString()); } Text.text = stringBuilder.ToString(); }
public bool processDrag(TouchPoint touch, float dt) { //If the window is touch or a previous touch is still going on if (_area.Contains((int)touch.X, (int)touch.Y) || _touchId == touch.Id) { Vector2 newPos = new Vector2(touch.X, touch.Y); Vector2 bckUpPos = _position; _position = newPos; Rectangle newArea = computeUIArea(this); _position = bckUpPos; if (!MyGame.ScreenArea.Contains(newArea) || MyGame.MapArea.Intersects(newArea)) { newPos = _position; } _velocity = (_velocity * NB_MOVE_RECORDED + (newPos - _position) / dt * SPEED_COEF) / (NB_MOVE_RECORDED + 1f); _position = newPos; _area = computeUIArea(this); _touchId = touch.Id; _touchReleased = false; //A touch should only move one UI window return true; } else { _touchReleased = true; return false; } }
void Awake() { //ステート state.setState(GameState.NotPlaying); //デブ GameObject g = (GameObject)Resources.Load("Debu"); debu = (GameObject)Instantiate(g, g.transform.position, g.transform.rotation); //プレイヤー target = GameObject.Find("PlayerSibo"); //ポジション defaultPosition = transform.position; defaultAngles = transform.eulerAngles; rotate = new Vector3(0, 10f, 0); approachPoint = target.transform.position - transform.position; //フォグ g = (GameObject)Resources.Load("TransformFog"); transformFog = (GameObject)Instantiate(g, g.transform.position, g.transform.rotation); transformFog.SetActive(false); //スキップ skip = false; //タッチパッド touchPoint = FindObjectOfType<TouchPoint>(); }
private double GetDelta(TouchPoint tpOne, TouchPoint tpTwo) { double tpOneYPos = tpOne.Position.Y; double tpTwoYPos = tpTwo.Position.Y; return tpOneYPos > tpTwoYPos ? tpOneYPos - tpTwoYPos : tpTwoYPos - tpOneYPos; }
public UIComponent checkHitUI(TouchPoint p) { foreach (UIComponent c in componentList) { return c.processTouchPoint(p); } return null; }
public static List<TouchPoint> UpdateTouches() { _Touches.Clear(); _TouchIDs.Clear(); LastCheck = Time.time; if (Input.touchCount > 0) { for (int i = 0; i < Input.touchCount; i++) { Touch touch = Input.GetTouch(i); Vector3 pos = Camera.main.ScreenToWorldPoint(touch.position); var touchPoint = new TouchPoint { ID = touch.fingerId, Position = pos, Phase = touch.phase }; _Touches.Add(touchPoint); _TouchIDs.Add(touchPoint.ID, touchPoint); } } else if (Input.GetMouseButton(0) || Input.GetMouseButtonUp(0)) { Vector3 pos = Camera.main.ScreenToWorldPoint(Input.mousePosition); TouchPhase phase = Input.GetMouseButtonDown(0) ? TouchPhase.Began : Input.GetMouseButtonUp(0) ? TouchPhase.Ended : TouchPhase.Moved; var touchPoint = new TouchPoint { ID = 1, Position = pos, Phase = phase }; _Touches.Add(touchPoint); _TouchIDs.Add(touchPoint.ID, touchPoint); } return _Touches; }
public override UIComponent processTouchPoint(TouchPoint p) { if (p != null) { if (componentArea.Contains(new Point((int)p.X, (int)p.Y))) { if (verticalScroller) { float dFromTop; dFromTop = (float)(p.Y - componentArea.Y); slideRatio = dFromTop / componentArea.Height; indicatorArea = new Rectangle(componentArea.X, (int)(slideRatio * componentArea.Height) + componentArea.Y - (defaultTexture.Width /2) , defaultTexture.Width, defaultTexture.Width); } else { float dFromLeft; dFromLeft = (float)(p.X - componentArea.X); slideRatio = dFromLeft / componentArea.Width; indicatorArea = new Rectangle((int)(slideRatio * componentArea.Width) + componentArea.X - (defaultTexture.Height / 2), componentArea.Y, defaultTexture.Height, defaultTexture.Height); } updateListeners(); return this; } } return null; }
public void Tap(TouchPoint tp) { if (hasActiveId && activeId == tp.Id) { tapedPoint = new Point((int)tp.CenterX, (int)tp.CenterY); taped = true; } }
/// <inheritdoc /> public override bool ShouldReceiveTouch(TouchPoint touch) { if (!IgnoreChildren) return base.ShouldReceiveTouch(touch); if (!base.ShouldReceiveTouch(touch)) return false; if (touch.Target != cachedTransform) return false; return true; }
public void Down(TouchPoint tp) { if (hasActiveId) return; hasActiveId = true; activeId = tp.Id; startingPos = new Vector2(tp.CenterX, tp.CenterY); actualPos = new Vector2(tp.CenterX, tp.CenterY); }
public virtual bool CheckAndHandleTap(TouchPoint t) { if (IsUnderneath(t)) { action(); return true; } else return false; }
protected override bool processTouch(TouchPoint touch, float dt) { _button.update(dt); if (_button.isTouchOn(Utils.touchPointToV2(touch))) { Hide(); } return false; }
/// <summary> /// Determines whether the touch is over a specific GameObject. /// </summary> /// <param name="touch"> The touch. </param> /// <param name="target"> The target. </param> /// <returns> <c>true</c> if the touch is over the GameObject; <c>false</c> otherwise.</returns> public static bool IsTouchOnTarget(TouchPoint touch, Transform target) { if (touch == null || touch.Layer == null || target == null) return false; TouchHit hit; if ((touch.Layer.Hit(touch.Position, out hit) == TouchLayer.LayerHitResult.Hit) && (target == hit.Transform || hit.Transform.IsChildOf(target))) return true; return false; }
void TouchesMovedHandler(object s, TouchEventArgs e) { int count = e.Touches.Count; for (int i = 0; i < count; i++) { TouchPoint touch = e.Touches[i]; print(touch.Position); } }
{ get; private set; } #endregion Properties #region Methods /// <summary> /// Adds the point. /// </summary> /// <param name="point">The point.</param> /// <returns></returns> public OperationResult AddPoint(TouchPoint point) {
private void AssertEqual(TouchPoint expected, TouchPoint actual) { Assert.Equal(expected.ClientX, actual.ClientX); Assert.Equal(expected.ClientY, actual.ClientY); Assert.Equal(expected.Identifier, actual.Identifier); Assert.Equal(expected.PageX, actual.PageX); Assert.Equal(expected.PageY, actual.PageY); Assert.Equal(expected.ScreenX, actual.ScreenX); Assert.Equal(expected.ScreenY, actual.ScreenY); }
internal bool BeginTouch(TouchPoint touch) { var result = beginTouch(touch); if (result == LayerHitResult.Hit) { touch.Layer = this; return true; } return false; }
public void TouchedMove(object sender, EventArgs e) { TouchEventArgs args = (TouchEventArgs)e; TouchPoint touch = args.TouchPoint; if (_touchId == touch.Id) { Position = new Vector2(touch.CenterX - _delta.X, touch.CenterY - _delta.Y); } }
public void addBlob(TouchPoint touchPoint) { if (SceneManager.Instance.HasScene(SceneManager.EScene.SOLO) || SceneManager.Instance.HasScene(SceneManager.EScene.MULTI)) { if (CoordHelper.Instance.getNextValueBox(CoordHelper.EProfile.ONEPLAYER).Contains(new Point((int)touchPoint.CenterX, (int)touchPoint.CenterY))) //HITTEST WITH P1 NEXT BOX nextBlob[CoordHelper.EProfile.ONEPLAYER] = 1; else if (CoordHelper.Instance.getNextValueBox(CoordHelper.EProfile.TWOPLAYER).Contains(new Point((int)touchPoint.CenterX, (int)touchPoint.CenterY))) //HITTEST WITH P1 NEXT BOX nextBlob[CoordHelper.EProfile.TWOPLAYER] = 1; } }
/// <summary> /// Adds a point. /// </summary> /// <param name="point">A point.</param> /// <returns></returns> public void AddPoint(TouchPoint point) { if (points.Contains(point)) { return; } points.Add(point); markDirty(); }
public void UpdateMyPoint(TouchPoint touchPoint, DateTime dateTime) { TimeSpan ts = dateTime - startTime; if (ts.TotalMilliseconds - life > STATICS.POINT_REFRESH_RATE) { life = ts.TotalMilliseconds; currentPoint = touchPoint; } }
public void Up(TouchPoint tp) { if (hasActiveId && activeId == tp.Id) { //if (actualPos.Y >= startingPos.Y + Constants.Measures.blockSize && hasActiveId && activeId == tp.Id) // dropedDown = true; hasActiveId = false; prevPos = Vector2.Zero; } }
public bool ShouldReceiveTouch(TouchLayer layer, TouchPoint touch) { if (layer == RenderTextureLayer) #pragma warning disable 252,253 return touch.InputSource == Source; #pragma warning restore 252,253 #pragma warning disable 252,253 return touch.InputSource != Source; #pragma warning restore 252,253 }
/// <summary> /// Removes a point from cluster. /// </summary> /// <param name="point"> A point. </param> public void RemovePoint(TouchPoint point) { if (!points.Contains(point)) { return; } points.Remove(point); markDirty(); }
private TouchPoint UpdateTouchPoint(TouchPoint tp, TuioCursor cursor) { tp.PreviousPoint = tp.CurrentPoint; tp.CurrentPoint = cursor.getPath().Last().ToPoint(GestureManager); tp.CurrentTimeMS = cursor.getTuioTime().getTotalMilliseconds(); tp.Distance = cursor.getTotalDistanceInPixel(this.GestureManager); tp.PathLength = cursor.getPath().Count; tp.DistanceRelative = cursor.getTotalDistance(); return(tp); }
/// <inheritdoc /> protected override void touchBegan(TouchPoint touch) { base.touchBegan(touch); if (NumTouches == 1) setState(GestureState.Began); var data = getPointerData(touch); ExecuteEvents.Execute(gameObject, data.Data, ExecuteEvents.pointerEnterHandler); ExecuteEvents.Execute(gameObject, data.Data, ExecuteEvents.pointerDownHandler); }
public WacomTouchReport(byte[] report, ref TouchPoint[] prevTouches) { Raw = report; AuxButtons = Array.Empty <bool>(); Touches = prevTouches ?? new TouchPoint[MAX_POINTS]; if (report[2] == 0x81) { ApplyTouchMask((ushort)(Raw[3] | (Raw[4] << 8))); prevTouches = (TouchPoint[])Touches.Clone(); return; } var nChunks = Raw[1]; for (var i = 0; i < nChunks; i++) { var offset = (i << 3) + 2; var touchID = Raw[offset]; if (touchID == 0x80) { var auxByte = report[1 + offset]; AuxButtons = new bool[] { auxByte.IsBitSet(0), auxByte.IsBitSet(1), auxByte.IsBitSet(2), auxByte.IsBitSet(3), }; continue; } touchID -= 2; if (touchID >= MAX_POINTS) { continue; } var touchState = Raw[1 + offset]; if (touchState == 0x20) { Touches[touchID] = null; } else { Touches[touchID] = new TouchPoint { TouchID = touchID, Position = new Vector2 { X = (Raw[2 + offset] << 4) | (Raw[4 + offset] >> 4), Y = (Raw[3 + offset] << 4) | (Raw[4 + offset] & 0xF) }, }; } } prevTouches = (TouchPoint[])Touches.Clone(); }
/// <inheritdoc /> protected override LayerHitResult beginTouch(TouchPoint touch) { TouchHit hit; var result = Hit(touch.Position, out hit); if (result == LayerHitResult.Hit) { touch.Hit = hit; touch.Target = hit.Transform; } return result; }
private void canvas_TouchMove(object sender, TouchEventArgs e) { // Get the ellipse that corresponds to the current touch-down. Ellipse ellipse = movingEllipses[e.TouchDevice.Id]; // Move it to the new touch-down point. TouchPoint touchPoint = e.GetTouchPoint(canvas); Canvas.SetTop(ellipse, touchPoint.Bounds.Top); Canvas.SetLeft(ellipse, touchPoint.Bounds.Left); }
internal bool BeginTouch(TouchPoint touch) { var result = beginTouch(touch); if (result == LayerHitResult.Hit) { touch.Layer = this; if (touchBeganInvoker != null) touchBeganInvoker(this, new TouchLayerEventArgs(touch)); return true; } return false; }
internal bool BeginTouch(TouchPoint touch) { var result = beginTouch(touch); if (result == LayerHitResult.Hit) { touch.Layer = this; return(true); } return(false); }
private void updateBlobProperties(TouchPoint touch, TuioBlob blob) { var props = touch.Properties; props["Angle"] = blob.Angle; props["Width"] = blob.Width; props["Height"] = blob.Height; props["Area"] = blob.Area; props["RotationVelocity"] = blob.RotationVelocity; props["RotationAcceleration"] = blob.RotationAcceleration; }
public My_Point(int id, object sdr, Type t, TouchPoint touchPoint, DateTime dateTime) { this.iD = id; startPoint = touchPoint; currentPoint = touchPoint; startTime = dateTime; life = 0; isLive = true; sender = sdr; senderType = t; }
protected override void OnTouchMove(System.Windows.Input.TouchEventArgs e) { int id = e.TouchDevice.Id; TouchPoint touchPoint = e.GetTouchPoint(this); System.Diagnostics.Debug.WriteLine(string.Format("id:{0} x:{1} y:{2}", id, touchPoint.Position.X, touchPoint.Position.Y)); base.OnTouchMove(e); e.Handled = true; }
private bool checkForUIDrag(TouchPoint touch, float dt) { foreach (SmallPlayerUI ui in _miniUIs) { if (ui.processDrag(touch, dt)) { return(true); } } return(false); }
private void checkThread() { uint[] monno = new uint[MAX_SUPPORTED_SCR]; int a; EloGetScreenInfo(monno, out a); TouchPoint tp = new TouchPoint(); uint monitor = monno[0]; bool pressureTouched = false; int lastPressure = 0; int highestPressure = 0; while (true) { EloGetTouch(&tp, false, GetPointsCode.ReturnOnNextValidTouch, ref monitor); if (!Calibrated) { HandleCalibration(tp); } else { pendingX = (int)((tp.X - rawOffset.X) / rawRatio.X); pendingY = (int)((tp.Y - rawOffset.Y) / rawRatio.Y); if (!pressureTouched) { if (tp.Z > lastPressure) { pressureTouched = true; pendingTouch = true; } } else if (tp.Z <= Math.Max(12, highestPressure - (Player.Playing ? 20 : 100))) { pressureTouched = false; highestPressure = 0; } if (pressureTouched && tp.Z > highestPressure) { highestPressure = tp.Z; } state = tp.Status == GetPointsStatus.UnTouch ? ButtonState.Released : ButtonState.Pressed; lastPressure = tp.Z; } } }
/// <summary> /// Updates pointer data for touch. /// </summary> /// <param name="touch"> The touch. </param> /// <returns> Updated pointer data. </returns> protected PointerEventData updatePointerData(TouchPoint touch) { PointerEventData pointerEvent; getPointerData(touch.Id, out pointerEvent, true); pointerEvent.position = touch.Position; pointerEvent.delta = touch.Position - touch.PreviousPosition; return(pointerEvent); }
private void HandleCalibration(TouchPoint tp) { Thread.Sleep(50); Point nativeMousePosition = MouseManager.GetNativePosition(); if (ratioBase1.X == 0) { if (nativeMousePosition.X < 200) { ratioBase1.X = tp.X; ratioBase1S.X = nativeMousePosition.X; } } else { if (nativeMousePosition.X > 600) { ratioBase2.X = tp.X; ratioBase2S.X = nativeMousePosition.X; } } if (ratioBase1.Y == 0) { if (nativeMousePosition.Y < 200) { ratioBase1.Y = tp.Y; ratioBase1S.Y = nativeMousePosition.Y; } } else { if (nativeMousePosition.Y > 600) { ratioBase2.Y = tp.Y; ratioBase2S.Y = nativeMousePosition.Y; } } if (ratioBase2.X > 0 && ratioBase2.Y > 0) { Calibrated = true; rawRatio.X = (float)(ratioBase2.X - ratioBase1.X) / (ratioBase2S.X - ratioBase1S.X); rawRatio.Y = (float)(ratioBase2.Y - ratioBase1.Y) / (ratioBase2S.Y - ratioBase1S.Y); rawOffset.X = ratioBase1.X - (ratioBase1S.X * rawRatio.X); rawOffset.Y = ratioBase1.Y - (ratioBase1S.Y * rawRatio.Y); ConfigManager.sTouchCalibration = rawRatio.X.ToString(GameBase.nfi) + ":" + rawRatio.Y.ToString(GameBase.nfi) + ":" + rawOffset.X.ToString(GameBase.nfi) + ":" + rawOffset.Y.ToString(GameBase.nfi); NotificationManager.ShowMessageMassive("Touchscreen Calibration Complete!", 2000); } }
public WacomTouchReport(byte[] report) { Raw = report; AuxButtons = new bool[0]; Touches = prevTouches ?? new TouchPoint[MAX_POINTS]; if (report[2] == 0x81) { ApplyTouchMask((ushort)(Raw[3] | (Raw[4] << 8))); prevTouches = (TouchPoint[])Touches.Clone(); return; } var nChunks = Raw[1]; for (var i = 0; i < nChunks; i++) { var offset = (i << 3) + 2; var touchID = Raw[offset]; if (touchID == 0x80) { AuxButtons = new bool[] { (report[1 + offset] & (1 << 0)) != 0, (report[1 + offset] & (1 << 1)) != 0, (report[1 + offset] & (1 << 2)) != 0, (report[1 + offset] & (1 << 3)) != 0 }; continue; } touchID -= 2; if (touchID >= MAX_POINTS) { continue; } var touchState = Raw[1 + offset]; if (touchState == 0x20) { Touches[touchID] = null; } else { Touches[touchID] = new TouchPoint { TouchID = touchID, Position = new Vector2 { X = (Raw[2 + offset] << 4) | (Raw[4 + offset] >> 4), Y = (Raw[3 + offset] << 4) | (Raw[4 + offset] & 0xF) }, }; } } prevTouches = (TouchPoint[])Touches.Clone(); }
/// <summary> /// configure the sensor /// </summary> /// <param name="names"></param> public void setUpConfiguration(string[] names) { touchpoints = new TouchPoint[names.Length]; for (int i = 0; i < names.Length; i++) { touchpoints[i] = new TouchPoint(); touchpoints[i].name = names[i]; touchpoints[i].duration = 0; touchpoints[i].touched = false; } }
public override void CancelTouch(TouchPoint touch, bool @return) { base.CancelTouch(touch, @return); map.Remove(touch.Id); if (@return) { TouchHit hit; if (!gesture.GetTargetHitResult(touch.Position, out hit)) return; map.Add(touch.Id, beginTouch(processCoords(hit.RaycastHit.textureCoord), touch.Tags).Id); } }
public HomeScreen(SurfaceWindow1 parentWindow) : base(parentWindow) { InitializeComponent(); touch1 = null; touch2 = null; initialDist = Double.MaxValue; triggered = false; down = false; newImage = null; }
protected override void OnTouchUp(TouchEventArgs e) { DoubleAnimation animation = new DoubleAnimation(0.5, 1, TimeSpan.FromSeconds(STATICS.ANIMATION_DURATION * 0.3)); this.BeginAnimation(Canvas.OpacityProperty, animation); TouchPoint point = e.GetTouchPoint(menuLayer); menuLayer.MainWindow.Controlers.TouchControler.TouchUp(e.TouchDevice, point); menuLayer.MainWindow.ControlWindow.UpdateTextInfo(menuLayer.MainWindow.Controlers.TouchControler.ToString(), 1); e.Handled = true; base.OnTouchUp(e); }
/// <summary> /// Sends a /tuio/2Dblb message /// The remote Host is specified in the appConfig /// The message is built according to TUIO 1.1 specifications (see http://www.tuio.org/?specification) /// </summary> /// <param name="contacts">Current active contacts</param> /// <param name="previousContacts">Contacts from the previous frame</param> public void sendTUIO_2DBlb(List <TouchPoint> contacts, ReadOnlyTouchPointCollection previousContacts) { //if (contacts.Count == 0) return; //#warning Properties about the device are now on the InteractiveSurfaceDevice class. //InteractiveSurface surface = Microsoft.Surface.Core.InteractiveSurface.PrimarySurfaceDevice; //double width = InteractiveSurface.PrimarySurfaceDevice.Right - InteractiveSurface.PrimarySurfaceDevice.Left; //double height = InteractiveSurface.PrimarySurfaceDevice.Bottom - InteractiveSurface.PrimarySurfaceDevice.Top; InteractiveSurfaceDevice surface = InteractiveSurface.PrimarySurfaceDevice; double width = surface.Right - surface.Left; double height = surface.Bottom - surface.Top; OSCBundle blobBundle = new OSCBundle(); OSCMessage sourceMessage = TUIO_2DBlb.sourceMessage(); blobBundle.Append(sourceMessage); OSCMessage aliveMessage = TUIO_2DBlb.aliveMessage(contacts); blobBundle.Append(aliveMessage); for (int i = 0; i < contacts.Count; i++) { TouchPoint c = contacts[i]; double x = (c.CenterX - surface.Left) / width; double y = (c.CenterY - surface.Top) / height; double w = c.MajorAxis / surface.Width; double h = c.MinorAxis / surface.Height; double f = c.PhysicalArea / (surface.Width * surface.Height); float angularVelocity = 0.0f; float angularAcceleration = 0.0f; if (previousContacts.Contains(c.Id)) { computeAngularVelocity(c, previousContacts.GetTouchPointFromId(c.Id), out angularVelocity, out angularAcceleration); } float X = 0.0f; float Y = 0.0f; getVelocity(c.Id, out X, out Y); //, surface); float motionAcceleration = 0.0f; getMotionAcceleration(c.Id, out motionAcceleration, c.FrameTimestamp); OSCMessage setMessage = TUIO_2DBlb.setMessage(c.Id, (float)x, (float)y, (float)c.Orientation, (float)w, (float)h, (float)(w * h), X, Y, angularVelocity, motionAcceleration, angularAcceleration); blobBundle.Append(setMessage); } OSCMessage frameMessage = TUIO_2DBlb.frameMessage(_Frame); blobBundle.Append(frameMessage); _Frame++; _OSCSender.Send(blobBundle); }
private TouchPoint CreateTouchPoint(TuioCursor cursor) { TouchPoint tp = new TouchPoint { StartPoint = cursor.getPath().First().ToPoint(GestureManager), StartTimeMS = cursor.getStartTime().getTotalMilliseconds(), CurrentPoint = cursor.getPath().First().ToPoint(GestureManager), SessionID = cursor.getSessionID() }; return(UpdateTouchPoint(tp, cursor)); }
public void OnEvent(TouchPoint touchPoint) { Vector3 screenPosition = RawTouchPosToCanvasCoords(touchPoint.GetPosition()); int touchID = touchPoint.GetID(); //Debug.Log(touchPoint.GetPosition() + " " + touchPoint.GetID() + " " + touchPoint.GetGesture()); if (!touchList.ContainsKey(touchID)) { if (touchPoint.GetGesture() == EventBase.Type.Down) { GameObject visualMarker = Instantiate(touchPointPrefab); visualMarker.name = "TouchPoint " + touchID; visualMarker.transform.SetParent(transform); // Update position with new touch data visualMarker.transform.position = screenPosition; visualMarker.transform.localScale = Vector3.one * 10; touchPoint.SetObjectTouched(visualMarker); touchPoint.Update(screenPosition, EventBase.Type.Down); touchList.Add(touchID, touchPoint); } } else { if (touchPoint.GetGesture() == EventBase.Type.Move) { // Get the existing touch data TouchPoint existingTouchPoint = (TouchPoint)touchList[touchID]; GameObject visualMarker = existingTouchPoint.GetObjectTouched(); // Update position with new touch data visualMarker.transform.position = RawTouchPosToCanvasCoords(touchPoint.GetPosition()); visualMarker.transform.localScale = Vector3.one * 10; existingTouchPoint.Update(screenPosition, EventBase.Type.Move); touchList[touchID] = existingTouchPoint; } else if (touchPoint.GetGesture() == EventBase.Type.Up) { // Get the existing touch data TouchPoint existingTouchPoint = (TouchPoint)touchList[touchID]; GameObject visualMarker = existingTouchPoint.GetObjectTouched(); existingTouchPoint.Update(screenPosition, EventBase.Type.Up); // Remove the TouchPoint Destroy(visualMarker); touchList.Remove(touchID); } } }
private static TouchPoint[] ReadTouchPointArray(JsonElement jsonElement) { var touchPoints = new TouchPoint[jsonElement.GetArrayLength()]; var i = 0; foreach (var item in jsonElement.EnumerateArray()) { touchPoints[i++] = ReadTouchPoint(item); } return(touchPoints); }
protected override void OnTouchMove(TouchEventArgs e) { TouchPoint point = e.GetTouchPoint(this); mainWindow.Controlers.TouchControler.TouchMove(this, this.GetType(), e.TouchDevice, point); if (STATICS.DEBUG_MODE) { mainWindow.ControlWindow.UpdateTextInfo(mainWindow.Controlers.TouchControler.ToString(), 1); } e.Handled = true; base.OnTouchMove(e); }
private void scrollViewer1_TouchMove(object sender, TouchEventArgs e) { if (mIsTouch == true) //如果正在触摸 { TouchPoint point = e.GetTouchPoint(scrollViewer1); //获取相对于ScrollViewer的触摸点位置 double DiffOffset = point.Position.Y - mPointY; //计算相对位置 //tb_Select.Focus(); this.scrollViewer1.ScrollToVerticalOffset(mOffsetY - DiffOffset);//ScrollViewer滚动到指定位 } }
static void VisualizeTag(SpriteBatch spriteBatch, TouchPoint tagTouch) { float scale = ((float)AppParameters.NOTE_SIZE) / TextureManager.NoteFrame.Width; PointF rotCenter = new PointF(tagTouch.CenterX, tagTouch.CenterY); PointF topLeft = new PointF(tagTouch.CenterX - AppParameters.MARKER_SIZE / 2, tagTouch.CenterY - AppParameters.MARKER_SIZE / 2); PointF noteCenter = new PointF(topLeft.X + AppParameters.NOTE_SIZE / 2, topLeft.Y + AppParameters.NOTE_SIZE / 2); float rotAngleInRads = tagTouch.Orientation - (float)Math.PI / 2; noteCenter = Utilities.rotatePoint(noteCenter, rotAngleInRads, rotCenter); Vector2 origin = new Vector2(TextureManager.NoteFrame.Width/2,TextureManager.NoteFrame.Height/2); spriteBatch.Draw(TextureManager.NoteFrame, new Vector2(noteCenter.X, noteCenter.Y), null, Microsoft.Xna.Framework.Color.White, rotAngleInRads, origin, scale, SpriteEffects.None, 0f); }
private void MainCanvas_TouchUp(object sender, TouchEventArgs e) { TouchPoint pointFromWindow = e.GetTouchPoint(this); //translate to coordinates relative to Top-Left corner of Screen Point locationFromScreen = this.PointToScreen(new Point(pointFromWindow.Position.X, pointFromWindow.Position.Y)); if (pointFromWindow.Position.Y < 100 && pointFromWindow.Position.X < 800) { bitOne = bitTwo = bitThree = bitFour = 0; pageCode = "0000"; } }
/// <inheritdoc /> protected override LayerHitResult beginTouch(TouchPoint touch) { TouchHit hit; var result = Hit(touch.Position, out hit); if (result == LayerHitResult.Hit) { touch.Hit = hit; touch.Target = hit.Transform; } return(result); }
public void TouchPointConstructorWithLocalValue() { tlog.Debug(tag, $"TouchPointConstructorWithLocalValue START"); var testingTarget = new TouchPoint(1, TouchPoint.StateType.Started, 0.0f, 0.0f, 1.0f, 2.0f); Assert.IsNotNull(testingTarget, "Should be not null!"); Assert.IsInstanceOf <TouchPoint>(testingTarget, "Should be an Instance of TouchPoint!"); testingTarget.Dispose(); tlog.Debug(tag, $"TouchPointConstructorWithLocalValue END (OK)"); }
/// <summary> /// [内部メソッド] /// UP イベントデータを実行する /// </summary> /// <param name="eventData">イベントデータ</param> private void executeUpEvent(Win32ApiWrapper.TouchEventData eventData) { // 接触点を軌道に追加する var touchPoint = new TouchPoint(eventData.x, eventData.y); this.orbit.Add(touchPoint); // 「タッチアップ」イベントハンドラを実行する var teArgs = new TouchEventArgs(touchPoint, this.orbit); OnTouchUp(teArgs); }
protected virtual bool processTouch(TouchPoint touch, float dt) { Vector2 touchPos = Utils.touchPointToV2(touch); float dist = Vector2.Distance(touchPos, _position); if (touch.IsTagRecognized) { return false; } if (touch.Id == _touchId || isTouchOnUI(touchPos)) { Vector2 direction = (touchPos - _position); float newTouchAngle = Utils.directionToAngle(direction); //same touch if (touch.Id == _touchId) { float newAngle = newTouchAngle + _angleOffset; float angleDiff = newAngle - _angle; float lastTouchAngle = _angle - _angleOffset; if (lastTouchAngle * newTouchAngle >= 0) { _angularVelocity = (_angularVelocity * NB_MOVE_RECORDED + angleDiff / dt * SPEED_COEF) / (NB_MOVE_RECORDED + 1f); } else { //Console.WriteLine("new angle : " + newTouchAngle + " _angle : " + lastTouchAngle); } //update angle _angle = newAngle; } //new touch else { _angleOffset = _angle - newTouchAngle; } _touchId = touch.Id; _touchReleased = false; return true; } else { _touchReleased = true; } return false; }
private void Button_PreviewTouchDown(object sender, TouchEventArgs e) { if (touch1 == null) { touch1 = e.GetTouchPoint(sender as SurfaceButton); } else { touch2 = e.GetTouchPoint(sender as SurfaceButton); initialDist = touchDist(touch1, touch2); } }