package edu.wpi.first.wpilibj.technobots;

import edu.wpi.first.wpilibj.Joystick;
import edu.wpi.first.wpilibj.buttons.Button;
import edu.wpi.first.wpilibj.buttons.JoystickButton;
import edu.wpi.first.wpilibj.technobots.commands.ReleaseBall;
import edu.wpi.first.wpilibj.technobots.commands.SetElbowSetPoint;
import edu.wpi.first.wpilibj.technobots.commands.ShooterOn;
import edu.wpi.first.wpilibj.technobots.commands.SweeperOn;

/**
 * This class is the glue that binds the controls on the physical operator
 * interface to the commands and command groups that allow control of the robot.
 */
public class OI {

    Joystick xbox;
    Button button1, button2, button3, button5;
    ShooterOn shooter;
    ReleaseBall releaseBall;

    public OI() {

        xbox = new Joystick(1);
        button1 = new JoystickButton(xbox, 1);
        button2 = new JoystickButton(xbox, 2);
        button3 = new JoystickButton(xbox, 3);
        button5 = new JoystickButton(xbox, 5);

        button1.whenPressed(new SetElbowSetPoint(4));
        button2.whenPressed(new SetElbowSetPoint(2));
        button3.whenPressed(new SetElbowSetPoint(0));

        button5.whenPressed(new SweeperOn());

        if (Buffer(xbox.getRawAxis(3)) > 0) {

            shooter = new ShooterOn();

        }

        if (Buffer(xbox.getRawAxis(3)) < 0) {

            releaseBall = new ReleaseBall();

        }
    }

    public double getMagnitude() {

        return xbox.getMagnitude();
    }

    public double getDirection() {

        return xbox.getDirectionDegrees();
    }

    public double getRotation() {

        return Buffer(xbox.getRawAxis(4));
    }

    private double Buffer(double n) {

        double buffers = 0.2;

        if (Math.abs(n) < buffers) {

            return n;
        }

        return n;
    }
}
@@ -1426,32 +1426,39 @@
 %0A        return 
+Buffer(
 xbox.getMagnitud
@@ -1460,16 +1460,17 @@
 nitude()
+)
 ;%0A    %7D%0A
@@ -1521,16 +1521,23 @@
  return 
+Buffer(
 xbox.get
@@ -1554,16 +1554,17 @@
 egrees()
+)
 ;%0A    %7D%0A

Add buffer to other xbox values