Exemplo n.º 1
0
 private void OnThumbBackInsideRadius(object sender, GamepadThumbEventArgs evt)
 {
     if (evt.Thumb == GamepadThumbs.Right)
     {
         myStage.Stop();
         Text = "(" + evt.XPosition + "," + evt.YPosition + ")";
     }
 }
Exemplo n.º 2
0
        private void OnRightThumbUpdate(object sender, GamepadThumbEventArgs evt)
        {
            if (evt.Thumb == GamepadThumbs.Right)
            {
                double rightThumbCurrentRadius = 0.0;
                double rightThumbRadius = 0.0;
                double rightThumbX = 0.0;
                double rightThumbY = 0.0;
                double deltaRadius = 0.0, deltax = 0.0, deltay = 0.0, deltaz = 0.05;
                double magnitude = 0.0;
                double deltapos = 2000;
                gamepad.GetThumbRadius(GamepadButtons.RightThumb, ref rightThumbRadius);
                gamepad.GetThumbXY(GamepadButtons.RightThumb, ref rightThumbX, ref rightThumbY);
                Gamepad gp = (Gamepad)sender;
                if (gp._ZdirectionDown)
                {
                    deltaz = -deltaz;
                }
                rightThumbCurrentRadius = gamepad.CalculateMagnitude((double)evt.XPosition, (double)evt.YPosition);

                deltaRadius = gamepad.CalculatePosDifference(rightThumbRadius, rightThumbCurrentRadius, 4000.0);

                if (deltaRadius <= 0.0)
                {
                    return;
                }

                deltax = gamepad.CalculatePosDifference((double)evt.XPosition, rightThumbX, 4000);
                deltay = gamepad.CalculatePosDifference((double)evt.YPosition, rightThumbX, 4000);


                magnitude = gamepad.CalculateMagnitude(deltax, deltay);

                deltax = deltax / magnitude;
                deltay = deltay / magnitude;

                if (Math.Abs(deltax) >= 0.9)
                {
                    deltay = 0.0;
                }

                if (Math.Abs(deltay) >= 0.9)
                {
                    deltax = 0.0;
                }

                deltax = deltax * deltapos;
                deltay = deltay * deltapos;

                deltax = deltax / myStage.XCountsPerInch;
                deltay = deltay / myStage.YCountsPerInch;
                deltaz = deltaz / myStage.ZCountsPerInch;

                if (gp._Move3Axis)
                {
                    myStage.MoveToRel(deltax, deltay, deltaz);
                }
                else
                {
                    myStage.MoveToRel(deltax, deltay, 0);
                }
                Text = "(" + evt.XPosition + "," + evt.YPosition + ")";
            }
        }
Exemplo n.º 3
0
        private void OnLeftThumbUpdate(object sender, GamepadThumbEventArgs evt)
        {
            if (evt.Thumb == GamepadThumbs.Left)
            {
                //               double x=0.0, y = 0.0, z = 0.0;
                double  leftThumbCurrentRadius = 0.0;
                double  leftThumbRadius = 0.0;
                double  leftThumbX = 0.0;
                double  leftThumbY = 0.0;
                double  deltaRadius = 0.0, deltax = 0.0, deltay = 0.0, deltaz = 0.05;
                double  magnitude = 0.0;
                double  deltapos = 100;
                Gamepad gp = (Gamepad)sender;

                gamepad.GetThumbRadius(GamepadButtons.LeftThumb, ref leftThumbRadius);
                gamepad.GetThumbXY(GamepadButtons.LeftThumb, ref leftThumbX, ref leftThumbY);

                leftThumbCurrentRadius = gamepad.CalculateMagnitude((double)evt.XPosition, (double)evt.YPosition);

                deltaRadius = gamepad.CalculatePosDifference(leftThumbRadius, leftThumbCurrentRadius, 5000);

                if (deltaRadius <= 0.0)
                {
                    return;
                }

                deltax    = gamepad.CalculatePosDifference((double)evt.XPosition, leftThumbX, 5000);
                deltay    = gamepad.CalculatePosDifference((double)evt.YPosition, leftThumbX, 5000);
                magnitude = gamepad.CalculateMagnitude(deltax, deltay);

                deltax = deltax / magnitude;
                deltay = deltay / magnitude;

                if (Math.Abs(deltax) > 0.0)
                {
                    return;
                }

                deltax = deltax * deltapos;
                deltay = deltay * deltapos;

                if (Math.Abs(deltax) >= 0.5)
                {
                    deltay = 0.0;
                }

                if (Math.Abs(deltay) >= 0.5)
                {
                    deltax = 0.0;
                }

                if (deltay > 0)
                {
                    deltaz             = -50.05;
                    gp._ZdirectionDown = true;
                }

                if (deltay < 0)
                {
                    deltaz             = 50.05;
                    gp._ZdirectionDown = false;
                }

                deltaz = deltaz / myStage.ZCountsPerInch;
                if (!gp._Move3Axis)
                {
                    myStage.MoveToRel(0, 0, deltaz);
                }
                Text = "(" + evt.XPosition + "," + evt.YPosition + ")";
            }
        }
Exemplo n.º 4
0
        void OnThumbUpdate(object sender, GamepadThumbEventArgs evt)
        {
            var analog = evt.Thumb == GamepadThumbs.Right ? profile.SelectedResolution.RightAnalog : profile.SelectedResolution.LeftAnalog;

            OnAnalogUpdate(this, new GamepadHelperEventArgs(evt.XPosition, evt.YPosition, evt.Thumb, analog));
        }