author | sandman <sandman> | 2002-06-16 01:31:36 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-06-16 01:31:36 (UTC) |
commit | ac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91 (patch) (unidiff) | |
tree | 9f21f116a4b7057c6a2f1bae45a0dfedc5bcae6b | |
parent | eb414eb5d393f0f727e833fc8901aef096558997 (diff) | |
download | opie-ac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91.zip opie-ac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91.tar.gz opie-ac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91.tar.bz2 |
Keyboard filter restructuring based on model detection:
1) Added a KeyboardFilter to main.cpp
!! Please use this class for low-level/model-based filtering !!
2) Cursor keys are rotated for H31xx and H38xx
3) Power button long-press toggles backlight on iPAQs now
(Mapped to F34/F35 - just like Z's)
-rw-r--r-- | core/launcher/desktop.cpp | 11 | ||||
-rw-r--r-- | core/launcher/launcher.pro | 2 | ||||
-rw-r--r-- | core/launcher/main.cpp | 91 |
3 files changed, 99 insertions, 5 deletions
diff --git a/core/launcher/desktop.cpp b/core/launcher/desktop.cpp index aa51898..ab4f14a 100644 --- a/core/launcher/desktop.cpp +++ b/core/launcher/desktop.cpp | |||
@@ -242,10 +242,13 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
242 | if ( press ) emit power(); | 242 | if ( press ) emit power(); |
243 | return TRUE; | 243 | return TRUE; |
244 | } | 244 | } |
245 | if ( ke->simpleData.keycode == Key_SysReq ) { | 245 | // This was used for the iPAQ PowerButton |
246 | if ( press ) emit power(); | 246 | // See main.cpp for new KeyboardFilter |
247 | return TRUE; | 247 | // |
248 | } | 248 | // if ( ke->simpleData.keycode == Key_SysReq ) { |
249 | // if ( press ) emit power(); | ||
250 | // return TRUE; | ||
251 | // } | ||
249 | if ( ke->simpleData.keycode == Key_F35 ) { | 252 | if ( ke->simpleData.keycode == Key_F35 ) { |
250 | if ( press ) emit backlight(); | 253 | if ( press ) emit backlight(); |
251 | return TRUE; | 254 | return TRUE; |
diff --git a/core/launcher/launcher.pro b/core/launcher/launcher.pro index c77da50..f94f338 100644 --- a/core/launcher/launcher.pro +++ b/core/launcher/launcher.pro | |||
@@ -109,7 +109,7 @@ DEPENDPATH += $(OPIEDIR)/rsync | |||
109 | 109 | ||
110 | TARGET = qpe | 110 | TARGET = qpe |
111 | 111 | ||
112 | LIBS += -lqpe -lcrypt | 112 | LIBS += -lqpe -lcrypt -lopie |
113 | 113 | ||
114 | TRANSLATIONS = ../i18n/de/qpe.ts | 114 | TRANSLATIONS = ../i18n/de/qpe.ts |
115 | TRANSLATIONS += ../i18n/pt_BR/qpe.ts | 115 | TRANSLATIONS += ../i18n/pt_BR/qpe.ts |
diff --git a/core/launcher/main.cpp b/core/launcher/main.cpp index fc6d829..347eee9 100644 --- a/core/launcher/main.cpp +++ b/core/launcher/main.cpp | |||
@@ -34,6 +34,8 @@ | |||
34 | #include <qpe/qcopenvelope_qws.h> | 34 | #include <qpe/qcopenvelope_qws.h> |
35 | #include <qpe/alarmserver.h> | 35 | #include <qpe/alarmserver.h> |
36 | 36 | ||
37 | #include <opie/ohwinfo.h> | ||
38 | |||
37 | #include <stdlib.h> | 39 | #include <stdlib.h> |
38 | #include <stdio.h> | 40 | #include <stdio.h> |
39 | #include <signal.h> | 41 | #include <signal.h> |
@@ -184,6 +186,93 @@ static void initBacklight() | |||
184 | } | 186 | } |
185 | 187 | ||
186 | 188 | ||
189 | class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter | ||
190 | { | ||
191 | public: | ||
192 | ModelKeyFilter ( ) : QObject ( 0, "MODEL_KEY_FILTER" ) | ||
193 | { | ||
194 | bool doinst = false; | ||
195 | |||
196 | m_model = OHwInfo::inst ( )-> model ( ); | ||
197 | m_power_timer = 0; | ||
198 | |||
199 | switch ( m_model ) { | ||
200 | case OMODEL_iPAQ_H31xx: | ||
201 | case OMODEL_iPAQ_H36xx: | ||
202 | case OMODEL_iPAQ_H37xx: | ||
203 | case OMODEL_iPAQ_H38xx: doinst = true; | ||
204 | break; | ||
205 | default : break; | ||
206 | } | ||
207 | if ( doinst ) | ||
208 | QWSServer::setKeyboardFilter ( this ); | ||
209 | } | ||
210 | |||
211 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ) | ||
212 | { | ||
213 | bool kill = false; | ||
214 | |||
215 | // Rotate cursor keys 180° | ||
216 | switch ( m_model ) { | ||
217 | case OMODEL_iPAQ_H31xx: | ||
218 | case OMODEL_iPAQ_H38xx: { | ||
219 | int newkeycode = keycode; | ||
220 | |||
221 | switch ( keycode ) { | ||
222 | case Key_Left : newkeycode = Key_Right; break; | ||
223 | case Key_Right: newkeycode = Key_Left; break; | ||
224 | case Key_Up : newkeycode = Key_Down; break; | ||
225 | case Key_Down : newkeycode = Key_Up; break; | ||
226 | } | ||
227 | if ( newkeycode != keycode ) { | ||
228 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | ||
229 | kill = true; | ||
230 | } | ||
231 | break; | ||
232 | } | ||
233 | default: break; | ||
234 | } | ||
235 | |||
236 | // map Power Button short/long press to F34/F35 | ||
237 | switch ( m_model ) { | ||
238 | case OMODEL_iPAQ_H31xx: | ||
239 | case OMODEL_iPAQ_H36xx: | ||
240 | case OMODEL_iPAQ_H37xx: | ||
241 | case OMODEL_iPAQ_H38xx: { | ||
242 | if ( keycode == Key_SysReq ) { | ||
243 | if ( isPress ) { | ||
244 | m_power_timer = startTimer ( 500 ); | ||
245 | } | ||
246 | else if ( m_power_timer ) { | ||
247 | killTimer ( m_power_timer ); | ||
248 | m_power_timer = 0; | ||
249 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, true, false ); | ||
250 | QWSServer::sendKeyEvent ( -1, Key_F34, 0, false, false ); | ||
251 | } | ||
252 | kill = true; | ||
253 | } | ||
254 | break; | ||
255 | } | ||
256 | default: break; | ||
257 | } | ||
258 | return kill; | ||
259 | } | ||
260 | |||
261 | virtual void timerEvent ( QTimerEvent * ) | ||
262 | { | ||
263 | killTimer ( m_power_timer ); | ||
264 | m_power_timer = 0; | ||
265 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, true, false ); | ||
266 | QWSServer::sendKeyEvent ( -1, Key_F35, 0, false, false ); | ||
267 | } | ||
268 | |||
269 | private: | ||
270 | OHwModel m_model; | ||
271 | bool m_power_press; | ||
272 | int m_power_timer; | ||
273 | }; | ||
274 | |||
275 | |||
187 | 276 | ||
188 | int initApplication( int argc, char ** argv ) | 277 | int initApplication( int argc, char ** argv ) |
189 | { | 278 | { |
@@ -209,6 +298,8 @@ int initApplication( int argc, char ** argv ) | |||
209 | QWSServer::setDesktopBackground( QImage() ); | 298 | QWSServer::setDesktopBackground( QImage() ); |
210 | DesktopApplication a( argc, argv, QApplication::GuiServer ); | 299 | DesktopApplication a( argc, argv, QApplication::GuiServer ); |
211 | 300 | ||
301 | (void) new ModelKeyFilter ( ); | ||
302 | |||
212 | initBacklight(); | 303 | initBacklight(); |
213 | 304 | ||
214 | AlarmServer::initialize(); | 305 | AlarmServer::initialize(); |