Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion rdev.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ wrapper = "2027.0.0a6.post1"

[params]

wpilib_bin_version = "2027.0.0-alpha-6-42-gfdc6fd9cb"
wpilib_bin_version = "2027.0.0-alpha-6-66-g489b993e6"
wpilib_bin_url = "https://frcmaven.wpi.edu/artifactory/development-2027"
# wpilib_bin_url = "https://frcmaven.wpi.edu/artifactory/development-2027"

Expand Down
4 changes: 4 additions & 0 deletions subprojects/pyntcore/semiwrap/Topic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ classes:
ignore: true
GetInstance:
GetName:
GetUserData:
ignore: true
SetUserData:
ignore: true
GetType:
GetTypeString:
SetPersistent:
Expand Down
6 changes: 6 additions & 0 deletions subprojects/robotpy-commands-v2/commands2/button/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,24 @@
from .commandgenerichid import CommandGenericHID
from .commanddualsensecontroller import CommandDualSenseController
from .commandgamepad import CommandGamepad
from .commandjoystick import CommandJoystick
from .commandnidsps4controller import CommandNiDsPS4Controller
from .commandnidsxboxcontroller import CommandNiDsXboxController
from .commandxboxcontroller import CommandXboxController
from .joystickbutton import JoystickButton
from .networkbutton import NetworkButton
from .povbutton import POVButton
from .trigger import Trigger

__all__ = [
"Trigger",
"CommandDualSenseController",
"CommandGenericHID",
"CommandGamepad",
"CommandJoystick",
"CommandNiDsPS4Controller",
"CommandNiDsXboxController",
"CommandXboxController",
"JoystickButton",
"NetworkButton",
"POVButton",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,354 @@
# THIS FILE WAS AUTO-GENERATED BY ./commandsv2/generate_hids.py. DO NOT MODIFY

from typing import Optional

from wpilib import EventLoop, DualSenseController

from .commandgenerichid import CommandGenericHID
from .trigger import Trigger


def _enum_value(value) -> int:
try:
return int(value)
except TypeError:
return value.value


class CommandDualSenseController:
"""
A version of :class:`wpilib.DualSenseController` with :class:`.Trigger` factories for command-based.
"""

_hid: CommandGenericHID
_controller: DualSenseController

def __init__(self, port: int):
"""
Construct an instance of a controller.

:param port: The port index on the Driver Station that the controller is plugged into.
"""
self._hid = CommandGenericHID.getCommandGenericHID(port)
self._controller = DualSenseController(self._hid.getHID())

def __getattr__(self, name: str):
return getattr(self._hid, name)

def getHID(self) -> CommandGenericHID:
"""
Get the underlying CommandGenericHID object.

:returns: the wrapped CommandGenericHID object
"""
return self._hid

def getController(self) -> DualSenseController:
"""
Get the wrapped controller object.

:returns: the wrapped controller object
"""
return self._controller

def cross(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Cross button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Cross button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.CROSS), loop)

def circle(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Circle button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Circle button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.CIRCLE), loop)

def square(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Square button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Square button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.SQUARE), loop)

def triangle(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Triangle button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Triangle button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.TRIANGLE), loop)

def create(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Create button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Create button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.CREATE), loop)

def PS(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the PS button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the PS button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.PS), loop)

def options(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Options button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Options button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.OPTIONS), loop)

def L3(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the L 3 button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the L 3 button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.L3), loop)

def R3(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the R 3 button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the R 3 button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.R3), loop)

def L1(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the L 1 button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the L 1 button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.L1), loop)

def R1(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the R 1 button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the R 1 button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.R1), loop)

def dpadUp(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.getDefaultButtonLoop`

:returns: a Trigger instance representing the Dpad Up button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.DPAD_UP), loop)

def dpadDown(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.getDefaultButtonLoop`

:returns: a Trigger instance representing the Dpad Down button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.DPAD_DOWN), loop)

def dpadLeft(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.getDefaultButtonLoop`

:returns: a Trigger instance representing the Dpad Left button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.DPAD_LEFT), loop)

def dpadRight(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.getDefaultButtonLoop`

:returns: a Trigger instance representing the Dpad Right button's digital signal
attached to the given loop.
"""
return self._hid.button(
_enum_value(DualSenseController.Button.DPAD_RIGHT), loop
)

def microphone(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Microphone button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Microphone button's digital signal
attached to the given loop.
"""
return self._hid.button(
_enum_value(DualSenseController.Button.MICROPHONE), loop
)

def touchpad(self, loop: Optional[EventLoop] = None) -> Trigger:
"""
Constructs a Trigger instance around the Touchpad button's digital signal.

:param loop: the event loop instance to attach the Trigger to, defaults
to :func:`commands2.CommandScheduler.getDefaultButtonLoop`

:returns: a Trigger instance representing the Touchpad button's digital signal
attached to the given loop.
"""
return self._hid.button(_enum_value(DualSenseController.Button.TOUCHPAD), loop)

def L2(
self,
threshold: float = 0.5,
loop: Optional[EventLoop] = None,
) -> Trigger:
"""
Constructs a Trigger instance around the L 2 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.getDefaultButtonLoop`

:returns: a Trigger instance that is true when the L 2 axis exceeds the
provided threshold, attached to the given event loop.
"""
return self._hid.axisGreaterThan(
_enum_value(DualSenseController.Axis.L2),
threshold,
loop,
)

def R2(
self,
threshold: float = 0.5,
loop: Optional[EventLoop] = None,
) -> Trigger:
"""
Constructs a Trigger instance around the R 2 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.getDefaultButtonLoop`

:returns: a Trigger instance that is true when the R 2 axis exceeds the
provided threshold, attached to the given event loop.
"""
return self._hid.axisGreaterThan(
_enum_value(DualSenseController.Axis.R2),
threshold,
loop,
)

def getLeftX(self) -> float:
"""
Get the Left X value of the controller.

:returns: the axis value.
"""
return self._controller.getLeftX()

def getLeftY(self) -> float:
"""
Get the Left Y value of the controller.

:returns: the axis value.
"""
return self._controller.getLeftY()

def getRightX(self) -> float:
"""
Get the Right X value of the controller.

:returns: the axis value.
"""
return self._controller.getRightX()

def getRightY(self) -> float:
"""
Get the Right Y value of the controller.

:returns: the axis value.
"""
return self._controller.getRightY()

def getL2(self) -> float:
"""
Get the L 2 value of the controller.

:returns: the axis value.
"""
return self._controller.getL2()

def getR2(self) -> float:
"""
Get the R 2 value of the controller.

:returns: the axis value.
"""
return self._controller.getR2()
Loading
Loading