|
WPILibC++
2020.3.2
|
Handle input from Xbox 360 or Xbox One controllers connected to the Driver Station. More...
#include <XboxController.h>
Public Types | |
| enum | Button { kBumperLeft = 5, kBumperRight = 6, kStickLeft = 9, kStickRight = 10, kA = 1, kB = 2, kX = 3, kY = 4, kBack = 7, kStart = 8 } |
| enum | Axis { kLeftX = 0, kRightX = 4, kLeftY = 1, kRightY = 5, kLeftTrigger = 2, kRightTrigger = 3 } |
Public Types inherited from frc::GenericHID | |
| enum | RumbleType { kLeftRumble, kRightRumble } |
| enum | HIDType { kUnknown = -1, kXInputUnknown = 0, kXInputGamepad = 1, kXInputWheel = 2, kXInputArcadeStick = 3, kXInputFlightStick = 4, kXInputDancePad = 5, kXInputGuitar = 6, kXInputGuitar2 = 7, kXInputDrumKit = 8, kXInputGuitar3 = 11, kXInputArcadePad = 19, kHIDJoystick = 20, kHIDGamepad = 21, kHIDDriving = 22, kHIDFlight = 23, kHID1stPerson = 24 } |
| enum | JoystickHand { kLeftHand = 0, kRightHand = 1 } |
Public Member Functions | |
| XboxController (int port) | |
| Construct an instance of an Xbox controller. More... | |
| XboxController (XboxController &&)=default | |
| XboxController & | operator= (XboxController &&)=default |
| double | GetX (JoystickHand hand) const override |
| Get the X axis value of the controller. More... | |
| double | GetY (JoystickHand hand) const override |
| Get the Y axis value of the controller. More... | |
| double | GetTriggerAxis (JoystickHand hand) const |
| Get the trigger axis value of the controller. More... | |
| bool | GetBumper (JoystickHand hand) const |
| Read the value of the bumper button on the controller. More... | |
| bool | GetBumperPressed (JoystickHand hand) |
| Whether the bumper was pressed since the last check. More... | |
| bool | GetBumperReleased (JoystickHand hand) |
| Whether the bumper was released since the last check. More... | |
| bool | GetStickButton (JoystickHand hand) const |
| Read the value of the stick button on the controller. More... | |
| bool | GetStickButtonPressed (JoystickHand hand) |
| Whether the stick button was pressed since the last check. More... | |
| bool | GetStickButtonReleased (JoystickHand hand) |
| Whether the stick button was released since the last check. More... | |
| bool | GetAButton () const |
| Read the value of the A button on the controller. More... | |
| bool | GetAButtonPressed () |
| Whether the A button was pressed since the last check. More... | |
| bool | GetAButtonReleased () |
| Whether the A button was released since the last check. More... | |
| bool | GetBButton () const |
| Read the value of the B button on the controller. More... | |
| bool | GetBButtonPressed () |
| Whether the B button was pressed since the last check. More... | |
| bool | GetBButtonReleased () |
| Whether the B button was released since the last check. More... | |
| bool | GetXButton () const |
| Read the value of the X button on the controller. More... | |
| bool | GetXButtonPressed () |
| Whether the X button was pressed since the last check. More... | |
| bool | GetXButtonReleased () |
| Whether the X button was released since the last check. More... | |
| bool | GetYButton () const |
| Read the value of the Y button on the controller. More... | |
| bool | GetYButtonPressed () |
| Whether the Y button was pressed since the last check. More... | |
| bool | GetYButtonReleased () |
| Whether the Y button was released since the last check. More... | |
| bool | GetBackButton () const |
| Whether the Y button was released since the last check. More... | |
| bool | GetBackButtonPressed () |
| Whether the back button was pressed since the last check. More... | |
| bool | GetBackButtonReleased () |
| Whether the back button was released since the last check. More... | |
| bool | GetStartButton () const |
| Read the value of the start button on the controller. More... | |
| bool | GetStartButtonPressed () |
| Whether the start button was pressed since the last check. More... | |
| bool | GetStartButtonReleased () |
| Whether the start button was released since the last check. More... | |
Public Member Functions inherited from frc::GenericHID | |
| GenericHID (int port) | |
| GenericHID (GenericHID &&)=default | |
| GenericHID & | operator= (GenericHID &&)=default |
| bool | GetRawButton (int button) const |
| Get the button value (starting at button 1). More... | |
| bool | GetRawButtonPressed (int button) |
| Whether the button was pressed since the last check. More... | |
| bool | GetRawButtonReleased (int button) |
| Whether the button was released since the last check. More... | |
| double | GetRawAxis (int axis) const |
| Get the value of the axis. More... | |
| int | GetPOV (int pov=0) const |
| Get the angle in degrees of a POV on the HID. More... | |
| int | GetAxisCount () const |
| Get the number of axes for the HID. More... | |
| int | GetPOVCount () const |
| Get the number of POVs for the HID. More... | |
| int | GetButtonCount () const |
| Get the number of buttons for the HID. More... | |
| GenericHID::HIDType | GetType () const |
| Get the type of the HID. More... | |
| std::string | GetName () const |
| Get the name of the HID. More... | |
| int | GetAxisType (int axis) const |
| Get the axis type of a joystick axis. More... | |
| int | GetPort () const |
| Get the port number of the HID. More... | |
| void | SetOutput (int outputNumber, bool value) |
| Set a single HID output value for the HID. More... | |
| void | SetOutputs (int value) |
| Set all output values for the HID. More... | |
| void | SetRumble (RumbleType type, double value) |
| Set the rumble output for the HID. More... | |
Public Member Functions inherited from frc::ErrorBase | |
| ErrorBase (const ErrorBase &)=default | |
| ErrorBase & | operator= (const ErrorBase &)=default |
| ErrorBase (ErrorBase &&)=default | |
| ErrorBase & | operator= (ErrorBase &&)=default |
| virtual Error & | GetError () |
| Retrieve the current error. More... | |
| virtual const Error & | GetError () const |
| Retrieve the current error. More... | |
| virtual void | ClearError () const |
| Clear the current error information associated with this sensor. | |
| virtual void | SetErrnoError (const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set error information associated with a C library call that set an error to the "errno" global variable. More... | |
| virtual void | SetImaqError (int success, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated from the nivision Imaq API. More... | |
| virtual void | SetError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | SetErrorRange (Error::Code code, int32_t minRange, int32_t maxRange, int32_t requestedValue, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | SetWPIError (const wpi::Twine &errorMessage, Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) const |
| Set the current error information associated with this sensor. More... | |
| virtual void | CloneError (const ErrorBase &rhs) const |
| virtual bool | StatusIsFatal () const |
| Check if the current error code represents a fatal error. More... | |
| void | ClearGlobalErrors () |
| Clear global errors. | |
Additional Inherited Members | |
Static Public Member Functions inherited from frc::ErrorBase | |
| static void | SetGlobalError (Error::Code code, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) |
| static void | SetGlobalWPIError (const wpi::Twine &errorMessage, const wpi::Twine &contextMessage, wpi::StringRef filename, wpi::StringRef function, int lineNumber) |
| static Error | GetGlobalError () |
| Retrieve the last global error. | |
| static std::vector< Error > | GetGlobalErrors () |
| Retrieve all global errors. | |
Protected Attributes inherited from frc::ErrorBase | |
| Error | m_error |
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.
|
explicit |
Construct an instance of an Xbox controller.
The controller index is the USB port on the Driver Station.
| port | The port on the Driver Station that the controller is plugged into (0-5). |
| bool frc::XboxController::GetAButton | ( | ) | const |
Read the value of the A button on the controller.
| bool frc::XboxController::GetAButtonPressed | ( | ) |
Whether the A button was pressed since the last check.
| bool frc::XboxController::GetAButtonReleased | ( | ) |
Whether the A button was released since the last check.
| bool frc::XboxController::GetBackButton | ( | ) | const |
Whether the Y button was released since the last check.
| bool frc::XboxController::GetBackButtonPressed | ( | ) |
Whether the back button was pressed since the last check.
| bool frc::XboxController::GetBackButtonReleased | ( | ) |
Whether the back button was released since the last check.
| bool frc::XboxController::GetBButton | ( | ) | const |
Read the value of the B button on the controller.
| bool frc::XboxController::GetBButtonPressed | ( | ) |
Whether the B button was pressed since the last check.
| bool frc::XboxController::GetBButtonReleased | ( | ) |
Whether the B button was released since the last check.
| bool frc::XboxController::GetBumper | ( | JoystickHand | hand | ) | const |
Read the value of the bumper button on the controller.
| hand | Side of controller whose value should be returned. |
| bool frc::XboxController::GetBumperPressed | ( | JoystickHand | hand | ) |
Whether the bumper was pressed since the last check.
| hand | Side of controller whose value should be returned. |
| bool frc::XboxController::GetBumperReleased | ( | JoystickHand | hand | ) |
Whether the bumper was released since the last check.
| hand | Side of controller whose value should be returned. |
| bool frc::XboxController::GetStartButton | ( | ) | const |
Read the value of the start button on the controller.
| hand | Side of controller whose value should be returned. |
| bool frc::XboxController::GetStartButtonPressed | ( | ) |
Whether the start button was pressed since the last check.
| bool frc::XboxController::GetStartButtonReleased | ( | ) |
Whether the start button was released since the last check.
| bool frc::XboxController::GetStickButton | ( | JoystickHand | hand | ) | const |
Read the value of the stick button on the controller.
| hand | Side of controller whose value should be returned. |
| bool frc::XboxController::GetStickButtonPressed | ( | JoystickHand | hand | ) |
Whether the stick button was pressed since the last check.
| hand | Side of controller whose value should be returned. |
| bool frc::XboxController::GetStickButtonReleased | ( | JoystickHand | hand | ) |
Whether the stick button was released since the last check.
| hand | Side of controller whose value should be returned. |
| double frc::XboxController::GetTriggerAxis | ( | JoystickHand | hand | ) | const |
Get the trigger axis value of the controller.
| hand | Side of controller whose value should be returned. |
|
overridevirtual |
Get the X axis value of the controller.
| hand | Side of controller whose value should be returned. |
Implements frc::GenericHID.
| bool frc::XboxController::GetXButton | ( | ) | const |
Read the value of the X button on the controller.
| bool frc::XboxController::GetXButtonPressed | ( | ) |
Whether the X button was pressed since the last check.
| bool frc::XboxController::GetXButtonReleased | ( | ) |
Whether the X button was released since the last check.
|
overridevirtual |
Get the Y axis value of the controller.
| hand | Side of controller whose value should be returned. |
Implements frc::GenericHID.
| bool frc::XboxController::GetYButton | ( | ) | const |
Read the value of the Y button on the controller.
| bool frc::XboxController::GetYButtonPressed | ( | ) |
Whether the Y button was pressed since the last check.
| bool frc::XboxController::GetYButtonReleased | ( | ) |
Whether the Y button was released since the last check.