blob: a99c1818792672018fecc973cbe1e6271c5f4e0b (
plain)
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
|
#ifndef _KEY_MODIFIERS_H_
#define _KEY_MODIFIERS_H_
#include <qmap.h>
#include <qtimer.h>
#include <qvaluelist.h>
#include <qnamespace.h>
#include <qpe/config.h>
#include "ConfigEx.h"
struct ModifierInfo {
public:
ModifierInfo(const QString& tp, int code, int mask, bool mode)
{
type = tp;
keycode = code;
keymask = mask;
pressed = false;
toggled = false;
toggle_mode = mode;
}
QString type;
int keycode;
int keymask;
bool pressed;
bool toggled;
bool toggle_mode;
private:
} ;
class KeyModifiers : public QObject
{
Q_OBJECT
public:
typedef QValueList<ModifierInfo*> ModifierList;
KeyModifiers();
virtual ~KeyModifiers();
void addType(const QString& type);
ModifierInfo* assign(const QString& type, int keycode,
int keymask = 0, bool toggle = false);
void assignRelease(int keycode);
void assignRelease(ModifierInfo* info, int keycode);
void setToggle();
void setToggle(ModifierInfo* info);
bool isToggled();
void resetStates();
void keepToggles();
bool pressKey(int keycode, int modifiers);
void releaseKey(int keycode);
int getState();
int getState(int modifiers, bool reset = false);
int getMask(const QString& type);
int getModifiers(int modifiers);
bool isModifier(int keycode);
void statistics();
void reset();
public slots:
void resetToggles();
private:
QMap<QString, int> m_types;
int m_bitmask;
ModifierList m_modifiers;
QMap<int, ModifierList*> m_releasekeys;
ModifierList m_togglekeys;
ModifierInfo* m_info;
QTimer* m_pTimer;
int m_timeout;
void clear();
void init();
};
#endif /* _KEY_MODIFIERS_H_ */
|