WPILibC++  unspecified
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Pages
frc::XboxController Class Reference

Handle input from Xbox 360 or Xbox One controllers connected to the Driver Station. More...

#include <XboxController.h>

Inheritance diagram for frc::XboxController:
frc::GamepadBase frc::ErrorBase frc::GenericHID

Public Member Functions

 XboxController (int port)
 Construct an instance of an Xbox controller. More...
 
 XboxController (const XboxController &)=delete
 
XboxControlleroperator= (const XboxController &)=delete
 
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...
 
bool GetBumper (JoystickHand hand) const override
 Read the value of the bumper button on the controller. More...
 
bool GetStickButton (JoystickHand hand) const override
 Read the value of the stick button on the controller. More...
 
virtual double GetTriggerAxis (JoystickHand hand) const
 Get the trigger axis value of the controller. More...
 
bool GetAButton () const
 Read the value of the A button on the controller. More...
 
bool GetBButton () const
 Read the value of the B button on the controller. More...
 
bool GetXButton () const
 Read the value of the X button on the controller. More...
 
bool GetYButton () const
 Read the value of the Y button on the controller. More...
 
bool GetBackButton () const
 Read the value of the back button on the controller. More...
 
bool GetStartButton () const
 Read the value of the start button on the controller. More...
 
- Public Member Functions inherited from frc::GamepadBase
 GamepadBase (int port)
 
- Public Member Functions inherited from frc::GenericHID
 GenericHID (int port)
 
virtual double GetRawAxis (int axis) const
 Get the value of the axis. More...
 
bool GetRawButton (int button) const
 Get the button value (starting at button 1) More...
 
int GetPOV (int pov=0) const
 Get the angle in degrees of a POV on the HID. More...
 
int GetPOVCount () const
 Get the number of POVs for the HID. More...
 
int GetPort () const
 Get the port number of 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...
 
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 &)=delete
 
ErrorBaseoperator= (const ErrorBase &)=delete
 
virtual ErrorGetError ()
 Retrieve the current error. More...
 
virtual const ErrorGetError () const
 
virtual void SetErrnoError (llvm::StringRef contextMessage, llvm::StringRef filename, llvm::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, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set the current error information associated from the nivision Imaq API. More...
 
virtual void SetError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::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, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void SetWPIError (llvm::StringRef errorMessage, Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber) const
 Set the current error information associated with this sensor. More...
 
virtual void CloneError (const ErrorBase &rhs) const
 
virtual void ClearError () const
 Clear the current error information associated with this sensor.
 
virtual bool StatusIsFatal () const
 Check if the current error code represents a fatal error. More...
 

Additional Inherited Members

- 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 }
 
- Static Public Member Functions inherited from frc::ErrorBase
static void SetGlobalError (Error::Code code, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber)
 
static void SetGlobalWPIError (llvm::StringRef errorMessage, llvm::StringRef contextMessage, llvm::StringRef filename, llvm::StringRef function, int lineNumber)
 
static ErrorGetGlobalError ()
 Retrieve the current global error.
 
- Protected Attributes inherited from frc::ErrorBase
Error m_error
 
- Static Protected Attributes inherited from frc::ErrorBase
static priority_mutex _globalErrorMutex
 
static Error _globalError
 

Detailed Description

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 returend. 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.

Constructor & Destructor Documentation

XboxController::XboxController ( int  port)
explicit

Construct an instance of an Xbox controller.

The joystick index is the USB port on the Driver Station.

Parameters
portThe port on the Driver Station that the joystick is plugged into (0-5).

Member Function Documentation

bool XboxController::GetAButton ( ) const

Read the value of the A button on the controller.

Parameters
handSide of controller whose value should be returned.
Returns
The state of the button.
bool XboxController::GetBackButton ( ) const

Read the value of the back button on the controller.

Parameters
handSide of controller whose value should be returned.
Returns
The state of the button.
bool XboxController::GetBButton ( ) const

Read the value of the B button on the controller.

Parameters
handSide of controller whose value should be returned.
Returns
The state of the button.
bool XboxController::GetBumper ( JoystickHand  hand) const
overridevirtual

Read the value of the bumper button on the controller.

Parameters
handSide of controller whose value should be returned.

Implements frc::GamepadBase.

bool XboxController::GetStartButton ( ) const

Read the value of the start button on the controller.

Parameters
handSide of controller whose value should be returned.
Returns
The state of the button.
bool XboxController::GetStickButton ( JoystickHand  hand) const
overridevirtual

Read the value of the stick button on the controller.

Parameters
handSide of controller whose value should be returned.
Returns
The state of the button.

Implements frc::GamepadBase.

double XboxController::GetTriggerAxis ( JoystickHand  hand) const
virtual

Get the trigger axis value of the controller.

Parameters
handSide of controller whose value should be returned.
double XboxController::GetX ( JoystickHand  hand) const
overridevirtual

Get the X axis value of the controller.

Parameters
handSide of controller whose value should be returned.

Implements frc::GenericHID.

bool XboxController::GetXButton ( ) const

Read the value of the X button on the controller.

Parameters
handSide of controller whose value should be returned.
Returns
The state of the button.
double XboxController::GetY ( JoystickHand  hand) const
overridevirtual

Get the Y axis value of the controller.

Parameters
handSide of controller whose value should be returned.

Implements frc::GenericHID.

bool XboxController::GetYButton ( ) const

Read the value of the Y button on the controller.

Parameters
handSide of controller whose value should be returned.
Returns
The state of the button.

The documentation for this class was generated from the following files: