PS4Controller

class wpilib.PS4Controller(port: int)

Bases: wpilib.interfaces._interfaces.GenericHID

Handle input from PS4 controllers connected to the Driver Station.

This class handles PS4 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 PS4 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

kL2 = 3
kLeftX = 0
kLeftY = 1
kR2 = 4
kRightX = 2
kRightY = 5
class Button

Bases: pybind11_builtins.pybind11_object

kCircle = 3
kCross = 2
kL1 = 5
kL2 = 7
kL3 = 11
kOptions = 10
kPS = 13
kR1 = 6
kR2 = 8
kR3 = 12
kShare = 9
kSquare = 1
kTouchpad = 14
kTriangle = 4
getCircleButton() bool

Read the value of the Circle button on the controller.

Returns

The state of the button.

getCircleButtonPressed() bool

Whether the Circle button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getCircleButtonReleased() bool

Whether the Circle button was released since the last check.

Returns

Whether the button was released since the last check.

getCrossButton() bool

Read the value of the Cross button on the controller.

Returns

The state of the button.

getCrossButtonPressed() bool

Whether the Cross button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getCrossButtonReleased() bool

Whether the Cross button was released since the last check.

Returns

Whether the button was released since the last check.

getL1Button() bool

Read the value of the L1 button on the controller.

Returns

The state of the button.

getL1ButtonPressed() bool

Whether the L1 button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getL1ButtonReleased() bool

Whether the L1 button was released since the last check.

Returns

Whether the button was released since the last check.

getL2Axis() float

Get the L2 axis value of the controller. Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].

Returns

the axis value.

getL2Button() bool

Read the value of the L2 button on the controller.

Returns

The state of the button.

getL2ButtonPressed() bool

Whether the L2 button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getL2ButtonReleased() bool

Whether the L2 button was released since the last check.

Returns

Whether the button was released since the last check.

getL3Button() bool

Read the value of the L3 button (pressing the left analog stick) on the controller.

Returns

The state of the button.

getL3ButtonPressed() bool

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

Returns

Whether the button was pressed since the last check.

getL3ButtonReleased() bool

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

Returns

Whether the button was released since the last check.

getLeftX() float

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

Returns

the axis value.

getLeftY() float

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

Returns

the axis value.

getOptionsButton() bool

Read the value of the Options button on the controller.

Returns

The state of the button.

getOptionsButtonPressed() bool

Whether the Options button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getOptionsButtonReleased() bool

Whether the Options button was released since the last check.

Returns

Whether the button was released since the last check.

getPSButton() bool

Read the value of the PS button on the controller.

Returns

The state of the button.

getPSButtonPressed() bool

Whether the PS button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getPSButtonReleased() bool

Whether the PS button was released since the last check.

Returns

Whether the button was released since the last check.

getR1Button() bool

Read the value of the R1 button on the controller.

Returns

The state of the button.

getR1ButtonPressed() bool

Whether the R1 button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getR1ButtonReleased() bool

Whether the R1 button was released since the last check.

Returns

Whether the button was released since the last check.

getR2Axis() float

Get the R2 axis value of the controller. Note that this axis is bound to the range of [0, 1] as opposed to the usual [-1, 1].

Returns

the axis value.

getR2Button() bool

Read the value of the R2 button on the controller.

Returns

The state of the button.

getR2ButtonPressed() bool

Whether the R2 button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getR2ButtonReleased() bool

Whether the R2 button was released since the last check.

Returns

Whether the button was released since the last check.

getR3Button() bool

Read the value of the R3 button (pressing the right analog stick) on the controller.

Returns

The state of the button.

getR3ButtonPressed() bool

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

Returns

Whether the button was pressed since the last check.

getR3ButtonReleased() bool

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

Returns

Whether the button was released since the last check.

getRightX() float

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

Returns

the axis value.

getRightY() float

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

Returns

the axis value.

getShareButton() bool

Read the value of the Share button on the controller.

Returns

The state of the button.

getShareButtonPressed() bool

Whether the Share button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getShareButtonReleased() bool

Whether the Share button was released since the last check.

Returns

Whether the button was released since the last check.

getSquareButton() bool

Read the value of the Square button on the controller.

Returns

The state of the button.

getSquareButtonPressed() bool

Whether the Square button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getSquareButtonReleased() bool

Whether the Square button was released since the last check.

Returns

Whether the button was released since the last check.

getTouchpad() bool

Read the value of the touchpad button on the controller.

Returns

The state of the button.

getTouchpadPressed() bool

Whether the touchpad was pressed since the last check.

Returns

Whether the touchpad was pressed since the last check.

getTouchpadReleased() bool

Whether the touchpad was released since the last check.

Returns

Whether the touchpad was released since the last check.

getTriangleButton() bool

Read the value of the Triangle button on the controller.

Returns

The state of the button.

getTriangleButtonPressed() bool

Whether the Triangle button was pressed since the last check.

Returns

Whether the button was pressed since the last check.

getTriangleButtonReleased() bool

Whether the Triangle button was released since the last check.

Returns

Whether the button was released since the last check.