-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqhidevice.h
40 lines (35 loc) · 1.16 KB
/
qhidevice.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
#ifndef QHIDEVICE_H
#define QHIDEVICE_H
#include <QObject>
#include <QTimer>
#include <hidapi/hidapi.h>
#include <qhidapi_global.h>
class QHIDAPISHARED_EXPORT QHIDevice : public QObject
{
Q_OBJECT
QByteArray recvBuf,reportBuf;
size_t expectData;
hid_device* _device;
QTimer poll, _timeout;
explicit QHIDevice(hid_device* dev, QObject *parent = 0);
public:
explicit QHIDevice(QString path, QObject *parent = 0);
QHIDevice(quint16 vendor_id, quint16 product_id, QObject *parent = 0);
QHIDevice(quint16 vendor_id, quint16 product_id, const QString& serial_number, QObject *parent = 0);
bool good();
QString manufacturer();
QString product();
QString serial();
QString indexedString(int index);
signals:
void receivedData(QByteArray data);
void receivedReport(QByteArray data);
void timeout();
void error(QString error);
public slots:
void read(size_t length, int timeout_ms = 0); //Send signal once length bytes received
void getReport(size_t length, int timeout_ms = 0); //Send signal once length bytes received
int write(const QByteArray& data);
int sendReport(const QByteArray& data);
};
#endif // QHIDEVICE_H