summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authorsandman <sandman>2002-10-27 15:52:44 (UTC)
committer sandman <sandman>2002-10-27 15:52:44 (UTC)
commitbf21c882b82bfcdbcdce6b2dc5d863a2a2fb37c7 (patch) (unidiff)
tree6f104afe571f394bea83b94cb0de9242ee742b88 /libopie/odevice.cpp
parent4ad1fa6d01c9de96d309cd662e658bcb1bb899a5 (diff)
downloadopie-bf21c882b82bfcdbcdce6b2dc5d863a2a2fb37c7.zip
opie-bf21c882b82bfcdbcdce6b2dc5d863a2a2fb37c7.tar.gz
opie-bf21c882b82bfcdbcdce6b2dc5d863a2a2fb37c7.tar.bz2
- new function to check for and read the light sensor
- redone the Model enum, to make it easier to check for "any iPAQ" !! This means every application using this enum has to be recompiled !!
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp42
1 files changed, 42 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 58bd663..44fe35f 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -70,32 +70,35 @@ public:
70class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { 70class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter {
71protected: 71protected:
72 virtual void init ( ); 72 virtual void init ( );
73 73
74public: 74public:
75 virtual bool setSoftSuspend ( bool soft ); 75 virtual bool setSoftSuspend ( bool soft );
76 76
77 virtual bool setDisplayBrightness ( int b ); 77 virtual bool setDisplayBrightness ( int b );
78 virtual int displayBrightnessResolution ( ) const; 78 virtual int displayBrightnessResolution ( ) const;
79 79
80 virtual void alarmSound ( ); 80 virtual void alarmSound ( );
81 81
82 virtual QValueList <OLed> ledList ( ) const; 82 virtual QValueList <OLed> ledList ( ) const;
83 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 83 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
84 virtual OLedState ledState ( OLed led ) const; 84 virtual OLedState ledState ( OLed led ) const;
85 virtual bool setLedState ( OLed led, OLedState st ); 85 virtual bool setLedState ( OLed led, OLedState st );
86
87 virtual bool hasLightSensor ( ) const;
88 virtual int readLightSensor ( );
86 89
87 //virtual QValueList <int> keyList ( ) const; 90 //virtual QValueList <int> keyList ( ) const;
88 91
89protected: 92protected:
90 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 93 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
91 virtual void timerEvent ( QTimerEvent *te ); 94 virtual void timerEvent ( QTimerEvent *te );
92 95
93 int m_power_timer; 96 int m_power_timer;
94 97
95 OLedState m_leds [2]; 98 OLedState m_leds [2];
96}; 99};
97 100
98class Zaurus : public ODevice { 101class Zaurus : public ODevice {
99protected: 102protected:
100 virtual void init ( ); 103 virtual void init ( );
101 104
@@ -343,32 +346,41 @@ QValueList <OLed> ODevice::ledList ( ) const
343 346
344QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 347QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
345{ 348{
346 return QValueList <OLedState> ( ); 349 return QValueList <OLedState> ( );
347} 350}
348 351
349OLedState ODevice::ledState ( OLed /*which*/ ) const 352OLedState ODevice::ledState ( OLed /*which*/ ) const
350{ 353{
351 return Led_Off; 354 return Led_Off;
352} 355}
353 356
354bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 357bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
355{ 358{
356 return false; 359 return false;
357} 360}
358 361
362bool ODevice::hasLightSensor ( ) const
363{
364 return false;
365}
366
367int ODevice::readLightSensor ( )
368{
369 return -1;
370}
359 371
360 372
361//QValueList <int> ODevice::keyList ( ) const 373//QValueList <int> ODevice::keyList ( ) const
362//{ 374//{
363 //return QValueList <int> ( ); 375 //return QValueList <int> ( );
364//} 376//}
365 377
366 378
367 379
368/************************************************** 380/**************************************************
369 * 381 *
370 * iPAQ 382 * iPAQ
371 * 383 *
372 **************************************************/ 384 **************************************************/
373 385
374void iPAQ::init ( ) 386void iPAQ::init ( )
@@ -653,32 +665,62 @@ bool iPAQ::setDisplayBrightness ( int bright )
653 FLITE_IN bl; 665 FLITE_IN bl;
654 bl. mode = 1; 666 bl. mode = 1;
655 bl. pwr = bright ? 1 : 0; 667 bl. pwr = bright ? 1 : 0;
656 bl. brightness = bright; 668 bl. brightness = bright;
657 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 669 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
658 ::close ( fd ); 670 ::close ( fd );
659 } 671 }
660 return res; 672 return res;
661} 673}
662 674
663int iPAQ::displayBrightnessResolution ( ) const 675int iPAQ::displayBrightnessResolution ( ) const
664{ 676{
665 return 255; // really 128, but logarithmic control is smoother this way 677 return 255; // really 128, but logarithmic control is smoother this way
666} 678}
667 679
668 680
681bool iPAQ::hasLightSensor ( ) const
682{
683 return true;
684}
685
686int iPAQ::readLightSensor ( )
687{
688 int fd;
689 int val = -1;
690
691 if (( fd = ::open ( "/proc/hal/lightsensor", O_RDONLY )) >= 0 ) {
692 char buffer [5];
693
694 if ( ::read ( fd, buffer, 4 ) == 4 ) {
695 char *endptr;
696
697 buffer [4] = 0;
698 val = ::strtol ( buffer + 2, &endptr, 16 );
699
700 if ( *endptr != 0 )
701 val = -1;
702 }
703
704 ::close ( fd );
705 }
706
707 return val;
708}
709
710
669/************************************************** 711/**************************************************
670 * 712 *
671 * Zaurus 713 * Zaurus
672 * 714 *
673 **************************************************/ 715 **************************************************/
674 716
675 717
676 718
677void Zaurus::init ( ) 719void Zaurus::init ( )
678{ 720{
679 d-> m_modelstr = "Zaurus SL5000"; 721 d-> m_modelstr = "Zaurus SL5000";
680 d-> m_model = Model_Zaurus_SL5000; 722 d-> m_model = Model_Zaurus_SL5000;
681 d-> m_vendorstr = "Sharp"; 723 d-> m_vendorstr = "Sharp";
682 d-> m_vendor = Vendor_Sharp; 724 d-> m_vendor = Vendor_Sharp;
683 725
684 QFile f ( "/proc/filesystems" ); 726 QFile f ( "/proc/filesystems" );