summaryrefslogtreecommitdiff
authorsandman <sandman>2002-06-16 01:31:36 (UTC)
committer sandman <sandman>2002-06-16 01:31:36 (UTC)
commitac7ddc479efedd5cbfb0f4a8a3e4fa304abfaa91 (patch) (unidiff)
tree9f21f116a4b7057c6a2f1bae45a0dfedc5bcae6b
parenteb414eb5d393f0f727e833fc8901aef096558997 (diff)
downloadopie-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)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--core/launcher/desktop.cpp11
-rw-r--r--core/launcher/launcher.pro2
-rw-r--r--core/launcher/main.cpp91
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
@@ -241,12 +241,15 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
241 if ( ke->simpleData.keycode == Key_F34 ) { 241 if ( ke->simpleData.keycode == Key_F34 ) {
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;
252 } 255 }
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
@@ -108,9 +108,9 @@ INCLUDEPATH += $(OPIEDIR)/rsync
108 DEPENDPATH+= $(OPIEDIR)/rsync 108 DEPENDPATH+= $(OPIEDIR)/rsync
109 109
110 TARGET = qpe 110 TARGET = qpe
111 111
112 LIBS += -lqpe -lcrypt 112 LIBS += -lqpe -lcrypt -lopie
113 113
114TRANSLATIONS = ../i18n/de/qpe.ts 114TRANSLATIONS = ../i18n/de/qpe.ts
115TRANSLATIONS += ../i18n/pt_BR/qpe.ts 115TRANSLATIONS += ../i18n/pt_BR/qpe.ts
116TRANSLATIONS += ../i18n/en/qpe.ts 116TRANSLATIONS += ../i18n/en/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
@@ -33,8 +33,10 @@
33#include <qwindowsystem_qws.h> 33#include <qwindowsystem_qws.h>
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>
40#include <unistd.h> 42#include <unistd.h>
@@ -183,8 +185,95 @@ static void initBacklight()
183 e << -3; // Forced on 185 e << -3; // Forced on
184} 186}
185 187
186 188
189class ModelKeyFilter : public QObject, public QWSServer::KeyboardFilter
190{
191public:
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
269private:
270 OHwModel m_model;
271 bool m_power_press;
272 int m_power_timer;
273};
274
275
187 276
188int initApplication( int argc, char ** argv ) 277int initApplication( int argc, char ** argv )
189{ 278{
190#ifdef QT_QWS_CASSIOPEIA 279#ifdef QT_QWS_CASSIOPEIA
@@ -208,8 +297,10 @@ int initApplication( int argc, char ** argv )
208 //Don't flicker at startup: 297 //Don't flicker at startup:
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();
215 306