1 --- libopie2/opiecore/device/odevice_ipaq.cpp.orig 2006-07-22 21:32:03.000000000 +0200
2 +++ libopie2/opiecore/device/odevice_ipaq.cpp 2006-07-22 22:49:57.000000000 +0200
6 #include <qapplication.h>
9 #include <qtextstream.h>
10 #include <qwindowsystem_qws.h>
18 - case Model_iPAQ_H191x:
20 - cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power");
22 - cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright );
23 - // No Global::shellQuote as we gurantee it to be sane
24 - res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
27 - case Model_iPAQ_HX4700:
28 - cmdline = QString::fromLatin1( "echo %1 > /sys/class/backlight/w100fb/brightness" ).arg( bright );
29 - // No Global::shellQuote as we gurantee it to be sane
30 - res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
35 + QDir sysClass( "/sys/class/backlight/" );
36 + sysClass.setFilter(QDir::Dirs);
37 + if ( sysClass.exists() && sysClass.count() > 2 ) {
38 + QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/brightness" );
39 + int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
42 + int val = bright * displayBrightnessResolution() / 255;
43 + int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
44 + res = ( ::write( fd, &buf[0], len ) == 0 );
48 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
53 int iPAQ::displayBrightnessResolution() const
57 + QDir sysClass( "/sys/class/backlight/" );
58 + sysClass.setFilter(QDir::Dirs);
59 + if ( sysClass.exists() && sysClass.count() > 2 ) {
60 + QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" );
61 + int fd = ::open( sysClassPath, O_RDONLY|O_NONBLOCK );
64 + if ( ::read( fd, &buf[0], sizeof buf ) )
65 + ::sscanf( &buf[0], "%d", &res );
72 case Model_iPAQ_H31xx:
73 case Model_iPAQ_H36xx:
80 - if ( model() == Model_iPAQ_H191x ) {
81 - cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
82 + QDir sysClass( "/sys/class/lcd/" );
83 + sysClass.setFilter(QDir::Dirs);
84 + if ( sysClass.exists() && sysClass.count() > 2 ) {
85 + QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/power" );
86 + int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
89 + buf[0] = on ? 0 : 4;
91 + res = ( ::write( fd, &buf[0], 2 ) == 0 );
95 - return OAbstractMobileDevice::setDisplayStatus(on);
96 + res = OAbstractMobileDevice::setDisplayStatus(on);
99 - res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
104 bool iPAQ::hasLightSensor() const
107 + switch ( model()) {
108 + case Model_iPAQ_H191x:
109 + case Model_iPAQ_H22xx:
117 int iPAQ::readLightSensor()