/// <summary> /// Handles any addition or update to gesture items in the inventory. /// </summary> /// <param name="gesture">Gesture that was added or updated.</param> private void UpdateInventoryGesture(InventoryGesture gesture) { var client = RadegastInstance.GlobalInstance.Client; client.Assets.RequestAsset(gesture.AssetUUID, AssetType.Gesture, false, (_, asset) => { var assetGesture = asset as AssetGesture; if (assetGesture == null) { return; } if (!assetGesture.Decode()) { return; } if (!Gestures.ContainsKey(gesture.UUID)) { Gestures.Add(gesture.UUID, new GestureTrigger()); } var existingGestureTrigger = Gestures[gesture.UUID]; existingGestureTrigger.TriggerLower = assetGesture.Trigger.ToLower(); existingGestureTrigger.Replacement = assetGesture.ReplaceWith; existingGestureTrigger.AssetID = assetGesture.AssetID; }); }
internal void UserInput(Gestures g) { Gestures aiGesture = ai.MakeDecision(g); figure1.text = GestureToString(g); figure2.text = GestureToString(aiGesture); result.text = "UNKNOWN"; if (RPSRules.FirstBeatsSecond(g, aiGesture)) { result.text = "WON"; score.addP1(); } else if (RPSRules.FirstBeatsSecond(aiGesture, g)) { result.text = "LOST"; score.addP2(); } else if (RPSRules.IsDraw(aiGesture, g)) { result.text = "DRAW"; } gameObject.SetActive(true); }
void onInput(ref POINTER_INFO ptr) { if(_gestures == null) _gestures = GameObject.FindGameObjectWithTag("UserHitbox").GetComponent<Gestures>(); switch(ptr.evt) { case POINTER_INFO.INPUT_EVENT.PRESS: _gestures.onBeginTouch(); Debug.Log("STARTED TO HOVER!"); _hovering = true; break; case POINTER_INFO.INPUT_EVENT.NO_CHANGE: if(_hovering) { _hoverTime += Time.deltaTime; if(_hoverTime >= hoverTime) { _hovering = false; _hoverTime = 0; doHover(); } } break; default: _hovering = false; _hoverTime = 0; break; } }
static bool InitKinect() { foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { sensor = potentialSensor; break; } } if (sensor == null) { return(false); } sensor.SkeletonStream.Enable(); sensor.SkeletonFrameReady += SkeletonFrameReady; Gestures.Load(); Dispatch.SkeletonMoved += SkeletonMoved; Dispatch.Beat += Beat; //Dispatch.Beat += (time, beat) => Console.WriteLine("Beat {0}", beat); sensor.Start(); return(true); }
//This method is called from Gestures.cs //TODO: This should accept a list of dirs instead of just one public void setGesture(Gestures.direction dir) { // Cast sun. //if (Input.GetKeyDown(KeyCode.Alpha1)) if (dir == Gestures.direction.N) { rw.SetWeather(RandomWeather.Weather.Sunny); } // Cast rain. //else if (Input.GetKeyDown(KeyCode.Alpha2)) else if (dir == Gestures.direction.S) { rw.SetWeather(RandomWeather.Weather.Rainy); } // Cast wind. //else if (Input.GetKeyDown(KeyCode.Alpha3)) else if (dir == Gestures.direction.E) { if (!wind_i) { if (TimedSpellInProgress()) Reset(); wind_i = (GameObject)Instantiate(wind); } } // Cast fertilizer. //else if (Input.GetKeyDown(KeyCode.Alpha4)) else if (dir == Gestures.direction.W) { if (!fertilizer_i) fertilizer_i = (GameObject) Instantiate(fertilizer); } }
private void Gestures_GestursChanged(object sender, NotifyCollectionChangedEventArgs e) { if (_gestureService == null) { _gestureService = IoC.Get <IKeyGestureService>(); } KeyGestures = new ReadOnlyCollection <MultiKeyGesture>(Gestures.Select(x => x.KeyGesture).ToList()); switch (e.Action) { case NotifyCollectionChangedAction.Add: var mapping = new CommandGestureScopeMapping(this, e.NewItems.OfType <GestureScopeMapping>().FirstOrDefault()); _gestureService.AddKeyGestures(mapping); break; case NotifyCollectionChangedAction.Remove: _gestureService.RemoveKeyGesture(e.OldItems.OfType <GestureScopeMapping>().FirstOrDefault()); break; case NotifyCollectionChangedAction.Reset: foreach (var gesture in Gestures) { _gestureService.RemoveKeyGesture(gesture); } break; default: throw new ArgumentOutOfRangeException(); } OnPropertyChanged(nameof(GestureText)); }
public Cord addCord(Gestures gesture, string keys) { Cord cord = new Cord(keys); Cords.Add(gesture, cord); return(cord); }
private bool Set(Gestures gesture, Point position) { int x = (int)position.X; int y = (int)position.Y; if (m_matrix[x, y] == -1) { m_matrix[x, y] = (int)gesture; if (gesture == Gestures.X) { m_window.drawX(position); } else { m_window.drawO(position); } return(true); } else { return(false); } }
private Gestures CheckWon(Gestures gesture) { for (int i = 0; i < BOARD_SIZE; i++) { if (m_matrix[i, 0] == (int)gesture && m_matrix[i, 1] == (int)gesture && m_matrix[i, 2] == (int)gesture) { return(gesture); } } for (int i = 0; i < BOARD_SIZE; i++) { if (m_matrix[0, i] == (int)gesture && m_matrix[1, i] == (int)gesture && m_matrix[2, i] == (int)gesture) { return(gesture); } } if (m_matrix[0, 0] == (int)gesture && m_matrix[1, 1] == (int)gesture && m_matrix[2, 2] == (int)gesture) { return(gesture); } if (m_matrix[2, 0] == (int)gesture && m_matrix[1, 1] == (int)gesture && m_matrix[0, 2] == (int)gesture) { return(gesture); } return(Gestures.NONE); }
public Tab() { HitTestTarget = true; Gestures.Add(new ClickGesture(2, () => Closing?.Invoke())); Awoke += Awake; Components.Add(new UpdatableNodeBehavior()); }
private void AddUserCombination(Gestures gesture) { if (!PossibleMoves.Contains(gesture)) { return; } if (!_exerciseTime.IsRunning) { return; } var index = _userCombi.Count; if (_correctCombi[index] != gesture) { _wrongCombi = true; GameEventManager.EndGame(); return; } var timeSpent = _exerciseTime.ElapsedMilliseconds; _exerciseTime.Reset(); _userCombi.Add(gesture); UpdateScore(timeSpent); if (_userCombi.Count == _correctCombi.Count) { NewRound(); return; } _exerciseTime.Start(); }
public void CheckMultiFingerGesture() { if (gestureFinger1 != Gestures.None && gestureFinger2 != Gestures.None) { if (gestureFinger1 == Gestures.Touch || gestureFinger2 == Gestures.Touch) { ResetTwoFingerGestures(); currentGesture = Gestures.TwoFingerTouch; } else if (((gestureFinger1 == Gestures.SwipeLeft || gestureFinger1 == Gestures.SwipeDownLeft || gestureFinger1 == Gestures.SwipeUpperLeft || gestureFinger1 == Gestures.SwipeUp) && (gestureFinger2 == Gestures.SwipeRight || gestureFinger2 == Gestures.SwipeDownRight || gestureFinger2 == Gestures.SwipeUpperRight || gestureFinger2 == Gestures.SwipeDown)) || (gestureFinger1 == Gestures.SwipeRight || gestureFinger1 == Gestures.SwipeDownRight || gestureFinger1 == Gestures.SwipeUpperRight || gestureFinger1 == Gestures.SwipeDown) && (gestureFinger2 == Gestures.SwipeLeft || gestureFinger2 == Gestures.SwipeDownLeft || gestureFinger2 == Gestures.SwipeUpperLeft || gestureFinger2 == Gestures.SwipeUp)) { ResetTwoFingerGestures(); currentGesture = Gestures.TwoFingerSwipeOutwards; } else if (gestureFinger2 == Gestures.SwipeLeft && gestureFinger1 == Gestures.SwipeRight) { ResetTwoFingerGestures(); currentGesture = Gestures.TwoFingerSwipeInwards; } else { ResetTwoFingerGestures(); } } }
public int SubscribeToGesture(Gestures gesture, Action <Vector2> handler) { int subResult = -1; switch (gesture) { case Gestures.SwipeUp: subResult = swipesController.SubscribeToSwipe(SwipesController.Swipe.Up, handler as Action <Vector2>); break; case Gestures.SwipeDown: subResult = swipesController.SubscribeToSwipe(SwipesController.Swipe.Down, handler as Action <Vector2>); break; case Gestures.SwipeLeft: subResult = swipesController.SubscribeToSwipe(SwipesController.Swipe.Left, handler as Action <Vector2>); break; case Gestures.SwipeRight: subResult = swipesController.SubscribeToSwipe(SwipesController.Swipe.Right, handler as Action <Vector2>); break; default: break; } return(subResult); }
/// <summary> /// Detect which gesture was performed based on specific parameters defined by each gesture /// </summary> /// <param name="leftStartPos">The initial position of the left controller when the grip is first pressed</param> /// <param name="leftEndPos">The final position of the left controller when the grip is released</param> /// <param name="rightStartPos">The initial position of the right controller when the grip is first pressed</param> /// <param name="rightEndPos">The final position of the right controller when the grip is released</param> /// <returns>The gesture that the motion satisfied</returns> public Gestures CheckGesture(Vector3 leftStartPos, Vector3 leftEndPos, Vector3 rightStartPos, Vector3 rightEndPos) { // Cache positions leftStart = leftStartPos; leftEnd = leftEndPos; rightStart = rightStartPos; rightEnd = rightEndPos; Gestures result = 0; // There may be a better way of doing this chain of if statements such as the Visitor Pattern but I can't seem to figure out a way of doing it if (IsProjectileGesture()) { result = Gestures.Projectile; } else if (IsUppercutGesture()) { result = Gestures.Uppercut; } else if (IsGroundPoundGesture()) { result = Gestures.GroundPound; } // Reset cached positions ResetPositions(); Debug.Log("Gesture triggered: " + result); return(result); }
public void GestureForReturnsAppropriateGestureForSide() { var gestures = new Gestures((Knobs)null); Assert.AreEqual(HandSide.Right, gestures.GestureFor(HandSide.Right).Side()); Assert.AreEqual(HandSide.Left, gestures.GestureFor(HandSide.Left).Side()); }
Sprite GetSpriteForGesture(Gestures gesture) { foreach (var sprite in sprites) { if (sprite.name == gesture.ToString ()) { return sprite; } } return null; }
public void AnyGrabsIsFalseIfNoGesturesAreGrabbing() { var nonGrabbingGesture = new Gesture(HandSide.Right, null); var anotherNonGrabbingGesture = new Gesture(HandSide.Left, null); var gestures = new Gestures(nonGrabbingGesture, anotherNonGrabbingGesture); Assert.False(gestures.AnyGrabs()); }
public static Gestures GetRandomGesture() { Array values = Enum.GetValues(typeof(Gestures)); Random random = new Random(); Gestures rand = (Gestures)values.GetValue(random.Next(values.Length)); return(rand); }
public void AddGestures(List <Gesture> gestures) { foreach (Gesture gesture in gestures) { Gestures.Add(gesture); myMatcher.AddGesture(gesture); GestureCount++; } }
public void OnTriggerStay(Collider col) { if (col.gameObject.GetComponentInParent <SensoHandExample>()) { if (!Grabbed && !Pinched) { SensoHandExample = col.gameObject.GetComponentInParent <SensoHandExample>(); gesture = SensoHandExample.gameObject.GetComponent <Gestures>(); } if (!gesture.PinchedOrGrabbed) { if (((SensoHandExample.HandType == Senso.EPositionType.RightHand) || (SensoHandExample.HandType == Senso.EPositionType.LeftHand)) && gesture.grab && Grab && col.gameObject.tag == "InteractableHand") { if (Grabbed == false) { if (col.gameObject.TryGetComponent(out rb)) { rb.isKinematic = true; rb.useGravity = false; } else { rb = col.gameObject.AddComponent <Rigidbody>(); rb.isKinematic = true; rb.useGravity = false; } CreateJoint(col.gameObject); Grabbed = true; gesture.PinchedOrGrabbed = true; } } else if (col.gameObject.tag == "InteractableFinger" && gesture.pinch && Pinch) { if (Pinched == false) { if (col.gameObject.TryGetComponent(out rb)) { rb.isKinematic = true; rb.useGravity = false; } else { rb = col.gameObject.AddComponent <Rigidbody>(); rb.isKinematic = true; rb.useGravity = false; } CreateJoint(col.gameObject); Pinched = true; gesture.PinchedOrGrabbed = true; } } } } }
protected override void Awake() { // On the current frame the button contents may not be loaded, // so delay its initialization until the next frame. SetState(InitialState()); textPresentersFeeder = new TextPresentersFeeder(this); clickGesture = new ClickGesture(); Gestures.Add(clickGesture); }
/// <summary> /// Create new instance by passing all needed data. /// </summary> /// <param name="player">Player performed gesture.</param> /// <param name="gesture">Recognized gesture.</param> /// <param name="probability">Probability of recognition.</param> /// <param name="length">Length of recognized gesture.</param> /// <param name="valid">Indicates, if gesture were recognized as valid (probability > gesture threshold).</param> /// <param name="forced">True if gesture was forced.</param> public GestureEventArgs(KinectGesturePlayer player, Gestures.IGesture gesture, double probability, int length, bool valid, bool forced = false) { SourcePlayer = player; Gesture = gesture; Probability = probability; IsForced = forced; IsValid = valid; Length = length; }
public void AnyGrabsIsTrueIfAnyGesturesIsGrabbing() { var grabbingGesture = new Gesture(HandSide.Left, null); grabbingGesture.grabbed = new Knob(null, new GameObject(), Vector3.up, 0); var nonGrabbingGesture = new Gesture(HandSide.Right, null); var gestures = new Gestures(grabbingGesture, nonGrabbingGesture); Assert.True(gestures.AnyGrabs()); }
private void HandleKeyboardInputComplete(IAsyncResult asyncResult) { var text = Guide.EndShowKeyboardInput(asyncResult); Text = text; _clickSubscription = Gestures.Subscribe(HandleClick); InvokeTextChanged(EventArgs.Empty); }
private void OnGesturerRecognized(int contactCount, Gestures gesture) { var actions = ApplicationManager.Instance.GetRecognizedDefinedAction(a => a.ContinuousGesture != null && a.ContinuousGesture.ContactCount == contactCount && a.ContinuousGesture.Gesture == gesture); if (actions.Count > 0) { OnTriggerFired(new TriggerFiredEventArgs(actions, _startPoint)); } }
/// <summary> /// Aktiviert oder deaktiviert eine registrierte Geste /// </summary> /// <param name="gesture">Der Identifier der Geste</param> /// <param name="active"></param> public virtual void SetGestureActive(string gesture, bool active) { if (Gestures != null) { if (Gestures.ContainsKey(gesture)) { Gestures[gesture].IsActive = active; } } }
public static bool FirstBeatsSecond(Gestures g1, Gestures g2) { for (int i = 0; i < wincombinations.Length; i++) { if (wincombinations[i][0] == g1) { return(wincombinations[i][1] == g2); } } return(false); }
/// <summary> /// Binds the left and right buttons to next and previous. /// </summary> private void BindGestures() { Gestures.Bind(PreviousOption, new ButtonPressed(Buttons.DPadLeft), new ButtonPressed(Buttons.LeftThumbstickLeft), new KeyPressed(Keys.Left)); Gestures.Bind(NextOption, new ButtonPressed(Buttons.DPadRight), new ButtonPressed(Buttons.LeftThumbstickRight), new KeyPressed(Keys.Right)); }
public PathArrowButton(Func <string, bool> openPath, string path = null) : base() { this.path = path; this.openPath = openPath; MinMaxHeight = 20; Presenter = new PathButtonPresenter(); base.Presenter = Presenter; if (path == null) { Updating += (float delta) => { var prevState = State; if (Expanded) { State = PathBarButtonState.Press; } else { if (IsMouseOverThisOrDescendant()) { if (WasClicked()) { State = PathBarButtonState.Press; } else { State = PathBarButtonState.Hover; } } else { State = PathBarButtonState.Normal; } } if (prevState != State) { Presenter.SetState(State); } }; } Gestures.Add(new ClickGesture(0, FlipState)); Layout = new HBoxLayout(); MinMaxSize = new Vector2(11, 20); Nodes.Add(icon = new Image { LayoutCell = new LayoutCell { Alignment = new Alignment { X = HAlignment.Center, Y = VAlignment.Center } }, MinMaxSize = new Vector2(11, 6), Texture = IconPool.GetTexture("Filesystem.PathSeparatorCollapsed") }); Expanded = false; }
/// <summary> /// Binds menu navigation to the up and down keys. /// Override this to implement different behavier. /// </summary> private void BindGestures() { Gestures.Bind(PreviousOption, new ButtonPressed(Buttons.DPadUp), new ButtonPressed(Buttons.LeftThumbstickUp), new KeyPressed(Keys.Up)); Gestures.Bind(NextOption, new ButtonPressed(Buttons.DPadDown), new ButtonPressed(Buttons.LeftThumbstickDown), new KeyPressed(Keys.Down)); }
public static Gestures GetWinGesture(Gestures g) { for (int i = 0; i < wincombinations.Length; i++) { if (wincombinations[i][0] == g) { return(wincombinations[i][1]); } } throw new ArgumentException("unreachable code"); }
/// <summary> /// Checks a single word for a gesture trigger and appends the final word to the output /// </summary> /// <param name="word">Word to check for gesture triggers</param> /// <param name="outString">Where to output the word or replacement word to</param> /// <returns>True if a gesture trigger was executed.</returns> private bool ProcessWord(string word, StringBuilder outString) { var possibleTriggers = new List <GestureTrigger>(); var client = RadegastInstance.GlobalInstance.Client; var lowerWord = word.ToLower(); client.Self.ActiveGestures.ForEach(pair => { var activeGestureID = pair.Key; if (!Gestures.ContainsKey(activeGestureID)) { return; } var gesture = Gestures[activeGestureID]; if (lowerWord != gesture.TriggerLower) { return; } possibleTriggers.Add(gesture); }); if (possibleTriggers.Count == 0) { outString.Append(word); outString.Append(' '); return(false); } GestureTrigger gestureToPlay; if (possibleTriggers.Count > 1) { var gestureIndexToPlay = Random.Next(possibleTriggers.Count); gestureToPlay = possibleTriggers[gestureIndexToPlay]; } else { gestureToPlay = possibleTriggers[0]; } client.Self.PlayGesture(gestureToPlay.AssetID); if (!String.IsNullOrEmpty(gestureToPlay.Replacement)) { outString.Append(gestureToPlay.Replacement); outString.Append(' '); } return(true); }
public void SetGestureSprite(Gestures gesture) { switch (gesture) { case Gestures.ExtendedHand: handSpriteRenderer.sprite = extendedHand; break; case Gestures.Fist: handSpriteRenderer.sprite = fist; break; } }
public GesturesStrategy(Gestures gestures, KnobArranger knobArranger, IDebug debug) { this.knobArranger = knobArranger; this.debug = debug; this.gestures = gestures; // move up and out to text writer, use lister interface gestures.GestureFor(HandSide.Right).OnGrab += OnGrab; gestures.GestureFor(HandSide.Left).OnGrab += OnGrab; gestures.GestureFor(HandSide.Right).OnRelease += OnRelease; gestures.GestureFor(HandSide.Left).OnRelease += OnRelease; gestures.GestureFor(HandSide.Right).OnTouch += OnTouch; gestures.GestureFor(HandSide.Left).OnTouch += OnTouch; }
public void reactGesture(Gestures recognisedGestures) { if (recognisedGestures != Gestures.None && recognisedGestures != Gestures.Move) { Debug.Print("Gesture {0}", recognisedGestures); } //var handRightPoint = tracker.Engager.Joints[JointType.HandRight].Position; //var leftPin = CoordinateConverter.cameraPointToScreen(handRightPoint.X, handRightPoint.Y); POINT leftPin; MyCursor.GetCursorPos(out leftPin); switch (recognisedGestures) { case Gestures.MouseDown: leftDown(leftPin.x, leftPin.y); break; case Gestures.MouseUp: //leftDown(leftPin.x, leftPin.y); leftUp(leftPin.x, leftPin.y); break; case Gestures.DoubleClick: MyCursor.mouse_event(MOUSEEVENTF.LEFTDOWN | MOUSEEVENTF.LEFTUP, leftPin.x, leftPin.y, 0, 0); Thread.Sleep(150); MyCursor.mouse_event(MOUSEEVENTF.LEFTDOWN | MOUSEEVENTF.LEFTUP, leftPin.x, leftPin.y, 0, 0); break; case Gestures.Move: moveCursor(); break; case Gestures.Scale: scaleWindow(); break; case Gestures.Scroll: scrollWindow(); break; default: //leftUp(0, 0); break; } }
/// <summary> /// Checks if a swipe is completed /// </summary> /// <param name="lastPosition">The last position of the swip</param> /// <param name="duration">The duration of the swipe</param> /// <param name="change">The change in position of the swipe</param> /// <param name="detectingGesture">The swipe that is being checked</param> /// <returns>A boolean to indicate that the swipe is completed</returns> private bool CheckPushCompleted(xn.Point3D lastPosition, float duration, float change, Gestures detectingGesture) { if (change >= _treshHold) { //Check if the swipe was fast enough. //If it is to slow it is not a swipe float speed = ((change / 1000) / duration); if (speed > _speedTreshold) { PushGestureRecognisedEventHandler(this, new PushGestureRecognisedEventArgs(detectingGesture, lastPosition, speed)); } //Reset settings ResetValues(); return true; } return false; }
public StillGestureRecognisedEventArgs(Gestures gesture, Point3D point, float fTime) { _gesture = gesture; _point = point; _timeHold = fTime; }
/// <summary> /// Initializes a new instance of the <see cref="GestureEventArgs"/> class. /// </summary> /// <param name="device">The sending device.</param> /// <param name="pressedGeneralKeys">The pressed general keys.</param> /// <param name="pressedGenericKeys">The interpreted pressed generic keys.</param> /// <param name="releasedGeneralKeys">The released general keys.</param> /// <param name="releasedGenericKeys">The interpreted released generic keys.</param> /// <param name="gesture">The gesture classification result.</param> public GestureEventArgs(BrailleIO.BrailleIODevice device, List<BrailleIO_DeviceButton> pressedGeneralKeys, List<String> pressedGenericKeys, List<BrailleIO_DeviceButton> releasedGeneralKeys, List<String> releasedGenericKeys, Gestures.Recognition.Interfaces.IClassificationResult gesture) : base(device, pressedGeneralKeys, pressedGenericKeys, releasedGeneralKeys, releasedGenericKeys) { this.Gesture = gesture; }
protected bool fireGestureEvent(BrailleIO.BrailleIODevice device, List<BrailleIO_DeviceButton> releasedGeneralKeys, List<String> releasedGenericKeys, List<BrailleIO_DeviceButton> pressedGeneralKeys, List<String> pressedGenericKeys, Gestures.Recognition.Interfaces.IClassificationResult gesture) { var args = new GestureEventArgs(device, pressedGeneralKeys, pressedGenericKeys, releasedGeneralKeys, releasedGenericKeys, gesture); Logger.Instance.Log(LogPriority.OFTEN, this, "Gesture performed: " + args.Gesture.ToString()); bool cancel = base.fireGestureEvent(args); if (cancel) { System.Diagnostics.Debug.WriteLine("InteractionManager Event canceled"); } return cancel; }
/// <summary> /// Removes a gesture from the list of tracked gestures. /// </summary> /// <param name="gesture">The gesture to remove</param> public void RemoveGesture(Gestures gesture) { if (_allowedGestures.Contains(gesture)) { _allowedGestures.Remove(gesture); } }
protected override void CheckStatus() { //Get the last postion and time xn.Point3D lastPosition = _traceHistory.Values[_traceHistory.Values.Count - 1]; float lastTime = _traceHistory.Keys[_traceHistory.Values.Count - 1]; //Initiate horizontal swipe if needed if (!_horizontalSwipeDetecting && _traceHistory.Values.Count >= 2) { _horizontalSwipeDetecting = true; _horizontalStartPoint = _previousPoint; _horizontalStartTime = _previousTime; //Detect if the swip is lefdt or rigth if (lastPosition.X > _horizontalStartPoint.X) _horizontalSwipeDirection = Gestures.SwipeLeft; else _horizontalSwipeDirection = Gestures.SwipeRight; } //Initiate vertical swipe if needed if (!_verticalSwipeDetecting && _traceHistory.Values.Count >= 2) { _verticalSwipeDetecting = true; _verticalStartPoint = _previousPoint; _verticalStartTime = _previousTime; //Detect if the swip is up or down if (lastPosition.Y > _verticalStartPoint.Y) _verticalSwipeDirection = Gestures.SwipeDown; else _verticalSwipeDirection = Gestures.SwipeUp; } else { //Check if the detecting swipe is still valid switch (_horizontalSwipeDirection) { case Gestures.SwipeLeft: if (lastPosition.X < _previousPoint.X) { float change = lastPosition.X - _horizontalStartPoint.X; float duration = lastTime - _horizontalStartTime; //Check if the swip is completed. //This is true if the treshold is passed. CheckSwipeCompleted(lastPosition, duration, change, Gestures.SwipeLeft); } else { //ResetHorizontalValues(); } break; case Gestures.SwipeRight: if (_previousPoint.X < lastPosition.X) { float change = _horizontalStartPoint.X - lastPosition.X; float duration = lastTime - _horizontalStartTime; //Check if the swip is completed. //This is true if the treshold is passed. CheckSwipeCompleted(lastPosition, duration, change, Gestures.SwipeRight); } else { //ResetHorizontalValues(); } break; } switch (_verticalSwipeDirection) { case Gestures.SwipeUp: if (_previousPoint.Y < lastPosition.Y) { float change = lastPosition.Y - _verticalStartPoint.Y; float duration = lastTime - _verticalStartTime; //Check if the swip is completed. //This is true if the treshold is passed. CheckSwipeCompleted(lastPosition, duration, change, Gestures.SwipeUp); } else { //ResetVerticalValues(); } break; case Gestures.SwipeDown: if (_previousPoint.Y < lastPosition.Y) { float change = _verticalStartPoint.Y - lastPosition.Y; float duration = lastTime - _verticalStartTime; //Check if the swip is completed. //This is true if the treshold is passed. CheckSwipeCompleted(lastPosition, duration, change, Gestures.SwipeDown); } else { //ResetVerticalValues(); } break; } } _previousPoint = lastPosition; _previousTime = lastTime; }
/// <summary> /// Removes a gesture to recognize /// </summary> /// <param name="gesture">The gesture to remove</param> internal void RemoveGesture(Gestures gesture) { if (_gestureGenerator != null) { switch (gesture) { case Gestures.Push: PushGesture pg = _handGestures.Find(hg => hg.GetType() == typeof(PushGesture)) as PushGesture; if (pg != null) { _handGestures.Remove(pg); pg.Dispose(); pg = null; } break; case Gestures.SwipeAll: SwipeGesture sg = _handGestures.Find(hg => hg.GetType() == typeof(SwipeGesture)) as SwipeGesture; if (sg != null) { _handGestures.Remove(sg); sg.Dispose(); sg = null; } break; case Gestures.Still: StillGesture stillg = _handGestures.Find(hg => hg.GetType() == typeof(StillGesture)) as StillGesture; if (stillg != null) { _handGestures.Remove(stillg); stillg.Dispose(); stillg = null; } break; } } }
void HandleNewGesture (Gestures gesture) { image.sprite = GetSpriteForGesture (gesture); }
public PushGestureRecognisedEventArgs(Gestures gesture, Point3D point, float speed) { _gesture = gesture; _point = point; _speed = speed; }
/// <summary> /// Emits GestureRecognized event. /// </summary> /// <param name="gesture">Recognized gesture.</param> /// <param name="probability">Gesture probability.</param> /// <param name="length">Gesture length.</param> /// <param name="forced">Was gesture forced?</param> private void OnGestureRecognized(Gestures.IGesture gesture, double probability, int length, bool forced = false) { //create copy of sequence (sequence is recycling in normal case) only if there if any listener if (GestureRecognized != null) GestureRecognized(this, new GestureEventArgs(this, gesture, probability, length, (probability >= gesture.ProbabilityThreshold), forced)); }
/// <summary> /// Register player joint as tracked by specified gesture. /// </summary> /// <remarks>If joint in not used yet, creates also filter and sequence tracker for it.</remarks> /// <param name="type">Type of joint which should be tracked.</param> /// <param name="gesture">Gesture for which is joint registered.</param> public void RegisterJoint(JointType type, Gestures.IGesture gesture) { if (!trackedPoints.ContainsKey(type)) { trackedPoints.Add(type, new Filter3D(3, 0.005f)); directionSequences.Add(type, new DirectionSequence(type)); } gestureListeners.Add(gesture); }
/// <summary> /// Register gesture for this player. /// </summary> /// <param name="gesture">Gesture to register.</param> /// <param name="forcedGestureRecognition">If true, thist gesture will be evaluated for every valid sequence and will be emited event for it. /// This means that event wil be emited for thist gesture every possible time not depending on his current likehood or if this event have maximal likehooh.</param> public void RegisterGesture(Gestures.IGesture gesture, bool forcedGestureRecognition = false) { gesture.RegisterJointListeners(this); if (forcedGestureRecognition) forcedRecognition.Add(gesture); }
private void UpdateTabControl(Gestures gesture) { //Get the new tabindex int tabIndex = 0; if (tabControl1.SelectedIndex == -1) tabIndex = 0; else { switch (gesture) { case Gestures.SwipeLeft: if (tabControl1.SelectedIndex != 0) tabIndex = tabControl1.SelectedIndex - 1; else tabIndex = tabControl1.Items.Count - 1; break; case Gestures.SwipeRight: if (tabControl1.SelectedIndex != tabControl1.Items.Count - 1) tabIndex = tabControl1.SelectedIndex + 1; else tabIndex = 0; break; } } tabControl1.SelectedIndex = tabIndex; }
public GestureRecognisedEventArgs(Gestures gesture, Point3D point) { _gesture = gesture; _point = point; }
public void SimulateGesture(Gestures.TouchGesture gesture) { _simulategesture(gesture); }
public PushGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point, float speed) { _gesture = gesture; _point = new Point3D(point.X, point.Y, point.Z); _speed = speed; }
/// <summary> /// Adds a gesture to recognize /// </summary> /// <param name="gesture">The gesture to recognize</param> internal void AddGesture(Gestures gesture) { if (_gestureGenerator != null) { switch (gesture) { case Gestures.Push: PushGesture pg = new PushGesture(); _handGestures.Add(pg); pg.PushGestureRecognisedEventHandler += new EventHandler<PushGestureRecognisedEventArgs>(pg_PushGestureRecognisedEventHandler); pg.HandDestroyed += new EventHandler<EventArgs>(hand_HandDestroyed); pg.Init(_manager); break; case Gestures.SwipeAll: SwipeGesture sg = new SwipeGesture(); _handGestures.Add(sg); sg.SwipeGestureRecognisedEventHandler += new EventHandler<SwipeGestureRecognisedEventArgs>(sg_SwipeGestureRecognisedEventHandler); sg.HandDestroyed += new EventHandler<EventArgs>(hand_HandDestroyed); sg.Init(_manager); break; case Gestures.Still: StillGesture stillg = new StillGesture(); _handGestures.Add(stillg); stillg.StillGestureRecognized += new EventHandler<StillGestureRecognisedEventArgs>(stillg_StillGestureRecognized); stillg.HandDestroyed += new EventHandler<EventArgs>(hand_HandDestroyed); stillg.Init(_manager); break; } } }
public ButtonActions GetPole(Gestures gesture) { if (gesture == Gestures.Positive) return Positive; else if (gesture == Gestures.Negative) return Negative; else if (gesture == Gestures.Analog) throw new InvalidOperationException(); return null; }
/// <summary> /// Add a gesture to the list of tracked gestures. /// </summary> /// <param name="gesture">The gesture to add.</param> public void AddGesture(Gestures gesture) { if (!_allowedGestures.Contains(gesture)) { _allowedGestures.Add(gesture); if (_gestureTracker != null) _gestureTracker.AddGesture(gesture); } }
public SwipeGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point) { _gesture = gesture; _point = new Point3D(point.X, point.Y, point.Z) ; }
/// <summary> /// Checks if a swipe is completed /// </summary> /// <param name="lastPosition">The last position of the swip</param> /// <param name="duration">The duration of the swipe</param> /// <param name="change">The change in position of the swipe</param> /// <param name="detectingGesture">The swipe that is being checked</param> /// <returns>A boolean to indicate that the swipe is completed</returns> private bool CheckSwipeCompleted(xn.Point3D lastPosition, float duration, float change, Gestures detectingGesture) { if (change >= _treshHold) { //Check if the swipe was fast enough. //If it is to slow it is not a swipe float speed = ((change / 1000) / duration); if (speed > _speedTreshold) { SwipeGestureRecognisedEventHandler(this, new SwipeGestureRecognisedEventArgs(detectingGesture, lastPosition)); } //Reset settings ResetValues(); return true; } else { switch (detectingGesture) { case Gestures.SwipeRight: case Gestures.SwipeLeft: ResetHorizontalValues(); break; case Gestures.SwipeDown: case Gestures.SwipeUp: ResetVerticalValues(); break; } } return false; }
public StillGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point, float fTime) { _gesture = gesture; _point = new Point3D(point.X, point.Y, point.Z); _timeHold = fTime; }
private void checkZoomGesture() { double initial_position = historyManager.getJoint(JointType.HandLeft, 0.3).Position.Z; double final_position = historyManager.getJoint(JointType.HandLeft, 0).Position.Z; double diff = final_position - initial_position; //vWindow.speech_feedback_value.Text = diff.ToString(); if (diff >= 0.25) { if (!((previousGesture == Gestures.ZoomOut) && ((DateTime.Now - lastGestureTime).Seconds < 1))) { vManager.zoom_in(1.04); lastGestureTime = DateTime.Now; previousGesture = Gestures.ZoomIn; } //vWindow.zoom_in(1.5); //Thread.Sleep(1000); //historyManager.clearHistory(); } else if (diff <= -0.25) { if (!((previousGesture == Gestures.ZoomIn) && ((DateTime.Now - lastGestureTime).Seconds < 1))) { vManager.zoom_out(1.04); lastGestureTime = DateTime.Now; previousGesture = Gestures.ZoomOut; } //Thread.Sleep(1000); //historyManager.clearHistory(); } }
public void processGesture(Gestures gesture) { }