SwitchProController
- class wpilib.SwitchProController(*args, **kwargs)
-
Handle input from SwitchPro controllers connected to the Driver Station.
This class handles SwitchPro input that comes from the Driver Station. Each time a value is requested the most recent value is returned.
Overloaded function.
__init__(self: wpilib._wpilib.SwitchProController, 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.
__init__(self: wpilib._wpilib.SwitchProController, 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(value: SupportsInt | SupportsIndex)
Bases:
pybind11_objectRepresents an axis on a SwitchProController.
Members:
LEFT_X : Left X.
LEFT_Y : Left Y.
RIGHT_X : Right X.
RIGHT_Y : Right Y.
ZL : ZL.
ZR : ZR.
- LEFT_X = <Axis.LEFT_X: 0>
- LEFT_Y = <Axis.LEFT_Y: 1>
- RIGHT_X = <Axis.RIGHT_X: 2>
- RIGHT_Y = <Axis.RIGHT_Y: 3>
- ZL = <Axis.ZL: 4>
- ZR = <Axis.ZR: 5>
- SwitchProController.Axis.name -> str
- property value
- class Button(value: SupportsInt | SupportsIndex)
Bases:
pybind11_objectRepresents a digital button on a SwitchProController.
Members:
B : B button.
A : A button.
Y : Y button.
X : X button.
MINUS : Minus button.
HOME : Home button.
PLUS : Plus button.
LEFT_STICK : Left Stick button.
RIGHT_STICK : Right Stick button.
L : L button.
R : R button.
DPAD_UP : Dpad Up button.
DPAD_DOWN : Dpad Down button.
DPAD_LEFT : Dpad Left button.
DPAD_RIGHT : Dpad Right button.
CAPTURE : Capture button.
- A = <Button.A: 1>
- B = <Button.B: 0>
- CAPTURE = <Button.CAPTURE: 15>
- DPAD_DOWN = <Button.DPAD_DOWN: 12>
- DPAD_LEFT = <Button.DPAD_LEFT: 13>
- DPAD_RIGHT = <Button.DPAD_RIGHT: 14>
- DPAD_UP = <Button.DPAD_UP: 11>
- HOME = <Button.HOME: 5>
- L = <Button.L: 9>
- LEFT_STICK = <Button.LEFT_STICK: 7>
- MINUS = <Button.MINUS: 4>
- PLUS = <Button.PLUS: 6>
- R = <Button.R: 10>
- RIGHT_STICK = <Button.RIGHT_STICK: 8>
- X = <Button.X: 3>
- Y = <Button.Y: 2>
- SwitchProController.Button.name -> str
- property value
- SUPPORTED_OUTPUTS = <SupportedOutputs.???: 9>
- SUPPORTS_MONO_LED = True
- SUPPORTS_RGB_LED = False
- SUPPORTS_RUMBLE = True
- SUPPORTS_TRIGGER_RUMBLE = False
- TOUCHPAD_COUNT = 0
- a(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the A button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the A button’s digital signal attached to the given loop.
- axis_greater_than(axis: wpilib._wpilib.SwitchProController.Axis, threshold: SupportsFloat | SupportsIndex, loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance that is true when the axis value is greater than threshold.
- Parameters:
axis – The axis to read.
threshold – The value above which this event should return true.
loop – the event loop instance to attach the event to.
- Returns:
an event instance that is true when the axis value is greater than the provided threshold.
- axis_less_than(axis: wpilib._wpilib.SwitchProController.Axis, threshold: SupportsFloat | SupportsIndex, loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance that is true when the axis value is less than threshold.
- Parameters:
axis – The axis to read.
threshold – The value below which this event should return true.
loop – the event loop instance to attach the event to.
- Returns:
an event instance that is true when the axis value is less than the provided threshold.
- b(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the B button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the B button’s digital signal attached to the given loop.
- button(button: wpilib._wpilib.SwitchProController.Button, loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around this button’s digital signal.
- Parameters:
button – the button
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the button’s digital signal attached to the given loop.
- capture(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Capture button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Capture button’s digital signal attached to the given loop.
- dpad_down(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Dpad Down button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Dpad Down button’s digital signal attached to the given loop.
- dpad_left(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Dpad Left button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Dpad Left button’s digital signal attached to the given loop.
- dpad_right(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Dpad Right button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Dpad Right button’s digital signal attached to the given loop.
- dpad_up(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Dpad Up button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Dpad Up button’s digital signal attached to the given loop.
- get_a_button() bool
Read the value of the A button on the controller.
- Returns:
The state of the button.
- get_a_button_pressed() bool
Whether the A button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_a_button_released() bool
Whether the A button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_axis(axis: wpilib._wpilib.SwitchProController.Axis) float
Get the value of the axis.
- Parameters:
axis – The axis to read
- Returns:
the axis value.
- get_b_button() bool
Read the value of the B button on the controller.
- Returns:
The state of the button.
- get_b_button_pressed() bool
Whether the B button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_b_button_released() bool
Whether the B button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_button(button: wpilib._wpilib.SwitchProController.Button) bool
Get the button value.
- Parameters:
button – The button to read
- Returns:
The state of the button.
- get_button_pressed(button: wpilib._wpilib.SwitchProController.Button) bool
Whether the button was pressed since the last check.
- Parameters:
button – The button to read
- Returns:
Whether the button was pressed since the last check.
- get_button_released(button: wpilib._wpilib.SwitchProController.Button) bool
Whether the button was released since the last check.
- Parameters:
button – The button to read
- Returns:
Whether the button was released since the last check.
- get_capture_button() bool
Read the value of the Capture button on the controller.
- Returns:
The state of the button.
- get_capture_button_pressed() bool
Whether the Capture button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_capture_button_released() bool
Whether the Capture button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_dpad_down_button() bool
Read the value of the Dpad Down button on the controller.
- Returns:
The state of the button.
- get_dpad_down_button_pressed() bool
Whether the Dpad Down button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_dpad_down_button_released() bool
Whether the Dpad Down button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_dpad_left_button() bool
Read the value of the Dpad Left button on the controller.
- Returns:
The state of the button.
- get_dpad_left_button_pressed() bool
Whether the Dpad Left button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_dpad_left_button_released() bool
Whether the Dpad Left button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_dpad_right_button() bool
Read the value of the Dpad Right button on the controller.
- Returns:
The state of the button.
- get_dpad_right_button_pressed() bool
Whether the Dpad Right button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_dpad_right_button_released() bool
Whether the Dpad Right button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_dpad_up_button() bool
Read the value of the Dpad Up button on the controller.
- Returns:
The state of the button.
- get_dpad_up_button_pressed() bool
Whether the Dpad Up button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_dpad_up_button_released() bool
Whether the Dpad Up button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_hid() wpilib._wpilib.GenericHID
Get the underlying GenericHID object.
- Returns:
the wrapped GenericHID object
- get_home_button() bool
Read the value of the Home button on the controller.
- Returns:
The state of the button.
- get_home_button_pressed() bool
Whether the Home button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_home_button_released() bool
Whether the Home button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_l_button() bool
Read the value of the L button on the controller.
- Returns:
The state of the button.
- get_l_button_pressed() bool
Whether the L button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_l_button_released() bool
Whether the L button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_left_stick_button() bool
Read the value of the Left Stick button on the controller.
- Returns:
The state of the button.
- get_left_stick_button_pressed() bool
Whether the Left Stick button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_left_stick_button_released() bool
Whether the 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 Left X value of the controller.
- Returns:
the axis value.
- get_left_y() float
Get the Left Y value of the controller.
- Returns:
the axis value.
- get_minus_button() bool
Read the value of the Minus button on the controller.
- Returns:
The state of the button.
- get_minus_button_pressed() bool
Whether the Minus button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_minus_button_released() bool
Whether the Minus button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_plus_button() bool
Read the value of the Plus button on the controller.
- Returns:
The state of the button.
- get_plus_button_pressed() bool
Whether the Plus button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_plus_button_released() bool
Whether the Plus 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 HID.
- Returns:
The port number of the HID.
- get_r_button() bool
Read the value of the R button on the controller.
- Returns:
The state of the button.
- get_r_button_pressed() bool
Whether the R button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_r_button_released() bool
Whether the R button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_right_stick_button() bool
Read the value of the Right Stick button on the controller.
- Returns:
The state of the button.
- get_right_stick_button_pressed() bool
Whether the Right Stick button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_right_stick_button_released() bool
Whether the 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 Right X value of the controller.
- Returns:
the axis value.
- get_right_y() float
Get the Right Y value of the controller.
- Returns:
the axis value.
- get_x_button() bool
Read the value of the X button on the controller.
- Returns:
The state of the button.
- get_x_button_pressed() bool
Whether the X button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_x_button_released() bool
Whether the X button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_y_button() bool
Read the value of the Y button on the controller.
- Returns:
The state of the button.
- get_y_button_pressed() bool
Whether the Y button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_y_button_released() bool
Whether the Y button was released since the last check.
- Returns:
Whether the button was released since the last check.
- get_zl() float
Get the ZL value of the controller.
- Returns:
the axis value.
- get_zr() float
Get the ZR value of the controller.
- Returns:
the axis value.
- home(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Home button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Home button’s digital signal attached to the given loop.
- init_sendable(builder: wpiutil._wpiutil.SendableBuilder) None
- is_connected() bool
Get if the HID is connected.
- Returns:
true if the HID is connected
- l(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the L button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the L button’s digital signal attached to the given loop.
- left_stick(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Left Stick button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Left Stick button’s digital signal attached to the given loop.
- minus(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Minus button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Minus button’s digital signal attached to the given loop.
- plus(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Plus button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Plus button’s digital signal attached to the given loop.
- r(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the R button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the R button’s digital signal attached to the given loop.
- right_stick(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Right Stick button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Right Stick button’s digital signal attached to the given loop.
- set_leds(r: SupportsInt | SupportsIndex, g: SupportsInt | SupportsIndex, b: SupportsInt | SupportsIndex) None
Set leds on the controller.
- Parameters:
r – Red value from 0-255
g – Green value from 0-255
b – Blue value from 0-255
- set_rumble(type: wpilib._wpilib.GenericHID.RumbleType, value: SupportsFloat | SupportsIndex) None
Set the rumble output for the HID.
- Parameters:
type – Which rumble value to set
value – The normalized value (0 to 1) to set the rumble to
- x(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the X button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the X button’s digital signal attached to the given loop.
- y(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Y button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Y button’s digital signal attached to the given loop.