qtopengl_joystick.h
Go to the documentation of this file.
1 
10 #ifndef QT_OPENGL_JOYSTICK_H
11 #define QT_OPENGL_JOYSTICK_H
12 
13 #include <QObject>
14 #include <QMap>
15 #include <QTime>
16 #include <QTimer>
17 #include <QStringList>
18 #include <SDL/SDL.h>
19 
20 #define SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT 25
21 #define SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY 250
22 
23 namespace argos {
24 
25  class CQTOpenGLJoystick : public QObject
26  {
27  Q_OBJECT
28 
29  public:
30  QStringList joystickNames;
31  SDL_Joystick *joystick;
32  int numAxes;
34  int numHats;
38  bool autoRepeat;
39  QTimer joystickTimer;
40  QMap<int, int> deadzones;
41  QMap<int, int> sensitivities;
42 
43  CQTOpenGLJoystick(QObject *parent = 0,
44  int joystickEventTimeout = SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT,
45  bool doAutoRepeat = TRUE,
48  void open(int);
49  void close();
50  inline bool isOpen() const { return joystick != NULL; }
51  int getAxisValue(int);
52  inline bool connected() const { return !joystickNames.isEmpty(); }
53 
54  private:
55  QMap<int, Sint16> axes;
56  QMap<int, Uint8> buttons;
57  QMap<int, Uint8> hats;
58  QMap<int, QTime> axisRepeatTimers;
59  QMap<int, QTime> buttonRepeatTimers;
60  QMap<int, QTime> hatRepeatTimers;
61 
62  signals:
63  void axisValueChanged(int axis, int value);
64  void buttonValueChanged(int button, bool value);
65  void hatValueChanged(int hat, int value);
66  void trackballValueChanged(int trackball, int deltaX, int deltaY);
67 
68  public slots:
69  void processEvents();
70  };
71 
72 }
73 
74 #endif
#define SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT
#define SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY
The namespace containing all the ARGoS related code.
Definition: ci_actuator.h:12
void hatValueChanged(int hat, int value)
void buttonValueChanged(int button, bool value)
CQTOpenGLJoystick(QObject *parent=0, int joystickEventTimeout=SDL_JOYSTICK_DEFAULT_EVENT_TIMEOUT, bool doAutoRepeat=TRUE, int autoRepeatDelay=SDL_JOYSTICK_DEFAULT_AUTOREPEAT_DELAY)
void trackballValueChanged(int trackball, int deltaX, int deltaY)
QMap< int, int > deadzones
void axisValueChanged(int axis, int value)
QMap< int, int > sensitivities