protected override void OnStep()
        {
            Point  middlePoint = (Point)GetVar("MiddlePoint");
            float  deadZone    = (float)GetVar("DeadZone");
            double sensivity   = (double)GetVar("Sensivity");
            bool   alwaysClick = (bool)GetVar("AlwaysClick");

            GloveHand lastRightSides = HandRecord.LastRightWithBothSides();
            GloveHand lastRightIndex = HandRecord.LastRightWithIndex();

            if (lastRightSides == null)
            {
                return;
            }

            double len   = GeometryExt.Distance(lastRightSides.SideMiddlePoint, middlePoint);
            Point  delta = HandRecord.RightSideMovementDelta(2, 10, 15);

            if (len > deadZone && Math.Abs(delta.X) >= 1 && Math.Abs(delta.Y) >= 1)
            {
                double xdiff = (-(lastRightSides.SideMiddlePoint.X - middlePoint.X) / len) * (len - deadZone);
                double ydiff = ((lastRightSides.SideMiddlePoint.Y - middlePoint.Y) / len) * (len - deadZone);

                double mxdiff = GeometryExt.Center(Screen.PrimaryScreen.Bounds).X + xdiff * sensivity;
                double mydiff = GeometryExt.Center(Screen.PrimaryScreen.Bounds).Y + ydiff * sensivity;
                //Console.WriteLine(mxdiff+":"+mydiff);
                Console.WriteLine(GeometryExt.Center(Screen.PrimaryScreen.Bounds));
                Mouse.SetPos((int)mxdiff, (int)mydiff);
            }
            if (alwaysClick || len <= deadZone)
            {
                if (lastRightIndex != null && lastRightIndex.SideFingers.Length == 2)
                {
                    if (GeometryExt.Distance(lastRightIndex.SideFingers[0].LightCenter, lastRightIndex.SideFingers[1].LightCenter) >= deadZone)
                    {
                        if (Math.Abs(lastRightIndex.SideFingers[0].LightCenter.Y - lastRightIndex.SideFingers[1].LightCenter.Y) <
                            Math.Abs(lastRightIndex.SideFingers[0].LightCenter.X - lastRightIndex.SideFingers[1].LightCenter.X)) // i side sono messi in orizzontale
                        {
                            Mouse.Release(false);
                            if (lastRightIndex.IndexFinger.LightCenter.Y > lastRightIndex.SideMiddlePoint.Y)
                            {
                                Mouse.Press(true);
                            }
                            else
                            {
                                Mouse.Release(true);
                            }
                        }
                        else //in verticale
                        {
                            Mouse.Release(true);
                            if (lastRightIndex.IndexFinger.LightCenter.X < lastRightIndex.SideMiddlePoint.X)
                            {
                                Mouse.Press(false);
                            }
                            else
                            {
                                Mouse.Release(false);
                            }
                        }
                    }
                }
            }
        }
Esempio n. 2
0
        protected override void OnStep()
        {
            double sensivity        = (double)GetVar("Sensivity");
            double acceleration     = (double)GetVar("Acceleration");
            double minDist          = (double)GetVar("MinDist");
            double maxDistMul       = (double)GetVar("MaxDistMul");
            double maxDistActionMul = (double)GetVar("MaxDistActionMul");
            int    trail            = (int)GetVar("Trail");
            double verticalMul      = (double)GetVar("VerticalMul");

            GloveHand lastRightSides = HandRecord.LastRightWithBothSides();
            GloveHand lastRightIndex = HandRecord.LastRightWithIndex();

            if (lastRightSides == null)
            {
                return;
            }

            Point delta = HandRecord.RightSideMovementDelta(trail);

            if (GeometryExt.Distance(lastRightSides.SideFingers[0].LightCenter, lastRightSides.SideFingers[1].LightCenter) >= minDist)
            {
                double acc2  = GeometryExt.Distance(lastRightSides.SideFingers[0].LightCenter, lastRightSides.SideFingers[1].LightCenter) / (minDist * maxDistMul);
                double xdiff = -delta.X * (sensivity * acc2);
                double ydiff = delta.Y * (sensivity * acc2);
                xdiff = Math.Sign(xdiff) * Math.Pow(Math.Abs(xdiff), acceleration);
                ydiff = Math.Sign(ydiff) * Math.Pow(Math.Abs(ydiff), acceleration);

                Mouse.MoveBy((int)xdiff, (int)ydiff);
            }

            if (lastRightIndex != null && lastRightIndex.SideFingers.Length == 2)
            {
                if (GeometryExt.Distance(lastRightIndex.SideFingers[0].LightCenter, lastRightIndex.SideFingers[1].LightCenter) >= minDist * maxDistActionMul)
                {
                    if (Math.Abs(lastRightIndex.SideFingers[0].LightCenter.Y - lastRightIndex.SideFingers[1].LightCenter.Y) <
                        Math.Abs(lastRightIndex.SideFingers[0].LightCenter.X - lastRightIndex.SideFingers[1].LightCenter.X) * verticalMul) // i side sono messi in orizzontale
                    {
                        Mouse.Release(MOUSE_BUTTON.RIGHT);
                        Mouse.Release(MOUSE_BUTTON.MIDDLE);
                        if (lastRightIndex.IndexFinger.LightCenter.Y > lastRightIndex.SideMiddlePoint.Y)
                        {
                            Mouse.Press(MOUSE_BUTTON.LEFT);
                        }
                        else
                        {
                            Mouse.Release(MOUSE_BUTTON.LEFT);
                        }


                        /*if (lastRightIndex.IndexFinger.LightCenter.X < Math.Min(lastRightIndex.SideFingers[0].LightCenter.X,
                         *                                                      lastRightIndex.SideFingers[1].LightCenter.X))
                         *  Mouse.Press(MOUSE_BUTTON.MIDDLE);
                         * else
                         *  Mouse.Release(MOUSE_BUTTON.MIDDLE);*/
                    }
                    else //in verticale
                    {
                        if (GeometryExt.Distance(lastRightIndex.IndexFinger.LightCenter, lastRightIndex.SideMiddlePoint) <= 15.0)
                        {
                            Mouse.Press(MOUSE_BUTTON.RIGHT);
                            Mouse.Press(MOUSE_BUTTON.LEFT);
                            Mouse.Release(MOUSE_BUTTON.MIDDLE);
                        }
                        else if (lastRightIndex.IndexFinger.LightCenter.X < lastRightIndex.SideMiddlePoint.X)
                        {
                            Mouse.Press(MOUSE_BUTTON.RIGHT);
                            Mouse.Release(MOUSE_BUTTON.LEFT);
                            Mouse.Release(MOUSE_BUTTON.MIDDLE);
                        }
                        else if (lastRightIndex.IndexFinger.LightCenter.X > lastRightIndex.SideMiddlePoint.X)
                        {
                            Mouse.Press(MOUSE_BUTTON.MIDDLE);
                        }
                    }
                }
            }
        }