36 yCInfo(
SDLJOYPAD) <<
"UseAllJoypadAsOne - set it to 1 to have all the connected joypad as one";
37 yCInfo(
SDLJOYPAD) <<
"DefaultJoystickNumber - select the id of the joypad to use if there are more than one joypad and UseAllJoypadAsOne is set to 0";
38 yCInfo(
SDLJOYPAD) <<
"stick - the number of stick to configure. a stick is simply a wrapping of 2 or more axes so for every stick";
39 yCInfo(
SDLJOYPAD) <<
" a group named STICK*ID* containing the stick's parameters is searched. ";
43 yCInfo(
SDLJOYPAD) <<
"axis[ID]_id - axis id for current stick related axis";
82 if(!rf.check(
"UseAllJoypadAsOne"))
84 if(rf.find(
"UseAllJoypadAsOne").asBool())
87 if (rf.check(
"DefaultJoystickNumber"))
89 joy_id = rf.find(
"DefaultJoystickNumber").asInt32();
90 yCInfo(
SDLJOYPAD,
"Multiple joysticks found, using #%d, as specified in the configuration options",
joy_id);
124 for(
size_t i = 0; i < m_device.size(); ++i)
126 if ( m_device[i] ==
nullptr )
148 yCInfo(
SDLJOYPAD) <<
"Actions successfully parsed and linked to the joypad";
157 if(!parseStickInfo(rf)){
return false;}
163 if(!
cfg.check(
"sticks") || !
cfg.find(
"sticks").isInt32())
169 for(
unsigned int i = 0; i < m_axisCount; i++)
171 m_axes.push_back(
true);
174 m_stickCount =
cfg.find(
"sticks").asInt32();
175 for(
unsigned int i = 0; i < m_stickCount; i++)
209 axisName =
"axis" + std::to_string(
j) +
"_id";
293 yCError(
SDLJOYPAD) <<
"SDL_Joypad: stick_id out of bounds when calling 'getStickDoF'' method";
305 for(i = 0; i < m_device.size(); ++i)
326bool SDLJoypad::getPureAxis(
unsigned int axis_id,
double& value)
331 for(i = 0; i < m_device.size(); ++i)
354 return getPureAxis(
axis_id, value);
373 for(
size_t i = 0; i <
stk.axes_ids.size(); i++)
381 if (
stk.axes_ids.size() > 2)
383 yCError(
SDLJOYPAD) <<
"Polar coordinate system is supported only for bidimensional stick at the moment";
386 value =
Vector3(
sqrt(value[0] * value[0] + value[1] * value[1]),
atan2(value[0], value[1]));
401 for(i = 0; i < m_device.size(); ++i)
424 for(i = 0; i < m_device.size(); ++i)
448void SDLJoypad::updateJoypad()
yarp::sig::Vector Vector3(const double &x, const double &y)
SDLJoypad: Device that reads inputs of Joypads compatible with the SDL library.
bool getRawAxisCount(unsigned int &axis_count) override
bool getRawButtonCount(unsigned int &button_count) override
bool getRawTouchSurfaceCount(unsigned int &touch_count) override
bool getRawStickDoF(unsigned int stick_id, unsigned int &DoF) override
bool getRawHat(unsigned int hat_id, unsigned char &value) override
bool getRawTrackballCount(unsigned int &trackball_count) override
bool close() override
Close the DeviceDriver.
bool getRawButton(unsigned int button_id, float &value) override
bool getRawAxis(unsigned int axis_id, double &value) override
bool getRawStickCount(unsigned int &stick_count) override
bool getRawHatCount(unsigned int &hat_count) override
bool getRawStick(unsigned int stick_id, yarp::sig::Vector &value, JoypadCtrl_coordinateMode coordinate_mode) override
bool getRawTrackball(unsigned int trackball_id, yarp::sig::Vector &value) override
bool getRawTouch(unsigned int touch_id, yarp::sig::Vector &value) override
std::map< int, std::string > m_actions
virtual bool executeAction(int action_id)
JoypadCtrl_coordinateMode
A simple collection of objects that can be described and transmitted in a portable way.
A mini-server for performing network communication in the background.
A base class for nested structures that can be searched.
void resize(size_t size) override
Resize the vector.
void push_back(const T &elem)
Push a new element in the vector: size is changed.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCWarning(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
double now()
Return the current time in seconds, relative to an arbitrary starting point.
An interface to the operating system, including Port based communication.
The main, catch-all namespace for YARP.