Inheritance: MonoBehaviour
コード例 #1
0
ファイル: GestureManager.cs プロジェクト: IMA-DZ/RadegastV2
        /// <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;
            });
        }
コード例 #2
0
ファイル: MatchResult.cs プロジェクト: ilushareg/RPS_Unity
    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);
    }
コード例 #3
0
ファイル: Hover.cs プロジェクト: pocdev/solar-sail
	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;
		}
	}
コード例 #4
0
        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);
        }
コード例 #5
0
ファイル: Spells.cs プロジェクト: JaydenIvanovic/HellaPlants
 //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);
     }
 }
コード例 #6
0
        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));
        }
コード例 #7
0
        public Cord addCord(Gestures gesture, string keys)
        {
            Cord cord = new Cord(keys);

            Cords.Add(gesture, cord);
            return(cord);
        }
コード例 #8
0
        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);
            }
        }
コード例 #9
0
        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);
        }
コード例 #10
0
 public Tab()
 {
     HitTestTarget = true;
     Gestures.Add(new ClickGesture(2, () => Closing?.Invoke()));
     Awoke += Awake;
     Components.Add(new UpdatableNodeBehavior());
 }
コード例 #11
0
ファイル: BrainScript.cs プロジェクト: Zakifull/DTU
    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();
    }
コード例 #12
0
 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();
         }
     }
 }
コード例 #13
0
    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);
    }
コード例 #14
0
        /// <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);
        }
コード例 #15
0
    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());
    }
コード例 #16
0
    Sprite GetSpriteForGesture(Gestures gesture) {
		foreach (var sprite in sprites) {
			if (sprite.name == gesture.ToString ()) {
				return sprite;
			}
		}
		return null;
	}
コード例 #17
0
    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());
    }
コード例 #18
0
ファイル: RPSRules.cs プロジェクト: ilushareg/RPS_Unity
        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);
        }
コード例 #19
0
 public void AddGestures(List <Gesture> gestures)
 {
     foreach (Gesture gesture in gestures)
     {
         Gestures.Add(gesture);
         myMatcher.AddGesture(gesture);
         GestureCount++;
     }
 }
コード例 #20
0
    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;
                    }
                }
            }
        }
    }
コード例 #21
0
 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);
 }
コード例 #22
0
 /// <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;
 }
コード例 #23
0
    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());
    }
コード例 #24
0
ファイル: TextBox.cs プロジェクト: samueldjack/simonsquared
        private void HandleKeyboardInputComplete(IAsyncResult asyncResult)
        {
            var text = Guide.EndShowKeyboardInput(asyncResult);

            Text = text;

            _clickSubscription = Gestures.Subscribe(HandleClick);

            InvokeTextChanged(EventArgs.Empty);
        }
コード例 #25
0
        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));
            }
        }
コード例 #26
0
 /// <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;
         }
     }
 }
コード例 #27
0
ファイル: RPSRules.cs プロジェクト: ilushareg/RPS_Unity
 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);
 }
コード例 #28
0
        /// <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));
        }
コード例 #29
0
 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;
 }
コード例 #30
0
        /// <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));
        }
コード例 #31
0
ファイル: RPSRules.cs プロジェクト: ilushareg/RPS_Unity
        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");
        }
コード例 #32
0
ファイル: GestureManager.cs プロジェクト: IMA-DZ/RadegastV2
        /// <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);
        }
コード例 #33
0
        public void SetGestureSprite(Gestures gesture)
        {
            switch (gesture)
            {
            case Gestures.ExtendedHand:
                handSpriteRenderer.sprite = extendedHand;
                break;

            case Gestures.Fist:
                handSpriteRenderer.sprite = fist;
                break;
            }
        }
コード例 #34
0
    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;
    }
コード例 #35
0
        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;
            }
        }
コード例 #36
0
ファイル: PushGesture.cs プロジェクト: Chicoo/KinectOnOpenNI
 /// <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;
 }
コード例 #37
0
 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; }
コード例 #39
0
 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;
 }
コード例 #40
0
 /// <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);
     }
 }
コード例 #41
0
ファイル: SwipeGesture.cs プロジェクト: Chicoo/KinectOnOpenNI
 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;
 }
コード例 #42
0
 /// <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;
         }
     }
 }
コード例 #43
0
	void HandleNewGesture (Gestures gesture) {
		image.sprite = GetSpriteForGesture (gesture);
	}
コード例 #44
0
 public PushGestureRecognisedEventArgs(Gestures gesture, Point3D point, float speed)
 {
     _gesture = gesture;
     _point = point;
     _speed = speed;
 }
コード例 #45
0
 /// <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));
 }
コード例 #46
0
 /// <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);
 }
コード例 #47
0
 /// <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);
 }
コード例 #48
0
 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;
 }
コード例 #49
0
 public GestureRecognisedEventArgs(Gestures gesture, Point3D point)
 {
     _gesture = gesture;
     _point = point;
 }
コード例 #50
0
ファイル: ScrollView.cs プロジェクト: sugasaki/Kinect
 public void SimulateGesture(Gestures.TouchGesture gesture)
 {
     _simulategesture(gesture);
 }
コード例 #51
0
 public PushGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point, float speed)
 {
     _gesture = gesture;
     _point = new Point3D(point.X, point.Y, point.Z);
     _speed = speed;
 }
コード例 #52
0
        /// <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;

                }
            }
        }
コード例 #53
0
ファイル: AxisActions.cs プロジェクト: Bradsama/padtie
        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;
        }
コード例 #54
0
 /// <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);
     }
 }
コード例 #55
0
 public SwipeGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point)
 {
     _gesture = gesture;
     _point = new Point3D(point.X, point.Y, point.Z) ;
 }
コード例 #56
0
ファイル: SwipeGesture.cs プロジェクト: Chicoo/KinectOnOpenNI
 /// <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;
 }
コード例 #57
0
 public StillGestureRecognisedEventArgs(Gestures gesture, xn.Point3D point, float fTime)
 {
     _gesture = gesture;
     _point = new Point3D(point.X, point.Y, point.Z);
     _timeHold = fTime;
 }
コード例 #58
0
ファイル: GestureManager.cs プロジェクト: asish-aryal/KSE
        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();
            }
        }
コード例 #59
0
ファイル: Controller.cs プロジェクト: asish-aryal/KSE
 public void processGesture(Gestures gesture)
 {
 }