-rw-r--r-- | libopie/odevice.cpp | 42 | ||||
-rw-r--r-- | libopie/odevice.h | 17 |
2 files changed, 54 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 58bd663..44fe35f 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -79,16 +79,19 @@ public: virtual void alarmSound ( ); virtual QValueList <OLed> ledList ( ) const; virtual QValueList <OLedState> ledStateList ( OLed led ) const; virtual OLedState ledState ( OLed led ) const; virtual bool setLedState ( OLed led, OLedState st ); + virtual bool hasLightSensor ( ) const; + virtual int readLightSensor ( ); + //virtual QValueList <int> keyList ( ) const; protected: virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); virtual void timerEvent ( QTimerEvent *te ); int m_power_timer; @@ -351,16 +354,25 @@ OLedState ODevice::ledState ( OLed /*which*/ ) const return Led_Off; } bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) { return false; } +bool ODevice::hasLightSensor ( ) const +{ + return false; +} + +int ODevice::readLightSensor ( ) +{ + return -1; +} //QValueList <int> ODevice::keyList ( ) const //{ // return QValueList <int> ( ); //} @@ -661,16 +673,46 @@ bool iPAQ::setDisplayBrightness ( int bright ) } int iPAQ::displayBrightnessResolution ( ) const { return 255; // really 128, but logarithmic control is smoother this way } +bool iPAQ::hasLightSensor ( ) const +{ + return true; +} + +int iPAQ::readLightSensor ( ) +{ + int fd; + int val = -1; + + if (( fd = ::open ( "/proc/hal/lightsensor", O_RDONLY )) >= 0 ) { + char buffer [5]; + + if ( ::read ( fd, buffer, 4 ) == 4 ) { + char *endptr; + + buffer [4] = 0; + val = ::strtol ( buffer + 2, &endptr, 16 ); + + if ( *endptr != 0 ) + val = -1; + } + + ::close ( fd ); + } + + return val; +} + + /************************************************** * * Zaurus * **************************************************/ diff --git a/libopie/odevice.h b/libopie/odevice.h index 38f3787..be2a9c7 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h @@ -25,22 +25,26 @@ class ODeviceData; namespace Opie { enum OModel { Model_Unknown, - Model_iPAQ_H31xx, - Model_iPAQ_H36xx, - Model_iPAQ_H37xx, - Model_iPAQ_H38xx, + Model_iPAQ = ( 1 << 16 ), - Model_Zaurus_SL5000 + Model_iPAQ_H31xx = ( Model_iPAQ | 1 ), + Model_iPAQ_H36xx = ( Model_iPAQ | 2 ), + Model_iPAQ_H37xx = ( Model_iPAQ | 3 ), + Model_iPAQ_H38xx = ( Model_iPAQ | 4 ), + + Model_Zaurus = ( 2 << 16 ), + + Model_Zaurus_SL5000 = ( Model_Zaurus | 1 ), }; enum OVendor { Vendor_Unknown, Vendor_HP, Vendor_Sharp }; @@ -124,15 +128,18 @@ public: virtual void keySound ( ); virtual void touchSound ( ); virtual QValueList <OLed> ledList ( ) const; virtual QValueList <OLedState> ledStateList ( OLed led ) const; virtual OLedState ledState ( OLed led ) const; virtual bool setLedState ( OLed led, OLedState st ); + virtual bool hasLightSensor ( ) const; + virtual int readLightSensor ( ); + //virtual QValueList <int> keyList ( ) const; }; } #endif |