Package edu.wpi.first.wpilibj
Class PS5Controller
java.lang.Object
edu.wpi.first.wpilibj.GenericHID
edu.wpi.first.wpilibj.PS5Controller
- All Implemented Interfaces:
Sendable
Handle input from PS5 controllers connected to the Driver Station.
This class handles PS5 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.
Only first party controllers from Sony are guaranteed to have the correct mapping, and only through the official NI DS. Sim is not guaranteed to have the same mapping, as well as any 3rd party controllers.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
Represents an axis on an PS5Controller.static enum
Represents a digital button on a PS5Controller.Nested classes/interfaces inherited from class edu.wpi.first.wpilibj.GenericHID
GenericHID.HIDType, GenericHID.RumbleType
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionConstructs an event instance around the circle button's digital signal.Constructs an event instance around the create button's digital signal.Constructs an event instance around the cross button's digital signal.boolean
Read the value of the circle button on the controller.boolean
Whether the circle button was pressed since the last check.boolean
Whether the circle button was released since the last check.boolean
Read the value of the create button on the controller.boolean
Whether the create button was pressed since the last check.boolean
Whether the create button was released since the last check.boolean
Read the value of the cross button on the controller.boolean
Whether the cross button was pressed since the last check.boolean
Whether the cross button was released since the last check.boolean
Read the value of the left trigger 1 button on the controller.boolean
Whether the left trigger 1 button was pressed since the last check.boolean
Whether the left trigger 1 button was released since the last check.double
Get the left trigger 2 axis value of the controller.boolean
Read the value of the left trigger 2 button on the controller.boolean
Whether the left trigger 2 button was pressed since the last check.boolean
Whether the left trigger 2 button was released since the last check.boolean
Read the value of the L3 (left stick) button on the controller.boolean
Whether the L3 (left stick) button was pressed since the last check.boolean
Whether the L3 (left stick) button was released since the last check.double
getLeftX()
Get the X axis value of left side of the controller.double
getLeftY()
Get the Y axis value of left side of the controller.boolean
Read the value of the options button on the controller.boolean
Whether the options button was pressed since the last check.boolean
Whether the options button was released since the last check.boolean
Read the value of the PlayStation button on the controller.boolean
Whether the PlayStation button was pressed since the last check.boolean
Whether the PlayStation button was released since the last check.boolean
Read the value of the right trigger 1 button on the controller.boolean
Whether the right trigger 1 button was pressed since the last check.boolean
Whether the right trigger 1 button was released since the last check.double
Get the right trigger 2 axis value of the controller.boolean
Read the value of the right trigger 2 button on the controller.boolean
Whether the right trigger 2 button was pressed since the last check.boolean
Whether the right trigger 2 button was released since the last check.boolean
Read the value of the R3 (right stick) button on the controller.boolean
Whether the R3 (right stick) button was pressed since the last check.boolean
Whether the R3 (right stick) button was released since the last check.double
Get the X axis value of right side of the controller.double
Get the Y axis value of right side of the controller.boolean
Read the value of the square button on the controller.boolean
Whether the square button was pressed since the last check.boolean
Whether the square button was released since the last check.boolean
Deprecated, for removal: This API element is subject to removal in a future version.boolean
Read the value of the touchpad button on the controller.boolean
Whether the touchpad button was pressed since the last check.boolean
Whether the touchpad button was released since the last check.boolean
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTouchpadButtonPressed()
instead.boolean
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTouchpadButtonReleased()
instead.boolean
Read the value of the triangle button on the controller.boolean
Whether the triangle button was pressed since the last check.boolean
Whether the triangle button was released since the last check.void
initSendable
(SendableBuilder builder) Initializes thisSendable
object.Constructs an event instance around the left trigger 1 button's digital signal.Constructs an event instance around the left trigger 2 button's digital signal.Constructs an event instance around the L3 (left stick) button's digital signal.Constructs an event instance around the options button's digital signal.Constructs an event instance around the PlayStation button's digital signal.Constructs an event instance around the right trigger 1 button's digital signal.Constructs an event instance around the right trigger 2 button's digital signal.Constructs an event instance around the R3 (right stick) button's digital signal.Constructs an event instance around the square button's digital signal.Constructs an event instance around the touchpad button's digital signal.Constructs an event instance around the triangle button's digital signal.Methods inherited from class edu.wpi.first.wpilibj.GenericHID
axisGreaterThan, axisLessThan, button, getAxisCount, getAxisType, getButtonCount, getName, getPort, getPOV, getPOV, getPOVCount, getRawAxis, getRawButton, getRawButtonPressed, getRawButtonReleased, getType, isConnected, pov, pov, povCenter, povDown, povDownLeft, povDownRight, povLeft, povRight, povUp, povUpLeft, povUpRight, setOutput, setOutputs, setRumble
-
Constructor Details
-
PS5Controller
Construct an instance of a controller.- Parameters:
port
- The port index on the Driver Station that the controller is plugged into (0-5).
-
-
Method Details
-
getLeftX
Get the X axis value of left side of the controller.- Returns:
- The axis value.
-
getLeftY
Get the Y axis value of left side of the controller.- Returns:
- The axis value.
-
getRightX
Get the X axis value of right side of the controller.- Returns:
- The axis value.
-
getRightY
Get the Y axis value of right side of the controller.- Returns:
- The axis value.
-
getL2Axis
Get the left trigger 2 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.
-
getR2Axis
Get the right trigger 2 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.
-
getSquareButton
Read the value of the square button on the controller.- Returns:
- The state of the button.
-
getSquareButtonPressed
Whether the square button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getSquareButtonReleased
Whether the square button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
square
Constructs an event instance around the square button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the square button's digital signal attached to the given loop.
-
getCrossButton
Read the value of the cross button on the controller.- Returns:
- The state of the button.
-
getCrossButtonPressed
Whether the cross button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getCrossButtonReleased
Whether the cross button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
cross
Constructs an event instance around the cross button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the cross button's digital signal attached to the given loop.
-
getCircleButton
Read the value of the circle button on the controller.- Returns:
- The state of the button.
-
getCircleButtonPressed
Whether the circle button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getCircleButtonReleased
Whether the circle button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
circle
Constructs an event instance around the circle button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the circle button's digital signal attached to the given loop.
-
getTriangleButton
Read the value of the triangle button on the controller.- Returns:
- The state of the button.
-
getTriangleButtonPressed
Whether the triangle button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getTriangleButtonReleased
Whether the triangle button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
triangle
Constructs an event instance around the triangle button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the triangle button's digital signal attached to the given loop.
-
getL1Button
Read the value of the left trigger 1 button on the controller.- Returns:
- The state of the button.
-
getL1ButtonPressed
Whether the left trigger 1 button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getL1ButtonReleased
Whether the left trigger 1 button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
L1
Constructs an event instance around the left trigger 1 button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the left trigger 1 button's digital signal attached to the given loop.
-
getR1Button
Read the value of the right trigger 1 button on the controller.- Returns:
- The state of the button.
-
getR1ButtonPressed
Whether the right trigger 1 button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getR1ButtonReleased
Whether the right trigger 1 button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
R1
Constructs an event instance around the right trigger 1 button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the right trigger 1 button's digital signal attached to the given loop.
-
getL2Button
Read the value of the left trigger 2 button on the controller.- Returns:
- The state of the button.
-
getL2ButtonPressed
Whether the left trigger 2 button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getL2ButtonReleased
Whether the left trigger 2 button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
L2
Constructs an event instance around the left trigger 2 button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the left trigger 2 button's digital signal attached to the given loop.
-
getR2Button
Read the value of the right trigger 2 button on the controller.- Returns:
- The state of the button.
-
getR2ButtonPressed
Whether the right trigger 2 button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getR2ButtonReleased
Whether the right trigger 2 button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
R2
Constructs an event instance around the right trigger 2 button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the right trigger 2 button's digital signal attached to the given loop.
-
getCreateButton
Read the value of the create button on the controller.- Returns:
- The state of the button.
-
getCreateButtonPressed
Whether the create button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getCreateButtonReleased
Whether the create button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
create
Constructs an event instance around the create button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the create button's digital signal attached to the given loop.
-
getOptionsButton
Read the value of the options button on the controller.- Returns:
- The state of the button.
-
getOptionsButtonPressed
Whether the options button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getOptionsButtonReleased
Whether the options button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
options
Constructs an event instance around the options button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the options button's digital signal attached to the given loop.
-
getL3Button
Read the value of the L3 (left stick) button on the controller.- Returns:
- The state of the button.
-
getL3ButtonPressed
Whether the L3 (left stick) button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getL3ButtonReleased
Whether the L3 (left stick) button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
L3
Constructs an event instance around the L3 (left stick) button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the L3 (left stick) button's digital signal attached to the given loop.
-
getR3Button
Read the value of the R3 (right stick) button on the controller.- Returns:
- The state of the button.
-
getR3ButtonPressed
Whether the R3 (right stick) button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getR3ButtonReleased
Whether the R3 (right stick) button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
R3
Constructs an event instance around the R3 (right stick) button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the R3 (right stick) button's digital signal attached to the given loop.
-
getPSButton
Read the value of the PlayStation button on the controller.- Returns:
- The state of the button.
-
getPSButtonPressed
Whether the PlayStation button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getPSButtonReleased
Whether the PlayStation button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
PS
Constructs an event instance around the PlayStation button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the PlayStation button's digital signal attached to the given loop.
-
getTouchpadButton
Read the value of the touchpad button on the controller.- Returns:
- The state of the button.
-
getTouchpadButtonPressed
Whether the touchpad button was pressed since the last check.- Returns:
- Whether the button was pressed since the last check.
-
getTouchpadButtonReleased
Whether the touchpad button was released since the last check.- Returns:
- Whether the button was released since the last check.
-
touchpad
Constructs an event instance around the touchpad button's digital signal.- Parameters:
loop
- the event loop instance to attach the event to.- Returns:
- an event instance representing the touchpad button's digital signal attached to the given loop.
-
getTouchpad
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTouchpadButton()
instead. This function is deprecated for removal to make function names consistent to allow the HID classes to be automatically generated.Read the value of the touchpad on the controller.- Returns:
- The state of the touchpad.
-
getTouchpadPressed
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTouchpadButtonPressed()
instead. This function is deprecated for removal to make function names consistent to allow the HID classes to be automatically generated.Whether the touchpad was pressed since the last check.- Returns:
- Whether the touchpad was pressed since the last check.
-
getTouchpadReleased
Deprecated, for removal: This API element is subject to removal in a future version.UsegetTouchpadButtonReleased()
instead. This function is deprecated for removal to make function names consistent to allow the HID classes to be automatically generated.Whether the touchpad was released since the last check.- Returns:
- Whether the touchpad was released since the last check.
-
initSendable
Description copied from interface:Sendable
Initializes thisSendable
object.- Specified by:
initSendable
in interfaceSendable
- Parameters:
builder
- sendable builder
-
getTouchpadButton()
instead.