XboxController

class wpilib.XboxController(port)[source]

Bases: wpilib.interfaces.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.

Construct an instance of an XBoxController. The XBoxController index is the USB port on the Driver Station.

Parameters:port (int) – The port on the Driver Station that the joystick is plugged into
class Button[source]

Bases: enum.IntEnum

An enumeration.

kA = 1
kB = 2
kBack = 7
kBumperLeft = 5
kBumperRight = 6
kStart = 8
kStickLeft = 9
kStickRight = 10
kX = 3
kY = 4
getAButton()[source]

Read the value of the A button on the controller

Return type:bool
Returns:The state of the A button
getAButtonPressed()[source]

Whether the A button was pressed since the last check.

Return type:bool
Returns:Whether the button was pressed since the last check.
getAButtonReleased()[source]

Whether the A button was released since the last check.

Return type:bool
Returns:Whether the button was released since the last check.
getBButton()[source]

Read the value of the B button on the controller

Return type:bool
Returns:The state of the B button
getBButtonPressed()[source]

Whether the B button was pressed since the last check.

Return type:bool
Returns:Whether the button was pressed since the last check.
getBButtonReleased()[source]

Whether the B button was released since the last check.

Return type:bool
Returns:Whether the button was released since the last check.
getBackButton()[source]

Read the value of the Back button on the controller

Return type:bool
Returns:The state of the Back button
getBackButtonPressed()[source]

Whether the Back button was pressed since the last check.

Return type:bool
Returns:Whether the button was pressed since the last check.
getBackButtonReleased()[source]

Whether the Back button was released since the last check.

Return type:bool
Returns:Whether the button was released since the last check.
getBumper(hand)[source]

Read the values of the bumper button on the controller.

Parameters:hand (Hand) – Side of controller whose value should be returned.
Return type:bool
Returns:The state of the button
getBumperPressed(hand)[source]

Whether the bumper was pressed since the last check.

Parameters:hand (Hand) – Side of controller whose value should be returned.
Return type:bool
Returns:Whether the button was pressed since the last check.
getBumperReleased(hand)[source]

Whether the bumper was released since the last check.

Parameters:hand (Hand) – Side of controller whose value should be returned.
Return type:bool
Returns:Whether the button was released since the last check.
getStartButton()[source]

Read the value of the Start button on the controller

Return type:bool
Returns:The state of the Start button
getStartButtonPressed()[source]

Whether the Start button was pressed since the last check.

Return type:bool
Returns:Whether the button was pressed since the last check.
getStartButtonReleased()[source]

Whether the Start button was released since the last check.

Return type:bool
Returns:Whether the button was released since the last check.
getStickButton(hand)[source]

Read the values of the stick button on the controller

Parameters:hand (Hand) – Side of the controller whose value should be returned
Return type:bool
Returns:The state of the button
getStickButtonPressed(hand)[source]

Whether the stick button was pressed since the last check.

Parameters:hand (Hand) – Side of controller whose value should be returned.
Return type:bool
Returns:Whether the button was pressed since the last check.
getStickButtonReleased(hand)[source]

Whether the stick button was released since the last check.

Parameters:hand (Hand) – Side of controller whose value should be returned.
Return type:bool
Returns:Whether the button was released since the last check.
getTriggerAxis(hand)[source]

Get the trigger axis value of the controller.

Parameters:hand (Hand) – Side of controller whose value should be returned
Return type:float
Returns:The trigger axis value of the controller
getX(hand)[source]

Get the X axis value of the controller.

Parameters:hand (Hand) – Side of controller whose value should be returned
Return type:float
Returns:The X axis value of the controller
getXButton()[source]

Read the value of the X button on the controller

Return type:bool
Returns:The state of the X button
getXButtonPressed()[source]

Whether the X button was pressed since the last check.

Return type:bool
Returns:Whether the button was pressed since the last check.
getXButtonReleased()[source]

Whether the X button was released since the last check.

Return type:bool
Returns:Whether the button was released since the last check.
getY(hand)[source]

Get the Y axis value of the controller.

Parameters:hand (Hand) – Side of controller whose value should be returned
Return type:float
Returns:The Y axis value of the controller
getYButton()[source]

Read the value of the Y button on the controller

Return type:bool
Returns:The state of the Y button
getYButtonPressed()[source]

Whether the Y button was pressed since the last check.

Return type:bool
Returns:Whether the button was pressed since the last check.
getYButtonReleased()[source]

Whether the Y button was released since the last check.

Return type:bool
Returns:Whether the button was released since the last check.