-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathperipheralcontrol.h
More file actions
50 lines (42 loc) · 1.35 KB
/
peripheralcontrol.h
File metadata and controls
50 lines (42 loc) · 1.35 KB
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
#ifndef PERIPHERALCONTROL_H
#define PERIPHERALCONTROL_H
#include <QMap>
#include <QObject>
// namespace name
struct KeyBoardInfo{
quint8 peripheralType; // 0 表示键盘, 1表示鼠标 其他暂时未定义
quint64 keyCode;
quint8 keyState;
quint32 count;
KeyBoardInfo()
: peripheralType(0)
,keyCode(0)
, keyState(0)
, count(0)
{}
};
class PeripheralControl : public QObject
{
Q_OBJECT
public:
enum KeyBordState{KeyBoardDownUp,KeyBordDown,KeyBordUp};
explicit PeripheralControl(QObject *parent = nullptr);
bool KeyBoardEvent(const quint64 keyCode, const quint8 keyState);
bool MouseLeftClick(const int dx, const int dy, const int once);
bool MouseRightClick(const int dx, const int dy, const int once);
void InsertKeyBoard(const quint64 keyCode, const quint8 keyState, const quint32 count);
void RunScript();
void ClearScript();
void ClearkeyBoardDownEvent();
private:
bool MouseEvent(const int dx, const int dy, const bool absolute);
void MouseLeftDown();
void MouseLeftUp();
void MouseRightDown();
void MouseRightUp();
void printKeyBoardEntry(const int code, const int state) const;
quint8 scanCodeFunc(const quint64 pKey);
QMap<quint64,KeyBoardInfo> periheralEventMap_;
quint64 lastKeyBoradCode = 0;
};
#endif // PERIPHERALCONTROL_H