XboxController

class wpilib.XboxController(port: int)

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 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(value: int)

Bases: pybind11_builtins.pybind11_object

Members:

kLeftX

kRightX

kLeftY

kRightY

kLeftTrigger

kRightTrigger

kLeftTrigger = <Axis.kLeftTrigger: 2>
kLeftX = <Axis.kLeftX: 0>
kLeftY = <Axis.kLeftY: 1>
kRightTrigger = <Axis.kRightTrigger: 3>
kRightX = <Axis.kRightX: 4>
kRightY = <Axis.kRightY: 5>
property name
property value
class Button(value: int)

Bases: pybind11_builtins.pybind11_object

Members:

kBumperLeft

kBumperRight

kStickLeft

kStickRight

kA

kB

kX

kY

kBack

kStart

kA = <Button.kA: 1>
kB = <Button.kB: 2>
kBack = <Button.kBack: 7>
kBumperLeft = <Button.kBumperLeft: 5>
kBumperRight = <Button.kBumperRight: 6>
kStart = <Button.kStart: 8>
kStickLeft = <Button.kStickLeft: 9>
kStickRight = <Button.kStickRight: 10>
kX = <Button.kX: 3>
kY = <Button.kY: 4>
property name
property value
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.

getBumper(hand: wpilib.interfaces._interfaces.GenericHID.Hand)bool

Read the value of the bumper button on the controller.

Parameters

hand – Side of controller whose value should be returned.

getBumperPressed(hand: wpilib.interfaces._interfaces.GenericHID.Hand)bool

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(hand: wpilib.interfaces._interfaces.GenericHID.Hand)bool

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.

getStartButton()bool

Read the value of the start button on the controller.

Parameters

hand – Side of controller whose value should be returned.

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.

getStickButton(hand: wpilib.interfaces._interfaces.GenericHID.Hand)bool

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(hand: wpilib.interfaces._interfaces.GenericHID.Hand)bool

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(hand: wpilib.interfaces._interfaces.GenericHID.Hand)bool

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.

getTriggerAxis(hand: wpilib.interfaces._interfaces.GenericHID.Hand)float

Get the trigger axis value of the controller.

Parameters

hand – Side of controller whose value should be returned.

getX(hand: wpilib.interfaces._interfaces.GenericHID.Hand)float

Get the X axis value of the controller.

Parameters

hand – Side of controller whose value should be returned.

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.

getY(hand: wpilib.interfaces._interfaces.GenericHID.Hand)float

Get the Y axis value of the controller.

Parameters

hand – Side of controller whose value should be returned.

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.