CommandDualSenseController

class commands2.button.CommandDualSenseController(hid: int | DualSenseController)[source]

Bases: object

A version of wpilib.DualSenseController with Trigger factories for command-based.

Construct an instance of a controller.

Parameters:

hid – The port index on the Driver Station that the controller is plugged into, or the DualSenseController object to use for this controller.

axis_greater_than(axis: Axis, threshold: float, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance that is true when the axis value is greater than threshold, attached to the given loop.

Parameters:
  • axis – the wpilib.DualSenseController.Axis to read

  • threshold – the value above which this Trigger should return true.

  • loop – the event loop instance to attach the Trigger to.

Returns:

a Trigger instance that is true when the axis value is greater than the provided threshold.

axis_less_than(axis: Axis, threshold: float, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance that is true when the axis value is less than threshold, attached to the given loop.

Parameters:
  • axis – the wpilib.DualSenseController.Axis to read

  • threshold – the value below which this Trigger should return true.

  • loop – the event loop instance to attach the Trigger to

Returns:

a Trigger instance that is true when the axis value is less than the provided threshold.

axis_magnitude_greater_than(axis: Axis, threshold: float, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance that is true when the axis magnitude is greater than threshold, attached to the given loop.

Parameters:
  • axis – the wpilib.DualSenseController.Axis to read

  • threshold – the value above which this Trigger should return true.

  • loop – the event loop instance to attach the Trigger to.

Returns:

a Trigger instance that is true when the axis magnitude is greater than the provided threshold.

button(button: Button, loop: EventLoop | None = None) Trigger[source]

Constructs an event instance around this button’s digital signal.

Parameters:
circle(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Circle button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Circle button’s digital signal attached to the given loop.

create(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Create button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Create button’s digital signal attached to the given loop.

cross(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Cross button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Cross button’s digital signal attached to the given loop.

dpad_down(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Dpad Down button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Dpad Down button’s digital signal attached to the given loop.

dpad_left(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Dpad Left button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Dpad Left button’s digital signal attached to the given loop.

dpad_right(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Dpad Right button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Dpad Right button’s digital signal attached to the given loop.

dpad_up(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Dpad Up button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Dpad Up button’s digital signal attached to the given loop.

get_axis(axis: Axis) float[source]

Get the value of the axis.

Parameters:

axis – the wpilib.DualSenseController.Axis to read

get_controller() DualSenseController[source]

Get the wrapped controller object.

Returns:

the wrapped controller object

get_hid() CommandGenericHID[source]

Get the underlying CommandGenericHID object.

Returns:

the wrapped CommandGenericHID object

get_l2() float[source]

Get the L2 value of the controller.

Returns:

the axis value.

get_left_x() float[source]

Get the Left X value of the controller.

Returns:

the axis value.

get_left_y() float[source]

Get the Left Y value of the controller.

Returns:

the axis value.

get_r2() float[source]

Get the R2 value of the controller.

Returns:

the axis value.

get_right_x() float[source]

Get the Right X value of the controller.

Returns:

the axis value.

get_right_y() float[source]

Get the Right Y value of the controller.

Returns:

the axis value.

l1(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the L1 button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the L1 button’s digital signal attached to the given loop.

l2(threshold: float = 0.5, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the L2 axis value. The returned Trigger will be true when the axis value is greater than threshold.

Parameters:
  • threshold – the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.

  • loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance that is true when the L2 axis exceeds the provided threshold, attached to the given event loop.

l3(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the L3 button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the L3 button’s digital signal attached to the given loop.

microphone(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Microphone button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Microphone button’s digital signal attached to the given loop.

options(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Options button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Options button’s digital signal attached to the given loop.

ps(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the PS button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the PS button’s digital signal attached to the given loop.

r1(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the R1 button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the R1 button’s digital signal attached to the given loop.

r2(threshold: float = 0.5, loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the R2 axis value. The returned Trigger will be true when the axis value is greater than threshold.

Parameters:
  • threshold – the minimum axis value for the returned Trigger to be true. This value should be in the range [0, 1] where 0 is the unpressed state of the axis.

  • loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance that is true when the R2 axis exceeds the provided threshold, attached to the given event loop.

r3(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the R3 button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the R3 button’s digital signal attached to the given loop.

square(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Square button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Square button’s digital signal attached to the given loop.

touchpad(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Touchpad button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Touchpad button’s digital signal attached to the given loop.

triangle(loop: EventLoop | None = None) Trigger[source]

Constructs a Trigger instance around the Triangle button’s digital signal.

Parameters:

loop – the event loop instance to attach the Trigger to, defaults to commands2.CommandScheduler.get_default_button_loop()

Returns:

a Trigger instance representing the Triangle button’s digital signal attached to the given loop.