package com.edinarobotics.utils.gamepad;

import edu.wpi.first.wpilibj.Joystick;

/**
 * Represents a gamepad with two joysticks and several buttons.
 * Makes interacting with a gamepad easier.
 * Returns results through a GamepadResult.
 */
public class Gamepad extends Joystick{
    public static final int LEFT_X_AXIS = 1;
    public static final int LEFT_Y_AXIS = 2;
    public static final int RIGHT_X_AXIS = 3;
    public static final int RIGHT_Y_AXIS = 4;
    
    public static final int DPAD_X = 5;
    public static final int DPAD_Y = 6;
    
    public static final int LEFT_BUMPER = 5;
    public static final int LEFT_TRIGGER = 7;
    public static final int RIGHT_BUMPER = 6;
    public static final int RIGHT_TRIGGER = 8;
    public static final int BUTTON_1 = 1;
    public static final int BUTTON_2 = 2;
    public static final int BUTTON_3 = 3;
    public static final int BUTTON_4 = 4;
    public static final int BUTTON_9 = 9;
    public static final int BUTTON_10 = 10;
                    
    
    public Gamepad(int port){
        super(port);
    }
    
    public double getLeftX(){
        return this.getRawAxis(LEFT_X_AXIS);
    }
    
    public double getLeftY(){
        return this.getRawAxis(LEFT_Y_AXIS);
    }
    
    public double getRightX(){
        return this.getRawAxis(RIGHT_X_AXIS);
    }
    
    public double getRightY(){
        return this.getRawAxis(RIGHT_Y_AXIS);
    }
    
    public double getDPadX()
    {
        return this.getRawAxis(DPAD_X);
    }
    
    public double getDPadY()
    {
        return this.getRawAxis(DPAD_Y);
    }
    
    public GamepadResult getJoysticks(){
        return new GamepadResult(getLeftX(),getLeftY(),getRightX(),getRightY());
    }

}

@@ -1001,24 +1001,78 @@
            %0A
+    private static final double DPAD_THRESHOLD = 0.9;%0A
     %0A    pub
@@ -1477,38 +1477,35 @@
     %0A    public 
-double
+int
  getDPadX()%0A    
@@ -1513,32 +1513,42 @@
 %0A        return 
+dPadToInt(
 this.getRawAxis(
@@ -1554,16 +1554,17 @@
 (DPAD_X)
+)
 ;%0A    %7D%0A
@@ -1575,30 +1575,27 @@
 %0A    public 
-double
+int
  getDPadY()%0A
@@ -1607,32 +1607,42 @@
 %0A        return 
+dPadToInt(
 this.getRawAxis(
@@ -1648,16 +1648,232 @@
 (DPAD_Y)
+);%0A    %7D%0A    %0A    private int dPadToInt(double value)%7B%0A        if(value %3E= DPAD_THRESHOLD)%7B%0A            return 1;%0A        %7D%0A        else if(value %3C= -DPAD_THRESHOLD)%7B%0A            return -1;%0A        %7D%0A        return 0
 ;%0A    %7D%0A

Change Gamepad's D-Pad methods to return integers for exact equality testing.