YARP
Yet Another Robot Platform
JoypadControlClient.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
9 #include <vector>
10 #include <JoypadControlNetUtils.h>
11 
12 #define DEFAULT_THREAD_PERIOD 10
13 
16 {
17 public:
19  virtual ~JoypadControlWatchdog() = default;
20 
21 
22  std::vector<JoypadControl::LoopablePort*> m_ports;
23  void run() override;
24 
25 };
26 
43 {
44 private:
45  //---------------utils
46  template<typename T>
48  typedef yarp::sig::Vector Vector;
50 
51  //---------------properties
52  yarp::os::Port m_rpcPort;
53  JOYPORT<Vector> m_buttonsPort;
54  JOYPORT<Vector> m_axisPort;
55  JOYPORT<Vector> m_trackballPort;
56  JOYPORT<Vector> m_touchPort;
57  JOYPORT<CharVector> m_hatsPort;
58  JOYPORT<Vector> m_stickPort;
59  std::vector<size_t> m_stickDof;
60  bool m_rpc_only;
61  std::string m_local;
62  std::string m_remote;
63 
64  JoypadControlWatchdog watchdog;
65  std::vector<JoypadControl::LoopablePort*> m_ports;
66 
67  //--------------method
68  bool getCount(const int& vocab_toget, unsigned int& value);
69  bool getJoypadInfo();
70 
71 public:
77  ~JoypadControlClient() override = default;
78 
79  //rateThread
80 
81  //DeviceDriver
82  bool open(yarp::os::Searchable& config) override;
83  bool close() override;
84 
85  //IJoypadController;
86  bool getRawAxisCount(unsigned int& axis_count) override;
87  bool getRawButtonCount(unsigned int& button_count) override;
88  bool getRawTrackballCount(unsigned int& Trackball_count) override;
89  bool getRawHatCount(unsigned int& Hat_count) override;
90  bool getRawTouchSurfaceCount(unsigned int& touch_count) override;
91  bool getRawStickCount(unsigned int& stick_count) override;
92  bool getRawStickDoF(unsigned int stick_id, unsigned int& DoF) override;
93  bool getRawButton(unsigned int button_id, float& value) override;
94  bool getRawTrackball(unsigned int trackball_id, yarp::sig::Vector& value) override;
95  bool getRawHat(unsigned int hat_id, unsigned char& value) override;
96  bool getRawAxis(unsigned int axis_id, double& value) override;
97  bool getRawStick(unsigned int stick_id, yarp::sig::Vector& value, JoypadCtrl_coordinateMode coordinate_mode) override;
98  bool getRawTouch(unsigned int touch_id, yarp::sig::Vector& value) override;
99 };
JoypadControlClient: joypad input network wrapper on client side
JoypadControlClient(JoypadControlClient &&)=delete
bool getRawAxisCount(unsigned int &axis_count) override
bool getRawHatCount(unsigned int &Hat_count) override
bool getRawButtonCount(unsigned int &button_count) override
JoypadControlClient(const JoypadControlClient &)=delete
bool getRawTrackballCount(unsigned int &Trackball_count) override
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
~JoypadControlClient() override=default
JoypadControlClient & operator=(const JoypadControlClient &)=delete
JoypadControlClient & operator=(JoypadControlClient &&)=delete
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
virtual ~JoypadControlWatchdog()=default
void run() override
Loop function.
std::vector< JoypadControl::LoopablePort * > m_ports
Interface implemented by all device drivers.
Definition: DeviceDriver.h:35
An abstraction for a periodic thread.
PeriodicThread(double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No, PeriodicThreadClock clockAccuracy=PeriodicThreadClock::Relative)
Constructor.
A mini-server for network communication.
Definition: Port.h:47
A base class for nested structures that can be searched.
Definition: Searchable.h:66