Package edu.wpi.first.wpilibj
Class XboxController
java.lang.Object
edu.wpi.first.wpilibj.GenericHID
edu.wpi.first.wpilibj.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.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classXboxController.AxisRepresents an axis on an XboxController.static classXboxController.ButtonRepresents a digital button on an XboxController.Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.GenericHID
GenericHID.HIDType, GenericHID.RumbleType -
Constructor Summary
Constructors Constructor Description XboxController(int port)Construct an instance of a controller. -
Method Summary
Modifier and Type Method Description booleangetAButton()Read the value of the A button on the controller.booleangetAButtonPressed()Whether the A button was pressed since the last check.booleangetAButtonReleased()Whether the A button was released since the last check.booleangetBackButton()Read the value of the back button on the controller.booleangetBackButtonPressed()Whether the back button was pressed since the last check.booleangetBackButtonReleased()Whether the back button was released since the last check.booleangetBButton()Read the value of the B button on the controller.booleangetBButtonPressed()Whether the B button was pressed since the last check.booleangetBButtonReleased()Whether the B button was released since the last check.booleangetLeftBumper()Read the value of the left bumper (LB) button on the controller.booleangetLeftBumperPressed()Whether the left bumper (LB) was pressed since the last check.booleangetLeftBumperReleased()Whether the left bumper (LB) was released since the last check.booleangetLeftStickButton()Read the value of the left stick button (LSB) on the controller.booleangetLeftStickButtonPressed()Whether the left stick button (LSB) was pressed since the last check.booleangetLeftStickButtonReleased()Whether the left stick button (LSB) was released since the last check.doublegetLeftTriggerAxis()Get the left trigger (LT) axis value of the controller.doublegetLeftX()Get the X axis value of left side of the controller.doublegetLeftY()Get the Y axis value of left side of the controller.booleangetRightBumper()Read the value of the right bumper (RB) button on the controller.booleangetRightBumperPressed()Whether the right bumper (RB) was pressed since the last check.booleangetRightBumperReleased()Whether the right bumper (RB) was released since the last check.booleangetRightStickButton()Read the value of the right stick button (RSB) on the controller.booleangetRightStickButtonPressed()Whether the right stick button (RSB) was pressed since the last check.booleangetRightStickButtonReleased()Whether the right stick (RSB) button was released since the last check.doublegetRightTriggerAxis()Get the right trigger (RT) axis value of the controller.doublegetRightX()Get the X axis value of right side of the controller.doublegetRightY()Get the Y axis value of right side of the controller.booleangetStartButton()Read the value of the start button on the controller.booleangetStartButtonPressed()Whether the start button was pressed since the last check.booleangetStartButtonReleased()Whether the start button was released since the last check.booleangetXButton()Read the value of the X button on the controller.booleangetXButtonPressed()Whether the X button was pressed since the last check.booleangetXButtonReleased()Whether the X button was released since the last check.booleangetYButton()Read the value of the Y button on the controller.booleangetYButtonPressed()Whether the Y button was pressed since the last check.booleangetYButtonReleased()Whether the Y button was released since the last check.Methods inherited from class edu.wpi.first.wpilibj.GenericHID
getAxisCount, getAxisType, getButtonCount, getName, getPort, getPOV, getPOV, getPOVCount, getRawAxis, getRawButton, getRawButtonPressed, getRawButtonReleased, getType, isConnected, setOutput, setOutputs, setRumble
-
Constructor Details
-
XboxController
Construct an instance of a controller.- Parameters:
port- The port index on the Driver Station that the controller is plugged into.
-
-
Method Details
-
getLeftX
Get the X axis value of left side of the controller.- Returns:
- The axis value.
-
getRightX
Get the X axis value of right side of the controller.- Returns:
- The axis value.
-
getLeftY
Get the Y axis value of left side of the controller.- Returns:
- The axis value.
-
getRightY
Get the Y axis value of right side of the controller.- Returns:
- The axis value.
-
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
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
Read the value of the left bumper (LB) button on the controller.- Returns:
- The state of the button.
-
getRightBumper
Read the value of the right bumper (RB) button on the controller.- Returns:
- The state of the button.
-
getLeftBumperPressed
Whether the left bumper (LB) was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getRightBumperPressed
Whether the right bumper (RB) was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getLeftBumperReleased
Whether the left bumper (LB) was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getRightBumperReleased
Whether the right bumper (RB) was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getLeftStickButton
Read the value of the left stick button (LSB) on the controller.- Returns:
- The state of the button.
-
getRightStickButton
Read the value of the right stick button (RSB) on the controller.- Returns:
- The state of the button.
-
getLeftStickButtonPressed
Whether the left stick button (LSB) was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getRightStickButtonPressed
Whether the right stick button (RSB) was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getLeftStickButtonReleased
Whether the left stick button (LSB) was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getRightStickButtonReleased
Whether the right stick (RSB) button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getAButton
Read the value of the A button on the controller.- Returns:
- The state of the button.
-
getAButtonPressed
Whether the A button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getAButtonReleased
Whether the A button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getBButton
Read the value of the B button on the controller.- Returns:
- The state of the button.
-
getBButtonPressed
Whether the B button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getBButtonReleased
Whether the B button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getXButton
Read the value of the X button on the controller.- Returns:
- The state of the button.
-
getXButtonPressed
Whether the X button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getXButtonReleased
Whether the X button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getYButton
Read the value of the Y button on the controller.- Returns:
- The state of the button.
-
getYButtonPressed
Whether the Y button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getYButtonReleased
Whether the Y button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getBackButton
Read the value of the back button on the controller.- Returns:
- The state of the button.
-
getBackButtonPressed
Whether the back button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getBackButtonReleased
Whether the back button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
getStartButton
Read the value of the start button on the controller.- Returns:
- The state of the button.
-
getStartButtonPressed
Whether the start button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getStartButtonReleased
Whether the start button was released since the last check.- Returns:
- Whether the button was released since the last check.
-