XboxController
- class wpilib.XboxController(*args, **kwargs)
Bases:
HIDDevice,SendableHandle input from Xbox controllers connected to the Driver Station.
This class handles Xbox 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.XboxController, 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.XboxController, 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.
- 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.
- class Axis
Bases:
pybind11_objectRepresents an axis on a XboxController.
- LEFT_TRIGGER = 4
- LEFT_X = 0
- LEFT_Y = 1
- RIGHT_TRIGGER = 5
- RIGHT_X = 2
- RIGHT_Y = 3
- 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.
- class Button
Bases:
pybind11_objectRepresents a digital button on a XboxController.
- A = 0
- B = 1
- DPAD_DOWN = 12
- DPAD_LEFT = 13
- DPAD_RIGHT = 14
- DPAD_UP = 11
- LEFT_BUMPER = 9
- LEFT_STICK = 7
- MENU = 6
- RIGHT_BUMPER = 10
- RIGHT_STICK = 8
- VIEW = 4
- X = 2
- XBOX = 5
- Y = 3
- SUPPORTED_OUTPUTS = <SupportedOutputs.???: 24>
- SUPPORTS_MONO_LED = False
- SUPPORTS_RGB_LED = False
- SUPPORTS_RUMBLE = True
- SUPPORTS_TRIGGER_RUMBLE = True
- TOUCHPAD_COUNT = 0
- 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.
- axisGreaterThan(axis: SupportsInt | SupportsIndex, 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.
- axisLessThan(axis: SupportsInt | SupportsIndex, 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.
- button(button: SupportsInt | SupportsIndex, 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.
- dpadDown(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.
- dpadLeft(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.
- dpadRight(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.
- dpadUp(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.
- getAButton() bool
Read the value of the A button on the controller.
- Returns:
The state of the button.
- getAButtonPressed() bool
Whether the A button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getAButtonReleased() bool
Whether the A button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getAxis(axis: SupportsInt | SupportsIndex) float
Get the value of the axis.
- Parameters:
axis – The axis to read
- Returns:
the axis value.
- getBButton() bool
Read the value of the B button on the controller.
- Returns:
The state of the button.
- getBButtonPressed() bool
Whether the B button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getBButtonReleased() bool
Whether the B button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getButton(button: SupportsInt | SupportsIndex) bool
Get the button value.
- Parameters:
button – The button to read
- Returns:
The state of the button.
- getButtonPressed(button: SupportsInt | SupportsIndex) 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.
- getButtonReleased(button: SupportsInt | SupportsIndex) 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.
- getDpadDownButton() bool
Read the value of the Dpad Down button on the controller.
- Returns:
The state of the button.
- getDpadDownButtonPressed() bool
Whether the Dpad Down button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getDpadDownButtonReleased() bool
Whether the Dpad Down button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getDpadLeftButton() bool
Read the value of the Dpad Left button on the controller.
- Returns:
The state of the button.
- getDpadLeftButtonPressed() bool
Whether the Dpad Left button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getDpadLeftButtonReleased() bool
Whether the Dpad Left button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getDpadRightButton() bool
Read the value of the Dpad Right button on the controller.
- Returns:
The state of the button.
- getDpadRightButtonPressed() bool
Whether the Dpad Right button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getDpadRightButtonReleased() bool
Whether the Dpad Right button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getDpadUpButton() bool
Read the value of the Dpad Up button on the controller.
- Returns:
The state of the button.
- getDpadUpButtonPressed() bool
Whether the Dpad Up button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getDpadUpButtonReleased() bool
Whether the Dpad Up button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getHID() wpilib._wpilib.GenericHID
Get the underlying GenericHID object.
- Returns:
the wrapped GenericHID object
- getLeftBumperButton() bool
Read the value of the Left Bumper button on the controller.
- Returns:
The state of the button.
- getLeftBumperButtonPressed() bool
Whether the Left Bumper button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getLeftBumperButtonReleased() bool
Whether the Left Bumper button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getLeftStickButton() bool
Read the value of the Left Stick button on the controller.
- Returns:
The state of the button.
- getLeftStickButtonPressed() bool
Whether the Left Stick button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getLeftStickButtonReleased() bool
Whether the Left Stick button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getLeftTrigger() float
Get the Left Trigger value of the controller.
- Returns:
the axis value.
- getLeftX() float
Get the Left X value of the controller.
- Returns:
the axis value.
- getLeftY() float
Get the Left Y value of the controller.
- Returns:
the axis value.
- getMenuButton() bool
Read the value of the Menu button on the controller.
- Returns:
The state of the button.
- getMenuButtonPressed() bool
Whether the Menu button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getMenuButtonReleased() bool
Whether the Menu button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getPort() int
Get the port number of the HID.
- Returns:
The port number of the HID.
- getRightBumperButton() bool
Read the value of the Right Bumper button on the controller.
- Returns:
The state of the button.
- getRightBumperButtonPressed() bool
Whether the Right Bumper button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getRightBumperButtonReleased() bool
Whether the Right Bumper button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getRightStickButton() bool
Read the value of the Right Stick button on the controller.
- Returns:
The state of the button.
- getRightStickButtonPressed() bool
Whether the Right Stick button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getRightStickButtonReleased() bool
Whether the Right Stick button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getRightTrigger() float
Get the Right Trigger value of the controller.
- Returns:
the axis value.
- getRightX() float
Get the Right X value of the controller.
- Returns:
the axis value.
- getRightY() float
Get the Right Y value of the controller.
- Returns:
the axis value.
- getViewButton() bool
Read the value of the View button on the controller.
- Returns:
The state of the button.
- getViewButtonPressed() bool
Whether the View button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getViewButtonReleased() bool
Whether the View button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getXButton() bool
Read the value of the X button on the controller.
- Returns:
The state of the button.
- getXButtonPressed() bool
Whether the X button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getXButtonReleased() bool
Whether the X button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getXboxButton() bool
Read the value of the Xbox button on the controller.
- Returns:
The state of the button.
- getXboxButtonPressed() bool
Whether the Xbox button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getXboxButtonReleased() bool
Whether the Xbox button was released since the last check.
- Returns:
Whether the button was released since the last check.
- getYButton() bool
Read the value of the Y button on the controller.
- Returns:
The state of the button.
- getYButtonPressed() bool
Whether the Y button was pressed since the last check.
- Returns:
Whether the button was pressed since the last check.
- getYButtonReleased() bool
Whether the Y button was released since the last check.
- Returns:
Whether the button was released since the last check.
- initSendable(builder: wpiutil._wpiutil.SendableBuilder) None
- isConnected() bool
Get if the HID is connected.
- Returns:
true if the HID is connected
- leftBumper(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.
- leftStick(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.
Constructs an event instance around the Menu button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Menu button’s digital signal attached to the given loop.
- rightBumper(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.
- rightStick(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.
- setLeds(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
- setRumble(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
- view(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the View button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the View button’s digital signal attached to the given loop.
- xbox(loop: wpilib._wpilib.EventLoop) wpilib._wpilib.BooleanEvent
Constructs an event instance around the Xbox button’s digital signal.
- Parameters:
loop – the event loop instance to attach the event to.
- Returns:
an event instance representing the Xbox button’s digital signal attached to the given loop.