-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 53 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 50 | ||||
-rw-r--r-- | libopie2/opiecore/okeyfilter.cpp | 119 | ||||
-rw-r--r-- | libopie2/opiecore/okeyfilter.h | 77 | ||||
-rw-r--r-- | libopie2/opiecore/opiecore.pro | 2 |
5 files changed, 253 insertions, 48 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 16c0538..791e409 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -1,28 +1,28 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
@@ -39,8 +39,9 @@ | |||
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | #include <opie2/okeyfilter.h> | ||
43 | 44 | ||
44 | /* STD */ | 45 | /* STD */ |
45 | #include <fcntl.h> | 46 | #include <fcntl.h> |
46 | #include <math.h> | 47 | #include <math.h> |
@@ -166,10 +167,12 @@ void iPAQ::initButtons() | |||
166 | { | 167 | { |
167 | if ( d->m_buttons ) | 168 | if ( d->m_buttons ) |
168 | return; | 169 | return; |
169 | 170 | ||
170 | if ( isQWS( ) ) | 171 | if ( isQWS( ) ) { |
171 | QWSServer::setKeyboardFilter ( this ); | 172 | Opie::Core::OKeyFilter::inst()->addPreHandler(this); |
173 | //QWSServer::setKeyboardFilter ( this ); | ||
174 | } | ||
172 | 175 | ||
173 | d->m_buttons = new QValueList <ODeviceButton>; | 176 | d->m_buttons = new QValueList <ODeviceButton>; |
174 | 177 | ||
175 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 178 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
@@ -270,18 +273,18 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
270 | } | 273 | } |
271 | break; | 274 | break; |
272 | } | 275 | } |
273 | 276 | ||
274 | // Rotate cursor keys 180° or 270° | 277 | // Rotate cursor keys 180 or 270 |
275 | case Key_Left : | 278 | case Key_Left : |
276 | case Key_Right: | 279 | case Key_Right: |
277 | case Key_Up : | 280 | case Key_Up : |
278 | case Key_Down : { | 281 | case Key_Down : { |
279 | if (( d->m_model == Model_iPAQ_H31xx ) || | 282 | if (( d->m_model == Model_iPAQ_H31xx ) || |
280 | ( d->m_model == Model_iPAQ_H38xx )) { | 283 | ( d->m_model == Model_iPAQ_H38xx )) { |
281 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 284 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
282 | } | 285 | } |
283 | // Rotate the cursor keys by 270° | 286 | // Rotate the cursor keys by 270 |
284 | // keycode - Key_Left = position of the button starting from left clockwise | 287 | // keycode - Key_Left = position of the button starting from left clockwise |
285 | // add the rotation to it and modolo. No we've the original offset | 288 | // add the rotation to it and modolo. No we've the original offset |
286 | // add the offset to the Key_Left key | 289 | // add the offset to the Key_Left key |
287 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 290 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index e62ea18..6c3253c 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -1,28 +1,28 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of the Opie Project | 2 | This file is part of the Opie Project |
3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> | 3 | Copyright (C) The Opie Team <opie-devel@handhelds.org> |
4 | =. | 4 | =. |
5 | .=l. | 5 | .=l. |
6 | .>+-= | 6 | .>+-= |
7 | _;:, .> :=|. This program is free software; you can | 7 | _;:, .> :=|. This program is free software; you can |
8 | .> <`_, > . <= redistribute it and/or modify it under | 8 | .> <`_, > . <= redistribute it and/or modify it under |
9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | 9 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public |
10 | .="- .-=="i, .._ License as published by the Free Software | 10 | .="- .-=="i, .._ License as published by the Free Software |
11 | - . .-<_> .<> Foundation; either version 2 of the License, | 11 | - . .-<_> .<> Foundation; either version 2 of the License, |
12 | ._= =} : or (at your option) any later version. | 12 | ._= =} : or (at your option) any later version. |
13 | .%`+i> _;_. | 13 | .%`+i> _;_. |
14 | .i_,=:_. -<s. This program is distributed in the hope that | 14 | .i_,=:_. -<s. This program is distributed in the hope that |
15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | 15 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; |
16 | : .. .:, . . . without even the implied warranty of | 16 | : .. .:, . . . without even the implied warranty of |
17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | 17 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A |
18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | 18 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU |
19 | ..}^=.= = ; Library General Public License for more | 19 | ..}^=.= = ; Library General Public License for more |
20 | ++= -. .` .: details. | 20 | ++= -. .` .: details. |
21 | : = ...= . :.=- | 21 | : = ...= . :.=- |
22 | -. .:....=;==+<; You should have received a copy of the GNU | 22 | -. .:....=;==+<; You should have received a copy of the GNU |
23 | -_. . . )=. = Library General Public License along with | 23 | -_. . . )=. = Library General Public License along with |
24 | -- :-=` this library; see the file COPYING.LIB. | 24 | -- :-=` this library; see the file COPYING.LIB. |
25 | If not, write to the Free Software Foundation, | 25 | If not, write to the Free Software Foundation, |
26 | Inc., 59 Temple Place - Suite 330, | 26 | Inc., 59 Temple Place - Suite 330, |
27 | Boston, MA 02111-1307, USA. | 27 | Boston, MA 02111-1307, USA. |
28 | */ | 28 | */ |
@@ -39,8 +39,9 @@ | |||
39 | #include <qpe/config.h> | 39 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 40 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 41 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 42 | #include <qpe/qcopenvelope_qws.h> |
43 | #include <opie2/okeyfilter.h> | ||
43 | 44 | ||
44 | /* STD */ | 45 | /* STD */ |
45 | #include <fcntl.h> | 46 | #include <fcntl.h> |
46 | #include <math.h> | 47 | #include <math.h> |
@@ -144,10 +145,13 @@ void SIMpad::initButtons() | |||
144 | { | 145 | { |
145 | if ( d->m_buttons ) | 146 | if ( d->m_buttons ) |
146 | return; | 147 | return; |
147 | 148 | ||
148 | if ( isQWS( ) ) | 149 | if ( isQWS( ) ) { |
149 | QWSServer::setKeyboardFilter ( this ); | 150 | Opie::Core::OKeyFilter::inst()->addPreHandler(this); |
151 | // QWSServer::setKeyboardFilter ( this ); | ||
152 | } | ||
153 | |||
150 | 154 | ||
151 | d->m_buttons = new QValueList <ODeviceButton>; | 155 | d->m_buttons = new QValueList <ODeviceButton>; |
152 | 156 | ||
153 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 157 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
diff --git a/libopie2/opiecore/okeyfilter.cpp b/libopie2/opiecore/okeyfilter.cpp new file mode 100644 index 0000000..d806dbd --- a/dev/null +++ b/libopie2/opiecore/okeyfilter.cpp | |||
@@ -0,0 +1,119 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> | ||
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
28 | |||
29 | #include "okeyfilter.h" | ||
30 | #include "device/odevice.h" | ||
31 | #include "odebug.h" | ||
32 | |||
33 | namespace Opie { | ||
34 | namespace Core { | ||
35 | |||
36 | QValueList<QWSServer::KeyboardFilter*> OKeyFilter::filterList; | ||
37 | QValueList<QWSServer::KeyboardFilter*> OKeyFilter::preFilterList; | ||
38 | |||
39 | OKeyFilter::OKeyFilter() | ||
40 | :QWSServer::KeyboardFilter() | ||
41 | { | ||
42 | filterList.clear(); | ||
43 | preFilterList.clear(); | ||
44 | if ( isQWS( ) ) { | ||
45 | QWSServer::setKeyboardFilter ( this ); | ||
46 | } | ||
47 | } | ||
48 | |||
49 | OKeyFilter::~OKeyFilter() | ||
50 | { | ||
51 | } | ||
52 | |||
53 | OKeyFilter* OKeyFilter::inst() | ||
54 | { | ||
55 | static OKeyFilter*ofilter = 0; | ||
56 | if (!ofilter) { | ||
57 | ofilter = new OKeyFilter; | ||
58 | } | ||
59 | return ofilter; | ||
60 | } | ||
61 | |||
62 | bool OKeyFilter::filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
63 | { | ||
64 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
65 | for (iter=preFilterList.begin();iter!=preFilterList.end();++iter) { | ||
66 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | ||
67 | return true; | ||
68 | } | ||
69 | } | ||
70 | for (iter=filterList.begin();iter!=filterList.end();++iter) { | ||
71 | if ((*iter)->filter(unicode,keycode,modifiers,isPress,autoRepeat)) { | ||
72 | return true; | ||
73 | } | ||
74 | } | ||
75 | return false; | ||
76 | } | ||
77 | |||
78 | void OKeyFilter::addHandler(QWSServer::KeyboardFilter*aF) | ||
79 | { | ||
80 | if (filterList.find(aF)!=filterList.end()) { | ||
81 | return; | ||
82 | } | ||
83 | odebug << "adding a keyboard filter handler"<<oendl; | ||
84 | filterList.append(aF); | ||
85 | } | ||
86 | |||
87 | void OKeyFilter::remHandler(QWSServer::KeyboardFilter*aF) | ||
88 | { | ||
89 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
90 | if ( (iter=filterList.find(aF))==filterList.end() ) { | ||
91 | return; | ||
92 | } | ||
93 | odebug << "removing a keyboard filter handler"<<oendl; | ||
94 | filterList.remove(iter); | ||
95 | } | ||
96 | |||
97 | void OKeyFilter::addPreHandler(QWSServer::KeyboardFilter*aF) | ||
98 | { | ||
99 | if (preFilterList.find(aF)!=preFilterList.end()) { | ||
100 | return; | ||
101 | } | ||
102 | odebug << "adding a preferred keyboard filter handler"<<oendl; | ||
103 | preFilterList.append(aF); | ||
104 | } | ||
105 | |||
106 | void OKeyFilter::remPreHandler(QWSServer::KeyboardFilter*aF) | ||
107 | { | ||
108 | QValueList<QWSServer::KeyboardFilter*>::Iterator iter; | ||
109 | if ( (iter=preFilterList.find(aF))==preFilterList.end() ) { | ||
110 | return; | ||
111 | } | ||
112 | odebug << "removing a preferred keyboard filter handler"<<oendl; | ||
113 | preFilterList.remove(iter); | ||
114 | } | ||
115 | |||
116 | /* namespace Core */ | ||
117 | } | ||
118 | /* namespace Opie */ | ||
119 | } | ||
diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h new file mode 100644 index 0000000..3f9f744 --- a/dev/null +++ b/libopie2/opiecore/okeyfilter.h | |||
@@ -0,0 +1,77 @@ | |||
1 | /* | ||
2 | This file is part of the Opie Project | ||
3 | =. Copyright (C) 2004 Rajko 'Alwin' Albrecht <alwin@handhelds.org> | ||
4 | .=l. Copyright (C) The Opie Team <opie-devel@handhelds.org> | ||
5 | .>+-= | ||
6 | _;:, .> :=|. This program is free software; you can | ||
7 | .> <`_, > . <= redistribute it and/or modify it under | ||
8 | :`=1 )Y*s>-.-- : the terms of the GNU Library General Public | ||
9 | .="- .-=="i, .._ License as published by the Free Software | ||
10 | - . .-<_> .<> Foundation; either version 2 of the License, | ||
11 | ._= =} : or (at your option) any later version. | ||
12 | .%`+i> _;_. | ||
13 | .i_,=:_. -<s. This program is distributed in the hope that | ||
14 | + . -:. = it will be useful, but WITHOUT ANY WARRANTY; | ||
15 | : .. .:, . . . without even the implied warranty of | ||
16 | =_ + =;=|` MERCHANTABILITY or FITNESS FOR A | ||
17 | _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU | ||
18 | ..}^=.= = ; Library General Public License for more | ||
19 | ++= -. .` .: details. | ||
20 | : = ...= . :.=- | ||
21 | -. .:....=;==+<; You should have received a copy of the GNU | ||
22 | -_. . . )=. = Library General Public License along with | ||
23 | -- :-=` this library; see the file COPYING.LIB. | ||
24 | If not, write to the Free Software Foundation, | ||
25 | Inc., 59 Temple Place - Suite 330, | ||
26 | Boston, MA 02111-1307, USA. | ||
27 | */ | ||
28 | |||
29 | /* QT */ | ||
30 | #include <qwindowsystem_qws.h> | ||
31 | #include <qvaluelist.h> | ||
32 | |||
33 | namespace Opie { | ||
34 | namespace Core { | ||
35 | class ODevice; | ||
36 | namespace Internal { | ||
37 | class iPAQ; | ||
38 | class SIMpad; | ||
39 | } | ||
40 | |||
41 | /** | ||
42 | * A singleton which will manage all possible keyboard filters inside opie. | ||
43 | * It makes sure that key handlers of odevice are checked first than the | ||
44 | * keyfilters of software. | ||
45 | * @short a keyfilter proxy | ||
46 | * @see QWSServer::KeyboardFilter | ||
47 | * @author Rajko Albrecht | ||
48 | * @version 1.0 | ||
49 | */ | ||
50 | class OKeyFilter:public QWSServer::KeyboardFilter | ||
51 | { | ||
52 | friend class Opie::Core::ODevice; | ||
53 | friend class Opie::Core::Internal::iPAQ; | ||
54 | friend class Opie::Core::Internal::SIMpad; | ||
55 | |||
56 | static QValueList<QWSServer::KeyboardFilter*> filterList; | ||
57 | static QValueList<QWSServer::KeyboardFilter*> preFilterList; | ||
58 | |||
59 | OKeyFilter(); | ||
60 | OKeyFilter(const OKeyFilter&):QWSServer::KeyboardFilter(){}; | ||
61 | |||
62 | protected: | ||
63 | void addPreHandler(QWSServer::KeyboardFilter*); | ||
64 | void remPreHandler(QWSServer::KeyboardFilter*); | ||
65 | |||
66 | public: | ||
67 | virtual ~OKeyFilter(); | ||
68 | virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | ||
69 | |||
70 | void addHandler(QWSServer::KeyboardFilter*); | ||
71 | void remHandler(QWSServer::KeyboardFilter*); | ||
72 | |||
73 | static OKeyFilter*inst(); | ||
74 | }; | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro index 5056d48..8189a7c 100644 --- a/libopie2/opiecore/opiecore.pro +++ b/libopie2/opiecore/opiecore.pro | |||
@@ -6,8 +6,9 @@ HEADERS = oapplication.h \ | |||
6 | odebug.h \ | 6 | odebug.h \ |
7 | oglobal.h \ | 7 | oglobal.h \ |
8 | oglobalsettings.h \ | 8 | oglobalsettings.h \ |
9 | okeyconfigmanager.h \ | 9 | okeyconfigmanager.h \ |
10 | okeyfilter.h \ | ||
10 | opluginloader.h \ | 11 | opluginloader.h \ |
11 | oprocess.h \ | 12 | oprocess.h \ |
12 | oprocctrl.h \ | 13 | oprocctrl.h \ |
13 | osmartpointer.h \ | 14 | osmartpointer.h \ |
@@ -19,8 +20,9 @@ SOURCES = oapplication.cpp \ | |||
19 | odebug.cpp \ | 20 | odebug.cpp \ |
20 | oglobal.cpp \ | 21 | oglobal.cpp \ |
21 | oglobalsettings.cpp \ | 22 | oglobalsettings.cpp \ |
22 | okeyconfigmanager.cpp \ | 23 | okeyconfigmanager.cpp \ |
24 | okeyfilter.cpp \ | ||
23 | opluginloader.cpp \ | 25 | opluginloader.cpp \ |
24 | oprocess.cpp \ | 26 | oprocess.cpp \ |
25 | oprocctrl.cpp \ | 27 | oprocctrl.cpp \ |
26 | ostorageinfo.cpp \ | 28 | ostorageinfo.cpp \ |