summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp30
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
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
@@ -1,100 +1,101 @@
1/* 1/*
2                 This file is part of the Opie Project 2                 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3              Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
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
57using namespace Opie::Core; 58using namespace Opie::Core;
58using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
59 60
60struct s_button simpad_buttons [] = { 61struct 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",
69 "addressbook", "raise()", 70 "addressbook", "raise()",
70 "addressbook", "beamBusinessCard()" }, 71 "addressbook", "beamBusinessCard()" },
71 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 72 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
72 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 73 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
73 "devicebuttons/simpad_lower_right", 74 "devicebuttons/simpad_lower_right",
74 "QPE/TaskBar", "toggleMenu()", 75 "QPE/TaskBar", "toggleMenu()",
75 "QPE/TaskBar", "toggleStartMenu()" }, 76 "QPE/TaskBar", "toggleStartMenu()" },
76 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 77 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
77 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 78 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
78 "devicebuttons/simpad_lower_left", 79 "devicebuttons/simpad_lower_left",
79 "opiemail", "raise()", 80 "opiemail", "raise()",
80 "opiemail", "newMail()" }, 81 "opiemail", "newMail()" },
81 82
82 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 83 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
83 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 84 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
84 "devicebuttons/simpad_upper_up", 85 "devicebuttons/simpad_upper_up",
85 "QPE/Launcher", "home()", 86 "QPE/Launcher", "home()",
86 "buttonsettings", "raise()" }, 87 "buttonsettings", "raise()" },
87 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 88 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
88 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 89 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
89 "devicebuttons/simpad_upper_down", 90 "devicebuttons/simpad_upper_down",
90 "addressbook", "raise()", 91 "addressbook", "raise()",
91 "addressbook", "beamBusinessCard()" }, 92 "addressbook", "beamBusinessCard()" },
92 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 93 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
93 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 94 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
94 "devicebuttons/simpad_upper_right", 95 "devicebuttons/simpad_upper_right",
95 "QPE/TaskBar", "toggleMenu()", 96 "QPE/TaskBar", "toggleMenu()",
96 "QPE/TaskBar", "toggleStartMenu()" }, 97 "QPE/TaskBar", "toggleStartMenu()" },
97 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 98 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
98 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 99 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
99 "devicebuttons/simpad_upper_left", 100 "devicebuttons/simpad_upper_left",
100 "QPE/Rotation", "flip()", 101 "QPE/Rotation", "flip()",
@@ -254,118 +255,129 @@ QValueList <OLed> SIMpad::ledList() const
254 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 255 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
255 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 256 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
256 return vl; 257 return vl;
257} 258}
258 259
259QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 260QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
260{ 261{
261 QValueList <OLedState> vl; 262 QValueList <OLedState> vl;
262 263
263 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 264 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
264 vl << Led_Off << Led_On; 265 vl << Led_Off << Led_On;
265 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 266 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
266 //vl << Led_Off; 267 //vl << Led_Off;
267 return vl; 268 return vl;
268} 269}
269 270
270OLedState SIMpad::ledState ( OLed l ) const 271OLedState SIMpad::ledState ( OLed l ) const
271{ 272{
272 switch ( l ) { 273 switch ( l ) {
273 case Led_Power: 274 case Led_Power:
274 return m_leds [0]; 275 return m_leds [0];
275 //case Led_Mail: 276 //case Led_Mail:
276 // return m_leds [1]; 277 // return m_leds [1];
277 default: 278 default:
278 return Led_Off; 279 return Led_Off;
279 } 280 }
280} 281}
281 282
282bool SIMpad::setLedState ( OLed l, OLedState st ) 283bool SIMpad::setLedState ( OLed l, OLedState st )
283{ 284{
284 if ( l == Led_Power ) { 285 if ( l == Led_Power ) {
285 m_leds [0] = st; 286 m_leds [0] = 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
293void SIMpad::timerEvent ( QTimerEvent * ) 294void 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
302void SIMpad::playAlarmSound() 303void 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
316bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 317bool 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
339bool SIMpad::setDisplayStatus ( bool on ) 334bool 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
347bool SIMpad::setDisplayBrightness ( int bright ) 342bool 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
367int SIMpad::displayBrightnessResolution() const 362int 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 */
372void 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
@@ -4,82 +4,84 @@
4 =. 4 =.
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#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class SIMpad : public ODevice 42class 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
62protected: 62protected:
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];
68private:
69 static void updateAllWidgets();
68}; 70};
69 71
70struct s_button { 72struct 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