ArPiRobot-CoreLib C++
C++ library for ArPiRobot robots
Public Member Functions | Protected Member Functions | List of all members
arpirobot::Gamepad Class Reference

#include <arpirobot/devices/gamepad/Gamepad.hpp>

Inheritance diagram for arpirobot::Gamepad:
arpirobot::BaseDevice

Public Member Functions

 Gamepad (int controllerNum)
 
 Gamepad (const Gamepad &other)=delete
 
Gamepadoperator= (const Gamepad &other)=delete
 
int getControllerNum ()
 
double getAxis (int axisNum, double deadband=0)
 
bool getButton (int buttonNum)
 
int getDpad (int dpadNum)
 
void setAxisTransform (int axisNum, BaseAxisTransform &transform)
 
void setAxisTransform (int axisNum, std::shared_ptr< BaseAxisTransform > transform)
 
void clearAxisTransform (int axisNum)
 
- Public Member Functions inherited from arpirobot::BaseDevice
virtual std::string getDeviceName ()
 
bool isLockedByAction (std::shared_ptr< Action > action=nullptr)
 Check if a given action locks the device. More...
 
bool isLockedByAction (Action &action)
 Check if a given action locks the device. More...
 

Protected Member Functions

void begin () override
 
bool isEnabled () override
 
bool shouldMatchRobotState () override
 
bool shouldDisableWithWatchdog () override
 
void enable () override
 
void disable () override
 

Additional Inherited Members

- Protected Attributes inherited from arpirobot::BaseDevice
bool initialized = false
 
std::string deviceName
 

Detailed Description

Gamepad receiving data from drive station

Constructor & Destructor Documentation

◆ Gamepad()

arpirobot::Gamepad::Gamepad ( int  controllerNum)
Parameters
controllerNumThe controller number for this controller. Top controller in DS is zero

Member Function Documentation

◆ clearAxisTransform()

void arpirobot::Gamepad::clearAxisTransform ( int  axisNum)

Remove a transform from an axis

Parameters
axisNumThe axis number to clear a transform from

◆ getAxis()

double arpirobot::Gamepad::getAxis ( int  axisNum,
double  deadband = 0 
)

Get an axis for this controller

Parameters
axisNumThe axis number
deadbandA minimum threshold for axis values. Values below this will be returned as zero.
Returns
The axis value after applying the deadband and (if required) an axis transform

◆ getButton()

bool arpirobot::Gamepad::getButton ( int  buttonNum)

Get a button for the controller

Parameters
buttonNumThe button number
Returns
true if pressed, else false

◆ getControllerNum()

int arpirobot::Gamepad::getControllerNum ( )

Get the controller number for this gamepad

Returns
The controller number

◆ getDpad()

int arpirobot::Gamepad::getDpad ( int  dpadNum)

Get the value of a dpad

Parameters
dpadNumThe dpad number
Returns
0 if center, 1 for up through 8 going clockwise

◆ setAxisTransform() [1/2]

void arpirobot::Gamepad::setAxisTransform ( int  axisNum,
BaseAxisTransform transform 
)

Set the axis transform for a given axis

Parameters
axisNumThe axis number to apply a transform to. Referenced object must remain in scope until cleared.
transformThe transform

◆ setAxisTransform() [2/2]

void arpirobot::Gamepad::setAxisTransform ( int  axisNum,
std::shared_ptr< BaseAxisTransform transform 
)

Set the axis transform for a given axis

Parameters
axisNumThe axis number to apply a transform to. Can use with std::make_shared
transformThe transform

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