-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmousedrv.h
198 lines (157 loc) · 4.88 KB
/
mousedrv.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
#ifndef MOUSEDRV_H
#define MOUSEDRV_H
#include <QtGui/QMainWindow>
#include <QSharedPointer>
#include <QTimer>
#include "ui_mousedrv.h"
#include "HidCtrl.h"
struct Stru_MouseMap
{
Stru_MouseMap();
Stru_MouseMap(int mode,uchar var0,uchar var1,uchar var2);
bool operator ==(const Stru_MouseMap &other) const;
unsigned char mode;
QVector<unsigned char> para;
};
struct Stru_DefineNode;
typedef QSharedPointer<Stru_DefineNode> DefinePtr;
struct Stru_DefineNode
{
Stru_DefineNode();
int type; //0 file,1 dir
QString name;
HdiMouseDefine define;
int defineType; //00 指定循环次数 01 直到有任一键按下 02 直到按键松开
QList<DefinePtr> dir;
QString guid;
};
Q_DECLARE_METATYPE(DefinePtr)
QDataStream& operator >>(QDataStream &stream,DefinePtr &profile);
QDataStream& operator <<(QDataStream &stream,const DefinePtr &profile);
void updateTreeDefine(QTreeWidgetItem *item,DefinePtr defineNode); //用defineNode,更新item
void addTreeDefine(QTreeWidgetItem *item,DefinePtr defineNode); //将defineNode,添加到item
//Stru_MouseProfile
struct Stru_MouseProfile
{
Stru_MouseProfile();
QString name;
HdiMousePara para;
HdiMouseMap map;
unsigned char reportGap;
QVector<QString> defineGuid;
QVector<int> dpiLevel;
};
QDataStream& operator >>(QDataStream &stream,Stru_MouseProfile &profile);
QDataStream& operator <<(QDataStream &stream,const Stru_MouseProfile &profile);
class MouseDrv : public QMainWindow
{
Q_OBJECT
public:
MouseDrv(QWidget *parent = 0, Qt::WFlags flags = 0);
~MouseDrv();
protected slots:
void onTabChange();
void onBtnMin();
void onBtnExit();
void onBtnProfileSel();
void onBtnProfileSet();
void onBtnSave();
void onBtnRecover();
void onBtnKey();
void onDPIChkBox();
void onDPIColorChanged();
void updateDPILabel();
void updateDPIPara();
void onBtnLed();
void onBtnFreq();
void updateSpeedLabel();
void updateSpeedPara();
void onBtnStartDefine();
void onBtnSaveDefine();
void onBtnDefineType();
void treeKeyUpdate();
void treeDefineContextMenu(const QPoint &pos);
void treeKeyContextMenu(const QPoint &pos);
void treeKeyDoubleClicked(QListWidgetItem *item);
void onHidTimerOut();
void onDelaySave();
protected:
enum{
SAVE_NONE = 0,
SAVE_PARA = 1,
SAVE_KEY_MAP = 2,
SAVE_REPORT_GAP = 4,
SAVE_ALL = SAVE_PARA | SAVE_KEY_MAP | SAVE_REPORT_GAP,
};
virtual void mousePressEvent(QMouseEvent *event);
virtual void mouseMoveEvent(QMouseEvent *event);
virtual void mouseReleaseEvent(QMouseEvent *event);
virtual bool eventFilter(QObject *obj, QEvent *event);
void initHrdMouse();
void initMouseSpecial();
void initDpiPage();
void updateTabColor();
QAction *showMenu(QPushButton *btn,QMenu &menu);
int toHrdIdx(int sys_key_idx);
int toSysIdx(int hdr_key_idx);
void InitProFile();
void SaveProFile(QString file_name);
bool LoadProFile(QString file_name);
void SwitchProFile(int idx);
void LoadDefine();
void SaveDefine();
bool SaveMouseSetting(int type);
bool SaveMouseSettingDelay(int type);
void LoadMouseSetting(int type);
void SetMousePara();
void GetMousePara();
void initMapTable();
void SetMouseMap();
void GetMouseMap();
void SetMouseGap();
void GetMouseGap();
DefinePtr FindDefine(DefinePtr ptr,QString name);
DefinePtr FindDefineByGuid(DefinePtr ptr,QString guid);
DefinePtr getTreeDefine(); //得到当前选中的宏定义,dir返回空
void updateTreeKeyList(HdiMouseDefine define);
int getDefineType();
void showBtnSaveDefine();
void hideBtnSaveDefine();
void onSetDefineDelay(const QPoint &pos);
private:
Ui::MouseDrvClass ui;
QString mMenuStyle;
QVector<QPushButton*> mBtnKey;
QVector<QSlider*> mDpiSlider;
QVector<QLabel*> mDpiLabel;
QVector<QCheckBox*> mDpiChkBox;
QVector<ColorButton*> mDpiColor;
QVector<QRadioButton*> mRadioDefine;
//define
bool mRecord;
HdiMouseDefine mRecordDefine;
DefinePtr curDefine;
//move window
QPoint windowPos,mousePos,dPos;
bool m_drag, m_move;
QPoint dragPos;
//hid ctrl
QVector<int> DPI_TABLE;
QMap<QString,Stru_MouseMap> mouseMap;
QMap<QString,unsigned char> ledMap;
QMap<QString,unsigned char> mReportGapMap;
QMap<QString,int> mouseButtonMap;
QMap<QString,Stru_MouseMap> mMediaMap;
Stru_MouseProfile *mProfile;
QVector<Stru_MouseProfile> mProfileList;
DefinePtr mDefineRoot;
int mProFileIdx;
QString mProfilePath;
CHidCtrl mHidCtrl;
int mSensorType;
int mMouseID;
int mSaveFlag;
bool m_bInit;
QTimer mHidTimer;
};
#endif // MOUSEDRV_H