YARP
Yet Another Robot Platform
JoypadControlClient.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 #include <yarp/dev/DeviceDriver.h>
11 #include <yarp/os/PeriodicThread.h>
12 #include <vector>
13 #include <JoypadControlNetUtils.h>
14 
28 #define DEFAULT_THREAD_PERIOD 10
29 
32 {
33 public:
35  virtual ~JoypadControlWatchdog() = default;
36 
37 
38  std::vector<JoypadControl::LoopablePort*> m_ports;
39  void run() override;
40 
41 };
42 
46 {
47 private:
48  //---------------utils
49  template<typename T>
51  typedef yarp::sig::Vector Vector;
53 
54  //---------------properties
55  yarp::os::Port m_rpcPort;
56  JOYPORT<Vector> m_buttonsPort;
57  JOYPORT<Vector> m_axisPort;
58  JOYPORT<Vector> m_trackballPort;
59  JOYPORT<Vector> m_touchPort;
60  JOYPORT<CharVector> m_hatsPort;
61  JOYPORT<Vector> m_stickPort;
62  std::vector<size_t> m_stickDof;
63  bool m_rpc_only;
64  std::string m_local;
65  std::string m_remote;
66 
67  JoypadControlWatchdog watchdog;
68  std::vector<JoypadControl::LoopablePort*> m_ports;
69 
70  //--------------method
71  bool getCount(const int& vocab_toget, unsigned int& value);
72  bool getJoypadInfo();
73 
74 public:
80  ~JoypadControlClient() override = default;
81 
82  //rateThread
83 
84  //DeviceDriver
85  bool open(yarp::os::Searchable& config) override;
86  bool close() override;
87 
88  //IJoypadController;
89  bool getRawAxisCount(unsigned int& axis_count) override;
90  bool getRawButtonCount(unsigned int& button_count) override;
91  bool getRawTrackballCount(unsigned int& Trackball_count) override;
92  bool getRawHatCount(unsigned int& Hat_count) override;
93  bool getRawTouchSurfaceCount(unsigned int& touch_count) override;
94  bool getRawStickCount(unsigned int& stick_count) override;
95  bool getRawStickDoF(unsigned int stick_id, unsigned int& DoF) override;
96  bool getRawButton(unsigned int button_id, float& value) override;
97  bool getRawTrackball(unsigned int trackball_id, yarp::sig::Vector& value) override;
98  bool getRawHat(unsigned int hat_id, unsigned char& value) override;
99  bool getRawAxis(unsigned int axis_id, double& value) override;
100  bool getRawStick(unsigned int stick_id, yarp::sig::Vector& value, JoypadCtrl_coordinateMode coordinate_mode) override;
101  bool getRawTouch(unsigned int touch_id, yarp::sig::Vector& value) override;
102 };
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:38
An abstraction for a periodic thread.
PeriodicThread(double period, ShouldUseSystemClock useSystemClock=ShouldUseSystemClock::No)
Constructor.
A mini-server for network communication.
Definition: Port.h:50
A base class for nested structures that can be searched.
Definition: Searchable.h:69