public class XboxController extends GamepadBase
This class handles Xbox input that comes from the Driver Station. Each time a value is requested the most recent value is returend. 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.
GenericHID.Hand, GenericHID.HIDType, GenericHID.RumbleType
Constructor and Description |
---|
XboxController(int port)
Construct an instance of a joystick.
|
Modifier and Type | Method and Description |
---|---|
boolean |
getAButton()
Read the value of the A button on the controller.
|
boolean |
getBackButton()
Read the value of the back button on the controller.
|
boolean |
getBButton()
Read the value of the B button on the controller.
|
boolean |
getBumper(GenericHID.Hand hand)
Read the value of the bumper button on the controller.
|
java.lang.String |
getName()
Get the name of the HID.
|
int |
getPOV(int pov)
Get the angle in degrees of a POV on the HID.
|
int |
getPOVCount()
For the current HID, return the number of POVs.
|
double |
getRawAxis(int axis)
Get the value of the axis.
|
boolean |
getRawButton(int button)
Get the button value (starting at button 1).
|
boolean |
getStartButton()
Read the value of the start button on the controller.
|
boolean |
getStickButton(GenericHID.Hand hand)
Read the value of the stick button on the controller.
|
boolean |
getTop(GenericHID.Hand hand)
This is not supported for the XboxController.
|
boolean |
getTrigger(GenericHID.Hand hand)
This is not supported for the XboxController.
|
double |
getTriggerAxis(GenericHID.Hand hand)
Get the trigger axis value of the controller.
|
GenericHID.HIDType |
getType()
Get the type of the HID.
|
double |
getX(GenericHID.Hand hand)
Get the X axis value of the controller.
|
boolean |
getXButton()
Read the value of the X button on the controller.
|
double |
getY(GenericHID.Hand hand)
Get the Y axis value of the controller.
|
boolean |
getYButton()
Read the value of the Y button on the controller.
|
void |
setOutput(int outputNumber,
boolean value)
Set a single HID output value for the HID.
|
void |
setOutputs(int value)
Set all HID output values for the HID.
|
void |
setRumble(GenericHID.RumbleType type,
double value)
Set the rumble output for the HID.
|
getBumper, getStickButton
getPort, getPOV, getX, getY
public XboxController(int port)
port
- The port on the Driver Station that the joystick is plugged into.public double getX(GenericHID.Hand hand)
getX
in class GenericHID
hand
- Side of controller whose value should be returned.public double getY(GenericHID.Hand hand)
getY
in class GenericHID
hand
- Side of controller whose value should be returned.public double getRawAxis(int axis)
getRawAxis
in class GamepadBase
axis
- The axis to read, starting at 0.public boolean getBumper(GenericHID.Hand hand)
getBumper
in class GamepadBase
hand
- Side of controller whose value should be returned.public boolean getTrigger(GenericHID.Hand hand)
hand
- This parameter is ignored for the Joystick class and is only here to complete the
GenericHID interface.public boolean getTop(GenericHID.Hand hand)
hand
- This parameter is ignored for the Joystick class and is only here to complete the
GenericHID interface.public boolean getRawButton(int button)
The appropriate button is returned as a boolean value.
getRawButton
in class GamepadBase
button
- The button number to be read (starting at 1).public double getTriggerAxis(GenericHID.Hand hand)
hand
- Side of controller whose value should be returned.public boolean getAButton()
public boolean getBButton()
public boolean getXButton()
public boolean getYButton()
public boolean getStickButton(GenericHID.Hand hand)
getStickButton
in class GamepadBase
hand
- Side of controller whose value should be returned.public boolean getBackButton()
public boolean getStartButton()
public int getPOV(int pov)
GenericHID
The POV angles start at 0 in the up direction, and increase clockwise (eg right is 90, upper-left is 315).
getPOV
in class GamepadBase
pov
- The index of the POV to read (starting at 0)public int getPOVCount()
GenericHID
getPOVCount
in class GamepadBase
public GenericHID.HIDType getType()
GenericHID
getType
in class GamepadBase
public java.lang.String getName()
GenericHID
getName
in class GamepadBase
public void setOutput(int outputNumber, boolean value)
GenericHID
setOutput
in class GamepadBase
outputNumber
- The index of the output to set (1-32)value
- The value to set the output topublic void setOutputs(int value)
GenericHID
setOutputs
in class GamepadBase
value
- The 32 bit output value (1 bit for each output)public void setRumble(GenericHID.RumbleType type, double value)
GenericHID
setRumble
in class GamepadBase
type
- Which rumble value to setvalue
- The normalized value (0 to 1) to set the rumble to