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 + ")"; } }