YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
SDLJoypad.h
Go to the documentation of this file.
1/*
2 * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3 * SPDX-License-Identifier: LGPL-2.1-or-later
4 */
5
6#ifndef SDLJOYPAD_H
7#define SDLJOYPAD_H
8
11#include <SDL.h>
12#include <vector>
13
14
15
16namespace SDLJoypadImpl {
17 struct stick;
18}
19
20
22{
23 std::vector<unsigned int> axes_ids;
24 float deadZone;
25 std::vector<int> direction;
26};
27
28
48class SDLJoypad :
50 // public yarp::dev::IJoypadController,
52{
53 typedef std::vector<SDLJoypadImpl::stick> stickVector;
54
55 SDL_Event m_event;
56 std::vector<SDL_Joystick*> m_device;
57 unsigned int m_buttonCount {0};
58 unsigned int m_axisCount {0};
59 unsigned int m_stickCount {0};
60 unsigned int m_touchCount {0};
61 unsigned int m_ballCount {0};
62 unsigned int m_hatCount {0};
63 bool m_allJoypad;
64 stickVector m_sticks;
65 std::vector<bool> m_axes;
66 double m_actionTimestamp;
67
68 void updateJoypad();
69 void pollActions();
70 bool parseStickInfo(const yarp::os::Searchable& cfg);
71 bool getPureAxis(unsigned int axis_id, double& value);
72public:
73
75 virtual ~SDLJoypad();
76 //DeviceDriver
77 bool open(yarp::os::Searchable& config) override;
78 bool close() override;
79
80 //IJoypadController
81 bool getRawAxisCount(unsigned int& axis_count) override;
82
83 bool getRawButtonCount(unsigned int& button_count) override;
84
85 bool getRawHatCount(unsigned int& hat_count) override;
86
87 bool getRawTrackballCount(unsigned int& trackball_count) override;
88
89 bool getRawTouchSurfaceCount(unsigned int& touch_count) override;
90
91 bool getRawStickCount(unsigned int& stick_count) override;
92
93 bool getRawStickDoF(unsigned int stick_id, unsigned int& DoF) override;
94
95 bool getRawButton(unsigned int button_id, float& value) override;
96
97 bool getRawTrackball(unsigned int trackball_id, yarp::sig::Vector& value) override;
98
99 bool getRawHat(unsigned int hat_id, unsigned char& value) override;
100
101 bool getRawAxis(unsigned int axis_id, double& value) override;
102
103 bool getRawStick(unsigned int stick_id, yarp::sig::Vector& value, JoypadCtrl_coordinateMode coordinate_mode) override;
104
105 bool getRawTouch(unsigned int touch_id, yarp::sig::Vector& value) override;
106};
107
108
109#endif //#define SDLJOYPAD_H
SDLJoypad: Device that reads inputs of Joypads compatible with the SDL library.
Definition SDLJoypad.h:52
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
virtual ~SDLJoypad()
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 open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition SDLJoypad.cpp:30
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
Interface implemented by all device drivers.
A base class for nested structures that can be searched.
Definition Searchable.h:31
std::vector< unsigned int > axes_ids
Definition SDLJoypad.h:23
std::vector< int > direction
Definition SDLJoypad.h:25