NiDsXboxController
- class wpilib.NiDsXboxController(*args, **kwargs)
-
Handle input from NiDsXbox controllers connected to the Driver Station.
This class handles NiDsXbox 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 Microsoft 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.NiDsXboxController, 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.NiDsXboxController, 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 NiDsXboxController.
- LEFT_TRIGGER = 2
- LEFT_X = 0
- LEFT_Y = 1
- RIGHT_TRIGGER = 3
- RIGHT_X = 4
- RIGHT_Y = 5
- class Button
Bases:
pybind11_objectRepresents a digital button on an NiDsXboxController.
- A = 0
- B = 1
- BACK = 6
- LEFT_BUMPER = 4
- LEFT_STICK = 8
- RIGHT_BUMPER = 5
- RIGHT_STICK = 9
- START = 7
- X = 2
- Y = 3
- 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.
- 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.
- back(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the back button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the back 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_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_back_button() bool
Read the value of the back button on the controller.
- Returns:
The state of the button.
- get_back_button_pressed() bool
Whether the back button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_back_button_released() bool
Whether the back 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_left_bumper_button() bool
Read the value of the left bumper button on the controller.
- Returns:
The state of the button.
- get_left_bumper_button_pressed() bool
Whether the left bumper button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_left_bumper_button_released() bool
Whether the left bumper 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_trigger_axis() float
Get the left trigger 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_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_port() int
Get the port number of the controller.
- Returns:
The port number of the controller.
- get_right_bumper_button() bool
Read the value of the right bumper button on the controller.
- Returns:
The state of the button.
- get_right_bumper_button_pressed() bool
Whether the right bumper button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_right_bumper_button_released() bool
Whether the right bumper 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_trigger_axis() float
Get the right trigger 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_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.
- get_start_button() bool
Read the value of the start button on the controller.
- Returns:
The state of the button.
- get_start_button_pressed() bool
Whether the start button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- get_start_button_released() bool
Whether the start 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_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.
- init_sendable(builder: wpiutil._wpiutil.SendableBuilder) None
- is_connected() bool
Get if the controller is connected.
- Returns:
true if the controller is connected
- left_bumper(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the left bumper button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the left bumper 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.
- left_trigger(*args, **kwargs)
Overloaded function.
left_trigger(self: wpilib._wpilib.NiDsXboxController, threshold: typing.SupportsFloat | typing.SupportsIndex, loop: wpilib._wpilib.EventLoop) -> wpilib._wpilib.BooleanEvent
Constructs an event instance around the axis value of the left trigger. The returned trigger will be true when the axis value is greater than
threshold.- Parameters:
threshold – the minimum axis value for the returned event 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 event to.
- Returns:
an event instance that is true when the left trigger’s axis exceeds the provided threshold, attached to the given event loop
left_trigger(self: wpilib._wpilib.NiDsXboxController, loop: wpilib._wpilib.EventLoop) -> wpilib._wpilib.BooleanEvent
Constructs an event instance around the axis value of the left trigger. The returned trigger will be true when the axis value is greater than 0.5.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance that is true when the left trigger’s axis exceeds 0.5, attached to the given event loop
- right_bumper(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the right bumper button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the right bumper 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.
- right_trigger(*args, **kwargs)
Overloaded function.
right_trigger(self: wpilib._wpilib.NiDsXboxController, threshold: typing.SupportsFloat | typing.SupportsIndex, loop: wpilib._wpilib.EventLoop) -> wpilib._wpilib.BooleanEvent
Constructs an event instance around the axis value of the right trigger. The returned trigger will be true when the axis value is greater than
threshold.- Parameters:
threshold – the minimum axis value for the returned event 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 event to.
- Returns:
an event instance that is true when the right trigger’s axis exceeds the provided threshold, attached to the given event loop
right_trigger(self: wpilib._wpilib.NiDsXboxController, loop: wpilib._wpilib.EventLoop) -> wpilib._wpilib.BooleanEvent
Constructs an event instance around the axis value of the right trigger. The returned trigger will be true when the axis value is greater than 0.5.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance that is true when the right trigger’s axis exceeds 0.5, attached to the given event 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
- start(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the start button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the start button’s digital signal attached to the given loop.
- 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.