author | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
---|---|---|
committer | alwin <alwin> | 2005-02-28 09:40:30 (UTC) |
commit | 2b64a84d39eeed5681d0ee5068c7d11a01527750 (patch) (unidiff) | |
tree | c8693340dbc5ef5e2f9afa90b690829ddff2c4bd /noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp | |
parent | 61fa699140c5efbb6ba0bf2a62f7e8fbf62976be (diff) | |
download | opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.zip opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.gz opie-2b64a84d39eeed5681d0ee5068c7d11a01527750.tar.bz2 |
other keymapping tool - not working this moment, I have to check it out
- the reason is that the config file is somewhat easier to understand than
from zkbapplet and has a nice config tool.
Please don't put it into any repositories this moment.
Diffstat (limited to 'noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp | 111 |
1 files changed, 111 insertions, 0 deletions
diff --git a/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp new file mode 100644 index 0000000..a61ea0a --- a/dev/null +++ b/noncore/applets/keyhelper/keyhelperapplet/extension/KeyExtensions.cpp | |||
@@ -0,0 +1,111 @@ | |||
1 | #include "KeyExtensions.h" | ||
2 | |||
3 | KeyExtensions::KeyExtensions() | ||
4 | { | ||
5 | qDebug("KeyExtensions::KeyExtensions()"); | ||
6 | m_cancelcode = 0; | ||
7 | } | ||
8 | |||
9 | KeyExtensions::~KeyExtensions() | ||
10 | { | ||
11 | qDebug("KeyExtensions::~KeyExtensions()"); | ||
12 | clear(); | ||
13 | } | ||
14 | |||
15 | void KeyExtensions::assign(const QString& kind, int keycode, | ||
16 | int keymask, const QValueList<int>& modcodes) | ||
17 | { | ||
18 | ExtensionInterface* ext; | ||
19 | #if 0 | ||
20 | ext = m_oExtFactory.createInstance(kind); | ||
21 | if(ext != NULL){ | ||
22 | ext->setKeycode(keycode); | ||
23 | ext->setKeymask(keymask); | ||
24 | ext->setModcodes(modcodes); | ||
25 | } | ||
26 | #else | ||
27 | ext = m_oExtFactory.createInstance(kind, keycode, keymask); | ||
28 | if(ext != NULL){ | ||
29 | ext->setModcodes(modcodes); | ||
30 | } | ||
31 | #endif | ||
32 | } | ||
33 | |||
34 | void KeyExtensions::assign(const QString& kind, int keycode, | ||
35 | int keymask, int modcode) | ||
36 | { | ||
37 | QValueList<int> modcodes; | ||
38 | modcodes.append(modcode); | ||
39 | assign(kind, keycode, keymask, modcodes); | ||
40 | } | ||
41 | |||
42 | bool KeyExtensions::doKey(int keycode, int keymask, bool isPress) | ||
43 | { | ||
44 | bool fCancel = false; | ||
45 | ExtensionList& list = m_oExtFactory.getList(); | ||
46 | for(ExtensionList::Iterator it=list.begin(); | ||
47 | it!=list.end(); ++it){ | ||
48 | if(isPress){ | ||
49 | int code = (*it)->getKeycode(); | ||
50 | if((*it)->getKeymask() == keymask | ||
51 | && (code == 0 || code == keycode)){ | ||
52 | if((*it)->onKeyPress(keycode)){ | ||
53 | fCancel = true; | ||
54 | } | ||
55 | qWarning("ext:onKeyPress[%s][%x][%d]", | ||
56 | (*it)->kind().latin1(), | ||
57 | (*it)->getKeycode(), | ||
58 | fCancel); | ||
59 | } | ||
60 | } else { | ||
61 | if(keycode == m_cancelcode){ | ||
62 | fCancel = true; | ||
63 | } | ||
64 | const QValueList<int>& rlist = (*it)->getModcodes(); | ||
65 | if(rlist.contains(keycode)){ | ||
66 | if((*it)->onModRelease(keycode)){ | ||
67 | m_pModifiers->resetToggles(); | ||
68 | } | ||
69 | qWarning("ext:onModRelease[%s][%x]", | ||
70 | (*it)->kind().latin1(), | ||
71 | keycode); | ||
72 | } | ||
73 | } | ||
74 | } | ||
75 | if(isPress && fCancel){ | ||
76 | m_cancelcode = keycode; | ||
77 | } else { | ||
78 | m_cancelcode = 0; | ||
79 | } | ||
80 | return(fCancel); | ||
81 | } | ||
82 | |||
83 | void KeyExtensions::clear() | ||
84 | { | ||
85 | m_oExtFactory.clear(); | ||
86 | } | ||
87 | |||
88 | void KeyExtensions::reset() | ||
89 | { | ||
90 | //clear(); | ||
91 | m_oExtFactory.reset(); | ||
92 | } | ||
93 | |||
94 | void KeyExtensions::init() | ||
95 | { | ||
96 | m_oExtFactory.sweep(); | ||
97 | } | ||
98 | |||
99 | void KeyExtensions::statistics() | ||
100 | { | ||
101 | qWarning("KeyExtensions::statistics()"); | ||
102 | ExtensionList& list = m_oExtFactory.getList(); | ||
103 | for(ExtensionList::Iterator it=list.begin(); | ||
104 | it!=list.end(); ++it){ | ||
105 | qWarning(" [%s][%x][%x]", | ||
106 | (*it)->kind().latin1(), | ||
107 | (*it)->getKeycode(), | ||
108 | (*it)->getKeymask()); | ||
109 | } | ||
110 | } | ||
111 | |||