/// <summary>
    /// 手掌姿勢偵測【第一場景】
    /// </summary>
    void HandGestureDetect()
    {
        //右手部分判定
        if (skeletonInformation.HandRightPos.x > skeletonInformation.ShoulderCenterPos.x)
        {
            if (skeletonInformation.HandRightPos.y > skeletonInformation.ShoulderCenterPos.y + offset)
                RightHandGestureType = GestureType.Up;
            if (skeletonInformation.HandRightPos.y > skeletonInformation.ShoulderCenterPos.y - offset*2 && skeletonInformation.HandRightPos.y < skeletonInformation.ShoulderCenterPos.y + offset)
                RightHandGestureType = GestureType.Mid;
            if (skeletonInformation.HandRightPos.y < skeletonInformation.ShoulderCenterPos.y - offset*2)
                RightHandGestureType = GestureType.Dowm;
        }

        //左手部分判定
        if (skeletonInformation.HandLeftPos.x < skeletonInformation.ShoulderCenterPos.x)
        {
            if (skeletonInformation.HandLeftPos.y > skeletonInformation.ShoulderCenterPos.y + offset)
                LeftHandGestureType = GestureType.Up;
            if (skeletonInformation.HandLeftPos.y > skeletonInformation.ShoulderCenterPos.y - offset*2 && skeletonInformation.HandLeftPos.y < skeletonInformation.ShoulderCenterPos.y + offset)
                LeftHandGestureType = GestureType.Mid;
            if (skeletonInformation.HandLeftPos.y < skeletonInformation.ShoulderCenterPos.y - offset*2)
                LeftHandGestureType = GestureType.Dowm;
        }

        LeftHand_LeftShouder_Offset = skeletonInformation.HandLeftPos.y - skeletonInformation.ShoulderLeftPos.y;
        RightHand_RightShouder_Offset = skeletonInformation.HandRightPos.y - skeletonInformation.ShoulderRightPos.y;

        //備用
        if (LeftHandGestureType == GestureType.Dowm && RightHandGestureType == GestureType.Up)
            GestureTypeOne = true;
    }
Exemple #2
0
 /// <summary>
 /// Disable the recognition of a specific gesture
 /// </summary>
 /// <param name="gestureType">The type of gesture to disable</param>
 public override void DisableGestureRecognition(GestureType gestureType)
 {
     switch (gestureType)
     {
         case GestureType.SwipeLeft:
             if (!m_IsSwipeRightEnabled)
                 m_Controller.EnableGesture(Gesture.GestureType.TYPESWIPE, false);
             m_IsSwipeLeftEnabled = false;
             break;
         case GestureType.SwipeRight:
             if (!m_IsSwipeLeftEnabled)
                 m_Controller.EnableGesture(Gesture.GestureType.TYPESWIPE, false);
             m_IsSwipeRightEnabled = false;
             break;
         case GestureType.Tap:
             m_Controller.EnableGesture(Gesture.GestureType.TYPEKEYTAP, false);
             break;
         case GestureType.Push:
             m_Controller.EnableGesture(Gesture.GestureType.TYPESCREENTAP, false);
             break;
         case GestureType.Circle:
             m_Controller.EnableGesture(Gesture.GestureType.TYPECIRCLE, false);
             break;
         case GestureType.None:
             throw new LeapException("None gesture is not implemented in the Leap Gesture API");
     }
 }
Exemple #3
0
        //sample = new GestureSample(gesture, rightHanded, duration, angles, interpretedPoints, velocities, inverseVelocities);
        public GestureSample(GestureType gType, bool rightHanded, float duration, List<float> angles, List<Vector2> interpretedPoints, List<Vector2> strokePoints, List<Vector2> velocities, List<Vector2> inverseVelocities)
        {
            Gesture = gType;
            Duration = duration;
            RightHanded = rightHanded;

            SpeakerAngles = new List<float>();
            SpeakerAngles.AddRange(angles);

            InterpretedPoints = new List<Vector2>();
            InterpretedPoints.AddRange(interpretedPoints);

            StrokePoints = new List<Vector2>();
            StrokePoints.AddRange(strokePoints);

            Velocities = new List<Vector2>();
            Velocities.AddRange(velocities);

            InverseVelocities = new List<Vector2>();
            InverseVelocities.AddRange(inverseVelocities);

            InversePoints = new List<Vector2>();
            foreach (Vector2 velocity_pair in InverseVelocities)
            {
                Vector2 P = new Vector2();
                P.X = (float)(velocity_pair.X * Math.Sin(SpeakerAngles[0] * Math.PI / 180.0));
                P.Y = (float)(velocity_pair.X * Math.Cos(SpeakerAngles[0] * Math.PI / 180.0));
                P.X += (float)(velocity_pair.Y * Math.Sin(SpeakerAngles[1] * Math.PI / 180.0));
                P.Y += (float)(velocity_pair.Y * Math.Cos(SpeakerAngles[1] * Math.PI / 180.0));
                InversePoints.Add(P);
            }
        }
Exemple #4
0
        public Gesture(GestureType type, IGestureSegment[] segments)
        {
            _type = type;
            _segments = segments;

            _name = type.ToString();
        }
Exemple #5
0
        /// <summary>
        /// Adds the specified gesture for recognition.
        /// </summary>
        /// <param name="type">The predefined <see cref="GestureType" />.</param>
        public void AddGesture(GestureType type)
        {
            IGestureSegment[] segments = null;

            // DEVELOPERS: If you add a new predefined gesture with a new GestureType,
            // simply add the proper segments to the switch statement here.
            switch (type)
            {
                case GestureType.SwipeRight:
                    segments = new IGestureSegment[3];

                    segments[0] = new SwipeRightSegment1();
                    segments[1] = new SwipeRightSegment2();
                    segments[2] = new SwipeRightSegment3();
                    break;

                case GestureType.All:
                case GestureType.None:
                default:
                    break;
            }

            if (type != GestureType.None)
            {
                Gesture gesture = new Gesture(type, segments);
                gesture.GestureRecognized += OnGestureRecognized;

                _gestures.Add(gesture);
            }
        }
 /// <summary>
 /// Adds the gesture.
 /// </summary>
 /// <param name="type">The gesture type.</param>
 /// <param name="gestureDefinition">The gesture definition.</param>
 public void AddGesture(GestureType type, IRelativeGestureSegment gestureDefinition)
 {
     Gesture gesture = new Gesture(type, gestureDefinition);
     //gesture.GestureRecognized += new EventHandler<GestureEventArgs>(this.Gesture_GestureRecognized);
     gesture.GestureRecognized += OnGestureRecognized;
     this.gestures.Add(gesture);
 }
Exemple #7
0
        internal CommandScene( Vector2 location, GestureType gestureType, string backgroundResourcePath )
            : this(location, gestureType, backgroundResourcePath,
			null,
			null,
			false)
        {
        }
        public VideoWindow(GestureDirection direction, GestureType type)
        {
            InitializeComponent();
            this.Title = type + " " + direction;

            vlc = new AxVLCPlugin2();
            formHost.Child = vlc;
            vlc.CreateControl();

            var videoPath = CreateUriTo(type, direction);
            MoveScreen(true);
            GestureParser.Pause(true);
            vlc.playlist.add(videoPath);
            vlc.playlist.play();

            EventHandler handler = null;

            handler = (sender, e) => {
                vlc.MediaPlayerEndReached -= handler;
                GestureParser.Pause(false);
                MoveScreen(false);
                canvasWindow.Activate();
                vlc.playlist.play();
                vlc.MediaPlayerEndReached += (senderI, eI) => {
                    vlc.playlist.play();
                };

            };

            vlc.MediaPlayerEndReached += handler;
        }
 public GestureDetectedEventArgs(GestureType type, float speed, Vector direction, long timestamp)
 {
     m_type = type;
     m_speed = speed;
     m_direction = direction;
     m_timestamp = timestamp;
 }
Exemple #10
0
 /// <summary>
 /// Enable the recognition of a specific gesture
 /// </summary>
 /// <param name="gestureType">The type of gesture to enable</param>
 public override void EnableGestureRecognition(GestureType gestureType)
 {
     switch (gestureType)
     {
         // we subscribe to the corresponding events from the scheduler (the one which prepare data and send them to the detection algorithm)
         case GestureType.SwipeLeft:
             m_Scheduler.EnableGestureRecognition(GestureType.SwipeLeft);
             m_Scheduler.SwipeLeftGestureDetected += OnSwipeLeftDetected;
             break;
         case GestureType.SwipeRight:
             m_Scheduler.EnableGestureRecognition(GestureType.SwipeRight);
             m_Scheduler.SwipeRightGestureDetected += OnSwipeRightDetected;
             break;
         case GestureType.Tap:
             m_Scheduler.EnableGestureRecognition(GestureType.Tap);
             m_Scheduler.TapGestureDetected += OnTapGestureDetected;
             break;
         case GestureType.Push:
             m_Scheduler.EnableGestureRecognition(GestureType.Push);
             m_Scheduler.PushGestureDetected += OnPushGestureDetected;
             break;
         case GestureType.None:
             m_Scheduler.EnableGestureRecognition(GestureType.None);
             m_Scheduler.NoGestureDetected += OnNoGestureDetected;
             break;
         case GestureType.Circle:
             throw new LeapException("The Circle gesture detection is not available in the IntuiLab gesture API");
     }
 }
Exemple #11
0
 /// <summary>
 /// Disable the recognition of a specific gesture
 /// </summary>
 /// <param name="gestureType">The type of gesture to disable</param>
 public override void DisableGestureRecognition(GestureType gestureType)
 {
     switch (gestureType)
     {
         // we unsubscribe to the corresponding events
         case GestureType.SwipeLeft:
             m_Scheduler.DisableGestureRecognition(GestureType.SwipeLeft);
             m_Scheduler.SwipeLeftGestureDetected -= OnSwipeLeftDetected;
             break;
         case GestureType.SwipeRight:
             m_Scheduler.DisableGestureRecognition(GestureType.SwipeRight);
             m_Scheduler.SwipeRightGestureDetected -= OnSwipeRightDetected;
             break;
         case GestureType.Tap:
             m_Scheduler.DisableGestureRecognition(GestureType.Tap);
             m_Scheduler.TapGestureDetected -= OnTapGestureDetected;
             break;
         case GestureType.Push:
             m_Scheduler.DisableGestureRecognition(GestureType.Push);
             m_Scheduler.PushGestureDetected -= OnPushGestureDetected;
             break;
         case GestureType.None:
             m_Scheduler.DisableGestureRecognition(GestureType.None);
             m_Scheduler.NoGestureDetected -= OnNoGestureDetected;
             break;
     }
 }
 public void OnGesture(GestureType gestureType)
 {
     if (gestureType == GestureType.ExplodeIn)
         ExplodeIn(() => { });
     if (gestureType == GestureType.ExplodeOut)
         ExplodeOut(() => { });
 }
Exemple #13
0
 /// <summary>
 /// Add new gesture input
 /// </summary>
 /// <param name="theGesture"></param>
 /// <param name="theTouchArea"></param>
 public void Add(GestureType theGesture, Rectangle theTouchArea)
 {
     // add new gesture as an enabled gesture
     TouchPanel.EnabledGestures = theGesture | TouchPanel.EnabledGestures;
     gestureInputs.Add(gestureInputs.Count, new GestureDefinition(theGesture, theTouchArea));
     if (theGesture == GestureType.Pinch)
         PinchGestureAvailable = true;
 }
 public KinectGesture(string shape)
 {
     Shape = shape;
     Type = GestureParser.GetTypeContext();
     Direction = GestureParser.GetDirectionContext();
     Pointer = CanvasWindow.GetCurrentPoint();
     Timestamp = DateTime.Now;
 }
 public GestureDefinition(GestureType theGestureType, Rectangle theGestureArea)
 {
     Gesture = new GestureSample(theGestureType, new TimeSpan(0),
                                 Vector2.Zero, Vector2.Zero,
                                 Vector2.Zero, Vector2.Zero);
     Type = theGestureType;
     CollisionArea = theGestureArea;
 }
Exemple #16
0
        protected Scene( Vector2 location, GestureType gestureType )
            : this(location, gestureType,
			null,
			null,
			false,
			true)
        {
        }
Exemple #17
0
 public Gesture(InputEventSystem inputEventSystem, GestureType type, String[] touchIDs)
 {
     this.inputEventSystem = inputEventSystem;
     this.id = GestureIDAssigner;
     GestureIDAssigner++;
     this.type = type;
     this.touchIDs = touchIDs;
 }
Exemple #18
0
 public GestureSample(GestureType gestureType, TimeSpan timestamp, Vector2 position, Vector2 position2, Vector2 delta, Vector2 delta2)
 {
   this._gestureType = gestureType;
   this._timestamp = timestamp;
   this._position = position;
   this._position2 = position2;
   this._delta = delta;
   this._delta2 = delta2;
 }
Exemple #19
0
 /// <summary>
 /// Initializes a new <see cref="GestureSample"/>.
 /// </summary>
 /// <param name="gestureType"><see cref="GestureType"/></param>
 /// <param name="timestamp"></param>
 /// <param name="position"></param>
 /// <param name="position2"></param>
 /// <param name="delta"></param>
 /// <param name="delta2"></param>
 public CCGesture(GestureType gestureType, TimeSpan timestamp, CCPoint position, CCPoint position2, CCPoint delta, CCPoint delta2)
 {
     this._gestureType = gestureType;
     this._timestamp = timestamp;
     this._position = position;
     this._position2 = position2;
     this._delta = delta;
     this._delta2 = delta2;
 }
        public static SpssCase AddTechniqueData(SpssCase gestureAttempt, GestureType type, Attempt attempt)
        {
            gestureAttempt[$"{type}Efficiency"] = attempt.Time.TotalSeconds;
            gestureAttempt[$"{type}Effectiveness"] = attempt.Hit;
            gestureAttempt[$"{type}Accuracy"] = MathHelper.GetDistance(attempt);
            gestureAttempt[$"{type}TargetSize"] = attempt.Size;
            gestureAttempt[$"{type}Direction"] = attempt.Direction;

            return gestureAttempt;
        }
Exemple #21
0
        public static void ClearState()
        {
            previousMouseState = Mouse.GetState();
            currentMouseState  = Mouse.GetState();
            previousKeyState   = Keyboard.GetState();
            currentKeyState    = Keyboard.GetState();
#if ANDROID
            currentGestureType = GestureType.None;
#endif
        }
Exemple #22
0
        public void BasicFreeDragTest(GestureType enabledGestures)
        {
            _tps.EnabledGestures = enabledGestures;
            var startPos = new Vector2(200, 200);

            //Place the finger down
            _tps.AddEvent(1, TouchLocationState.Pressed, startPos);
            TouchPanelState.CurrentTimestamp = GameTimeForFrame(1);

            //Move it until it should have made a drag
            int diff  = 0;
            int frame = 1;

            while (new Vector2(diff).Length() < TouchPanelState.TapJitterTolerance)
            {
                Assert.False(_tps.IsGestureAvailable);

                diff += 5;
                frame++;

                _tps.AddEvent(1, TouchLocationState.Moved, startPos + new Vector2(diff));
                TouchPanelState.CurrentTimestamp = (GameTimeForFrame(frame));
            }

            //We should have a gesture now
            Assert.True(_tps.IsGestureAvailable);
            var gesture = _tps.ReadGesture();

            Assert.False(_tps.IsGestureAvailable);

            //Should get the correct type at the new touch location, with the given delta
            Assert.AreEqual(GestureType.FreeDrag, gesture.GestureType);
            Assert.AreEqual(startPos + new Vector2(diff), gesture.Position);

            Assert.AreEqual(new Vector2(5), gesture.Delta);

            //If DragComplete is enabled, releasing our touch will generate a DragComplete gesture
            frame++;
            _tps.AddEvent(1, TouchLocationState.Released, startPos + new Vector2(diff));
            TouchPanelState.CurrentTimestamp = (GameTimeForFrame(frame));

            if ((enabledGestures & GestureType.DragComplete) == GestureType.DragComplete)
            {
                Assert.True(_tps.IsGestureAvailable);
                gesture = _tps.ReadGesture();
                Assert.False(_tps.IsGestureAvailable);

                Assert.AreEqual(GestureType.DragComplete, gesture.GestureType);
                Assert.AreEqual(Vector2.Zero, gesture.Position); //This is (0,0) in XNA too. It's weird though!
            }
            else
            {
                Assert.False(_tps.IsGestureAvailable);
            }
        }
Exemple #23
0
 // Update the counter of a gesture. Everytime a gesture is added then the corresponding counter increases
 private void UpdateCounters(GestureType type, int n)
 {
     if (gesturesCounters.ContainsKey(type))
     {
         gesturesCounters[type] += n;
     }
     else
     {
         gesturesCounters[type] = n;
     }
 }
        void OnSwipe(GestureType CurrentGesture)
        {
            switch (CurrentGesture)
            {
            case GestureType.LeftToRight:
                switch (UserManager.SwipeLeftAction)
                {
                case SwipeAction.sendkey:
                    sendKey(UserManager.SwipeLeftArray[2]);
                    Trace.WriteLine("sendkey " + UserManager.SwipeLeftArray[2]);
                    break;

                case SwipeAction.click:

                    int xpos = 0; int ypos = 0;
                    GetMousePos(out xpos, out ypos);         //save last mouse pos
                    uint clickX = (uint)Int16.Parse(UserManager.SwipeLeftArray[2]);
                    uint clickY = (uint)Int16.Parse(UserManager.SwipeLeftArray[3]);
                    NativeMethods.SetCursorPos((int)clickX, (int)clickY); //move to click position
                    DoMouseClick(clickX, clickY);                         //click
                    NativeMethods.SetCursorPos(xpos, ypos);               //return to previous position
                    Trace.WriteLine("click " + clickX + " " + clickY);
                    break;

                default:
                    break;
                }
                break;

            case GestureType.RightToLeft:
                switch (UserManager.SwipeRightAction)
                {
                case SwipeAction.sendkey:
                    sendKey(UserManager.SwipeRightArray[2]);
                    Trace.WriteLine("sendkey " + UserManager.SwipeRightArray[2]);
                    break;

                case SwipeAction.click:
                    int xpos = 0; int ypos = 0;
                    GetMousePos(out xpos, out ypos);         //save last mouse pos
                    uint clickX = (uint)Int16.Parse(UserManager.SwipeRightArray[2]);
                    uint clickY = (uint)Int16.Parse(UserManager.SwipeRightArray[3]);
                    NativeMethods.SetCursorPos((int)clickX, (int)clickY); //move to click position
                    DoMouseClick(clickX, clickY);                         //click
                    NativeMethods.SetCursorPos(xpos, ypos);               //return to previous position
                    Trace.WriteLine("click " + clickX + " " + clickY);
                    break;

                default:
                    break;
                }
                break;
            }
        }
 ///API-No.214
 /// <summary>
 /// GTLeft/GTRight设置可见光束的长度 默认3米
 /// </summary>
 /// <param name="distance">单位米</param>
 public static void SetGTEndPointerDistance(float distance, GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         GTLeft.inputDeviceTargetDetecterBase.MaxEndPointRange = distance;
     }
     else if (GTRight && type == GestureType.Right)
     {
         GTRight.inputDeviceTargetDetecterBase.MaxEndPointRange = distance;
     }
 }
 ///API-No.218
 /// <summary>
 /// 关闭GTLeft
 /// </summary>
 /// <param name="type"></param>
 public static void DisableableGT(GestureType type = GestureType.Right)
 {
     if (Gesture26Dof && type == GestureType.Left)
     {
         Gesture26Dof.LeftHandOpen = false;
     }
     else if (Gesture26Dof && type == GestureType.Right)
     {
         Gesture26Dof.RightHandOpen = false;
     }
 }
Exemple #27
0
        /// <summary>
        /// Fizbin gestures callback.
        /// </summary>
        /// <param name="gestureType">The gesture type</param>
        /// <param name="trackingID">The tracking ID</param>
        void KinectGestureGenerator_GestureRecognized(GestureType gestureType, int trackingID)
        {
            //This will call the KinectInfo constructor,
            //And then assign gestureType string to Gesture property.
            ServerMessage kinectInfo = new ServerMessage()
            {
                Gesture = gestureType.ToString()
            };

            Webserver.SendToClients(kinectInfo.ToJSON());
        }
Exemple #28
0
 public static bool HasSample(GestureType type)
 {
     for (int i = 0; i < gestureCount; i++)
     {
         if ((gestures[i].GestureType & type) != 0)
         {
             return(true);
         }
     }
     return(false);
 }
 private void Reset()
 {
     GlobalListener   = false;
     OverrideTarget   = false;
     TargetGameObject = gameObject;
     GestureType      = GestureType.Tap;
     SwipeDirection   = Swipe.None;
     OnGestureEvent   = new TouchInfoEvent();
     OnGestureAction  = delegate { };
     GameEvents       = new List <string>();
 }
Exemple #30
0
    public bool GestureCompleted(ulong userId, int userIndex, GestureType gesture, KinectInterop.JointType joint, Vector3 screenPos)
    {
        if (userIndex != playerIndex)
        {
            return(false);
        }

        stageAvatarController.MoveStageOriginToCurrentPosition();

        return(true);
    }
Exemple #31
0
        /// <summary>
        /// Displays the iOS matchmaker to the player.
        /// </summary>
        /// <remarks>
        /// Note this is not overloaded in derived classes on purpose.  This is
        /// only a reason this exists is for caching effects.
        /// </remarks>
        /// <param name="minPlayers">Minimum players to find</param>
        /// <param name="maxPlayers">Maximum players to find</param>
        /// <param name="playersToInvite">Players to invite/param>
        public static void ShowMatchMaker(int minPlayers, int maxPlayers, string[] playersToInvite)
        {
            AssertInitialised();

            if ((Gamer.SignedInGamers.Count > 0) && (Gamer.SignedInGamers[0].IsSignedInToLive))
            {
                // Lazy load it
                if (matchmakerViewController == null)
                {
                    matchmakerViewController = new GKMatchmakerViewController(new GKMatchRequest());
                }

                if (matchmakerViewController != null)
                {
                    matchmakerViewController.MatchRequest.MinPlayers      = minPlayers;
                    matchmakerViewController.MatchRequest.MaxPlayers      = maxPlayers;
                    matchmakerViewController.MatchRequest.PlayersToInvite = playersToInvite;

                    matchmakerViewController.DidFailWithError += delegate(object sender, GKErrorEventArgs e) {
                        matchmakerViewController.DismissModalViewControllerAnimated(true);
                        IsVisible = false;
                        TouchPanel.EnabledGestures = prevGestures;
                    };

                    matchmakerViewController.DidFindMatch += delegate(object sender, GKMatchEventArgs e) {
                        Guide.Match = e.Match;
                    };

                    matchmakerViewController.DidFindPlayers += delegate(object sender, GKPlayersEventArgs e) {
                    };

                    matchmakerViewController.WasCancelled += delegate(object sender, EventArgs e) {
                        matchmakerViewController.DismissModalViewControllerAnimated(true);
                        IsVisible = false;
                        TouchPanel.EnabledGestures = prevGestures;
                    };

                    if (_window != null)
                    {
                        if (viewController == null)
                        {
                            viewController = new GuideViewController(_gameViewController);
                            _window.Add(viewController.View);
                            viewController.View.Hidden = true;
                        }

                        prevGestures = TouchPanel.EnabledGestures;
                        TouchPanel.EnabledGestures = GestureType.None;
                        viewController.PresentModalViewController(matchmakerViewController, true);
                        IsVisible = true;
                    }
                }
            }
        }
Exemple #32
0
 public void EnableGesture(GestureType type)
 {
     if (_gestureDetector == null)
     {
         _gestureDetector = new GestureDetector(this);
     }
     if (!_enabledGestures.Contains(type))
     {
         _enabledGestures.Add(type);
     }
 }
Exemple #33
0
 public void OnGesture(GestureType gestureType)
 {
     if (gestureType == GestureType.ExplodeIn)
     {
         ExplodeIn(() => { });
     }
     if (gestureType == GestureType.ExplodeOut)
     {
         ExplodeOut(() => { });
     }
 }
Exemple #34
0
 private void SetCallback <T>(GestureType type, GestureState state, Action <T> action)
 {
     if (action == null)
     {
         SetGestureCallback(type, state, null);
     }
     else
     {
         SetGestureCallback(type, state, new Action <object>((info) => action((T)info)));
     }
 }
Exemple #35
0
 public static IEnumerable <GestureSample> GetSample(GestureType type)
 {
     for (int i = 0; i < gestureCount; i++)
     {
         if ((gestures[i].GestureType & type) != 0)
         {
             yield return(gestures[i]);
         }
     }
     yield break;
 }
 // The Role of this method modified correctly GestureType value.
 // This method is for the primary gestures.
 public static Gesture.GestureType UseGestureType(GestureType gestureType)
 {
     switch (gestureType)
     {
         case GestureType.swipe: return Gesture.GestureType.TYPE_SWIPE;
         case GestureType.circle: return Gesture.GestureType.TYPE_CIRCLE;
         case GestureType.keytab: return Gesture.GestureType.TYPE_KEY_TAP;
         case GestureType.screentab: return Gesture.GestureType.TYPE_SCREEN_TAP;
         default: return Gesture.GestureType.TYPE_INVALID;
     }
 }
        internal PotentialGesture(
            InputEventSystem inputEventSystem,
            GestureType type, String[] touchIDs)
        {
            this.id = PotentialGestureIDAssigner;
            this.inputEventSystem = inputEventSystem;
            PotentialGestureIDAssigner++;

            this.type = type;
            this.touchIDs = touchIDs;
        }
Exemple #38
0
    /// <summary>
    /// Used by the Gesture capturing script.
    /// </summary>
    /// <param name="sentGesture"></param>
    public void ReceiveGesture(GestureType sentGesture)
    {
        _receivedGesture = sentGesture;

        if (_receivedGesture == GestureType.None)
            CursorManager.instance.ChangeCursorStatus(CursorManager.CursorGestureStatus.Normal);
        else
            ProcessReceivedGesture();

        _listening = false;
    }
 ///API-No.221
 /// <summary>
 /// 设置是否启用手势射线抓取功能
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static void SetRay(bool isOn, GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         GTLeft.SetRay(isOn);
     }
     else if (GTRight && type == GestureType.Right)
     {
         GTRight.SetRay(isOn);
     }
 }
Exemple #40
0
 public void MouseMove(int aX, int aY)
 {
     if (this.m_bEnableTouchScrolling)
     {
         int num  = aY - this.m_MousePosition.Y;
         int num2 = aX - this.m_MousePosition.X;
         if ((Math.Abs(num) >= this.m_MinY) || (Math.Abs(num2) >= this.m_MinX))
         {
             this.m_TouchAutoScrollDiffY += num;
             this.m_TouchAutoScrollDiffX += num2;
             if ((Environment.TickCount - this.m_TouchTime1) > 300)
             {
                 this.m_TouchAutoScrollDiffY = 0;
                 this.m_TouchAutoScrollDiffX = 0;
                 this.m_TouchTime0           = Environment.TickCount;
                 this.m_TouchTime1           = this.m_TouchTime0;
                 this.m_bTouchScrolling      = false;
             }
             else
             {
                 this.m_TouchTime1 = Environment.TickCount;
                 if ((this.m_dpiY == 0f) || (this.m_dpiX == 0f))
                 {
                     using (Graphics graphics = this.m_Parent.CreateGraphics())
                     {
                         this.m_dpiX = graphics.DpiX / 96f;
                         this.m_dpiY = graphics.DpiY / 96f;
                     }
                 }
                 this.m_bTouchScrolling = true;
                 this.m_MousePosition.X = aX;
                 this.m_MousePosition.Y = aY;
                 if (Math.Abs(this.m_TouchAutoScrollDiffX) < Math.Abs(this.m_TouchAutoScrollDiffY))
                 {
                     this.m_LeftRightGesture = false;
                 }
                 else
                 {
                     this.m_LeftRightGesture = true;
                 }
                 if (this.m_LeftRightGesture)
                 {
                     GestureType gestureType = (this.m_TouchAutoScrollDiffX > 0) ? GestureType.Left : GestureType.Right;
                     this.OnMouseMoveDetected(gestureType, -num2, -num);
                 }
                 else
                 {
                     GestureType type2 = (this.m_TouchAutoScrollDiffY > 0) ? GestureType.Up : GestureType.Down;
                     this.OnMouseMoveDetected(type2, -num2, -num);
                 }
             }
         }
     }
 }
Exemple #41
0
        public static SpssCase AddTechniqueDataLong(SpssCase gestureAttempt, GestureType type, Attempt attempt)
        {
            gestureAttempt[$"Efficiency"]    = attempt.Time.TotalSeconds;
            gestureAttempt[$"Effectiveness"] = attempt.Hit;
            gestureAttempt[$"Accuracy"]      = MathHelper.GetDistance(attempt);
            gestureAttempt[$"TargetSize"]    = attempt.Size;
            gestureAttempt[$"Direction"]     = attempt.Direction;
            gestureAttempt[$"AttemptNumber"] = attempt.AttemptNumber;

            return(gestureAttempt);
        }
Exemple #42
0
 //ATTENTION 在去除手势的过程后,原本的foreach循环必须跳出
 public static void DisableGesture(GestureType gestureType)
 {
     if (inputDictionary.ContainsKey(gestureType))
     {
         inputDictionary.Remove(gestureType);
     }
     TouchPanel.EnabledGestures = GestureType.None;
     foreach (GestureType g in inputDictionary.Keys)
     {
         TouchPanel.EnabledGestures = TouchPanel.EnabledGestures | gestureType;
     }
 }
Exemple #43
0
        /// <summary>
        /// constructor
        /// </summary>
        public TouchManager(ConvertToGameCoord gameCoord, GestureType supportedGestures = GestureType.Tap) : base(gameCoord)
        {
            TouchStartPosition = new TouchLocation[_numTouches];

            //Check if we even have a touchscreen available
            TouchPanelCapabilities touch = TouchPanel.GetCapabilities();

            IsEnabled = touch.IsConnected;

            //enable the tap gesture if available
            SupportedGestures = supportedGestures;
        }
 ///API-No.204
 /// <summary>
 /// GTLeft/GTRight 检测到碰撞信息集合,包含碰撞到的物体,数据等
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static SCPointEventData GTPointerEventData(GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         return(GTLeft.inputDataBase.pointerEventData);
     }
     else if (GTRight && type == GestureType.Right)
     {
         return(GTRight.inputDataBase.pointerEventData);
     }
     return(null);
 }
 ///API-No.209
 /// <summary>
 /// GTLeft/GTRight某个按键是否按下后松开,当前帧有效,下帧复位,参考Input.GetKeyUp
 /// </summary>
 /// <param name="inputKeyCode">具体按键,GTLeft/GTRight支持Enter/Back/Function</param>
 /// <returns></returns>
 public static bool IsGTKeyUp(InputKeyCode inputKeyCode, GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         return(GTLeft.inputDataBase.GetKeyUp(inputKeyCode));
     }
     else if (GTRight && type == GestureType.Right)
     {
         return(GTRight.inputDataBase.GetKeyUp(inputKeyCode));
     }
     return(false);
 }
        public GestureDefinition(GestureSample theGestureSample)
        {
            Gesture = theGestureSample;
            Type = theGestureSample.GestureType;
            CollisionArea = new Rectangle((int)theGestureSample.Position.X,
                                          (int)theGestureSample.Position.Y, 5, 5);

            Delta = theGestureSample.Delta;
            Delta2 = theGestureSample.Delta2;
            Position = theGestureSample.Position;
            Position2 = theGestureSample.Position2;
        }
 void Start()
 {
     arrowLayer        = 10;
     layerMask         = 1 << arrowLayer;
     currentStepTime   = stepTime;
     isStartRecongnize = false;
     bOutputResult     = false;
     gestureType       = GestureType.None;
     NotificationManager.Instance.Subscribe(NotificationType.Gesture_Recongnize.ToString(), GestureRecongnize);
     StartUnderEditorTest();
     mainCamera = Camera.main;
 }
 ///API-No.216
 /// <summary>
 /// GTLeft/GTRight获取光束
 /// </summary>
 /// <param name="distance">单位米</param>
 public static LineRenderer GetGTLine(GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         return(GTLeft.inputDeviceUIBase.model.lineIndicate.line);
     }
     else if (GTRight && type == GestureType.Right)
     {
         return(GTRight.inputDeviceUIBase.model.lineIndicate.line);
     }
     return(null);
 }
 ///API-No.215
 /// <summary>
 /// GTLeft/GTRight获取光束终点的Focus对象
 /// </summary>
 /// <param name="distance">单位米</param>
 public static Focus GetGTFocus(GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         return(GTLeft.inputDeviceUIBase.model.lineIndicate.focus);
     }
     else if (GTRight && type == GestureType.Right)
     {
         return(GTRight.inputDeviceUIBase.model.lineIndicate.focus);
     }
     return(null);
 }
Exemple #50
0
 public GestureDefinition(GestureType theGestureType,
                          Rectangle theGestureArea)
 {
     Gesture = new GestureSample(theGestureType,
                                 new TimeSpan(0),
                                 Vector2.Zero,
                                 Vector2.Zero,
                                 Vector2.Zero,
                                 Vector2.Zero);
     Type          = theGestureType;
     CollisionArea = theGestureArea;
 }
 ///API-No.211
 /// <summary>
 /// GTLeft/GTRight某个按键的实时状态,参考Input.GetKey
 /// </summary>
 /// <param name="inputKeyCode">具体按键,GTLeft/GTRight支持Enter/Back/Function</param>
 /// <returns></returns>
 public static InputKeyState GTKeyCurrentState(InputKeyCode inputKeyCode, GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         return(GTLeft.inputDataBase.GetKeyCurrentState(inputKeyCode));
     }
     else if (GTRight && type == GestureType.Right)
     {
         return(GTRight.inputDataBase.GetKeyCurrentState(inputKeyCode));
     }
     return(InputKeyState.Null);
 }
    // Get a list of detected gestures from the list retrieved from OpenCV
    // This function just converts the list of detected gestures retrieved from OpenCV to the format that we can use in Unity
    public static List <GestureFrame> GetList(GestureType type, CvDetectedGesture[] gestures, int n)
    {
        List <GestureFrame> list = new List <GestureFrame>();

        for (int i = 0; i < n; i++)
        {
            GestureFrame g = new GestureFrame(type, gestures[i]);
            list.Add(g);
        }

        return(list);
    }
 ///API-No.203
 /// <summary>
 /// GTLeft/GTRight的手势数据,具体数据见handInfo
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static handInfo GThandInfo(GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         return(GTLeft.inputData26DofGesture.handInfo);
     }
     else if (GTRight && type == GestureType.Right)
     {
         return(GTRight.inputData26DofGesture.handInfo);
     }
     return(null);
 }
 ///API-No.219
 /// <summary>
 /// 获取手势游戏对象,具体见fingerUI
 /// </summary>
 /// <param name="type"></param>
 /// <returns></returns>
 public static Model26DofGesture.fingerUI[] GetFingerUI(GestureType type = GestureType.Right)
 {
     if (GTLeft && type == GestureType.Left)
     {
         return(GTLeft.inputDevice26DofGestureUI.model26DofGesture.fingers);
     }
     else if (GTRight && type == GestureType.Right)
     {
         return(GTRight.inputDevice26DofGestureUI.model26DofGesture.fingers);
     }
     return(null);
 }
 internal GestureEventTranslation(GestureType type, GestureState state, int numberOfFingers, TimeSpan deltaTime, TimeSpan totalTime, 
                                   GestureShape shape, Vector2 startPos, Vector2 currPos, Vector2 deltaTrans)
 {
     Type = type;
     State = state;
     NumberOfFinger = numberOfFingers;
     DeltaTime = deltaTime;
     TotalTime = totalTime;
     Shape = shape;
     StartPosition = startPos;
     CurrentPosition = currPos;
     DeltaTranslation = deltaTrans;
     TotalTranslation = currPos - startPos;
     AverageSpeed = TotalTranslation / (float)(TotalTime.TotalSeconds + 0.0001f); // avoid division by zero
 }
Exemple #56
0
 public GestureSample(GestureType gestureType, TimeSpan timestamp, Vector2 worldPosition, Vector2 worldPosition2,
     Vector2 worldDelta, Vector2 worldDelta2, Vector2 screenPosition, Vector2 screenPosition2, Vector2 screenDelta, Vector2 screenDelta2)
     : this()
 {
     GestureType = gestureType;
     Timestamp = timestamp;
     WorldPosition = worldPosition;
     WorldPosition2 = worldPosition2;
     WorldDelta = worldDelta;
     WorldDelta2 = worldDelta2;
     ScreenPosition = screenPosition;
     ScreenPosition2 = screenPosition2;
     ScreenDelta = screenDelta;
     ScreenDelta2 = screenDelta2;
 }
 public ActionResult GetImage(string testId, GestureType type, DataSource source = DataSource.Old)
 {
     List<Attempt> attempts = new List<Attempt>();
     if(testId != "average") {
         attempts = AttemptRepository.GetTest(testId, source).Attempts[type];
     }
     else {
         var tests = AttemptRepository.GetTests(source);
         foreach(var test in tests) {
             attempts.AddRange(test.Attempts[type]);
         }
     }
     MemoryStream ms;
     DataVisualizer.DrawHitBox(attempts, out ms);
     return File(ms, "image/png");
 }
 /// <summary>
 /// Initializes a new instance of <see cref="GestureController"/>.
 /// </summary>
 /// <param name="type">The gesture type to recognize. Set to GesureType.All for instantly adding all of the predefined gestures.</param>
 public GestureController(GestureType type)
 {
     if (type == GestureType.All)
     {
         foreach (GestureType t in Enum.GetValues(typeof(GestureType)))
         {
             if (t != GestureType.All)
             {
                 AddGesture(t);
             }
         }
     }
     else
     {
         AddGesture(type);
     }
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="Gesture"/> class.
 /// </summary>
 /// <param name="type">The type of gesture.</param>
 /// <param name="gestureParts">The gesture parts.</param>
 public Gesture(GestureType type, IRelativeGestureSegment gestureParts)
 {
     switch (type)
     {
         case GestureType.HandCloseOrOpen:
             this.Interval = 1;
             break;
         case GestureType.HeadMoved:
             this.Interval = 1;
             break;
         default:
             this.Interval = 5;
             break;
     }
     this.gestureParts = gestureParts;
     this.type = type;
     this._count = 0;
 }
 /// <summary>
 /// Initializes a new instance of the <see cref="SimpleConcreteGestureInputPlayable"/> class.
 /// </summary>
 /// <param name="mst">The MST.</param>
 /// <param name="mask">The mask.</param>
 /// <param name="et">The et.</param>
 public SimpleConcreteGestureInputPlayable(GestureType gestureType, Action<GestureSample> mst = null, InputMask mask = InputMask.GSYSTEM, EntityType et = Input.EntityType.TOOLS)
 {
     this.GestureType = gestureType;
     this.GestureFired += mst;
     this.EntityType = et;
     this.mask = mask;
 }