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
@@ -221,52 +221,55 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e )
221 return TRUE; 221 return TRUE;
222 } 222 }
223 /* menu key now opens application menu/toolbar 223 /* menu key now opens application menu/toolbar
224 if ( ke->simpleData.keycode == Key_F11 ) { 224 if ( ke->simpleData.keycode == Key_F11 ) {
225 if ( press ) emit menu(); 225 if ( press ) emit menu();
226 return TRUE; 226 return TRUE;
227 } 227 }
228 */ 228 */
229 if ( ke->simpleData.keycode == Key_F12 ) { 229 if ( ke->simpleData.keycode == Key_F12 ) {
230 while( activePopupWidget() ) 230 while( activePopupWidget() )
231 activePopupWidget()->close(); 231 activePopupWidget()->close();
232 if ( press ) emit launch(); 232 if ( press ) emit launch();
233 return TRUE; 233 return TRUE;
234 } 234 }
235 if ( ke->simpleData.keycode == Key_F13 ) { 235 if ( ke->simpleData.keycode == Key_F13 ) {
236 if ( press ) emit email(); 236 if ( press ) emit email();
237 return TRUE; 237 return TRUE;
238 } 238 }
239 } 239 }
240 240
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 }
253 if ( ke->simpleData.keycode == Key_F32 ) { 256 if ( ke->simpleData.keycode == Key_F32 ) {
254 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" ); 257 if ( press ) QCopEnvelope e( "QPE/Desktop", "startSync()" );
255 return TRUE; 258 return TRUE;
256 } 259 }
257 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) { 260 if ( ke->simpleData.keycode == Key_F31 && !ke->simpleData.modifiers ) {
258 if ( press ) emit symbol(); 261 if ( press ) emit symbol();
259 return TRUE; 262 return TRUE;
260 } 263 }
261 if ( ke->simpleData.keycode == Key_NumLock ) { 264 if ( ke->simpleData.keycode == Key_NumLock ) {
262 if ( press ) emit numLockStateToggle(); 265 if ( press ) emit numLockStateToggle();
263 } 266 }
264 if ( ke->simpleData.keycode == Key_CapsLock ) { 267 if ( ke->simpleData.keycode == Key_CapsLock ) {
265 if ( press ) emit capsLockStateToggle(); 268 if ( press ) emit capsLockStateToggle();
266 } 269 }
267 if ( press ) 270 if ( press )
268 qpedesktop->keyClick(); 271 qpedesktop->keyClick();
269 } else { 272 } else {
270 if ( e->type == QWSEvent::Mouse ) { 273 if ( e->type == QWSEvent::Mouse ) {
271 QWSMouseEvent *me = (QWSMouseEvent *)e; 274 QWSMouseEvent *me = (QWSMouseEvent *)e;
272 static bool up = TRUE; 275 static bool up = 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
@@ -88,36 +88,36 @@ SOURCES = background.cpp \
88 $(OPIEDIR)/rsync/search.c \ 88 $(OPIEDIR)/rsync/search.c \
89 $(OPIEDIR)/rsync/stats.c \ 89 $(OPIEDIR)/rsync/stats.c \
90 $(OPIEDIR)/rsync/stream.c \ 90 $(OPIEDIR)/rsync/stream.c \
91 $(OPIEDIR)/rsync/sumset.c \ 91 $(OPIEDIR)/rsync/sumset.c \
92 $(OPIEDIR)/rsync/trace.c \ 92 $(OPIEDIR)/rsync/trace.c \
93 $(OPIEDIR)/rsync/tube.c \ 93 $(OPIEDIR)/rsync/tube.c \
94 $(OPIEDIR)/rsync/util.c \ 94 $(OPIEDIR)/rsync/util.c \
95 $(OPIEDIR)/rsync/version.c \ 95 $(OPIEDIR)/rsync/version.c \
96 $(OPIEDIR)/rsync/whole.c \ 96 $(OPIEDIR)/rsync/whole.c \
97 $(OPIEDIR)/rsync/qrsync.cpp 97 $(OPIEDIR)/rsync/qrsync.cpp
98 98
99 INTERFACES= shutdown.ui syncdialog.ui 99 INTERFACES= shutdown.ui syncdialog.ui
100 100
101INCLUDEPATH += $(OPIEDIR)/include 101INCLUDEPATH += $(OPIEDIR)/include
102 DEPENDPATH+= $(OPIEDIR)/include . 102 DEPENDPATH+= $(OPIEDIR)/include .
103 103
104INCLUDEPATH += $(OPIEDIR)/calibrate 104INCLUDEPATH += $(OPIEDIR)/calibrate
105 DEPENDPATH+= $(OPIEDIR)/calibrate 105 DEPENDPATH+= $(OPIEDIR)/calibrate
106 106
107INCLUDEPATH += $(OPIEDIR)/rsync 107INCLUDEPATH += $(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
117TRANSLATIONS += ../i18n/hu/qpe.ts 117TRANSLATIONS += ../i18n/hu/qpe.ts
118TRANSLATIONS += ../i18n/ja/qpe.ts 118TRANSLATIONS += ../i18n/ja/qpe.ts
119TRANSLATIONS += ../i18n/fr/qpe.ts 119TRANSLATIONS += ../i18n/fr/qpe.ts
120TRANSLATIONS += ../i18n/ko/qpe.ts 120TRANSLATIONS += ../i18n/ko/qpe.ts
121TRANSLATIONS += ../i18n/no/qpe.ts 121TRANSLATIONS += ../i18n/no/qpe.ts
122TRANSLATIONS += ../i18n/zh_CN/qpe.ts 122TRANSLATIONS += ../i18n/zh_CN/qpe.ts
123TRANSLATIONS += ../i18n/zh_TW/qpe.ts 123TRANSLATIONS += ../i18n/zh_TW/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
@@ -13,48 +13,50 @@
13** 13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information. 14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15** 15**
16** Contact info@trolltech.com if any conditions of this licensing are 16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you. 17** not clear to you.
18** 18**
19**********************************************************************/ 19**********************************************************************/
20 20
21#include "desktop.h" 21#include "desktop.h"
22#include "taskbar.h" 22#include "taskbar.h"
23#include "stabmon.h" 23#include "stabmon.h"
24 24
25#include <qpe/qpeapplication.h> 25#include <qpe/qpeapplication.h>
26#include <qpe/network.h> 26#include <qpe/network.h>
27#include <qpe/config.h> 27#include <qpe/config.h>
28#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ ) 28#if defined( QT_QWS_CUSTOM ) || defined( QT_QWS_IPAQ )
29#include <qpe/custom.h> 29#include <qpe/custom.h>
30#endif 30#endif
31 31
32#include <qfile.h> 32#include <qfile.h>
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>
41 43
42#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX) 44#if defined(QT_QWS_CASSIOPEIA) || defined(QT_QWS_IPAQ) || defined(QT_QWS_EBX)
43#include "../calibrate/calibrate.h" 45#include "../calibrate/calibrate.h"
44#endif 46#endif
45 47
46#ifdef QT_QWS_LOGIN 48#ifdef QT_QWS_LOGIN
47#include "../login/qdmdialogimpl.h" 49#include "../login/qdmdialogimpl.h"
48#endif 50#endif
49 51
50#ifdef QT_QWS_CASSIOPEIA 52#ifdef QT_QWS_CASSIOPEIA
51static void ignoreMessage( QtMsgType, const char * ) 53static void ignoreMessage( QtMsgType, const char * )
52{ 54{
53} 55}
54#include <sys/mount.h> 56#include <sys/mount.h>
55#include <sys/types.h> 57#include <sys/types.h>
56#include <sys/stat.h> 58#include <sys/stat.h>
57#include <sys/time.h> 59#include <sys/time.h>
58#include <fcntl.h> 60#include <fcntl.h>
59#include <qdatetime.h> 61#include <qdatetime.h>
60 62
@@ -163,73 +165,162 @@ void initEnvironment()
163 Config config("locale"); 165 Config config("locale");
164 config.setGroup( "Location" ); 166 config.setGroup( "Location" );
165 QString tz = config.readEntry( "Timezone", getenv("TZ") ); 167 QString tz = config.readEntry( "Timezone", getenv("TZ") );
166 168
167 // if not timezone set, pick New York 169 // if not timezone set, pick New York
168 if (tz.isNull()) 170 if (tz.isNull())
169 tz = "America/New_York"; 171 tz = "America/New_York";
170 172
171 setenv( "TZ", tz, 1 ); 173 setenv( "TZ", tz, 1 );
172 config.writeEntry( "Timezone", tz); 174 config.writeEntry( "Timezone", tz);
173 175
174 config.setGroup( "Language" ); 176 config.setGroup( "Language" );
175 QString lang = config.readEntry( "Language", getenv("LANG") ); 177 QString lang = config.readEntry( "Language", getenv("LANG") );
176 if ( !lang.isNull() ) 178 if ( !lang.isNull() )
177 setenv( "LANG", lang, 1 ); 179 setenv( "LANG", lang, 1 );
178} 180}
179 181
180static void initBacklight() 182static void initBacklight()
181{ 183{
182 QCopEnvelope e("QPE/System", "setBacklight(int)" ); 184 QCopEnvelope e("QPE/System", "setBacklight(int)" );
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
191 initCassiopeia(); 280 initCassiopeia();
192#endif 281#endif
193 282
194#ifdef QPE_OWNAPM 283#ifdef QPE_OWNAPM
195 initAPM(); 284 initAPM();
196#endif 285#endif
197 286
198#ifdef QT_DEMO_SINGLE_FLOPPY 287#ifdef QT_DEMO_SINGLE_FLOPPY
199 initFloppy(); 288 initFloppy();
200#endif 289#endif
201 290
202 initEnvironment(); 291 initEnvironment();
203 292
204#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX) 293#if !defined(QT_QWS_CASSIOPEIA) && !defined(QT_QWS_IPAQ) && !defined(QT_QWS_EBX)
205 setenv( "QWS_SIZE", "240x320", 0 ); 294 setenv( "QWS_SIZE", "240x320", 0 );
206#endif 295#endif
207 296
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
216#if defined(QT_QWS_LOGIN) 307#if defined(QT_QWS_LOGIN)
217 for( int i=0; i<a.argc(); i++ ) 308 for( int i=0; i<a.argc(); i++ )
218 if( strcmp( a.argv()[i], "-login" ) == 0 ) { 309 if( strcmp( a.argv()[i], "-login" ) == 0 ) {
219 QDMDialogImpl::login( ); 310 QDMDialogImpl::login( );
220 return 0; 311 return 0;
221 } 312 }
222#endif 313#endif
223 314
224 Desktop *d = new Desktop(); 315 Desktop *d = new Desktop();
225 316
226 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) ); 317 QObject::connect( &a, SIGNAL(datebook()), d, SLOT(raiseDatebook()) );
227 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) ); 318 QObject::connect( &a, SIGNAL(contacts()), d, SLOT(raiseContacts()) );
228 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) ); 319 QObject::connect( &a, SIGNAL(launch()), d, SLOT(raiseLauncher()) );
229 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) ); 320 QObject::connect( &a, SIGNAL(email()), d, SLOT(raiseEmail()) );
230 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) ); 321 QObject::connect( &a, SIGNAL(power()), d, SLOT(togglePower()) );
231 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) ); 322 QObject::connect( &a, SIGNAL(backlight()), d, SLOT(toggleLight()) );
232 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) ); 323 QObject::connect( &a, SIGNAL(symbol()), d, SLOT(toggleSymbolInput()) );
233 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) ); 324 QObject::connect( &a, SIGNAL(numLockStateToggle()), d, SLOT(toggleNumLockState()) );
234 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) ); 325 QObject::connect( &a, SIGNAL(capsLockStateToggle()), d, SLOT(toggleCapsLockState()) );
235 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) ); 326 QObject::connect( &a, SIGNAL(prepareForRestart()), d, SLOT(terminateServers()) );