author | sandman <sandman> | 2002-10-27 15:52:44 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-10-27 15:52:44 (UTC) |
commit | bf21c882b82bfcdbcdce6b2dc5d863a2a2fb37c7 (patch) (unidiff) | |
tree | 6f104afe571f394bea83b94cb0de9242ee742b88 | |
parent | 4ad1fa6d01c9de96d309cd662e658bcb1bb899a5 (diff) | |
download | opie-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 !!
-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 | |||
@@ -85,2 +85,5 @@ public: | |||
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 | ||
@@ -358,2 +361,11 @@ bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | |||
358 | 361 | ||
362 | bool ODevice::hasLightSensor ( ) const | ||
363 | { | ||
364 | return false; | ||
365 | } | ||
366 | |||
367 | int ODevice::readLightSensor ( ) | ||
368 | { | ||
369 | return -1; | ||
370 | } | ||
359 | 371 | ||
@@ -668,2 +680,32 @@ int iPAQ::displayBrightnessResolution ( ) const | |||
668 | 680 | ||
681 | bool iPAQ::hasLightSensor ( ) const | ||
682 | { | ||
683 | return true; | ||
684 | } | ||
685 | |||
686 | int 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 | /************************************************** |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 38f3787..be2a9c7 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -32,8 +32,12 @@ enum OModel { | |||
32 | 32 | ||
33 | Model_iPAQ_H31xx, | 33 | Model_iPAQ = ( 1 << 16 ), |
34 | Model_iPAQ_H36xx, | ||
35 | Model_iPAQ_H37xx, | ||
36 | Model_iPAQ_H38xx, | ||
37 | 34 | ||
38 | Model_Zaurus_SL5000 | 35 | Model_iPAQ_H31xx = ( Model_iPAQ | 1 ), |
36 | Model_iPAQ_H36xx = ( Model_iPAQ | 2 ), | ||
37 | Model_iPAQ_H37xx = ( Model_iPAQ | 3 ), | ||
38 | Model_iPAQ_H38xx = ( Model_iPAQ | 4 ), | ||
39 | |||
40 | Model_Zaurus = ( 2 << 16 ), | ||
41 | |||
42 | Model_Zaurus_SL5000 = ( Model_Zaurus | 1 ), | ||
39 | }; | 43 | }; |
@@ -131,2 +135,5 @@ public: | |||
131 | 135 | ||
136 | virtual bool hasLightSensor ( ) const; | ||
137 | virtual int readLightSensor ( ); | ||
138 | |||
132 | //virtual QValueList <int> keyList ( ) const; | 139 | //virtual QValueList <int> keyList ( ) const; |