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.Hand, GenericHID.HIDType, GenericHID.RumbleType
-
-
Constructor Summary
Constructors Constructor Description XboxController(int port)Construct an instance of a joystick.
-
Method Summary
All Methods Instance Methods Concrete Methods 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.booleangetBumper(GenericHID.Hand hand)Read the value of the bumper button on the controller.booleangetBumperPressed(GenericHID.Hand hand)Whether the bumper was pressed since the last check.booleangetBumperReleased(GenericHID.Hand hand)Whether the bumper was released since the last check.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.booleangetStickButton(GenericHID.Hand hand)Read the value of the stick button on the controller.booleangetStickButtonPressed(GenericHID.Hand hand)Whether the stick button was pressed since the last check.booleangetStickButtonReleased(GenericHID.Hand hand)Whether the stick button was released since the last check.doublegetTriggerAxis(GenericHID.Hand hand)Get the trigger axis value of the controller.doublegetX(GenericHID.Hand hand)Get the X axis value of the controller.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.doublegetY(GenericHID.Hand hand)Get the Y axis value of the controller.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, getX, getY, setOutput, setOutputs, setRumble
-
-
-
-
Method Detail
-
getX
public double getX(GenericHID.Hand hand)
Get the X axis value of the controller.- Specified by:
getXin classGenericHID- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- The X axis value of the controller.
-
getY
public double getY(GenericHID.Hand hand)
Get the Y axis value of the controller.- Specified by:
getYin classGenericHID- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- The Y axis value of the controller.
-
getTriggerAxis
public double getTriggerAxis(GenericHID.Hand hand)
Get the trigger axis value of the controller.- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- The trigger axis value of the controller.
-
getBumper
public boolean getBumper(GenericHID.Hand hand)
Read the value of the bumper button on the controller.- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- The state of the button.
-
getBumperPressed
public boolean getBumperPressed(GenericHID.Hand hand)
Whether the bumper was pressed since the last check.- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- Whether the button was pressed since the last check.
-
getBumperReleased
public boolean getBumperReleased(GenericHID.Hand hand)
Whether the bumper was released since the last check.- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- Whether the button was released since the last check.
-
getStickButton
public boolean getStickButton(GenericHID.Hand hand)
Read the value of the stick button on the controller.- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- The state of the button.
-
getStickButtonPressed
public boolean getStickButtonPressed(GenericHID.Hand hand)
Whether the stick button was pressed since the last check.- Parameters:
hand- Side of controller whose value should be returned.- Returns:
- Whether the button was pressed since the last check.
-
getStickButtonReleased
public boolean getStickButtonReleased(GenericHID.Hand hand)
Whether the stick button was released since the last check.- Parameters:
hand- Side of controller whose value should be returned.- 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.
-
-