private async void doWork() { await Controller.DetectGameControllersAsync(); Controller.InputReceived += Controller_InputReceived; double X1, Y1; Vector vec = new Vector(0, 0); getXY(vec, out X1, out Y1); MoveEyeBall(LeftEye, LeftPupil, X1, Y1); MoveEyeBall(RightEye, RightPupil, X1, Y1); }
private void getXY(Vector vector, out double X1, out double Y1) { double radians = DegreesToRadians(vector.direction); // Scale the magnitude double maxrange = 150; double magnitude = (vector.magnitude / 4096) * (maxrange); // Opposite Side double sin = Math.Sin(radians); //double opposite = sin * magnitude; X1 = 150 + (sin * magnitude); // Adjacent Side double cos = Math.Cos(radians); //double adjacent = cos * magnitude; Y1 = 150 - (cos * magnitude); }
private static double GetXVelocity(Vector vec) { double Direction = vec.direction; double Velocity = 0; if (Direction > 45 && Direction <135 ) { // forwards Velocity = vec.magnitude; } else if (Direction > 225 && Direction < 315) { Velocity = 4095 - (vec.magnitude + 4095); } else { Velocity = 0; } return Velocity; }
public AnalogueStickBase(double XAxis, double YAxis) { vector = new Vector(XAxis, YAxis); coordinates = new Coordinates(XAxis, YAxis); }
public AnalogueStickBase() { vector = new Vector(); coordinates = new Coordinates(); }