WPILibC++  unspecified
frc::GenericHID Class Referenceabstract

GenericHID Interface. More...

#include <GenericHID.h>

Inheritance diagram for frc::GenericHID:
Collaboration diagram for frc::GenericHID:

Public Types

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

 GenericHID (int port)
 
virtual double GetX (JoystickHand hand=kRightHand) const =0
 
virtual double GetY (JoystickHand hand=kRightHand) const =0
 
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 &)=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

- 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 std::mutex _globalErrorMutex
 
static Error _globalError
 

Detailed Description

GenericHID Interface.

Member Function Documentation

int GenericHID::GetAxisCount ( ) const

Get the number of axes for the HID.

Returns
the number of axis for the current HID
int GenericHID::GetAxisType ( int  axis) const

Get the axis type of a joystick axis.

Returns
the axis type of a joystick axis.
int GenericHID::GetButtonCount ( ) const

Get the number of buttons for the HID.

Returns
the number of buttons on the current HID
std::string GenericHID::GetName ( ) const

Get the name of the HID.

Returns
the name of the HID.
int GenericHID::GetPort ( ) const

Get the port number of the HID.

Returns
The port number of the HID.
int GenericHID::GetPOV ( int  pov = 0) const

Get the angle in degrees of a POV on the HID.

The POV angles start at 0 in the up direction, and increase clockwise (e.g. right is 90, upper-left is 315).

Parameters
povThe index of the POV to read (starting at 0)
Returns
the angle of the POV in degrees, or -1 if the POV is not pressed.
int GenericHID::GetPOVCount ( ) const

Get the number of POVs for the HID.

Returns
the number of POVs for the current HID
double GenericHID::GetRawAxis ( int  axis) const

Get the value of the axis.

Parameters
axisThe axis to read, starting at 0.
Returns
The value of the axis.
bool GenericHID::GetRawButton ( int  button) const

Get the button value (starting at button 1).

The buttons are returned in a single 16 bit value with one bit representing the state of each button. The appropriate button is returned as a boolean value.

Parameters
buttonThe button number to be read (starting at 1)
Returns
The state of the button.
bool GenericHID::GetRawButtonPressed ( int  button)

Whether the button was pressed since the last check.

Button indexes begin at 1.

Parameters
buttonThe button index, beginning at 1.
Returns
Whether the button was pressed since the last check.
bool GenericHID::GetRawButtonReleased ( int  button)

Whether the button was released since the last check.

Button indexes begin at 1.

Parameters
buttonThe button index, beginning at 1.
Returns
Whether the button was released since the last check.
GenericHID::HIDType GenericHID::GetType ( ) const

Get the type of the HID.

Returns
the type of the HID.
void GenericHID::SetOutput ( int  outputNumber,
bool  value 
)

Set a single HID output value for the HID.

Parameters
outputNumberThe index of the output to set (1-32)
valueThe value to set the output to
void GenericHID::SetOutputs ( int  value)

Set all output values for the HID.

Parameters
valueThe 32 bit output value (1 bit for each output)
void GenericHID::SetRumble ( RumbleType  type,
double  value 
)

Set the rumble output for the HID.

The DS currently supports 2 rumble values, left rumble and right rumble.

Parameters
typeWhich rumble value to set
valueThe normalized value (0 to 1) to set the rumble to

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