summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp409
-rw-r--r--libopie/odevice.h121
2 files changed, 356 insertions, 174 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 3bc1e0c..c84312e 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -38,2 +38,5 @@
38 38
39#include <qwindowsystem_qws.h>
40
41
39// _IO and friends are only defined in kernel headers ... 42// _IO and friends are only defined in kernel headers ...
@@ -47,2 +50,3 @@
47 50
51using namespace Opie;
48 52
@@ -50,2 +54,4 @@ class ODeviceData {
50public: 54public:
55 bool m_qwsserver;
56
51 QString m_vendorstr; 57 QString m_vendorstr;
@@ -60,7 +66,6 @@ public:
60 QString m_sysverstr; 66 QString m_sysverstr;
61
62 OLedState m_leds [4]; // just for convenience ...
63}; 67};
64 68
65class ODeviceIPAQ : public ODevice { 69
70class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter {
66protected: 71protected:
@@ -69,3 +74,3 @@ protected:
69public: 74public:
70 virtual bool setPowerButtonHandler ( PowerButtonHandler h ); 75 virtual bool setSoftSuspend ( bool soft );
71 76
@@ -75,9 +80,20 @@ public:
75 virtual void alarmSound ( ); 80 virtual void alarmSound ( );
76 81
77 virtual uint hasLeds ( ) const; 82 virtual QValueList <OLed> ledList ( ) const;
78 virtual OLedState led ( uint which ) const; 83 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
79 virtual bool setLed ( uint which, OLedState st ); 84 virtual OLedState ledState ( OLed led ) const;
85 virtual bool setLedState ( OLed led, OLedState st );
86
87 //virtual QValueList <int> keyList ( ) const;
88
89protected:
90 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
91 virtual void timerEvent ( QTimerEvent *te );
92
93 int m_power_timer;
94
95 OLedState m_leds [2];
80}; 96};
81 97
82class ODeviceZaurus : public ODevice { 98class Zaurus : public ODevice {
83protected: 99protected:
@@ -86,3 +102,3 @@ protected:
86 public: 102 public:
87 virtual bool setPowerButtonHandler ( PowerButtonHandler h ); 103 virtual bool setSoftSuspend ( bool soft );
88 104
@@ -95,5 +111,8 @@ public:
95 111
96 virtual uint hasLeds ( ) const; 112 virtual QValueList <OLed> ledList ( ) const;
97 virtual OLedState led ( uint which ) const; 113 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
98 virtual bool setLed ( uint which, OLedState st ); 114 virtual OLedState ledState ( OLed led ) const;
115 virtual bool setLedState ( OLed led, OLedState st );
116
117 //virtual QValueList <int> keyList ( ) const;
99 118
@@ -101,2 +120,4 @@ protected:
101 virtual void buzzer ( int snd ); 120 virtual void buzzer ( int snd );
121
122 OLedState m_leds [1];
102}; 123};
@@ -106,2 +127,5 @@ protected:
106 127
128
129
130
107ODevice *ODevice::inst ( ) 131ODevice *ODevice::inst ( )
@@ -112,5 +136,5 @@ ODevice *ODevice::inst ( )
112 if ( QFile::exists ( "/proc/hal/model" )) 136 if ( QFile::exists ( "/proc/hal/model" ))
113 dev = new ODeviceIPAQ ( ); 137 dev = new iPAQ ( );
114 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 138 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
115 dev = new ODeviceZaurus ( ); 139 dev = new Zaurus ( );
116 else 140 else
@@ -135,8 +159,10 @@ ODevice::ODevice ( )
135 159
160 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
161
136 d-> m_modelstr = "Unknown"; 162 d-> m_modelstr = "Unknown";
137 d-> m_model = OMODEL_Unknown; 163 d-> m_model = Model_Unknown;
138 d-> m_vendorstr = "Unkown"; 164 d-> m_vendorstr = "Unkown";
139 d-> m_vendor = OVENDOR_Unknown; 165 d-> m_vendor = Vendor_Unknown;
140 d-> m_systemstr = "Unkown"; 166 d-> m_systemstr = "Unkown";
141 d-> m_system = OSYSTEM_Unknown; 167 d-> m_system = System_Unknown;
142 d-> m_sysverstr = "0.0"; 168 d-> m_sysverstr = "0.0";
@@ -153,3 +179,3 @@ ODevice::~ODevice ( )
153 179
154bool ODevice::setPowerButtonHandler ( ODevice::PowerButtonHandler ) 180bool ODevice::setSoftSuspend ( bool /*soft*/ )
155{ 181{
@@ -165,3 +191,6 @@ bool ODevice::suspend ( )
165{ 191{
166 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices 192 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
193 return false;
194
195 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
167 return false; 196 return false;
@@ -175,3 +204,3 @@ bool ODevice::suspend ( )
175 204
176 ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped 205 // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
177 ::gettimeofday ( &tvs, 0 ); 206 ::gettimeofday ( &tvs, 0 );
@@ -181,5 +210,6 @@ bool ODevice::suspend ( )
181 res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending 210 res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending
211 ::close ( fd );
182 212
183 if ( res ) { 213 if ( res ) {
184 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group 214 // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group
185 215
@@ -190,7 +220,6 @@ bool ODevice::suspend ( )
190 220
191 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group 221 // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
192 } 222 }
193 223
194 ::close ( fd ); 224 // ::signal ( SIGTSTP, SIG_DFL );
195 ::signal ( SIGTSTP, SIG_DFL );
196 } 225 }
@@ -213,3 +242,3 @@ bool ODevice::setDisplayStatus ( bool on )
213{ 242{
214 if ( d-> m_model == OMODEL_Unknown ) 243 if ( d-> m_model == Model_Unknown )
215 return false; 244 return false;
@@ -236,3 +265,3 @@ int ODevice::displayBrightnessResolution ( ) const
236 265
237QString ODevice::vendorString ( ) 266QString ODevice::vendorString ( ) const
238{ 267{
@@ -241,3 +270,3 @@ QString ODevice::vendorString ( )
241 270
242OVendor ODevice::vendor ( ) 271OVendor ODevice::vendor ( ) const
243{ 272{
@@ -246,3 +275,3 @@ OVendor ODevice::vendor ( )
246 275
247QString ODevice::modelString ( ) 276QString ODevice::modelString ( ) const
248{ 277{
@@ -251,3 +280,3 @@ QString ODevice::modelString ( )
251 280
252OModel ODevice::model ( ) 281OModel ODevice::model ( ) const
253{ 282{
@@ -256,3 +285,3 @@ OModel ODevice::model ( )
256 285
257QString ODevice::systemString ( ) 286QString ODevice::systemString ( ) const
258{ 287{
@@ -261,3 +290,3 @@ QString ODevice::systemString ( )
261 290
262OSystem ODevice::system ( ) 291OSystem ODevice::system ( ) const
263{ 292{
@@ -266,3 +295,3 @@ OSystem ODevice::system ( )
266 295
267QString ODevice::systemVersionString ( ) 296QString ODevice::systemVersionString ( ) const
268{ 297{
@@ -308,13 +337,19 @@ void ODevice::touchSound ( )
308 337
309uint ODevice::hasLeds ( ) const 338
339QValueList <OLed> ODevice::ledList ( ) const
340{
341 return QValueList <OLed> ( );
342}
343
344QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
310{ 345{
311 return 0; 346 return QValueList <OLedState> ( );
312} 347}
313 348
314OLedState ODevice::led ( uint /*which*/ ) const 349OLedState ODevice::ledState ( OLed /*which*/ ) const
315{ 350{
316 return OLED_Off; 351 return Led_Off;
317} 352}
318 353
319bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) 354bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
320{ 355{
@@ -325,2 +360,8 @@ bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ )
325 360
361//QValueList <int> ODevice::keyList ( ) const
362//{
363 //return QValueList <int> ( );
364//}
365
366
326 367
@@ -332,6 +373,6 @@ bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ )
332 373
333void ODeviceIPAQ::init ( ) 374void iPAQ::init ( )
334{ 375{
335 d-> m_vendorstr = "HP"; 376 d-> m_vendorstr = "HP";
336 d-> m_vendor = OVENDOR_HP; 377 d-> m_vendor = Vendor_HP;
337 378
@@ -345,11 +386,11 @@ void ODeviceIPAQ::init ( )
345 if ( d-> m_modelstr == "H3100" ) 386 if ( d-> m_modelstr == "H3100" )
346 d-> m_model = OMODEL_iPAQ_H31xx; 387 d-> m_model = Model_iPAQ_H31xx;
347 else if ( d-> m_modelstr == "H3600" ) 388 else if ( d-> m_modelstr == "H3600" )
348 d-> m_model = OMODEL_iPAQ_H36xx; 389 d-> m_model = Model_iPAQ_H36xx;
349 else if ( d-> m_modelstr == "H3700" ) 390 else if ( d-> m_modelstr == "H3700" )
350 d-> m_model = OMODEL_iPAQ_H37xx; 391 d-> m_model = Model_iPAQ_H37xx;
351 else if ( d-> m_modelstr == "H3800" ) 392 else if ( d-> m_modelstr == "H3800" )
352 d-> m_model = OMODEL_iPAQ_H38xx; 393 d-> m_model = Model_iPAQ_H38xx;
353 else 394 else
354 d-> m_model = OMODEL_Unknown; 395 d-> m_model = Model_Unknown;
355 396
@@ -361,3 +402,3 @@ void ODeviceIPAQ::init ( )
361 d-> m_systemstr = "Familiar"; 402 d-> m_systemstr = "Familiar";
362 d-> m_system = OSYSTEM_Familiar; 403 d-> m_system = System_Familiar;
363 404
@@ -369,3 +410,8 @@ void ODeviceIPAQ::init ( )
369 410
370 d-> m_leds [0] = OLED_Off; 411 m_leds [0] = m_leds [1] = Led_Off;
412
413 m_power_timer = 0;
414
415 if ( d-> m_qwsserver )
416 QWSServer::setKeyboardFilter ( this );
371} 417}
@@ -391,3 +437,139 @@ typedef struct {
391 437
392void ODeviceIPAQ::alarmSound ( ) 438
439QValueList <OLed> iPAQ::ledList ( ) const
440{
441 QValueList <OLed> vl;
442 vl << Led_Power;
443
444 if ( d-> m_model == Model_iPAQ_H38xx )
445 vl << Led_BlueTooth;
446 return vl;
447}
448
449QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
450{
451 QValueList <OLedState> vl;
452
453 if ( l == Led_Power )
454 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
455 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
456 vl << Led_Off; // << Led_On << ???
457
458 return vl;
459}
460
461OLedState iPAQ::ledState ( OLed l ) const
462 {
463 switch ( l ) {
464 case Led_Power:
465 return m_leds [0];
466 case Led_BlueTooth:
467 return m_leds [1];
468 default:
469 return Led_Off;
470 }
471}
472
473bool iPAQ::setLedState ( OLed l, OLedState st )
474{
475 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
476
477 if ( l == Led_Power ) {
478 if ( fd >= 0 ) {
479 LED_IN leds;
480 ::memset ( &leds, 0, sizeof( leds ));
481 leds. TotalTime = 0;
482 leds. OnTime = 0;
483 leds. OffTime = 1;
484 leds. OffOnBlink = 2;
485
486 switch ( st ) {
487 case Led_Off : leds. OffOnBlink = 0; break;
488 case Led_On : leds. OffOnBlink = 1; break;
489 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
490 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
491 }
492
493 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
494 m_leds [0] = st;
495 return true;
496 }
497 }
498 }
499 return false;
500}
501
502
503//QValueList <int> iPAQ::keyList ( ) const
504//{
505 //QValueList <int> vl;
506 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight;
507 //return vl;
508//}
509
510bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
511{
512 int newkeycode = keycode;
513
514
515 // simple susbstitutions
516 switch ( d-> m_model ) {
517 case Model_iPAQ_H38xx:
518 // H38xx has no "Q" key anymore - this is now the Mail key
519 if ( keycode == HardKey_Menu )
520 newkeycode = HardKey_Mail;
521 //nobreak
522
523 case Model_iPAQ_H31xx:
524 // Rotate cursor keys 180°
525 switch ( keycode ) {
526 case Key_Left : newkeycode = Key_Right; break;
527 case Key_Right: newkeycode = Key_Left; break;
528 case Key_Up : newkeycode = Key_Down; break;
529 case Key_Down : newkeycode = Key_Up; break;
530 }
531 break;
532
533 case Model_iPAQ_H36xx:
534 case Model_iPAQ_H37xx:
535 // map Power Button short/long press to F34/F35
536 if ( keycode == Key_SysReq ) {
537 if ( isPress ) {
538 if ( m_power_timer )
539 killTimer ( m_power_timer );
540 m_power_timer = startTimer ( 500 );
541 }
542 else if ( m_power_timer ) {
543 killTimer ( m_power_timer );
544 m_power_timer = 0;
545 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
546 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
547 }
548 newkeycode = Key_unknown;
549 }
550 break;
551
552 default:
553 break;
554 }
555
556 if ( newkeycode != keycode ) {
557 if ( newkeycode != Key_unknown )
558 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
559 return true;
560 }
561 else
562 return false;
563}
564
565void iPAQ::timerEvent ( QTimerEvent * )
566{
567 killTimer ( m_power_timer );
568 m_power_timer = 0;
569 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
570 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
571}
572
573
574void iPAQ::alarmSound ( )
393{ 575{
@@ -434,45 +616,4 @@ void ODeviceIPAQ::alarmSound ( )
434 616
435uint ODeviceIPAQ::hasLeds ( ) const
436{
437 return 1;
438}
439
440OLedState ODeviceIPAQ::led ( uint which ) const
441{
442 if ( which == 0 )
443 return d-> m_leds [0];
444 else
445 return OLED_Off;
446}
447 617
448bool ODeviceIPAQ::setLed ( uint which, OLedState st ) 618bool iPAQ::setSoftSuspend ( bool soft )
449{
450 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK );
451
452 if ( which == 0 ) {
453 if ( fd >= 0 ) {
454 LED_IN leds;
455 ::memset ( &leds, 0, sizeof( leds ));
456 leds. TotalTime = 0;
457 leds. OnTime = 0;
458 leds. OffTime = 1;
459 leds. OffOnBlink = 2;
460
461 switch ( st ) {
462 case OLED_Off : leds. OffOnBlink = 0; break;
463 case OLED_On : leds. OffOnBlink = 1; break;
464 case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
465 case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
466 }
467
468 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
469 d-> m_leds [0] = st;
470 return true;
471 }
472 }
473 }
474 return false;
475}
476
477bool ODeviceIPAQ::setPowerButtonHandler ( ODevice::PowerButtonHandler p )
478{ 619{
@@ -482,3 +623,3 @@ bool ODeviceIPAQ::setPowerButtonHandler ( ODevice::PowerButtonHandler p )
482 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 623 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
483 if ( ::write ( fd, p == KERNEL ? "0" : "1", 1 ) == 1 ) 624 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
484 res = true; 625 res = true;
@@ -496,3 +637,3 @@ bool ODeviceIPAQ::setPowerButtonHandler ( ODevice::PowerButtonHandler p )
496 637
497bool ODeviceIPAQ::setDisplayBrightness ( int bright ) 638bool iPAQ::setDisplayBrightness ( int bright )
498{ 639{
@@ -523,3 +664,3 @@ bool ODeviceIPAQ::setDisplayBrightness ( int bright )
523 664
524int ODeviceIPAQ::displayBrightnessResolution ( ) const 665int iPAQ::displayBrightnessResolution ( ) const
525{ 666{
@@ -537,8 +678,8 @@ int ODeviceIPAQ::displayBrightnessResolution ( ) const
537 678
538void ODeviceZaurus::init ( ) 679void Zaurus::init ( )
539{ 680{
540 d-> m_modelstr = "Zaurus SL5000"; 681 d-> m_modelstr = "Zaurus SL5000";
541 d-> m_model = OMODEL_Zaurus_SL5000; 682 d-> m_model = Model_Zaurus_SL5000;
542 d-> m_vendorstr = "Sharp"; 683 d-> m_vendorstr = "Sharp";
543 d-> m_vendor = OVENDOR_Sharp; 684 d-> m_vendor = Vendor_Sharp;
544 685
@@ -548,3 +689,3 @@ void ODeviceZaurus::init ( )
548 d-> m_systemstr = "OpenZaurus"; 689 d-> m_systemstr = "OpenZaurus";
549 d-> m_system = OSYSTEM_OpenZaurus; 690 d-> m_system = System_OpenZaurus;
550 691
@@ -561,3 +702,3 @@ void ODeviceZaurus::init ( )
561 d-> m_systemstr = "Zaurus"; 702 d-> m_systemstr = "Zaurus";
562 d-> m_system = OSYSTEM_Zaurus; 703 d-> m_system = System_Zaurus;
563 } 704 }
@@ -565,3 +706,3 @@ void ODeviceZaurus::init ( )
565 706
566 d-> m_leds [0] = OLED_Off; 707 m_leds [0] = Led_Off;
567} 708}
@@ -635,3 +776,3 @@ typedef struct sharp_led_status {
635 776
636void ODeviceZaurus::buzzer ( int sound ) 777void Zaurus::buzzer ( int sound )
637{ 778{
@@ -644,3 +785,3 @@ void ODeviceZaurus::buzzer ( int sound )
644 785
645void ODeviceZaurus::alarmSound ( ) 786void Zaurus::alarmSound ( )
646{ 787{
@@ -649,3 +790,3 @@ void ODeviceZaurus::alarmSound ( )
649 790
650void ODeviceZaurus::touchSound ( ) 791void Zaurus::touchSound ( )
651{ 792{
@@ -654,3 +795,3 @@ void ODeviceZaurus::touchSound ( )
654 795
655void ODeviceZaurus::keySound ( ) 796void Zaurus::keySound ( )
656{ 797{
@@ -660,16 +801,27 @@ void ODeviceZaurus::keySound ( )
660 801
661uint ODeviceZaurus::hasLeds ( ) const 802QValueList <OLed> Zaurus::ledList ( ) const
803{
804 QValueList <OLed> vl;
805 vl << Led_Mail;
806 return vl;
807}
808
809QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
662{ 810{
663 return 1; 811 QValueList <OLedState> vl;
812
813 if ( l == Led_Mail )
814 vl << Led_Off << Led_On << Led_BlinkSlow;
815 return vl;
664} 816}
665 817
666OLedState ODeviceZaurus::led ( uint which ) const 818OLedState Zaurus::ledState ( OLed which ) const
667{ 819{
668 if ( which == 0 ) 820 if ( which == Led_Mail )
669 return d-> m_leds [0]; 821 return m_leds [0];
670 else 822 else
671 return OLED_Off; 823 return Led_Off;
672} 824}
673 825
674bool ODeviceZaurus::setLed ( uint which, OLedState st ) 826bool Zaurus::setLedState ( OLed which, OLedState st )
675{ 827{
@@ -677,3 +829,3 @@ bool ODeviceZaurus::setLed ( uint which, OLedState st )
677 829
678 if ( which == 0 ) { 830 if ( which == Led_Mail ) {
679 if ( fd >= 0 ) { 831 if ( fd >= 0 ) {
@@ -682,12 +834,13 @@ bool ODeviceZaurus::setLed ( uint which, OLedState st )
682 leds. which = SHARP_LED_MAIL_EXISTS; 834 leds. which = SHARP_LED_MAIL_EXISTS;
835 bool ok = true;
683 836
684 switch ( st ) { 837 switch ( st ) {
685 case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 838 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
686 case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 839 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
687 case OLED_BlinkSlow: 840 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
688 case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 841 default : ok = false;
689 } 842 }
690 843
691 if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { 844 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
692 d-> m_leds [0] = st; 845 m_leds [0] = st;
693 return true; 846 return true;
@@ -699,3 +852,3 @@ bool ODeviceZaurus::setLed ( uint which, OLedState st )
699 852
700bool ODeviceZaurus::setPowerButtonHandler ( ODevice::PowerButtonHandler p ) 853bool Zaurus::setSoftSuspend ( bool soft )
701{ 854{
@@ -710,8 +863,8 @@ bool ODeviceZaurus::setPowerButtonHandler ( ODevice::PowerButtonHandler p )
710 if ( sources >= 0 ) { 863 if ( sources >= 0 ) {
711 if ( p == KERNEL ) 864 if ( soft )
712 sources |= APM_EVT_POWER_BUTTON;
713 else
714 sources &= ~APM_EVT_POWER_BUTTON; 865 sources &= ~APM_EVT_POWER_BUTTON;
866 else
867 sources |= APM_EVT_POWER_BUTTON;
715 868
716 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources & ~APM_EVT_POWER_BUTTON ) >= 0 ) // set new event sources 869 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
717 res = true; 870 res = true;
@@ -732,3 +885,3 @@ bool ODeviceZaurus::setPowerButtonHandler ( ODevice::PowerButtonHandler p )
732 885
733bool ODeviceZaurus::setDisplayBrightness ( int bright ) 886bool Zaurus::setDisplayBrightness ( int bright )
734{ 887{
@@ -753,3 +906,3 @@ bool ODeviceZaurus::setDisplayBrightness ( int bright )
753 906
754int ODeviceZaurus::displayBrightnessResolution ( ) const 907int Zaurus::displayBrightnessResolution ( ) const
755{ 908{
@@ -757 +910,9 @@ int ODeviceZaurus::displayBrightnessResolution ( ) const
757} 910}
911
912//QValueList <int> Zaurus::keyList ( ) const
913//{
914 //QValueList <int> vl;
915 //vl << HardKey_Datebook << HardKey_Contacts << HardKey_Mail << HardKey_Menu << HardKey_Home << HardKey_Suspend << HardKey_Backlight;
916 //return vl;
917//}
918
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 2f676ff..38f3787 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -23,3 +23,3 @@
23#include <qstring.h> 23#include <qstring.h>
24 24#include <qnamespace.h>
25 25
@@ -27,11 +27,13 @@ class ODeviceData;
27 27
28namespace Opie {
29
28enum OModel { 30enum OModel {
29 OMODEL_Unknown, 31 Model_Unknown,
30 32
31 OMODEL_iPAQ_H31xx, 33 Model_iPAQ_H31xx,
32 OMODEL_iPAQ_H36xx, 34 Model_iPAQ_H36xx,
33 OMODEL_iPAQ_H37xx, 35 Model_iPAQ_H37xx,
34 OMODEL_iPAQ_H38xx, 36 Model_iPAQ_H38xx,
35 37
36 OMODEL_Zaurus_SL5000 38 Model_Zaurus_SL5000
37}; 39};
@@ -39,6 +41,6 @@ enum OModel {
39 enum OVendor { 41 enum OVendor {
40 OVENDOR_Unknown, 42 Vendor_Unknown,
41 43
42 OVENDOR_HP, 44 Vendor_HP,
43 OVENDOR_Sharp 45 Vendor_Sharp
44 }; 46 };
@@ -46,7 +48,7 @@ enum OVendor {
46enum OSystem { 48enum OSystem {
47 OSYSTEM_Unknown, 49 System_Unknown,
48 50
49 OSYSTEM_Familiar, 51 System_Familiar,
50 OSYSTEM_Zaurus, 52 System_Zaurus,
51 OSYSTEM_OpenZaurus 53 System_OpenZaurus
52}; 54};
@@ -54,6 +56,23 @@ enum OSystem {
54enum OLedState { 56enum OLedState {
55 OLED_Off, 57 Led_Off,
56 OLED_On, 58 Led_On,
57 OLED_BlinkSlow, 59 Led_BlinkSlow,
58 OLED_BlinkFast 60 Led_BlinkFast
61};
62
63enum OLed {
64 Led_Mail,
65 Led_Power,
66 Led_BlueTooth
67};
68
69enum OHardKey {
70 HardKey_Datebook = Qt::Key_F9,
71 HardKey_Contacts = Qt::Key_F10,
72 HardKey_Menu = Qt::Key_F11,
73 HardKey_Home = Qt::Key_F12,
74 HardKey_Mail = Qt::Key_F14,
75 HardKey_Record = Qt::Key_F24,
76 HardKey_Suspend = Qt::Key_F34,
77 HardKey_Backlight = Qt::Key_F35,
59}; 78};
@@ -63,31 +82,40 @@ class ODevice
63{ 82{
83private:
84 ODevice ( const ODevice & );
85
86protected:
87 ODevice ( );
88 virtual void init ( );
89
90 ODeviceData *d;
91
64public: 92public:
93 virtual ~ODevice ( );
94
65 static ODevice *inst ( ); 95 static ODevice *inst ( );
66 96
67 // system
68 enum PowerButtonHandler {
69 KERNEL,
70 OPIE
71 };
72 97
73 virtual bool setPowerButtonHandler ( PowerButtonHandler h );
74 virtual bool suspend ( );
75 98
76 virtual bool setDisplayStatus ( bool on );
77 virtual bool setDisplayBrightness ( int brightness );
78 virtual int displayBrightnessResolution ( ) const;
79
80// information 99// information
81 100
82 QString modelString ( ); 101 QString modelString ( ) const;
83 OModel model ( ); 102 OModel model ( ) const;
84 103
85 QString vendorString ( ); 104 QString vendorString ( ) const;
86 OVendor vendor ( ); 105 OVendor vendor ( ) const;
106
107 QString systemString ( ) const;
108 OSystem system ( ) const;
109
110 QString systemVersionString ( ) const;
87 111
88 QString systemString ( ); 112 // system
89 OSystem system ( );
90 113
91 QString systemVersionString ( ); 114 virtual bool setSoftSuspend ( bool on );
115 virtual bool suspend ( );
92 116
117 virtual bool setDisplayStatus ( bool on );
118 virtual bool setDisplayBrightness ( int brightness );
119 virtual int displayBrightnessResolution ( ) const;
120
93// input / output 121// input / output
@@ -98,20 +126,13 @@ public:
98 126
99 virtual uint hasLeds ( ) const; 127 virtual QValueList <OLed> ledList ( ) const;
100 virtual OLedState led ( uint which ) const; 128 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
101 virtual bool setLed ( uint which, OLedState st ); 129 virtual OLedState ledState ( OLed led ) const;
102 130 virtual bool setLedState ( OLed led, OLedState st );
103 virtual ~ODevice ( );
104 131
105protected: 132 //virtual QValueList <int> keyList ( ) const;
106 ODevice ( );
107 virtual void init ( );
108
109 ODeviceData *d;
110
111private:
112 ODevice ( const ODevice & );
113}; 133};
114 134
115#endif 135}
116 136
137#endif
117 138