Class XboxController


  • public class XboxController
    extends GenericHID
    Handle input from Xbox 360 or Xbox One controllers connected to the Driver Station.

    This class handles Xbox input that comes from the Driver Station. Each time a value is requested the most recent value is returned. There is a single class instance for each controller and the mapping of ports to hardware buttons depends on the code in the Driver Station.

    • Constructor Detail

      • XboxController

        public XboxController​(int port)
        Construct an instance of a controller.
        Parameters:
        port - The port index on the Driver Station that the controller is plugged into.
    • Method Detail

      • getLeftX

        public double getLeftX()
        Get the X axis value of left side of the controller.
        Returns:
        The axis value.
      • getRightX

        public double getRightX()
        Get the X axis value of right side of the controller.
        Returns:
        The axis value.
      • getLeftY

        public double getLeftY()
        Get the Y axis value of left side of the controller.
        Returns:
        The axis value.
      • getRightY

        public double getRightY()
        Get the Y axis value of right side of the controller.
        Returns:
        The axis value.
      • getLeftTriggerAxis

        public double getLeftTriggerAxis()
        Get the left trigger (LT) axis value of the controller. Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].
        Returns:
        The axis value.
      • getRightTriggerAxis

        public double getRightTriggerAxis()
        Get the right trigger (RT) axis value of the controller. Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].
        Returns:
        The axis value.
      • getLeftBumper

        public boolean getLeftBumper()
        Read the value of the left bumper (LB) button on the controller.
        Returns:
        The state of the button.
      • getRightBumper

        public boolean getRightBumper()
        Read the value of the right bumper (RB) button on the controller.
        Returns:
        The state of the button.
      • getLeftBumperPressed

        public boolean getLeftBumperPressed()
        Whether the left bumper (LB) was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getRightBumperPressed

        public boolean getRightBumperPressed()
        Whether the right bumper (RB) was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getLeftBumperReleased

        public boolean getLeftBumperReleased()
        Whether the left bumper (LB) was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getRightBumperReleased

        public boolean getRightBumperReleased()
        Whether the right bumper (RB) was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getLeftStickButton

        public boolean getLeftStickButton()
        Read the value of the left stick button (LSB) on the controller.
        Returns:
        The state of the button.
      • getRightStickButton

        public boolean getRightStickButton()
        Read the value of the right stick button (RSB) on the controller.
        Returns:
        The state of the button.
      • getLeftStickButtonPressed

        public boolean getLeftStickButtonPressed()
        Whether the left stick button (LSB) was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getRightStickButtonPressed

        public boolean getRightStickButtonPressed()
        Whether the right stick button (RSB) was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getLeftStickButtonReleased

        public boolean getLeftStickButtonReleased()
        Whether the left stick button (LSB) was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getRightStickButtonReleased

        public boolean getRightStickButtonReleased()
        Whether the right stick (RSB) button was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getAButton

        public boolean getAButton()
        Read the value of the A button on the controller.
        Returns:
        The state of the button.
      • getAButtonPressed

        public boolean getAButtonPressed()
        Whether the A button was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getAButtonReleased

        public boolean getAButtonReleased()
        Whether the A button was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getBButton

        public boolean getBButton()
        Read the value of the B button on the controller.
        Returns:
        The state of the button.
      • getBButtonPressed

        public boolean getBButtonPressed()
        Whether the B button was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getBButtonReleased

        public boolean getBButtonReleased()
        Whether the B button was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getXButton

        public boolean getXButton()
        Read the value of the X button on the controller.
        Returns:
        The state of the button.
      • getXButtonPressed

        public boolean getXButtonPressed()
        Whether the X button was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getXButtonReleased

        public boolean getXButtonReleased()
        Whether the X button was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getYButton

        public boolean getYButton()
        Read the value of the Y button on the controller.
        Returns:
        The state of the button.
      • getYButtonPressed

        public boolean getYButtonPressed()
        Whether the Y button was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getYButtonReleased

        public boolean getYButtonReleased()
        Whether the Y button was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getBackButton

        public boolean getBackButton()
        Read the value of the back button on the controller.
        Returns:
        The state of the button.
      • getBackButtonPressed

        public boolean getBackButtonPressed()
        Whether the back button was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getBackButtonReleased

        public boolean getBackButtonReleased()
        Whether the back button was released since the last check.
        Returns:
        Whether the button was released since the last check.
      • getStartButton

        public boolean getStartButton()
        Read the value of the start button on the controller.
        Returns:
        The state of the button.
      • getStartButtonPressed

        public boolean getStartButtonPressed()
        Whether the start button was pressed since the last check.
        Returns:
        Whether the button was pressed since the last check.
      • getStartButtonReleased

        public boolean getStartButtonReleased()
        Whether the start button was released since the last check.
        Returns:
        Whether the button was released since the last check.