-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 | |||
@@ -243,8 +243,11 @@ bool DesktopApplication::qwsEventFilter( QWSEvent *e ) | |||
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(); |
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 | |||
@@ -110,5 +110,5 @@ DEPENDPATH += $(OPIEDIR)/rsync | |||
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 |
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 | |||
@@ -35,4 +35,6 @@ | |||
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> |
@@ -185,4 +187,91 @@ static void initBacklight() | |||
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 ) |
@@ -210,4 +299,6 @@ int initApplication( int argc, char ** argv ) | |||
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 | ||