package com.edinarobotics.utils.gamepad;

/**
 * Represents the state of both of a Gamepad's joysticks.
 * Can be used to filter these joysticks (deadzoning, scaling, etc.).
 */
public class GamepadResult {
    private double lx;
    private double ly;
    private double rx;
    private double ry;
    
    /**
     * Creates a GamepadResult from the cartesian coordinates of two joysticks.
     * @param lx the left x-value.
     * @param ly the left y-value.
     * @param rx the right x-value.
     * @param ry  the right y-value.
     */
    public GamepadResult(double lx,double ly,double rx,double ry){
        this.lx = lx;
        this.ly = ly;
        this.rx = rx;
        this.ry = ry;
        
    }
    
    public double getLeftX(){
        return lx;
    }
    
    public double getLeftY(){
        return ly;
    }
    
    public double getRightX(){
        return rx;
    }
    
    public double getRightY(){
        return ry;
    }
}

@@ -35,16 +35,55 @@
 mepad;%0A%0A
+import com.sun.squawk.util.MathUtils;%0A%0A
 /**%0A * R
@@ -987,10 +987,1214 @@
 ;%0A    %7D%0A
+    %0A    public double getLeftMagnitude()%7B%0A        return Math.sqrt(MathUtils.pow(getLeftX(), 2)+MathUtils.pow(getLeftY(), 2));%0A    %7D%0A    %0A    public double getRightMagnitude()%7B%0A        return Math.sqrt(MathUtils.pow(getRightX(), 2)+MathUtils.pow(getRightY(), 2));%0A    %7D%0A    %0A    /**%0A     * Returns the direction of the left joystick on the gamepad. The angle%0A     * is clockwise from straight up (along the y-axis) and is suitable%0A     * to pass to%0A     * %7B@link edu.wpi.first.wpilibj.RobotDrive#mecanumDrive_Polar(double, double, double)%7D.%0A     * @return The direction angle in degrees of the left joystick.%0A     */%0A    public double getLeftDirection()%7B%0A        return Math.toDegrees(MathUtils.atan2(getLeftX(), -getLeftY()));%0A    %7D%0A    %0A    /**%0A     * Returns the direction of the right joystick on the gamepad. The angle%0A     * is clockwise from straight up (along the y-axis) and is suitable%0A     * to pass to%0A     * %7B@link edu.wpi.first.wpilibj.RobotDrive#mecanumDrive_Polar(double, double, double)%7D.%0A     * @return The direction angle in degrees of the right joystick.%0A     */%0A    public double getRightDirection()%7B%0A        return Math.toDegrees(MathUtils.atan2(getRightX(), -getRightY()));%0A    %7D%0A
 %7D%0A

Add polar conversion methods to GamepadResult.