]> git.defcon.no Git - joysticktest/blob - joystickthread.h
Working test with Qt GUI. Threaded, with no thread safety.
[joysticktest] / joystickthread.h
1 #ifndef JOYSTICKTHREAD_H
2 #define JOYSTICKTHREAD_H
3
4 #include <QThread>
5 #include "joystickdata.h"
6
7 #define JS_EVENT_BUTTON 0x01 /* button pressed/released */
8 #define JS_EVENT_AXIS 0x02 /* joystick moved */
9 #define JS_EVENT_INIT 0x80 /* initial state of device */
10 #define JS_EVENT_AXISENUM 0x81 /* enumeration of available axis */
11 #define JS_EVENT_BUTTONENUM 0x81 /* enumeration of available buttons */
12
13 struct js_event {
14 unsigned int time; /* event timestamp in milliseconds */
15 short value; /* value */
16 unsigned char type; /* event type */
17 unsigned char number; /* axis/button number */
18 };
19
20 class JoystickThread : public QThread
21 {
22 private:
23 JoystickData *jd;
24 int open_joystick(char *joystick_device);
25 int read_joystick_event(struct js_event *jse);
26
27 int done;
28 int joystick_fd;
29 QString device;
30
31 public:
32 JoystickThread(JoystickData *jd, const QString device);
33 void run();
34 void stop();
35 };
36
37 #endif // JOYSTICKTHREAD_H