Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions src/main/java/frc/robot/RobotContainer.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,53 @@
import edu.wpi.first.wpilibj2.command.WaitCommand;
import edu.wpi.first.wpilibj2.command.button.JoystickButton;



import edu.wpi.first.wpilibj.XboxController;

public class XboxController {
// XboxController Port (You can see the port of the controller in FRC Driver Station)
private final int controllerPort = 0;
// An XboxController at that port
private final XboxController controller = new XboxController(controllerPort);

// Controller Joysticks. X axis is horizontal value of joystick, y axis is vertical.
// Fully left on the X axis gives a value of -1, fully right gives a value of 1.
// Fully down on the Y axis gives a value of -1, fully up gives a value of 1.
private double leftYAxisValue, leftXAxisValue, rightYAxisValue, rightXAxisValue;
// Controller Triggers. 0 is completely released, 1 is completely pressed, 0.5 is half pressed etc.
private double leftTriggerValue, rightTriggerValue;
// Controller Buttons and Bumpers
private boolean rightBumperPressed, leftBumperPressed;
private boolean aButtonPressed, bButtonPressed, yButtonPressed, xButtonPressed;
// Controller DPad Angle (It's dumb and gives you the "angle" of the DPad. For example, 90 degrees is right, 180 down, 270 left, 0 up)
private int dpadAngle;

public XboxController() {
// Joystick Axis
leftYAxisValue = controller.getLeftY();
leftXAxisValue = controller.getLeftX();
rightYAxisValue = controller.getRightY();
rightXAxisValue = controller.getRightX();

// Trigger Axis
leftTriggerValue = controller.getLeftTriggerAxis();
rightTriggerValue = controller.getRightTriggerAxis();

// Bumper Buttons
rightBumperPressed = controller.getRightBumper();
leftBumperPressed = controller.getLeftBumper();

// Some other buttons
aButtonPressed = controller.getAButton();
bButtonPressed = controller.getBButton();
xButtonPressed = controller.getXButton();
yButtonPressed = controller.getYButton();

// Dpad
dpadAngle = controller.getPOV();
}
}
/**
* This class is where the bulk of the robot should be declared. Since Command-based is a
* "declarative" paradigm, very little robot logic should actually be handled in the {@link Robot}
Expand Down