83 if(!rf.check(
"UseAllJoypadAsOne"))
85 if(rf.find(
"UseAllJoypadAsOne").asBool())
88 if (rf.check(
"DefaultJoystickNumber"))
90 joy_id = rf.find(
"DefaultJoystickNumber").asInt32();
91 yCInfo(
SDLJOYPAD,
"Multiple joysticks found, using #%d, as specified in the configuration options",
joy_id);
125 for(
size_t i = 0; i < m_device.size(); ++i)
127 if ( m_device[i] ==
nullptr )
140 if(m_actionsHandler.parseActions(rf, m_buttonCount, &
actionCount))
149 yCInfo(
SDLJOYPAD) <<
"Actions successfully parsed and linked to the joypad";
158 if(!parseStickInfo(rf)){
return false;}
164 if(!
cfg.check(
"sticks") || !
cfg.find(
"sticks").isInt32())
170 for(
size_t i = 0; i < m_axisCount; i++)
172 m_axes.push_back(
true);
175 m_stickCount =
cfg.find(
"sticks").asInt32();
176 for(
size_t i = 0; i < m_stickCount; i++)
210 axisName =
"axis" + std::to_string(j) +
"_id";
211 invertName =
"invert_axis_" + std::to_string(j);
220 if(axis_id > m_axisCount - 1)
234 m_axes[axis_id] =
false;
262 button_count = m_buttonCount;
280 touch_count = m_touchCount;
286 stick_count = m_stickCount;
292 if(button_id > m_buttonCount - 1)
299 for(i = 0; i < m_device.size(); ++i)
322ReturnValue SDLJoypad::getPureAxis(
size_t axis_id,
double& value)
324 if(axis_id > m_axisCount - 1)
331 for(i = 0; i < m_device.size(); ++i)
351 if(axis_id > m_axisCount - 1)
358 return getPureAxis(axis_id, value);
371 if (stick_id > m_stickCount - 1)
382 yCError(
SDLJOYPAD) <<
"Only for 2-dimensional sticks are supported at the moment";
386 for(
size_t i = 0; i <
stk_config.axes_ids.size(); i++)
410 if(hat_id > m_hatCount - 1)
417 for(i = 0; i < m_device.size(); ++i)
436 if(trackball_id > m_ballCount - 1)
444 for(i = 0; i < m_device.size(); ++i)
467void SDLJoypad::updateJoypad()
494 int&
actCount = count ? *count : dummy;
514 yDebug() <<
"error parsing cfg";
531 yCError(
SDLJOYPAD) <<
"Button's actions parameters must be in the format 'unsigned int string' and the button id must be in range";
#define ReturnValue_error_method_failed
#define ReturnValue_error_not_implemented_by_device
#define ReturnValue_error_input_out_of_bounds
yarp::sig::Vector Vector3(const double &x, const double &y)
const std::string buttActionGroupName
std::map< int, std::string > m_actions
bool parseActions(const yarp::os::Searchable &cfg, size_t maxButtons, int *count=nullptr)
bool executeAction(int action_id)
bool actionDetected(int button_id)
SDLJoypad: Device that reads inputs of Joypads compatible with the SDL library.
yarp::dev::ReturnValue getAxis(size_t axis_id, double &value) override
Get the value of an axis if present, return false otherwise.
yarp::dev::ReturnValue getHat(size_t hat_id, unsigned char &value) override
Get the value of an Hat.
yarp::dev::ReturnValue getAxisCount(size_t &axis_count) override
Get number of axes.
yarp::dev::ReturnValue getHatCount(size_t &hat_count) override
Get number of hats.
yarp::dev::ReturnValue getTrackball(size_t trackball_id, yarp::dev::TrackballData &value) override
Get the axes change of a Trackball.
yarp::dev::ReturnValue getTouchSurfaceCount(size_t &touch_count) override
Get the number of touch surface.
yarp::dev::ReturnValue getButton(size_t button_id, double &value) override
Get the value of a button.
yarp::dev::ReturnValue getStick(size_t stick_id, yarp::dev::StickData &value, JoypadCtrl_coordinateMode coordinate_mode) override
Get the value of a stick if present, return false otherwise.
yarp::dev::ReturnValue getTrackballCount(size_t &trackball_count) override
Get number of trackballs.
yarp::dev::ReturnValue getButtonCount(size_t &button_count) override
Get number of buttons.
yarp::dev::ReturnValue getStickCount(size_t &stick_count) override
Get the number of the sticks.
bool close() override
Close the DeviceDriver.
yarp::dev::ReturnValue getTouch(size_t touch_id, std::vector< yarp::dev::TouchData > &value) override
Get the value of a touch if present, return false otherwise.
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 push_back(const Scalar &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.