summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp12
-rw-r--r--libopie/odevice.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9f64fc0..4c49c4f 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -65,48 +65,49 @@ public:
QString m_sysverstr;
};
class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter {
protected:
virtual void init ( );
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution ( ) const;
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 int lightSensorResolution ( ) const;
//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;
OLedState m_leds [2];
};
class Zaurus : public ODevice {
protected:
virtual void init ( );
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution ( ) const;
virtual void alarmSound ( );
virtual void keySound ( );
@@ -348,48 +349,52 @@ QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
{
return QValueList <OLedState> ( );
}
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;
}
+int ODevice::lightSensorResolution ( ) const
+{
+ return 0;
+}
//QValueList <int> ODevice::keyList ( ) const
//{
// return QValueList <int> ( );
//}
/**************************************************
*
* iPAQ
*
**************************************************/
void iPAQ::init ( )
{
d-> m_vendorstr = "HP";
d-> m_vendor = Vendor_HP;
QFile f ( "/proc/hal/model" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
@@ -661,73 +666,76 @@ bool iPAQ::setDisplayBrightness ( int bright )
bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic
// bright = ( bright + 1 ) / 2;
if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
FLITE_IN bl;
bl. mode = 1;
bl. pwr = bright ? 1 : 0;
bl. brightness = bright;
res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
::close ( fd );
}
return res;
}
int iPAQ::displayBrightnessResolution ( ) const
{
return 256; // really 128, but logarithmic control is smoother this way
}
bool iPAQ::hasLightSensor ( ) const
{
return true;
}
-#include <errno.h>
-#include <string.h>
+
int iPAQ::readLightSensor ( )
{
int fd;
int val = -1;
if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
char buffer [8];
if ( ::read ( fd, buffer, 5 ) == 5 ) {
char *endptr;
buffer [4] = 0;
val = ::strtol ( buffer + 2, &endptr, 16 );
if ( *endptr != 0 )
val = -1;
}
::close ( fd );
}
return val;
}
+int iPAQ::lightSensorResolution ( ) const
+{
+ return 256;
+}
/**************************************************
*
* Zaurus
*
**************************************************/
void Zaurus::init ( )
{
d-> m_modelstr = "Zaurus SL5000";
d-> m_model = Model_Zaurus_SL5000;
d-> m_vendorstr = "Sharp";
d-> m_vendor = Vendor_Sharp;
QFile f ( "/proc/filesystems" );
if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
d-> m_systemstr = "OpenZaurus";
d-> m_system = System_OpenZaurus;
f. close ( );
diff --git a/libopie/odevice.h b/libopie/odevice.h
index be2a9c7..e07b91c 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -114,32 +114,33 @@ public:
QString systemVersionString ( ) const;
// system
virtual bool setSoftSuspend ( bool on );
virtual bool suspend ( );
virtual bool setDisplayStatus ( bool on );
virtual bool setDisplayBrightness ( int brightness );
virtual int displayBrightnessResolution ( ) const;
// input / output
virtual void alarmSound ( );
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 int lightSensorResolution ( ) const;
//virtual QValueList <int> keyList ( ) const;
};
}
#endif