예제 #1
0
        private void usb_OnDataRecieved_5(object sender, UsbLibrary.DataRecievedEventArgs args)
        {
            SensorData tmp = new SensorData(args.data);

            i++;
            if (i % speedChar == 0)
            {
                this.BeginInvoke(updateCrartDelegat, tmp);
                i = 1;
            }

            switch (status)
            {
            case Status.Mouse:
                Mouse.MoveMouse(tmp.Gz, tmp.Gx);
                break;

            case Status.Gestures:
                GesturesEnum ge = Gestures.IdentifyGesture(tmp);
                if (ge != GesturesEnum.None)
                {
                    this.BeginInvoke(updateGesturesLableDelegat, ge);
                }

                if (ge != GesturesEnum.None)
                {
                    System.Diagnostics.Debug.Print("--------------{0}", ge.ToString());
                }
                break;

            case Status.Level:
                this.BeginInvoke(updateLevelDelegat, tmp);
                break;
            }
        }
예제 #2
0
        public static GesturesEnum IdentifyGesture(SensorData sd)
        {
            GesturesEnum ge = GesturesEnum.None;

            if (sd.Gz > 200)
            {
                ge = GesturesEnum.Left;
            }
            if (sd.Gz < -200)
            {
                ge = GesturesEnum.Right;
            }

            if (sd.Gx > 200)
            {
                ge = GesturesEnum.Up;
            }
            if (sd.Gx < -200)
            {
                ge = GesturesEnum.Down;
            }

            if (sd.Gy > 200)
            {
                ge = GesturesEnum.Clockwise;
            }
            if (sd.Gy < -200)
            {
                ge = GesturesEnum.CounterclockWise;
            }

            if (ge == lastGestures)
            {
                ge = GesturesEnum.None;
            }
            else
            {
                lastGestures = ge;
            }

            return(ge);
        }
예제 #3
0
        private void updateGesturesLable(GesturesEnum ge)
        {
            string str = "";

            switch (ge)
            {
            case GesturesEnum.Left:
                str = "Влево";
                System.Windows.Forms.SendKeys.Send("{LEFT}");
                break;

            case GesturesEnum.Right:
                str = "Вправо";
                System.Windows.Forms.SendKeys.Send("{RIGHT}");
                break;

            case GesturesEnum.Up:
                str = "Вверх";
                System.Windows.Forms.SendKeys.Send("{UP}");
                break;

            case GesturesEnum.Down:
                str = "Вниз";
                System.Windows.Forms.SendKeys.Send("{DOWN}");
                break;

            case GesturesEnum.Clockwise:
                str = "По часовой стрелки";
                System.Windows.Forms.SendKeys.Send("{ESC}");
                break;

            case GesturesEnum.CounterclockWise:
                str = "Против часовой стрелки";
                System.Windows.Forms.SendKeys.Send("{ENTER}");
                break;
            }

            GesturesLable.Text = str;
        }
예제 #4
0
 public SwipeGestureWrapper(GesturesEnum gesture, long timestamp)
 {
     Gesture = gesture;
     Timestamp = timestamp;
 }
예제 #5
0
 public SwipeGestureWrapper(GesturesEnum gesture, long timestamp)
 {
     Gesture   = gesture;
     Timestamp = timestamp;
 }
예제 #6
0
 public SwipeEventArgs(GesturesEnum gesture)
 {
     Gesture = gesture;
 }
예제 #7
0
 public SwipeEventArgs(GesturesEnum gesture)
 {
     Gesture = gesture;
 }