protected override void OnStep() { Point origin = (Point)GetVar("Origin"); Point size = (Point)GetVar("Size"); double sensivity = (double)GetVar("Sensivity"); bool alwaysClick = (bool)GetVar("AlwaysClick"); GloveHand lastRightSides = HandRecord.LastRightWithBothSides(); GloveHand lastRightIndex = HandRecord.LastRightWithIndex(); if (lastRightSides == null) { return; } Rectangle box = new Rectangle(origin.X, origin.Y, size.X, size.Y); if (Collision.Inside(box, lastRightSides.SideMiddlePoint)) //we can move { int ydiff = (int)((double)(lastRightSides.SideMiddlePoint.Y - origin.Y) / (double)size.Y * (double)Screen.PrimaryScreen.Bounds.Height); int xdiff = (int)((double)(size.X - (lastRightSides.SideMiddlePoint.X - origin.X)) / (double)size.X * (double)Screen.PrimaryScreen.Bounds.Width); Mouse.SetPos(xdiff, ydiff); } _lastPos = lastRightSides.SideMiddlePoint; if (alwaysClick || Collision.Inside(box, lastRightSides.SideMiddlePoint)) { if (lastRightIndex != null && lastRightIndex.SideFingers.Length == 2) { if (GeometryExt.Distance(lastRightIndex.SideFingers[0].LightCenter, lastRightIndex.SideFingers[1].LightCenter) >= size.X / 3.0) { 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.Press(false); if (lastRightIndex.IndexFinger.LightCenter.X > lastRightIndex.SideMiddlePoint.X) { Mouse.Press(true); } else { Mouse.Release(true); } } } } } }
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); } } } } } }
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); } } } } }
protected override void OnStep() { Point middlePoint = (Point)GetVar("MiddlePoint"); float deadZone = (float)GetVar("DeadZone"); double sensivity = (double)GetVar("Sensivity"); double acceleration = (double)GetVar("Acceleration"); bool alwaysClick = (bool)GetVar("AlwaysClick"); GloveHand lastRightSides = HandRecord.LastRightWithBothSides(); GloveHand lastRightIndex = HandRecord.LastRightWithIndex(); if (lastRightSides == null) { return; } double len = GeometryExt.Distance(lastRightSides.SideMiddlePoint, middlePoint); if (len > deadZone) { double xdiff = (-(lastRightSides.SideMiddlePoint.X - middlePoint.X) / len) * (len - deadZone); double ydiff = ((lastRightSides.SideMiddlePoint.Y - middlePoint.Y) / len) * (len - deadZone); xdiff /= sensivity; ydiff /= sensivity; 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 (alwaysClick || len <= deadZone) { if (lastRightIndex != null && lastRightIndex.SideFingers.Length == 2) { if (GeometryExt.Distance(lastRightIndex.SideFingers[0].LightCenter, lastRightIndex.SideFingers[1].LightCenter) >= deadZone * 1.5) { 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.Press(false); if (lastRightIndex.IndexFinger.LightCenter.X > lastRightIndex.SideMiddlePoint.X) { Mouse.Press(true); } else { Mouse.Release(true); } } } } } }