XboxController¶
-
class
wpilib.
XboxController
(port)[source]¶ Bases:
wpilib.interfaces.GenericHID
Handle input from Xbox 360 or Xbox One 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. 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.
Construct an instance of an XBoxController. The XBoxController index is the USB port on the Driver Station.
Parameters: port – The port on the Driver Station that the joystick is plugged into -
class
Button
[source]¶ Bases:
object
-
kA
= 1¶
-
kB
= 2¶
-
kBack
= 7¶
-
kBumperLeft
= 5¶
-
kBumperRight
= 6¶
-
kStart
= 8¶
-
kStickLeft
= 9¶
-
kStickRight
= 10¶
-
kX
= 3¶
-
kY
= 4¶
-
-
getAButton
()[source]¶ Read the value of the A button on the controller
Returns: The state of the A button Return type: boolean
-
getAButtonPressed
()[source]¶ Whether the A button was pressed since the last check.
Returns: Whether the button was pressed since the last check.
-
getAButtonReleased
()[source]¶ Whether the A button was released since the last check.
Returns: Whether the button was released since the last check.
-
getBButton
()[source]¶ Read the value of the B button on the controller
Returns: The state of the B button Return type: boolean
-
getBButtonPressed
()[source]¶ Whether the B button was pressed since the last check.
Returns: Whether the button was pressed since the last check.
-
getBButtonReleased
()[source]¶ Whether the B button was released since the last check.
Returns: Whether the button was released since the last check.
-
getBackButton
()[source]¶ Read the value of the Back button on the controller
Returns: The state of the Back button Return type: boolean
-
getBackButtonPressed
()[source]¶ Whether the Back button was pressed since the last check.
Returns: Whether the button was pressed since the last check.
-
getBackButtonReleased
()[source]¶ Whether the Back button was released since the last check.
Returns: Whether the button was released since the last check.
-
getBumper
(hand)[source]¶ Read the values of the bumper button on the controller.
Parameters: hand – Side of controller whose value should be returned. Returns: The state of the button Return type: boolean
-
getBumperPressed
(hand)[source]¶ Whether the bumper was pressed since the last check.
Parameters: hand – Side of controller whose value should be returned. Returns: Whether the button was pressed since the last check.
-
getBumperReleased
(hand)[source]¶ Whether the bumper was released since the last check.
Parameters: hand – Side of controller whose value should be returned. Returns: Whether the button was released since the last check.
-
getStartButton
()[source]¶ Read the value of the Start button on the controller
Returns: The state of the Start button Return type: boolean
-
getStartButtonPressed
()[source]¶ Whether the Start button was pressed since the last check.
Returns: Whether the button was pressed since the last check.
-
getStartButtonReleased
()[source]¶ Whether the Start button was released since the last check.
Returns: Whether the button was released since the last check.
-
getStickButton
(hand)[source]¶ Read the values of the stick button on the controller
Parameters: hand – Side of the controller whose value should be returned Returns: The state of the button Return type: boolean
-
getStickButtonPressed
(hand)[source]¶ Whether the stick button was pressed since the last check.
Parameters: hand – Side of controller whose value should be returned. Returns: Whether the button was pressed since the last check.
-
getStickButtonReleased
(hand)[source]¶ Whether the stick button was released since the last check.
Parameters: hand – Side of controller whose value should be returned. Returns: Whether the button was released since the last check.
-
getTriggerAxis
(hand)[source]¶ Get the trigger axis value of the controller.
Parameters: hand – Side of controller whose value should be returned Returns: The trigger axis value of the controller Return type: float
-
getX
(hand)[source]¶ Get the X axis value of the controller.
Parameters: hand – Side of controller whose value should be returned Returns: The X axis value of the controller Return type: float
-
getXButton
()[source]¶ Read the value of the X button on the controller
Returns: The state of the X button Return type: boolean
-
getXButtonPressed
()[source]¶ Whether the X button was pressed since the last check.
Returns: Whether the button was pressed since the last check.
-
getXButtonReleased
()[source]¶ Whether the X button was released since the last check.
Returns: Whether the button was released since the last check.
-
getY
(hand)[source]¶ Get the Y axis value of the controller.
Parameters: hand – Side of controller whose value should be returned Returns: The Y axis value of the controller Return type: float
-
getYButton
()[source]¶ Read the value of the Y button on the controller
Returns: The state of the Y button Return type: boolean
-
class