YARP
Yet Another Robot Platform
yarp::dev::IJoypadEventDriven Class Referenceabstract

#include <yarp/dev/IJoypadController.h>

+ Inheritance diagram for yarp::dev::IJoypadEventDriven:

Public Types

enum  JoypadCtrl_coordinateMode
 
- Public Types inherited from yarp::dev::IJoypadController
enum  JoypadCtrl_coordinateMode {
  JypCtrlcoord_POLAR = 0,
  JypCtrlcoord_CARTESIAN = 1
}
 

Public Member Functions

bool getAxisCount (unsigned int &axis_count) override final
 Get number of Axes. More...
 
bool getButtonCount (unsigned int &button_count) override final
 Get number of Buttons. More...
 
bool getTrackballCount (unsigned int &Trackball_count) override final
 Get number of trackballs. More...
 
bool getHatCount (unsigned int &Hat_count) override final
 Get number of Hats. More...
 
bool getTouchSurfaceCount (unsigned int &touch_count) override final
 get the number of touch surface. More...
 
bool getStickCount (unsigned int &stick_count) override final
 get the number of the sticks More...
 
bool getStickDoF (unsigned int stick_id, unsigned int &DoF) override final
 Get the Degree Of Freedom count for desired stick. More...
 
bool getButton (unsigned int button_id, float &value) override final
 Get the value of a button. More...
 
bool getTrackball (unsigned int trackball_id, yarp::sig::Vector &value) override final
 Get the axes change of a Trackball. More...
 
bool getHat (unsigned int hat_id, unsigned char &value) override final
 Get the value of an Hat. More...
 
bool getAxis (unsigned int axis_id, double &value) override final
 Get the value of an axis if present, return false otherwise. More...
 
bool getStick (unsigned int stick_id, yarp::sig::Vector &value, JoypadCtrl_coordinateMode coordinate_mode) override final
 Get the value of a stick if present, return false otherwise. More...
 
bool getTouch (unsigned int touch_id, yarp::sig::Vector &value) override final
 Get the value of a touch if present, return false otherwise. More...
 
 IJoypadEventDriven ()
 
 IJoypadEventDriven (int rate)
 
 IJoypadEventDriven (double period)
 
bool threadInit () override final
 Initialization method. More...
 
void run () override final
 Loop function. More...
 
bool eventDriven (bool enable, yarp::dev::IJoypadEvent *event=nullptr) override
 Activate event Driven mode. More...
 
bool isEventDriven () override
 
- Public Member Functions inherited from yarp::dev::IJoypadController
virtual ~IJoypadController ()
 Destructor. More...
 

Protected Member Functions

virtual bool getRawAxisCount (unsigned int &axis_count)=0
 
virtual bool getRawButtonCount (unsigned int &button_count)=0
 
virtual bool getRawTrackballCount (unsigned int &Trackball_count)=0
 
virtual bool getRawHatCount (unsigned int &Hat_count)=0
 
virtual bool getRawTouchSurfaceCount (unsigned int &touch_count)=0
 
virtual bool getRawStickCount (unsigned int &stick_count)=0
 
virtual bool getRawStickDoF (unsigned int stick_id, unsigned int &DoF)=0
 
virtual bool getRawButton (unsigned int button_id, float &value)=0
 
virtual bool getRawTrackball (unsigned int trackball_id, yarp::sig::Vector &value)=0
 
virtual bool getRawHat (unsigned int hat_id, unsigned char &value)=0
 
virtual bool getRawAxis (unsigned int axis_id, double &value)=0
 
virtual bool getRawStick (unsigned int stick_id, yarp::sig::Vector &value, JoypadCtrl_coordinateMode coordinate_mode)=0
 
virtual bool getRawTouch (unsigned int touch_id, yarp::sig::Vector &value)=0
 
virtual bool executeAction (int action_id)
 
virtual bool parseActions (const yarp::os::Searchable &cfg, int *count=nullptr)
 
- Protected Member Functions inherited from yarp::dev::IJoypadController
virtual bool parseActions (const yarp::os::Searchable &cfg, int *count=nullptr)
 
virtual bool executeAction (int action_id)
 

Protected Attributes

std::map< int, std::string > m_actions
 
- Protected Attributes inherited from yarp::dev::IJoypadController
std::map< int, std::string > m_actions
 

Detailed Description

Definition at line 207 of file IJoypadController.h.

Member Enumeration Documentation

◆ JoypadCtrl_coordinateMode

Constructor & Destructor Documentation

◆ IJoypadEventDriven() [1/3]

yarp::dev::IJoypadEventDriven::IJoypadEventDriven ( )

Definition at line 24 of file IJoypadController.cpp.

◆ IJoypadEventDriven() [2/3]

yarp::dev::IJoypadEventDriven::IJoypadEventDriven ( int  rate)
explicit

Definition at line 27 of file IJoypadController.cpp.

◆ IJoypadEventDriven() [3/3]

yarp::dev::IJoypadEventDriven::IJoypadEventDriven ( double  period)
explicit

Definition at line 29 of file IJoypadController.cpp.

Member Function Documentation

◆ eventDriven()

bool yarp::dev::IJoypadEventDriven::eventDriven ( bool  enable,
yarp::dev::IJoypadEvent event = nullptr 
)
overridevirtual

Activate event Driven mode.

eventDriven

Parameters
enablea bool to turn on or off the eventDriven mode
eventa pointer to a valid yarp::dev::IJoypadEvent object whom action() method will be called on event detection
Returns
true if succeeded. false otherwise

Reimplemented from yarp::dev::IJoypadController.

Definition at line 238 of file IJoypadController.cpp.

◆ executeAction()

bool yarp::dev::IJoypadController::executeAction
protected

Definition at line 43 of file IJoypadController.cpp.

◆ getAxis()

bool yarp::dev::IJoypadEventDriven::getAxis ( unsigned int  axis_id,
double &  value 
)
finaloverridevirtual

Get the value of an axis if present, return false otherwise.

getAxis

Parameters
axis_idId of the axis to get. must be > -1 && < getAxisCount(), return false otherwise
valuereference to be valued. the absolute boundaries for the values should be -1.0 and 1.0 However the actual range depends on the physical device (example: analog trigger does not have a central position thus can give a value from 0.0 to 0.1)
Returns
true if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 359 of file IJoypadController.cpp.

◆ getAxisCount()

bool yarp::dev::IJoypadEventDriven::getAxisCount ( unsigned int &  axis_count)
finaloverridevirtual

Get number of Axes.

getAxisCount

Parameters
axes_countunsigned int reference that will contain the result
Returns
true if succeeded. false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 287 of file IJoypadController.cpp.

◆ getButton()

bool yarp::dev::IJoypadEventDriven::getButton ( unsigned int  button_id,
float &  value 
)
finaloverridevirtual

Get the value of a button.

from 0-unpressed to 1-fullpressed and values in the middle in the analog-face-button case

getButton

Parameters
button_idId of the button to get. Must be > -1 && < getButtonCount(), return false otherwise
valuereference to be valued. The value will be from 0.0 (not even touched) to 1.0 (fully pressed)
Returns
true if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 327 of file IJoypadController.cpp.

◆ getButtonCount()

bool yarp::dev::IJoypadEventDriven::getButtonCount ( unsigned int &  button_count)
finaloverridevirtual

Get number of Buttons.

getButtonCount

Parameters
button_countunsigned int reference that will contain the result
Returns
true if succeeded. false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 292 of file IJoypadController.cpp.

◆ getHat()

bool yarp::dev::IJoypadEventDriven::getHat ( unsigned int  hat_id,
unsigned char &  value 
)
finaloverridevirtual

Get the value of an Hat.

getHat

Parameters
hat_idId of the POV hat to get. Must be > -1 && < getHatCount(), return false otherwise
valuereference to be valued. use the YRPJOY_HAT_ macro series to get the currently pressed directions
Returns
true if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 348 of file IJoypadController.cpp.

◆ getHatCount()

bool yarp::dev::IJoypadEventDriven::getHatCount ( unsigned int &  Hat_count)
finaloverridevirtual

Get number of Hats.

getHatsCount

Parameters
Hat_countunsigned int reference that will contain the result
Returns
true if succeeded. false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 302 of file IJoypadController.cpp.

◆ getRawAxis()

virtual bool yarp::dev::IJoypadEventDriven::getRawAxis ( unsigned int  axis_id,
double &  value 
)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawAxisCount()

virtual bool yarp::dev::IJoypadEventDriven::getRawAxisCount ( unsigned int &  axis_count)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawButton()

virtual bool yarp::dev::IJoypadEventDriven::getRawButton ( unsigned int  button_id,
float &  value 
)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawButtonCount()

virtual bool yarp::dev::IJoypadEventDriven::getRawButtonCount ( unsigned int &  button_count)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawHat()

virtual bool yarp::dev::IJoypadEventDriven::getRawHat ( unsigned int  hat_id,
unsigned char &  value 
)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawHatCount()

virtual bool yarp::dev::IJoypadEventDriven::getRawHatCount ( unsigned int &  Hat_count)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawStick()

virtual bool yarp::dev::IJoypadEventDriven::getRawStick ( unsigned int  stick_id,
yarp::sig::Vector value,
JoypadCtrl_coordinateMode  coordinate_mode 
)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawStickCount()

virtual bool yarp::dev::IJoypadEventDriven::getRawStickCount ( unsigned int &  stick_count)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawStickDoF()

virtual bool yarp::dev::IJoypadEventDriven::getRawStickDoF ( unsigned int  stick_id,
unsigned int &  DoF 
)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawTouch()

virtual bool yarp::dev::IJoypadEventDriven::getRawTouch ( unsigned int  touch_id,
yarp::sig::Vector value 
)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawTouchSurfaceCount()

virtual bool yarp::dev::IJoypadEventDriven::getRawTouchSurfaceCount ( unsigned int &  touch_count)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawTrackball()

virtual bool yarp::dev::IJoypadEventDriven::getRawTrackball ( unsigned int  trackball_id,
yarp::sig::Vector value 
)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getRawTrackballCount()

virtual bool yarp::dev::IJoypadEventDriven::getRawTrackballCount ( unsigned int &  Trackball_count)
protectedpure virtual

Implemented in SDLJoypad, and JoypadControlClient.

◆ getStick()

bool yarp::dev::IJoypadEventDriven::getStick ( unsigned int  stick_id,
yarp::sig::Vector value,
JoypadCtrl_coordinateMode  coordinate_mode 
)
finaloverridevirtual

Get the value of a stick if present, return false otherwise.

getStick

Parameters
stick_idId of the stick to get. must be > -1 && < getStickCount(), return false otherwise
valuea vector that will contain the joystick position. the size of the vector will give you the Number of degrees of freedom and the value will be from -1.0 to 1.0
coordinate_modeto get data in cartesian mode or polar (spheric in 3 dof position cases) mode
Returns
true if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 370 of file IJoypadController.cpp.

◆ getStickCount()

bool yarp::dev::IJoypadEventDriven::getStickCount ( unsigned int &  stick_count)
finaloverridevirtual

get the number of the sticks

getStickCount

Parameters
stick_countunsigned int reference that will contain the result
Returns
bool if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 312 of file IJoypadController.cpp.

◆ getStickDoF()

bool yarp::dev::IJoypadEventDriven::getStickDoF ( unsigned int  stick_id,
unsigned int &  DoF 
)
finaloverridevirtual

Get the Degree Of Freedom count for desired stick.

getStickDoF

Parameters
stick_idId of the stick. must be > -1 && < getStickCount(), return false otherwise
DoFan unsigned int reference that will contain the value.
Returns
true if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 317 of file IJoypadController.cpp.

◆ getTouch()

bool yarp::dev::IJoypadEventDriven::getTouch ( unsigned int  touch_id,
yarp::sig::Vector value 
)
finaloverridevirtual

Get the value of a touch if present, return false otherwise.

getTouch

Parameters
valuea vector that will contain the touch values normalized from 0.0 to 1.0.
Returns
true if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 381 of file IJoypadController.cpp.

◆ getTouchSurfaceCount()

bool yarp::dev::IJoypadEventDriven::getTouchSurfaceCount ( unsigned int &  touch_count)
finaloverridevirtual

get the number of touch surface.

multiple touch surface can rappresent either multiple physical monotouch surface or a multitouch surface or a combination of the two

hasTouchSurface

Parameters
touch_countunsigned int reference that will contain the result
Returns
true if succeeded. false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 307 of file IJoypadController.cpp.

◆ getTrackball()

bool yarp::dev::IJoypadEventDriven::getTrackball ( unsigned int  trackball_id,
yarp::sig::Vector value 
)
finaloverridevirtual

Get the axes change of a Trackball.

getTrackball

Parameters
trackball_idId of the Trackball to get. Must be > -1 && < getTrackballCount(), return false otherwise
valuereference to be valued. the value will be from 0.0 (not moving) to 1.0 (full velocity)
Returns
true if succeeded, false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 337 of file IJoypadController.cpp.

◆ getTrackballCount()

bool yarp::dev::IJoypadEventDriven::getTrackballCount ( unsigned int &  Trackball_count)
finaloverridevirtual

Get number of trackballs.

getTrackballCount

Parameters
Trackball_countunsigned int reference that will contain the result
Returns
true if succeeded. false otherwise

Implements yarp::dev::IJoypadController.

Definition at line 297 of file IJoypadController.cpp.

◆ isEventDriven()

bool yarp::dev::IJoypadEventDriven::isEventDriven ( )
inlineoverridevirtual

Reimplemented from yarp::dev::IJoypadController.

Definition at line 273 of file IJoypadController.h.

◆ parseActions()

bool yarp::dev::IJoypadController::parseActions
protected

Definition at line 42 of file IJoypadController.cpp.

◆ run()

void yarp::dev::IJoypadEventDriven::run ( )
finaloverridevirtual

Loop function.

This is the thread itself. The thread calls the run() function every <period> ms. At the end of each run, the thread will sleep the amounth of time required, taking into account the time spent inside the loop function. Example: requested period is 10ms, the run() function take 3ms to be executed, the thread will sleep for 7ms.

Note: after each run is completed, the thread will call a yield() in order to facilitate other threads to run.

Implements yarp::os::PeriodicThread.

Definition at line 126 of file IJoypadController.cpp.

◆ threadInit()

bool yarp::dev::IJoypadEventDriven::threadInit ( )
finaloverridevirtual

Initialization method.

The thread executes this function when it starts and before "run". This is a good place to perform initialization tasks that need to be done by the thread itself (device drivers initialization, memory allocation etc). If the function returns false the thread quits and never calls "run". The return value of threadInit() is notified to the class and passed as a parameter to afterStart(). Note that afterStart() is called by the same thread that is executing the "start" method.

Reimplemented from yarp::os::PeriodicThread.

Definition at line 60 of file IJoypadController.cpp.

Member Data Documentation

◆ m_actions

std::map<int, std::string> yarp::dev::IJoypadController::m_actions
protected

Definition at line 40 of file IJoypadController.h.


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