XboxController

class wpilib.XboxController(port: int)

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

The controller index is the USB port on the Driver Station.

Parameters

port – The port on the Driver Station that the controller is plugged into (0-5).

class Axis

Bases: pybind11_builtins.pybind11_object

kLeftTrigger = 2
kLeftX = 0
kLeftY = 1
kRightTrigger = 3
kRightX = 4
kRightY = 5
class Button

Bases: pybind11_builtins.pybind11_object

kA = 1
kB = 2
kBack = 7
kLeftBumper = 5
kLeftStick = 9
kRightBumper = 6
kRightStick = 10
kStart = 8
kX = 3
kY = 4
getAButton() bool

Read the value of the A button on the controller.

Returns

The state of the button.

getAButtonPressed() bool

Whether the A button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getAButtonReleased() bool

Whether the A button was released since the last check.

Returns

Whether the button was released since the last check.

getBButton() bool

Read the value of the B button on the controller.

Returns

The state of the button.

getBButtonPressed() bool

Whether the B button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getBButtonReleased() bool

Whether the B button was released since the last check.

Returns

Whether the button was released since the last check.

getBackButton() bool

Whether the Y button was released since the last check.

Returns

Whether the button was released since the last check.

getBackButtonPressed() bool

Whether the back button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getBackButtonReleased() bool

Whether the back button was released since the last check.

Returns

Whether the button was released since the last check.

getLeftBumper() bool

Read the value of the left bumper (LB) button on the controller.

getLeftBumperPressed() bool

Whether the left bumper (LB) was pressed since the last check.

getLeftBumperReleased() bool

Whether the left bumper (LB) was released since the last check.

getLeftStickButton() bool

Read the value of the left stick button (LSB) on the controller.

getLeftStickButtonPressed() bool

Whether the left stick button (LSB) was pressed since the last check.

getLeftStickButtonReleased() bool

Whether the left stick button (LSB) was released since the last check.

getLeftTriggerAxis() float

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].

getLeftX() float

Get the X axis value of left side of the controller.

getLeftY() float

Get the Y axis value of left side of the controller.

getRightBumper() bool

Read the value of the right bumper (RB) button on the controller.

getRightBumperPressed() bool

Whether the right bumper (RB) was pressed since the last check.

getRightBumperReleased() bool

Whether the right bumper (RB) was released since the last check.

getRightStickButton() bool

Read the value of the right stick button (RSB) on the controller.

getRightStickButtonPressed() bool

Whether the right stick button (RSB) was pressed since the last check.

getRightStickButtonReleased() bool

Whether the right stick button (RSB) was released since the last check.

getRightTriggerAxis() float

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].

getRightX() float

Get the X axis value of right side of the controller.

getRightY() float

Get the Y axis value of right side of the controller.

getStartButton() bool

Read the value of the start button on the controller.

Returns

The state of the button.

getStartButtonPressed() bool

Whether the start button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getStartButtonReleased() bool

Whether the start button was released since the last check.

Returns

Whether the button was released since the last check.

getXButton() bool

Read the value of the X button on the controller.

Returns

The state of the button.

getXButtonPressed() bool

Whether the X button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getXButtonReleased() bool

Whether the X button was released since the last check.

Returns

Whether the button was released since the last check.

getYButton() bool

Read the value of the Y button on the controller.

Returns

The state of the button.

getYButtonPressed() bool

Whether the Y button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getYButtonReleased() bool

Whether the Y button was released since the last check.

Returns

Whether the button was released since the last check.