-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller.h
55 lines (45 loc) · 1.29 KB
/
controller.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#ifndef CONTROLLER_H
#define CONTROLLER_H
#include <QObject>
#include <QTimer>
#include <QDebug>
#include <QFuture>
#include <QtConcurrent/QtConcurrent>
#include <linux/joystick.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
class controller : public QObject
{
Q_OBJECT
Q_PROPERTY(QString loc MEMBER loc NOTIFY locChanged)
Q_PROPERTY(bool locValid READ getLocValid NOTIFY locValidChanged)
Q_PROPERTY(float yaw MEMBER yaw NOTIFY yawChanged)
Q_PROPERTY(float roll MEMBER roll NOTIFY rollChanged)
Q_PROPERTY(float pitch MEMBER pitch NOTIFY pitchChanged)
Q_PROPERTY(float throtl MEMBER throtl NOTIFY throtlChanged)
QString loc;
bool locValid = false;
int fdescriptor = -1;
QTimer dataReady;
QFuture<void> future;
// QFuture<void> future;
private slots:
void initController();
void emitSignals();
public:
float yaw = 0, roll = 0, pitch = 0, throtl = 0;
explicit controller(QObject *parent = nullptr);
bool getLocValid(){return locValid;};
void processEvent();
~controller(){locValid = false; close(fdescriptor);};
signals:
void yawChanged();
void rollChanged();
void pitchChanged();
void throtlChanged();
void inputReady();
void locChanged();
void locValidChanged();
};
#endif // CONTROLLER_H