summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp225
1 files changed, 140 insertions, 85 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index d86654e..160568b 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -59,165 +59,167 @@ public:
59 QString m_vendorstr; 59 QString m_vendorstr;
60 OVendor m_vendor; 60 OVendor m_vendor;
61 61
62 QString m_modelstr; 62 QString m_modelstr;
63 OModel m_model; 63 OModel m_model;
64 64
65 QString m_systemstr; 65 QString m_systemstr;
66 OSystem m_system; 66 OSystem m_system;
67 67
68 QString m_sysverstr; 68 QString m_sysverstr;
69 69
70 Transformation m_rotation; 70 Transformation m_rotation;
71 ODirection m_direction; 71 ODirection m_direction;
72 72
73 QValueList <ODeviceButton> *m_buttons; 73 QValueList <ODeviceButton> *m_buttons;
74 uint m_holdtime; 74 uint m_holdtime;
75}; 75};
76 76
77 77
78class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 78class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
79protected: 79protected:
80 virtual void init ( ); 80 virtual void init ( );
81 virtual void initButtons ( ); 81 virtual void initButtons ( );
82 82
83public: 83public:
84 virtual bool setSoftSuspend ( bool soft ); 84 virtual bool setSoftSuspend ( bool soft );
85 85
86 virtual bool setDisplayBrightness ( int b ); 86 virtual bool setDisplayBrightness ( int b );
87 virtual int displayBrightnessResolution ( ) const; 87 virtual int displayBrightnessResolution ( ) const;
88 88
89 virtual void alarmSound ( ); 89 virtual void alarmSound ( );
90 90
91 virtual QValueList <OLed> ledList ( ) const; 91 virtual QValueList <OLed> ledList ( ) const;
92 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 92 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
93 virtual OLedState ledState ( OLed led ) const; 93 virtual OLedState ledState ( OLed led ) const;
94 virtual bool setLedState ( OLed led, OLedState st ); 94 virtual bool setLedState ( OLed led, OLedState st );
95 95
96 virtual bool hasLightSensor ( ) const; 96 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 97 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 98 virtual int lightSensorResolution ( ) const;
99 99
100protected: 100protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 102 virtual void timerEvent ( QTimerEvent *te );
103 103
104 int m_power_timer; 104 int m_power_timer;
105 105
106 OLedState m_leds [2]; 106 OLedState m_leds [2];
107}; 107};
108 108
109class Zaurus : public ODevice { 109class Zaurus : public ODevice {
110protected: 110protected:
111 virtual void init ( ); 111 virtual void init ( );
112 virtual void initButtons ( ); 112 virtual void initButtons ( );
113 113
114public: 114public:
115 virtual bool setSoftSuspend ( bool soft ); 115 virtual bool setSoftSuspend ( bool soft );
116 116
117 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
119 119
120 virtual void alarmSound ( ); 120 virtual void alarmSound ( );
121 virtual void keySound ( ); 121 virtual void keySound ( );
122 virtual void touchSound ( ); 122 virtual void touchSound ( );
123 123
124 virtual QValueList <OLed> ledList ( ) const; 124 virtual QValueList <OLed> ledList ( ) const;
125 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 125 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
126 virtual OLedState ledState ( OLed led ) const; 126 virtual OLedState ledState ( OLed led ) const;
127 virtual bool setLedState ( OLed led, OLedState st ); 127 virtual bool setLedState ( OLed led, OLedState st );
128 128
129protected: 129protected:
130 virtual void buzzer ( int snd ); 130 virtual void buzzer ( int snd );
131 131
132 OLedState m_leds [1]; 132 OLedState m_leds [1];
133}; 133};
134 134
135class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 135class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
136protected: 136protected:
137 virtual void init ( ); 137 virtual void init ( );
138 virtual void initButtons ( ); 138 virtual void initButtons ( );
139 139
140public: 140public:
141 virtual bool setSoftSuspend ( bool soft ); 141 virtual bool setSoftSuspend ( bool soft );
142 virtual bool suspend(); 142 virtual bool suspend();
143 143
144 virtual bool setDisplayStatus( bool on ); 144 virtual bool setDisplayStatus( bool on );
145 virtual bool setDisplayBrightness ( int b ); 145 virtual bool setDisplayBrightness ( int b );
146 virtual int displayBrightnessResolution ( ) const; 146 virtual int displayBrightnessResolution ( ) const;
147 147
148 virtual void alarmSound ( ); 148 virtual void alarmSound ( );
149 149
150 virtual QValueList <OLed> ledList ( ) const; 150 virtual QValueList <OLed> ledList ( ) const;
151 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 151 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
152 virtual OLedState ledState ( OLed led ) const; 152 virtual OLedState ledState ( OLed led ) const;
153 virtual bool setLedState ( OLed led, OLedState st ); 153 virtual bool setLedState ( OLed led, OLedState st );
154 154
155protected: 155protected:
156 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 156 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
157 virtual void timerEvent ( QTimerEvent *te ); 157 virtual void timerEvent ( QTimerEvent *te );
158 158
159 int m_power_timer; 159 int m_power_timer;
160 160
161 OLedState m_leds [1]; //FIXME check if really only one 161 OLedState m_leds [1]; //FIXME check if really only one
162}; 162};
163 163
164class Ramses : public ODevice, public QWSServer::KeyboardFilter { 164class Ramses : public ODevice, public QWSServer::KeyboardFilter {
165protected: 165protected:
166 virtual void init ( ); 166 virtual void init ( );
167 virtual void initButtons ( );
168 167
169public: 168public:
170 virtual bool setSoftSuspend ( bool soft ); 169 virtual bool setSoftSuspend ( bool soft );
170 virtual bool suspend ( );
171 171
172 virtual bool setDisplayStatus( bool on ); 172 virtual bool setDisplayStatus( bool on );
173 virtual bool setDisplayBrightness ( int b ); 173 virtual bool setDisplayBrightness ( int b );
174 virtual int displayBrightnessResolution ( ) const; 174 virtual int displayBrightnessResolution ( ) const;
175 virtual bool setDisplayContrast ( int b );
176 virtual int displayContrastResolution ( ) const;
175 177
176protected: 178protected:
177 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 179 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
178 virtual void timerEvent ( QTimerEvent *te ); 180 virtual void timerEvent ( QTimerEvent *te );
179 181
180 int m_power_timer; 182 int m_power_timer;
181}; 183};
182 184
183struct i_button { 185struct i_button {
184 uint model; 186 uint model;
185 Qt::Key code; 187 Qt::Key code;
186 char *utext; 188 char *utext;
187 char *pix; 189 char *pix;
188 char *fpressedservice; 190 char *fpressedservice;
189 char *fpressedaction; 191 char *fpressedaction;
190 char *fheldservice; 192 char *fheldservice;
191 char *fheldaction; 193 char *fheldaction;
192} ipaq_buttons [] = { 194} ipaq_buttons [] = {
193 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 195 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
194 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 196 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
195 "devicebuttons/ipaq_calendar", 197 "devicebuttons/ipaq_calendar",
196 "datebook", "nextView()", 198 "datebook", "nextView()",
197 "today", "raise()" }, 199 "today", "raise()" },
198 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 200 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
199 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 201 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
200 "devicebuttons/ipaq_contact", 202 "devicebuttons/ipaq_contact",
201 "addressbook", "raise()", 203 "addressbook", "raise()",
202 "addressbook", "beamBusinessCard()" }, 204 "addressbook", "beamBusinessCard()" },
203 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 205 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
204 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 206 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
205 "devicebuttons/ipaq_menu", 207 "devicebuttons/ipaq_menu",
206 "QPE/TaskBar", "toggleMenu()", 208 "QPE/TaskBar", "toggleMenu()",
207 "QPE/TaskBar", "toggleStartMenu()" }, 209 "QPE/TaskBar", "toggleStartMenu()" },
208 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 210 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
209 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 211 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
210 "devicebuttons/ipaq_mail", 212 "devicebuttons/ipaq_mail",
211 "mail", "raise()", 213 "mail", "raise()",
212 "mail", "newMail()" }, 214 "mail", "newMail()" },
213 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 215 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
214 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 216 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
215 "devicebuttons/ipaq_home", 217 "devicebuttons/ipaq_home",
216 "QPE/Launcher", "home()", 218 "QPE/Launcher", "home()",
217 "buttonsettings", "raise()" }, 219 "buttonsettings", "raise()" },
218 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
219 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 221 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
220 "devicebuttons/ipaq_record", 222 "devicebuttons/ipaq_record",
221 "QPE/VMemo", "toggleRecord()", 223 "QPE/VMemo", "toggleRecord()",
222 "sound", "raise()" }, 224 "sound", "raise()" },
223}; 225};
@@ -324,65 +326,65 @@ struct s_button {
324 "QPE/TaskBar", "toggleStartMenu()" }, 326 "QPE/TaskBar", "toggleStartMenu()" },
325 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 327 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
326 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 328 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
327 "devicebuttons/simpad_upper_left", 329 "devicebuttons/simpad_upper_left",
328 "QPE/Rotation", "flip()", 330 "QPE/Rotation", "flip()",
329 "QPE/Rotation", "flip()" }, 331 "QPE/Rotation", "flip()" },
330 /* 332 /*
331 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 333 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
332 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 334 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
333 "devicebuttons/simpad_lower_upper", 335 "devicebuttons/simpad_lower_upper",
334 "QPE/Launcher", "home()", 336 "QPE/Launcher", "home()",
335 "buttonsettings", "raise()" }, 337 "buttonsettings", "raise()" },
336 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 338 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
337 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 339 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
338 "devicebuttons/simpad_upper_lower", 340 "devicebuttons/simpad_upper_lower",
339 "QPE/Launcher", "home()", 341 "QPE/Launcher", "home()",
340 "buttonsettings", "raise()" }, 342 "buttonsettings", "raise()" },
341 */ 343 */
342}; 344};
343 345
344struct r_button { 346struct r_button {
345 uint model; 347 uint model;
346 Qt::Key code; 348 Qt::Key code;
347 char *utext; 349 char *utext;
348 char *pix; 350 char *pix;
349 char *fpressedservice; 351 char *fpressedservice;
350 char *fpressedaction; 352 char *fpressedaction;
351 char *fheldservice; 353 char *fheldservice;
352 char *fheldaction; 354 char *fheldaction;
353} ramses_buttons [] = { 355} ramses_buttons [] = {
354 { Model_Ramses_MNCI, 356 { Model_Ramses_MNCI,
355 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 357 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
356 "devicebuttons/simpad_menu", 358 "devicebuttons/z_menu",
357 "QPE/TaskBar", "toggleMenu()", 359 "QPE/TaskBar", "toggleMenu()",
358 "QPE/TaskBar", "toggleStartMenu()" }, 360 "QPE/TaskBar", "toggleStartMenu()" },
359 { Model_Ramses_MNCI, 361 { Model_Ramses_MNCI,
360 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 362 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
361 "devicebuttons/ipaq_home", 363 "devicebuttons/ipaq_home",
362 "QPE/Launcher", "home()", 364 "QPE/Launcher", "home()",
363 "buttonsettings", "raise()" }, 365 "buttonsettings", "raise()" },
364}; 366};
365 367
366static QCString makeChannel ( const char *str ) 368static QCString makeChannel ( const char *str )
367{ 369{
368 if ( str && !::strchr ( str, '/' )) 370 if ( str && !::strchr ( str, '/' ))
369 return QCString ( "QPE/Application/" ) + str; 371 return QCString ( "QPE/Application/" ) + str;
370 else 372 else
371 return str; 373 return str;
372} 374}
373 375
374static inline bool isQWS() 376static inline bool isQWS()
375{ 377{
376 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 378 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
377} 379}
378 380
379ODevice *ODevice::inst ( ) 381ODevice *ODevice::inst ( )
380{ 382{
381 static ODevice *dev = 0; 383 static ODevice *dev = 0;
382 384
383 if ( !dev ) { 385 if ( !dev ) {
384 if ( QFile::exists ( "/proc/hal/model" )) 386 if ( QFile::exists ( "/proc/hal/model" ))
385 dev = new iPAQ ( ); 387 dev = new iPAQ ( );
386 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 388 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
387 dev = new Zaurus ( ); 389 dev = new Zaurus ( );
388 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 390 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
@@ -464,136 +466,161 @@ void ODevice::initButtons ( )
464 466
465 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 467 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
466 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 468 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
467} 469}
468 470
469ODevice::~ODevice ( ) 471ODevice::~ODevice ( )
470{ 472{
471 delete d; 473 delete d;
472} 474}
473 475
474bool ODevice::setSoftSuspend ( bool /*soft*/ ) 476bool ODevice::setSoftSuspend ( bool /*soft*/ )
475{ 477{
476 return false; 478 return false;
477} 479}
478 480
479//#include <linux/apm_bios.h> 481//#include <linux/apm_bios.h>
480 482
481#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 483#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
482 484
483/** 485/**
484 * This method will try to suspend the device 486 * This method will try to suspend the device
485 * It only works if the user is the QWS Server and the apm application 487 * It only works if the user is the QWS Server and the apm application
486 * is installed. 488 * is installed.
487 * It tries to suspend and then waits some time cause some distributions 489 * It tries to suspend and then waits some time cause some distributions
488 * do have asynchronus apm implementations. 490 * do have asynchronus apm implementations.
489 * This method will either fail and return false or it'll suspend the 491 * This method will either fail and return false or it'll suspend the
490 * device and return once the device got woken up 492 * device and return once the device got woken up
491 * 493 *
492 * @return if the device got suspended 494 * @return if the device got suspended
493 */ 495 */
494bool ODevice::suspend ( ) 496bool ODevice::suspend ( )
495{ 497{
498 qDebug("ODevice::suspend");
496 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 499 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
497 return false; 500 return false;
498 501
499 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 502 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
500 return false; 503 return false;
501 504
502 bool res = false; 505 bool res = false;
503 506
504 struct timeval tvs, tvn; 507 struct timeval tvs, tvn;
505 ::gettimeofday ( &tvs, 0 ); 508 ::gettimeofday ( &tvs, 0 );
506 509
507 ::sync ( ); // flush fs caches 510 ::sync ( ); // flush fs caches
508 res = ( ::system ( "apm --suspend" ) == 0 ); 511 res = ( ::system ( "apm --suspend" ) == 0 );
509 512
510 // This is needed because the iPAQ apm implementation is asynchronous and we 513 // This is needed because the iPAQ apm implementation is asynchronous and we
511 // can not be sure when exactly the device is really suspended 514 // can not be sure when exactly the device is really suspended
512 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 515 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
513 516
514 if ( res ) { 517 if ( res ) {
515 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 518 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
516 ::usleep ( 200 * 1000 ); 519 ::usleep ( 200 * 1000 );
517 ::gettimeofday ( &tvn, 0 ); 520 ::gettimeofday ( &tvn, 0 );
518 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 521 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
519 } 522 }
520 523
521 return res; 524 return res;
522} 525}
523 526
524//#include <linux/fb.h> better not rely on kernel headers in userspace ... 527//#include <linux/fb.h> better not rely on kernel headers in userspace ...
525 528
526#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 529#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
527 530
528/* VESA Blanking Levels */ 531/* VESA Blanking Levels */
529#define VESA_NO_BLANKING 0 532#define VESA_NO_BLANKING 0
530#define VESA_VSYNC_SUSPEND 1 533#define VESA_VSYNC_SUSPEND 1
531#define VESA_HSYNC_SUSPEND 2 534#define VESA_HSYNC_SUSPEND 2
532#define VESA_POWERDOWN 3 535#define VESA_POWERDOWN 3
533 536
534/** 537/**
535 * This sets the display on or off 538 * This sets the display on or off
536 */ 539 */
537bool ODevice::setDisplayStatus ( bool on ) 540bool ODevice::setDisplayStatus ( bool on )
538{ 541{
542 qDebug("ODevice::setDisplayStatus(%d)", on);
543
539 if ( d-> m_model == Model_Unknown ) 544 if ( d-> m_model == Model_Unknown )
540 return false; 545 return false;
541 546
542 bool res = false; 547 bool res = false;
543 int fd; 548 int fd;
544 549
545 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 550 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
546 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 551 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
547 ::close ( fd ); 552 ::close ( fd );
548 } 553 }
549 return res; 554 return res;
550} 555}
551 556
552/** 557/**
553 * This sets the display brightness 558 * This sets the display brightness
554 * @return success or failure 559 * @return success or failure
555 */ 560 */
556bool ODevice::setDisplayBrightness ( int p) 561bool ODevice::setDisplayBrightness ( int p)
557{ 562{
558 Q_UNUSED( p ) 563 Q_UNUSED( p )
559 return false; 564 return false;
560} 565}
561 566
567/**
568 * @return return the max value for the brightness settings slider
569 */
562int ODevice::displayBrightnessResolution ( ) const 570int ODevice::displayBrightnessResolution ( ) const
563{ 571{
564 return 16; 572 return 16;
565} 573}
566 574
567/** 575/**
576 * This sets the display contrast
577 * @return success or failure
578 */
579bool ODevice::setDisplayContrast ( int p)
580{
581 Q_UNUSED( p )
582 return false;
583}
584
585/**
586 * @return return the max value for the brightness settings slider
587 * or 0 if the device doesn't support setting of a contrast
588 */
589int ODevice::displayContrastResolution ( ) const
590{
591 return 0;
592}
593
594/**
568 * This returns the vendor as string 595 * This returns the vendor as string
569 * @return Vendor as QString 596 * @return Vendor as QString
570 */ 597 */
571QString ODevice::vendorString ( ) const 598QString ODevice::vendorString ( ) const
572{ 599{
573 return d-> m_vendorstr; 600 return d-> m_vendorstr;
574} 601}
575 602
576/** 603/**
577 * This returns the vendor as one of the values of OVendor 604 * This returns the vendor as one of the values of OVendor
578 * @return OVendor 605 * @return OVendor
579 */ 606 */
580OVendor ODevice::vendor ( ) const 607OVendor ODevice::vendor ( ) const
581{ 608{
582 return d-> m_vendor; 609 return d-> m_vendor;
583} 610}
584 611
585/** 612/**
586 * This returns the model as a string 613 * This returns the model as a string
587 * @return A string representing the model 614 * @return A string representing the model
588 */ 615 */
589QString ODevice::modelString ( ) const 616QString ODevice::modelString ( ) const
590{ 617{
591 return d-> m_modelstr; 618 return d-> m_modelstr;
592} 619}
593 620
594/** 621/**
595 * This does return the OModel used 622 * This does return the OModel used
596 */ 623 */
597OModel ODevice::model ( ) const 624OModel ODevice::model ( ) const
598{ 625{
599 return d-> m_model; 626 return d-> m_model;
@@ -641,65 +668,64 @@ ODirection ODevice::direction ( ) const
641 668
642/** 669/**
643 * This plays an alarmSound 670 * This plays an alarmSound
644 */ 671 */
645void ODevice::alarmSound ( ) 672void ODevice::alarmSound ( )
646{ 673{
647#ifndef QT_NO_SOUND 674#ifndef QT_NO_SOUND
648 static Sound snd ( "alarm" ); 675 static Sound snd ( "alarm" );
649 676
650 if ( snd. isFinished ( )) 677 if ( snd. isFinished ( ))
651 snd. play ( ); 678 snd. play ( );
652#endif 679#endif
653} 680}
654 681
655/** 682/**
656 * This plays a key sound 683 * This plays a key sound
657 */ 684 */
658void ODevice::keySound ( ) 685void ODevice::keySound ( )
659{ 686{
660#ifndef QT_NO_SOUND 687#ifndef QT_NO_SOUND
661 static Sound snd ( "keysound" ); 688 static Sound snd ( "keysound" );
662 689
663 if ( snd. isFinished ( )) 690 if ( snd. isFinished ( ))
664 snd. play ( ); 691 snd. play ( );
665#endif 692#endif
666} 693}
667 694
668/** 695/**
669 * This plays a touch sound 696 * This plays a touch sound
670 */ 697 */
671void ODevice::touchSound ( ) 698void ODevice::touchSound ( )
672{ 699{
673
674#ifndef QT_NO_SOUND 700#ifndef QT_NO_SOUND
675 static Sound snd ( "touchsound" ); 701 static Sound snd ( "touchsound" );
676 702
677 if ( snd. isFinished ( )) 703 if ( snd. isFinished ( ))
678 snd. play ( ); 704 snd. play ( );
679#endif 705#endif
680} 706}
681 707
682/** 708/**
683 * This method will return a list of leds 709 * This method will return a list of leds
684 * available on this device 710 * available on this device
685 * @return a list of LEDs. 711 * @return a list of LEDs.
686 */ 712 */
687QValueList <OLed> ODevice::ledList ( ) const 713QValueList <OLed> ODevice::ledList ( ) const
688{ 714{
689 return QValueList <OLed> ( ); 715 return QValueList <OLed> ( );
690} 716}
691 717
692/** 718/**
693 * This does return the state of the LEDs 719 * This does return the state of the LEDs
694 */ 720 */
695QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 721QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
696{ 722{
697 return QValueList <OLedState> ( ); 723 return QValueList <OLedState> ( );
698} 724}
699 725
700/** 726/**
701 * @return the state for a given OLed 727 * @return the state for a given OLed
702 */ 728 */
703OLedState ODevice::ledState ( OLed /*which*/ ) const 729OLedState ODevice::ledState ( OLed /*which*/ ) const
704{ 730{
705 return Led_Off; 731 return Led_Off;
@@ -1864,180 +1890,209 @@ bool SIMpad::setDisplayBrightness ( int bright )
1864 const int mask = SIMPAD_BACKLIGHT_MASK; 1890 const int mask = SIMPAD_BACKLIGHT_MASK;
1865 value = value << 8; 1891 value = value << 8;
1866 value += mask; 1892 value += mask;
1867 char writeCommand[100]; 1893 char writeCommand[100];
1868 const int count = sprintf( writeCommand, "0x%x\n", value ); 1894 const int count = sprintf( writeCommand, "0x%x\n", value );
1869 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1895 res = ( ::write ( fd, writeCommand, count ) != -1 );
1870 ::close ( fd ); 1896 ::close ( fd );
1871 } 1897 }
1872 return res; 1898 return res;
1873} 1899}
1874 1900
1875 1901
1876int SIMpad::displayBrightnessResolution ( ) const 1902int SIMpad::displayBrightnessResolution ( ) const
1877{ 1903{
1878 switch ( model ( )) { 1904 switch ( model ( )) {
1879 case Model_SIMpad_CL4: 1905 case Model_SIMpad_CL4:
1880 case Model_SIMpad_SL4: 1906 case Model_SIMpad_SL4:
1881 case Model_SIMpad_SLC: 1907 case Model_SIMpad_SLC:
1882 case Model_SIMpad_TSinus: 1908 case Model_SIMpad_TSinus:
1883 return 255; //TODO find out if this is save 1909 return 255; //TODO find out if this is save
1884 1910
1885 default: 1911 default:
1886 return 2; 1912 return 2;
1887 } 1913 }
1888} 1914}
1889 1915
1890/************************************************** 1916/**************************************************
1891 * 1917 *
1892 * Ramses 1918 * Ramses
1893 * 1919 *
1894 **************************************************/ 1920 **************************************************/
1895 1921
1896void Ramses::init ( ) 1922void Ramses::init()
1897{ 1923{
1898 d->m_vendorstr = "M und N"; 1924 d->m_vendorstr = "M und N";
1899 d->m_vendor = Vendor_MundN; 1925 d->m_vendor = Vendor_MundN;
1900 1926
1901 QFile f( "/proc/sys/board/ramses" ); 1927 QFile f("/proc/sys/board/ramses");
1902 1928
1903 d->m_modelstr = "Ramses"; 1929 d->m_modelstr = "Ramses";
1904 d->m_model = Model_Ramses_MNCI; 1930 d->m_model = Model_Ramses_MNCI;
1905 1931
1906 d->m_rotation = Rot180; 1932 d->m_rotation = Rot0;
1907 d->m_direction = CCW;
1908 d->m_holdtime = 1000; 1933 d->m_holdtime = 1000;
1909 1934
1910 f.setName( "/etc/oz_version" ); 1935 f.setName("/etc/oz_version");
1911 1936
1912 if ( f.open( IO_ReadOnly )) { 1937 if (f.open(IO_ReadOnly)) {
1913 d->m_systemstr = "OpenEmbedded/Ramses"; 1938 d->m_systemstr = "OpenEmbedded/Ramses";
1914 d->m_system = System_OpenZaurus; 1939 d->m_system = System_OpenZaurus;
1915 1940
1916 QTextStream ts ( &f ); 1941 QTextStream ts(&f);
1917 ts.setDevice ( &f ); 1942 ts.setDevice(&f);
1918 d->m_sysverstr = ts.readLine ( ); 1943 d->m_sysverstr = ts.readLine();
1919 f.close ( ); 1944 f.close();
1920 } 1945 }
1921 1946
1922 m_power_timer = 0; 1947 m_power_timer = 0;
1923 1948
1924} 1949}
1925 1950
1926void Ramses::initButtons ( ) 1951bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
1927{ 1952{
1928 if ( d->m_buttons ) 1953 Q_UNUSED( keycode );
1929 return; 1954 Q_UNUSED( modifiers );
1930 1955 Q_UNUSED( isPress );
1931 if ( isQWS( ) ) 1956 Q_UNUSED( autoRepeat );
1932 QWSServer::setKeyboardFilter ( this );
1933
1934 d->m_buttons = new QValueList <ODeviceButton>;
1935
1936 for ( uint i = 0; i < ( sizeof( ramses_buttons ) / sizeof( s_button )); i++ ) {
1937 r_button *rb = ramses_buttons + i;
1938 ODeviceButton b;
1939
1940 if (( rb->model & d->m_model ) == d->m_model ) {
1941 b.setKeycode( rb->code );
1942 b.setUserText( QObject::tr ( "Button", rb->utext ));
1943 b.setPixmap( Resource::loadPixmap ( rb->pix ));
1944 b.setFactoryPresetPressedAction( OQCopMessage ( makeChannel ( rb->fpressedservice ), rb->fpressedaction ));
1945 b.setFactoryPresetHeldAction( OQCopMessage ( makeChannel ( rb->fheldservice ), rb->fheldaction ));
1946
1947 d->m_buttons->append( b );
1948 }
1949 }
1950 reloadButtonMapping();
1951
1952 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1953 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1954}
1955
1956bool Ramses::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1957{
1958 //TODO
1959 return false; 1957 return false;
1960} 1958}
1961 1959
1962void Ramses::timerEvent ( QTimerEvent * ) 1960void Ramses::timerEvent(QTimerEvent *)
1963{ 1961{
1964 killTimer ( m_power_timer ); 1962 killTimer(m_power_timer);
1965 m_power_timer = 0; 1963 m_power_timer = 0;
1966 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1964 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
1967 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1965 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
1968} 1966}
1969 1967
1970 1968
1971bool Ramses::setSoftSuspend ( bool soft ) 1969bool Ramses::setSoftSuspend(bool soft)
1972{ 1970{
1971 qDebug("Ramses::setSoftSuspend(%d)", soft);
1972#if 0
1973 bool res = false; 1973 bool res = false;
1974 int fd; 1974 int fd;
1975 1975
1976 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1976 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
1977 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1977 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
1978 1978
1979 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1979 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
1980 1980
1981 if ( sources >= 0 ) { 1981 if (sources >= 0) {
1982 if ( soft ) 1982 if (soft)
1983 sources &= ~APM_EVT_POWER_BUTTON; 1983 sources &= ~APM_EVT_POWER_BUTTON;
1984 else 1984 else
1985 sources |= APM_EVT_POWER_BUTTON; 1985 sources |= APM_EVT_POWER_BUTTON;
1986 1986
1987 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1987 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
1988 res = true; 1988 res = true;
1989 else 1989 else
1990 perror ( "APM_IOCGEVTSRC" ); 1990 perror("APM_IOCGEVTSRC");
1991 } 1991 }
1992 else 1992 else
1993 perror ( "APM_IOCGEVTSRC" ); 1993 perror("APM_IOCGEVTSRC");
1994 1994
1995 ::close ( fd ); 1995 ::close(fd);
1996 } 1996 }
1997 else 1997 else
1998 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1998 perror("/dev/apm_bios or /dev/misc/apm_bios");
1999 1999
2000 return res; 2000 return res;
2001#else
2002 return true;
2003#endif
2004}
2005
2006bool Ramses::suspend ( )
2007{
2008 qDebug("Ramses::suspend");
2001} 2009}
2002 2010
2003/** 2011/**
2004 * This sets the display on or off 2012 * This sets the display on or off
2005 */ 2013 */
2006bool Ramses::setDisplayStatus ( bool on ) 2014bool Ramses::setDisplayStatus(bool on)
2007{ 2015{
2016 qDebug("Ramses::setDisplayStatus(%d)", on);
2017#if 0
2008 bool res = false; 2018 bool res = false;
2009 int fd; 2019 int fd;
2010 2020
2011 if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { 2021 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2012 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 2022 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2013 ::close ( fd ); 2023 ::close(fd);
2014 } 2024 }
2015 return res; 2025 return res;
2026#else
2027 return true;
2028#endif
2016} 2029}
2017 2030
2018 2031
2019bool Ramses::setDisplayBrightness ( int bright ) 2032/*
2033 * We get something between 0..255 into us
2034*/
2035bool Ramses::setDisplayBrightness(int bright)
2020{ 2036{
2021 qDebug( "ODevice for Ramses: setDisplayBrightness( %d )", bright ); 2037 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2022 bool res = false; 2038 bool res = false;
2023 int fd; 2039 int fd;
2024 2040
2025 if ( bright > 255 ) 2041 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2026 bright = 100; 2042
2027 if ( bright < 0 ) 2043 if (bright > 255 )
2044 bright = 255;
2045 if (bright < 0)
2028 bright = 0; 2046 bright = 0;
2047 bright = 500-(bright * 500 / 255);
2029 2048
2030 if (( fd = ::open ( "/proc/sys/board/pwm0", O_WRONLY )) >= 0 ) { 2049 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2050 qDebug(" %d -> pwm1", bright);
2031 char writeCommand[100]; 2051 char writeCommand[100];
2032 const int count = sprintf( writeCommand, "%d\n", bright); 2052 const int count = sprintf(writeCommand, "%d\n", bright);
2033 res = ( ::write ( fd, writeCommand, count ) != -1 ); 2053 res = (::write(fd, writeCommand, count) != -1);
2034 ::close ( fd ); 2054 ::close(fd);
2055 } else {
2056 qWarning("no write");
2057 }
2058 return res;
2059}
2060
2061
2062int Ramses::displayBrightnessResolution() const
2063{
2064 return 32;
2065}
2066
2067bool Ramses::setDisplayContrast(int contr)
2068{
2069 qDebug("Ramses::setDisplayContrast(%d)", contr);
2070 bool res = false;
2071 int fd;
2072
2073 // pwm0 contrast: 35 steps 65..100 (dunkel->hell)
2074
2075 if (contr > 255 )
2076 contr = 255;
2077 if (contr < 0)
2078 contr = 0;
2079 contr = 65 + (contr * 350 / 255);
2080
2081 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2082 qDebug(" %d -> pwm0", contr);
2083 char writeCommand[100];
2084 const int count = sprintf(writeCommand, "%d\n", contr);
2085 res = (::write(fd, writeCommand, count) != -1);
2086 res = true;
2087 ::close(fd);
2088 } else {
2089 qWarning("no write");
2035 } 2090 }
2036 return res; 2091 return res;
2037} 2092}
2038 2093
2039 2094
2040int Ramses::displayBrightnessResolution ( ) const 2095int Ramses::displayContrastResolution() const
2041{ 2096{
2042 return 100; 2097 return 32;
2043} 2098}