Source code for commands2.button.commandsteamcontroller

# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY

from typing import Optional, Union

from wpilib import EventLoop, SteamController

from .commandgenerichid import CommandGenericHID
from .trigger import Trigger


[docs] class CommandSteamController: """ A version of :class:`wpilib.SteamController` with :class:`.Trigger` factories for command-based. """ _hid: CommandGenericHID _controller: SteamController def __init__(self, hid: Union[int, SteamController]): """ Construct an instance of a controller. :param hid: The port index on the Driver Station that the controller is plugged into, or the SteamController object to use for this controller. """ if isinstance(hid, int): self._hid = CommandGenericHID.get_command_generic_hid(hid) self._controller = SteamController(self._hid.get_hid()) else: self._hid = CommandGenericHID(hid.get_hid()) self._controller = hid
[docs] def get_hid(self) -> CommandGenericHID: """ Get the underlying CommandGenericHID object. :returns: the wrapped CommandGenericHID object """ return self._hid
[docs] def get_controller(self) -> SteamController: """ Get the wrapped controller object. :returns: the wrapped controller object """ return self._controller
[docs] def button( self, button: SteamController.Button, loop: Optional[EventLoop] = None, ) -> Trigger: """ Constructs an event instance around this button's digital signal. :param button: the :class:`wpilib.SteamController.Button` to read :param loop: the event loop instance to attach the event to """ return self._hid.button(button.value, loop)
[docs] def a(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the A button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the A button's digital signal attached to the given loop. """ return self.button(SteamController.Button.A, loop)
[docs] def b(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the B button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the B button's digital signal attached to the given loop. """ return self.button(SteamController.Button.B, loop)
[docs] def x(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the X button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the X button's digital signal attached to the given loop. """ return self.button(SteamController.Button.X, loop)
[docs] def y(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Y button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Y button's digital signal attached to the given loop. """ return self.button(SteamController.Button.Y, loop)
[docs] def menu(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Menu button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Menu button's digital signal attached to the given loop. """ return self.button(SteamController.Button.MENU, loop)
[docs] def steam(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Steam button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Steam button's digital signal attached to the given loop. """ return self.button(SteamController.Button.STEAM, loop)
[docs] def view(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the View button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the View button's digital signal attached to the given loop. """ return self.button(SteamController.Button.VIEW, loop)
[docs] def left_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Left Stick button's digital signal attached to the given loop. """ return self.button(SteamController.Button.LEFT_STICK, loop)
[docs] def right_stick(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Right Stick button's digital signal attached to the given loop. """ return self.button(SteamController.Button.RIGHT_STICK, loop)
[docs] def left_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Left Bumper button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Left Bumper button's digital signal attached to the given loop. """ return self.button(SteamController.Button.LEFT_BUMPER, loop)
[docs] def right_bumper(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Right Bumper button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Right Bumper button's digital signal attached to the given loop. """ return self.button(SteamController.Button.RIGHT_BUMPER, loop)
[docs] def dpad_up(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Up button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Dpad Up button's digital signal attached to the given loop. """ return self.button(SteamController.Button.DPAD_UP, loop)
[docs] def dpad_down(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Down button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Dpad Down button's digital signal attached to the given loop. """ return self.button(SteamController.Button.DPAD_DOWN, loop)
[docs] def dpad_left(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Left button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Dpad Left button's digital signal attached to the given loop. """ return self.button(SteamController.Button.DPAD_LEFT, loop)
[docs] def dpad_right(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Dpad Right button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Dpad Right button's digital signal attached to the given loop. """ return self.button(SteamController.Button.DPAD_RIGHT, loop)
[docs] def qam(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the QAM button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the QAM button's digital signal attached to the given loop. """ return self.button(SteamController.Button.QAM, loop)
[docs] def right_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Right Paddle 1 button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Right Paddle 1 button's digital signal attached to the given loop. """ return self.button(SteamController.Button.RIGHT_PADDLE_1, loop)
[docs] def left_paddle1(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Left Paddle 1 button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Left Paddle 1 button's digital signal attached to the given loop. """ return self.button(SteamController.Button.LEFT_PADDLE_1, loop)
[docs] def right_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Right Paddle 2 button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Right Paddle 2 button's digital signal attached to the given loop. """ return self.button(SteamController.Button.RIGHT_PADDLE_2, loop)
[docs] def left_paddle2(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Left Paddle 2 button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Left Paddle 2 button's digital signal attached to the given loop. """ return self.button(SteamController.Button.LEFT_PADDLE_2, loop)
[docs] def left_touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Left Touchpad button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Left Touchpad button's digital signal attached to the given loop. """ return self.button(SteamController.Button.LEFT_TOUCHPAD, loop)
[docs] def right_touchpad(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Right Touchpad button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Right Touchpad button's digital signal attached to the given loop. """ return self.button(SteamController.Button.RIGHT_TOUCHPAD, loop)
[docs] def left_stick_touch(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Left Stick Touch button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Left Stick Touch button's digital signal attached to the given loop. """ return self.button(SteamController.Button.LEFT_STICK_TOUCH, loop)
[docs] def right_stick_touch(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Right Stick Touch button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Right Stick Touch button's digital signal attached to the given loop. """ return self.button(SteamController.Button.RIGHT_STICK_TOUCH, loop)
[docs] def left_grip_touch(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Left Grip Touch button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Left Grip Touch button's digital signal attached to the given loop. """ return self.button(SteamController.Button.LEFT_GRIP_TOUCH, loop)
[docs] def right_grip_touch(self, loop: Optional[EventLoop] = None) -> Trigger: """ Constructs a Trigger instance around the Right Grip Touch button's digital signal. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance representing the Right Grip Touch button's digital signal attached to the given loop. """ return self.button(SteamController.Button.RIGHT_GRIP_TOUCH, loop)
[docs] def left_trigger( self, threshold: float = 0.5, loop: Optional[EventLoop] = None, ) -> Trigger: """ Constructs a Trigger instance around the Left Trigger axis value. The returned Trigger will be true when the axis value is greater than ``threshold``. :param 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. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance that is true when the Left Trigger axis exceeds the provided threshold, attached to the given event loop. """ return self.axis_greater_than( SteamController.Axis.LEFT_TRIGGER, threshold, loop, )
[docs] def right_trigger( self, threshold: float = 0.5, loop: Optional[EventLoop] = None, ) -> Trigger: """ Constructs a Trigger instance around the Right Trigger axis value. The returned Trigger will be true when the axis value is greater than ``threshold``. :param 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. :param loop: the event loop instance to attach the Trigger to, defaults to :func:`commands2.CommandScheduler.get_default_button_loop` :returns: a Trigger instance that is true when the Right Trigger axis exceeds the provided threshold, attached to the given event loop. """ return self.axis_greater_than( SteamController.Axis.RIGHT_TRIGGER, threshold, loop, )
[docs] def axis_less_than( self, axis: SteamController.Axis, threshold: float, loop: Optional[EventLoop] = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is less than ``threshold``, attached to the given loop. :param axis: the :class:`wpilib.SteamController.Axis` to read :param threshold: the value below which this Trigger should return true. :param 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. """ return self._hid.axis_less_than(axis.value, threshold, loop)
[docs] def axis_greater_than( self, axis: SteamController.Axis, threshold: float, loop: Optional[EventLoop] = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis value is greater than ``threshold``, attached to the given loop. :param axis: the :class:`wpilib.SteamController.Axis` to read :param threshold: the value above which this Trigger should return true. :param 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. """ return self._hid.axis_greater_than(axis.value, threshold, loop)
[docs] def axis_magnitude_greater_than( self, axis: SteamController.Axis, threshold: float, loop: Optional[EventLoop] = None, ) -> Trigger: """ Constructs a Trigger instance that is true when the axis magnitude is greater than ``threshold``, attached to the given loop. :param axis: the :class:`wpilib.SteamController.Axis` to read :param threshold: the value above which this Trigger should return true. :param 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. """ return self._hid.axis_magnitude_greater_than(axis.value, threshold, loop)
[docs] def get_axis(self, axis: SteamController.Axis) -> float: """ Get the value of the axis. :param axis: the :class:`wpilib.SteamController.Axis` to read """ return self._hid.get_raw_axis(axis.value)
[docs] def get_left_x(self) -> float: """ Get the Left X value of the controller. :returns: the axis value. """ return self._controller.get_left_x()
[docs] def get_left_y(self) -> float: """ Get the Left Y value of the controller. :returns: the axis value. """ return self._controller.get_left_y()
[docs] def get_right_x(self) -> float: """ Get the Right X value of the controller. :returns: the axis value. """ return self._controller.get_right_x()
[docs] def get_right_y(self) -> float: """ Get the Right Y value of the controller. :returns: the axis value. """ return self._controller.get_right_y()
[docs] def get_left_trigger(self) -> float: """ Get the Left Trigger value of the controller. :returns: the axis value. """ return self._controller.get_left_trigger()
[docs] def get_right_trigger(self) -> float: """ Get the Right Trigger value of the controller. :returns: the axis value. """ return self._controller.get_right_trigger()