NiDsPS4Controller
- class wpilib.NiDsPS4Controller(*args, **kwargs)
-
Handle input from NiDsPS4 controllers connected to the Driver Station.
This class handles NiDsPS4 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.
Overloaded function.
__init__(self: wpilib._wpilib.NiDsPS4Controller, port: typing.SupportsInt | typing.SupportsIndex) -> None
Construct an instance of a 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).
__init__(self: wpilib._wpilib.NiDsPS4Controller, hid: wpilib._wpilib.GenericHID) -> None
Construct an instance of a controller with a GenericHID object.
- Parameters:
hid – The GenericHID object to use for this controller.
- class Axis
Bases:
pybind11_objectRepresents an axis on an NiDsPS4Controller.
- L2 = 3
- LEFT_X = 0
- LEFT_Y = 1
- R2 = 4
- RIGHT_X = 2
- RIGHT_Y = 5
- class Button
Bases:
pybind11_objectRepresents a digital button on an NiDsPS4Controller.
- CIRCLE = 2
- CROSS = 1
- L1 = 4
- L2 = 6
- L3 = 10
- OPTIONS = 9
- PS = 12
- R1 = 5
- R2 = 7
- R3 = 11
- SHARE = 8
- SQUARE = 0
- TOUCHPAD = 13
- TRIANGLE = 3
- circle(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- cross(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- get_circle_button() bool
Read the value of the circle button on the controller.
- Returns:
The state of the button.
- get_circle_button_pressed() bool
Whether the circle button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_circle_button_released() bool
Whether the circle button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_cross_button() bool
Read the value of the cross button on the controller.
- Returns:
The state of the button.
- get_cross_button_pressed() bool
Whether the cross button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_cross_button_released() bool
Whether the cross button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_gamepad_type() wpilib._wpilib.GenericHID.HIDType
Get the type of the controller.
- Returns:
the type of the controller.
- get_hid() wpilib._wpilib.GenericHID
Get the underlying GenericHID object.
- Returns:
the wrapped GenericHID object
- get_l1_button() bool
Read the value of the left trigger 1 button on the controller.
- Returns:
The state of the button.
- get_l1_button_pressed() bool
Whether the left trigger 1 button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_l1_button_released() bool
Whether the left trigger 1 button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_l2_axis() float
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.
- get_l2_button() bool
Read the value of the left trigger 2 button on the controller.
- Returns:
The state of the button.
- get_l2_button_pressed() bool
Whether the left trigger 2 button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_l2_button_released() bool
Whether the left trigger 2 button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_l3_button() bool
Read the value of the L3 (left stick) button on the controller.
- Returns:
The state of the button.
- get_l3_button_pressed() bool
Whether the L3 (left stick) button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_l3_button_released() bool
Whether the L3 (left stick) button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_left_x() float
Get the X axis value of left side of the controller. Right is positive.
- Returns:
the axis value.
- get_left_y() float
Get the Y axis value of left side of the controller. Back is positive.
- Returns:
the axis value.
- get_name() str
Get the name of the controller.
- Returns:
the name of the controller.
- get_options_button() bool
Read the value of the options button on the controller.
- Returns:
The state of the button.
- get_options_button_pressed() bool
Whether the options button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_options_button_released() bool
Whether the options button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_port() int
Get the port number of the controller.
- Returns:
The port number of the controller.
- get_ps_button() bool
Read the value of the PlayStation button on the controller.
- Returns:
The state of the button.
- get_ps_button_pressed() bool
Whether the PlayStation button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_ps_button_released() bool
Whether the PlayStation button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_r1_button() bool
Read the value of the right trigger 1 button on the controller.
- Returns:
The state of the button.
- get_r1_button_pressed() bool
Whether the right trigger 1 button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_r1_button_released() bool
Whether the right trigger 1 button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_r2_axis() float
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.
- get_r2_button() bool
Read the value of the right trigger 2 button on the controller.
- Returns:
The state of the button.
- get_r2_button_pressed() bool
Whether the right trigger 2 button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_r2_button_released() bool
Whether the right trigger 2 button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_r3_button() bool
Read the value of the R3 (right stick) button on the controller.
- Returns:
The state of the button.
- get_r3_button_pressed() bool
Whether the R3 (right stick) button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_r3_button_released() bool
Whether the R3 (right stick) button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_right_x() float
Get the X axis value of right side of the controller. Right is positive.
- Returns:
the axis value.
- get_right_y() float
Get the Y axis value of right side of the controller. Back is positive.
- Returns:
the axis value.
Read the value of the share button on the controller.
- Returns:
The state of the button.
Whether the share button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
Whether the share button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_square_button() bool
Read the value of the square button on the controller.
- Returns:
The state of the button.
- get_square_button_pressed() bool
Whether the square button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_square_button_released() bool
Whether the square button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_supported_outputs() wpilib._wpilib.GenericHID.SupportedOutputs
Get the supported outputs of the controller.
- Returns:
the supported outputs of the controller.
- get_touchpad_button() bool
Read the value of the touchpad button on the controller.
- Returns:
The state of the button.
- get_touchpad_button_pressed() bool
Whether the touchpad button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_touchpad_button_released() bool
Whether the touchpad button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_triangle_button() bool
Read the value of the triangle button on the controller.
- Returns:
The state of the button.
- get_triangle_button_pressed() bool
Whether the triangle button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_triangle_button_released() bool
Whether the triangle button was released since the last check.
- Returns:
Whether the button was released since the last check.
- init_sendable(builder: wpiutil._wpiutil.SendableBuilder) None
- is_connected() bool
Get if the controller is connected.
- Returns:
true if the controller is connected
- l1(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- l2(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- l3(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- options(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- ps(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- r1(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- r2(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- r3(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- set_rumble(type: wpilib._wpilib.GenericHID.RumbleType, value: SupportsFloat | SupportsIndex) None
Set the rumble output for the HID.
The DS currently supports 4 rumble values: left rumble, right rumble, left trigger rumble, and right trigger rumble.
- Parameters:
type – Which rumble value to set
value – The normalized value (0 to 1) to set the rumble to
Constructs an event instance around the share button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the share button’s digital signal attached to the given loop.
- square(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- touchpad(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.
- triangle(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
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.