21 m_ports.push_back(&m_buttonsPort );
22 m_ports.push_back(&m_axisPort );
23 m_ports.push_back(&m_stickPort );
24 m_ports.push_back(&m_trackballPort);
25 m_ports.push_back(&m_touchPort );
26 m_ports.push_back(&m_hatsPort );
30bool JoypadControlClient::getJoypadInfo()
37 std::vector<std::tuple<int, JoypadControl::LoopablePort*, std::string> >
vocabs_ports;
47 if (!getCount(std::get<0>(
vocab_port), count)) {
53 std::string destination;
60 for(
unsigned int i = 0; i < count; i++)
74 if(!std::get<1>(
vocab_port)->contactable->open(portname))
131 port->onTimeout(0.5);
136bool JoypadControlClient::getCount(
const int&
vocab_toget,
unsigned int& value)
143 value = m_buttonsPort.count;
148 value = m_axisPort.count;
152 value = m_trackballPort.count;
157 value = m_touchPort.count;
162 value = m_stickPort.count;
167 value = m_hatsPort.count;
180 m_rpcPort.
write(cmd, response);
230 m_rpcPort.
write(cmd, response);
253 m_rpcPort.
write(cmd, response);
267 std::lock_guard<std::mutex>
l(m_buttonsPort.mutex);
268 if(
button_id < m_buttonsPort.storage.size())
270 value = m_buttonsPort.storage[
button_id];
293 m_rpcPort.
write(cmd, response);
307 std::lock_guard<std::mutex>
l(m_trackballPort.mutex);
332 m_rpcPort.
write(cmd, response);
345 std::lock_guard<std::mutex>
l(m_hatsPort.mutex);
346 if(
hat_id < m_hatsPort.storage.size())
348 value = m_hatsPort.storage[
hat_id];
369 m_rpcPort.
write(cmd, response);
383 std::lock_guard<std::mutex>
l(m_axisPort.mutex);
384 if(
axis_id < m_axisPort.storage.size())
386 value = m_axisPort.storage[
axis_id];
411 m_rpcPort.
write(cmd, response);
427 m_rpcPort.
write(cmd, response);
430 for(
int i = 0; i <
dof; i++)
450 std::lock_guard<std::mutex>
l(m_stickPort.mutex);
461 offset += m_stickDof[
j];
464 for(
size_t i = 0; i < m_stickDof[
stick_id]; ++i)
466 value.
push_back(m_stickPort.storage[offset + i]);
485 m_rpcPort.
write(cmd, response);
499 std::lock_guard<std::mutex>
l(m_touchPort.mutex);
500 if(
touch_id < m_touchPort.storage.size()/2)
516 std::vector<JoypadControl::LoopablePort*>
portv;
517 portv.push_back(&m_buttonsPort);
518 portv.push_back(&m_axisPort);
519 portv.push_back(&m_hatsPort);
520 portv.push_back(&m_touchPort);
521 portv.push_back(&m_trackballPort);
522 portv.push_back(&m_stickPort);
527 p->contactable->
close();
constexpr yarp::conf::vocab32_t VOCAB_OK
constexpr yarp::conf::vocab32_t VOCAB_GET
constexpr yarp::conf::vocab32_t VOCAB_VALUE
constexpr yarp::conf::vocab32_t VOCAB_COUNT
constexpr yarp::conf::vocab32_t VOCAB_BUTTON
constexpr yarp::conf::vocab32_t VOCAB_IJOYPADCTRL
constexpr yarp::conf::vocab32_t VOCAB_TOUCH
constexpr yarp::conf::vocab32_t VOCAB_HAT
constexpr yarp::conf::vocab32_t VOCAB_TRACKBALL
constexpr yarp::conf::vocab32_t VOCAB_CARTESIAN
constexpr yarp::conf::vocab32_t VOCAB_STICKDOF
constexpr yarp::conf::vocab32_t VOCAB_AXIS
constexpr yarp::conf::vocab32_t VOCAB_POLAR
constexpr yarp::conf::vocab32_t VOCAB_STICK
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool getRawAxisCount(unsigned int &axis_count) override
bool getRawHatCount(unsigned int &Hat_count) override
bool getRawButtonCount(unsigned int &button_count) override
bool getRawTrackballCount(unsigned int &Trackball_count) override
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
bool getRawButton(unsigned int button_id, float &value) override
bool getRawHat(unsigned int hat_id, unsigned char &value) override
bool getRawStickDoF(unsigned int stick_id, unsigned int &DoF) override
bool close() override
Close the DeviceDriver.
bool getRawStickCount(unsigned int &stick_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
bool getRawTouchSurfaceCount(unsigned int &touch_count) override
bool getRawAxis(unsigned int axis_id, double &value) override
void run() override
Loop function.
std::vector< JoypadControl::LoopablePort * > m_ports
bool getStickDoF(unsigned int stick_id, unsigned int &DoF) override final
Get the Degree Of Freedom count for desired stick.
bool getStickCount(unsigned int &stick_count) override final
Get the number of the sticks.
JoypadCtrl_coordinateMode
A simple collection of objects that can be described and transmitted in a portable way.
void addVocab32(yarp::conf::vocab32_t x)
Places a vocabulary item in the bottle, at the end of the list.
Value & get(size_type index) const
Reads a Value v from a certain part of the list.
void addInt32(std::int32_t x)
Places a 32-bit integer in the bottle, at the end of the list.
A mini-server for performing network communication in the background.
void close() override
Stop port activity.
void interrupt() override
Interrupt any current reads or writes attached to the port.
void useCallback(TypedReaderCallback< T > &callback) override
Set an object whose onRead method will be called when data is available.
static bool connect(const std::string &src, const std::string &dest, const std::string &carrier="", bool quiet=true)
Request that an output port connect to an input port.
bool start()
Call this to start the thread.
bool write(const PortWriter &writer, const PortWriter *callback=nullptr) const override
Write an object to the port.
void close() override
Stop port activity.
bool open(const std::string &name) override
Start port operation, with a specific name, with automatically-chosen network parameters.
A base class for nested structures that can be searched.
virtual yarp::conf::float64_t asFloat64() const
Get 64-bit floating point value.
virtual yarp::conf::vocab32_t asVocab32() const
Get vocabulary identifier as an integer.
virtual std::int32_t asInt32() const
Get 32-bit integer value.
virtual bool isFloat64() const
Checks if value is a 64-bit floating point number.
virtual bool isInt32() const
Checks if value is a 32-bit integer.
void push_back(const T &elem)
Push a new element in the vector: size is changed.
#define yCInfo(component,...)
#define yCError(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.