-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 30 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 2 |
2 files changed, 23 insertions, 9 deletions
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 4ae3c4f..ebf0cbb 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -5,64 +5,65 @@ | |||
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 | */ |
29 | 29 | ||
30 | #include "odevice_simpad.h" | 30 | #include "odevice_simpad.h" |
31 | 31 | ||
32 | /* QT */ | 32 | /* QT */ |
33 | #include <qapplication.h> | 33 | #include <qapplication.h> |
34 | #include <qfile.h> | 34 | #include <qfile.h> |
35 | #include <qtextstream.h> | 35 | #include <qtextstream.h> |
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | #include <qwidgetlist.h> | ||
37 | 38 | ||
38 | /* OPIE */ | 39 | /* OPIE */ |
39 | #include <qpe/config.h> | 40 | #include <qpe/config.h> |
40 | #include <qpe/resource.h> | 41 | #include <qpe/resource.h> |
41 | #include <qpe/sound.h> | 42 | #include <qpe/sound.h> |
42 | #include <qpe/qcopenvelope_qws.h> | 43 | #include <qpe/qcopenvelope_qws.h> |
43 | #include <opie2/okeyfilter.h> | 44 | #include <opie2/okeyfilter.h> |
44 | 45 | ||
45 | /* STD */ | 46 | /* STD */ |
46 | #include <fcntl.h> | 47 | #include <fcntl.h> |
47 | #include <math.h> | 48 | #include <math.h> |
48 | #include <stdlib.h> | 49 | #include <stdlib.h> |
49 | #include <signal.h> | 50 | #include <signal.h> |
50 | #include <sys/ioctl.h> | 51 | #include <sys/ioctl.h> |
51 | #include <sys/time.h> | 52 | #include <sys/time.h> |
52 | #include <unistd.h> | 53 | #include <unistd.h> |
53 | #ifndef QT_NO_SOUND | 54 | #ifndef QT_NO_SOUND |
54 | #include <linux/soundcard.h> | 55 | #include <linux/soundcard.h> |
55 | #endif | 56 | #endif |
56 | 57 | ||
57 | using namespace Opie::Core; | 58 | using namespace Opie::Core; |
58 | using namespace Opie::Core::Internal; | 59 | using namespace Opie::Core::Internal; |
59 | 60 | ||
60 | struct s_button simpad_buttons [] = { | 61 | struct s_button simpad_buttons [] = { |
61 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 62 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
62 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), | 63 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), |
63 | "devicebuttons/simpad_lower_up", | 64 | "devicebuttons/simpad_lower_up", |
64 | "datebook", "nextView()", | 65 | "datebook", "nextView()", |
65 | "today", "raise()" }, | 66 | "today", "raise()" }, |
66 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 67 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
67 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), | 68 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), |
68 | "devicebuttons/simpad_lower_down", | 69 | "devicebuttons/simpad_lower_down", |
@@ -286,86 +287,97 @@ bool SIMpad::setLedState ( OLed l, OLedState st ) | |||
286 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); | 287 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); |
287 | return true; | 288 | return true; |
288 | } | 289 | } |
289 | 290 | ||
290 | return false; | 291 | return false; |
291 | } | 292 | } |
292 | 293 | ||
293 | void SIMpad::timerEvent ( QTimerEvent * ) | 294 | void SIMpad::timerEvent ( QTimerEvent * ) |
294 | { | 295 | { |
295 | killTimer ( m_power_timer ); | 296 | killTimer ( m_power_timer ); |
296 | m_power_timer = 0; | 297 | m_power_timer = 0; |
297 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 298 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
298 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 299 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
299 | } | 300 | } |
300 | 301 | ||
301 | 302 | ||
302 | void SIMpad::playAlarmSound() | 303 | void SIMpad::playAlarmSound() |
303 | { | 304 | { |
304 | #ifndef QT_NO_SOUND | 305 | #ifndef QT_NO_SOUND |
305 | static Sound snd ( "alarm" ); | 306 | static Sound snd ( "alarm" ); |
306 | if(!snd.isFinished()) | 307 | if(!snd.isFinished()) |
307 | return; | 308 | return; |
308 | 309 | ||
309 | /* save as the Sound is static! */ | 310 | /* save as the Sound is static! */ |
310 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 311 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
311 | snd. play(); | 312 | snd. play(); |
312 | #endif | 313 | #endif |
313 | } | 314 | } |
314 | 315 | ||
315 | 316 | ||
316 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 317 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
317 | { | 318 | { |
318 | qDebug( "ODevice for SIMpad: suspend()" ); | ||
319 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 319 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
320 | return false; | 320 | return false; |
321 | 321 | ||
322 | /* | ||
323 | * we need to save the screen content | ||
324 | * then go to suspend using ODevice::suspend | ||
325 | * and finally restore the screen content | ||
326 | */ | ||
327 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); | ||
328 | bool res = ODevice::suspend(); | 322 | bool res = ODevice::suspend(); |
329 | 323 | ||
330 | /* | 324 | /* |
331 | * restore | 325 | * restore the screen content if we really |
326 | * supended the device | ||
332 | */ | 327 | */ |
333 | if ( res ) | 328 | if ( res ) |
334 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); | 329 | updateAllWidgets(); |
335 | 330 | ||
336 | return res; | 331 | return res; |
337 | } | 332 | } |
338 | 333 | ||
339 | bool SIMpad::setDisplayStatus ( bool on ) | 334 | bool SIMpad::setDisplayStatus ( bool on ) |
340 | { | 335 | { |
341 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 336 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
342 | 337 | ||
343 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); | 338 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); |
344 | } | 339 | } |
345 | 340 | ||
346 | 341 | ||
347 | bool SIMpad::setDisplayBrightness ( int bright ) | 342 | bool SIMpad::setDisplayBrightness ( int bright ) |
348 | { | 343 | { |
349 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 344 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
350 | bool res = false; | 345 | bool res = false; |
351 | int fd; | 346 | int fd; |
352 | 347 | ||
353 | if ( bright > 255 ) | 348 | if ( bright > 255 ) |
354 | bright = 255; | 349 | bright = 255; |
355 | if ( bright < 1 ) | 350 | if ( bright < 1 ) |
356 | bright = 0; | 351 | bright = 0; |
357 | 352 | ||
358 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 353 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
359 | QCString str = QFile::encodeName( QString::number(bright)); | 354 | QCString str = QFile::encodeName( QString::number(bright)); |
360 | res = ( ::write(fd, str, str.length()) != -1 ); | 355 | res = ( ::write(fd, str, str.length()) != -1 ); |
361 | ::close ( fd ); | 356 | ::close ( fd ); |
362 | } | 357 | } |
363 | return res; | 358 | return res; |
364 | } | 359 | } |
365 | 360 | ||
366 | 361 | ||
367 | int SIMpad::displayBrightnessResolution() const | 362 | int SIMpad::displayBrightnessResolution() const |
368 | { | 363 | { |
369 | return 255; // All SIMpad models share the same display | 364 | return 255; // All SIMpad models share the same display |
370 | } | 365 | } |
371 | 366 | ||
367 | |||
368 | /* | ||
369 | * The MQ200 DRAM content is lost during suspend | ||
370 | * so we will just repaint every widget on resume | ||
371 | */ | ||
372 | void SIMpad::updateAllWidgets() { | ||
373 | QWidgetList *list = QApplication::allWidgets(); | ||
374 | QWidgetListIt it( *list ); | ||
375 | QWidget *wid; | ||
376 | |||
377 | while ((wid=it.current()) != 0 ) { | ||
378 | wid->update(); | ||
379 | ++it; | ||
380 | } | ||
381 | |||
382 | delete list; | ||
383 | } | ||
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h index dbcbbb4..c25b911 100644 --- a/libopie2/opiecore/device/odevice_simpad.h +++ b/libopie2/opiecore/device/odevice_simpad.h | |||
@@ -36,50 +36,52 @@ | |||
36 | #include <qwindowsystem_qws.h> | 36 | #include <qwindowsystem_qws.h> |
37 | 37 | ||
38 | namespace Opie { | 38 | namespace Opie { |
39 | namespace Core { | 39 | namespace Core { |
40 | namespace Internal { | 40 | namespace Internal { |
41 | 41 | ||
42 | class SIMpad : public ODevice | 42 | class SIMpad : public ODevice |
43 | { | 43 | { |
44 | protected: | 44 | protected: |
45 | virtual void init(const QString&); | 45 | virtual void init(const QString&); |
46 | virtual void initButtons(); | 46 | virtual void initButtons(); |
47 | 47 | ||
48 | public: | 48 | public: |
49 | virtual bool suspend(); | 49 | virtual bool suspend(); |
50 | 50 | ||
51 | virtual bool setDisplayStatus( bool on ); | 51 | virtual bool setDisplayStatus( bool on ); |
52 | virtual bool setDisplayBrightness( int b ); | 52 | virtual bool setDisplayBrightness( int b ); |
53 | virtual int displayBrightnessResolution() const; | 53 | virtual int displayBrightnessResolution() const; |
54 | 54 | ||
55 | virtual void playAlarmSound(); | 55 | virtual void playAlarmSound(); |
56 | 56 | ||
57 | virtual QValueList <OLed> ledList() const; | 57 | virtual QValueList <OLed> ledList() const; |
58 | virtual QValueList <OLedState> ledStateList( OLed led ) const; | 58 | virtual QValueList <OLedState> ledStateList( OLed led ) const; |
59 | virtual OLedState ledState( OLed led ) const; | 59 | virtual OLedState ledState( OLed led ) const; |
60 | virtual bool setLedState( OLed led, OLedState st ); | 60 | virtual bool setLedState( OLed led, OLedState st ); |
61 | 61 | ||
62 | protected: | 62 | protected: |
63 | virtual void timerEvent( QTimerEvent *te ); | 63 | virtual void timerEvent( QTimerEvent *te ); |
64 | 64 | ||
65 | int m_power_timer; | 65 | int m_power_timer; |
66 | 66 | ||
67 | OLedState m_leds [2]; | 67 | OLedState m_leds [2]; |
68 | private: | ||
69 | static void updateAllWidgets(); | ||
68 | }; | 70 | }; |
69 | 71 | ||
70 | struct s_button { | 72 | struct s_button { |
71 | uint model; | 73 | uint model; |
72 | Qt::Key code; | 74 | Qt::Key code; |
73 | char *utext; | 75 | char *utext; |
74 | char *pix; | 76 | char *pix; |
75 | char *fpressedservice; | 77 | char *fpressedservice; |
76 | char *fpressedaction; | 78 | char *fpressedaction; |
77 | char *fheldservice; | 79 | char *fheldservice; |
78 | char *fheldaction; | 80 | char *fheldaction; |
79 | }; | 81 | }; |
80 | 82 | ||
81 | } | 83 | } |
82 | } | 84 | } |
83 | } | 85 | } |
84 | 86 | ||
85 | #endif | 87 | #endif |