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) (side-by-side diff)
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
@@ -83,6 +83,9 @@ public:
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;
@@ -356,6 +359,15 @@ 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
@@ -666,6 +678,36 @@ int iPAQ::displayBrightnessResolution ( ) const
}
+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