summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Side-by-side diff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp41
1 files changed, 23 insertions, 18 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index cb7dd74..d78277f 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1063,169 +1063,174 @@ int iPAQ::displayBrightnessResolution ( ) const
{
switch ( model ( )) {
case Model_iPAQ_H31xx:
case Model_iPAQ_H36xx:
case Model_iPAQ_H37xx:
return 128; // really 256, but >128 could damage the LCD
case Model_iPAQ_H38xx:
case Model_iPAQ_H39xx:
return 64;
default:
return 2;
}
}
bool iPAQ::hasLightSensor ( ) const
{
return true;
}
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_vendorstr = "Sharp";
d-> m_vendor = Vendor_Sharp;
QFile f ( "/proc/filesystems" );
+ QString model;
if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
d-> m_vendorstr = "OpenZaurus Team";
d-> m_systemstr = "OpenZaurus";
d-> m_system = System_OpenZaurus;
f. close ( );
f. setName ( "/etc/oz_version" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
f. close ( );
}
}
else {
d-> m_systemstr = "Zaurus";
d-> m_system = System_Zaurus;
}
- f. setName ( "/proc/deviceinfo/product" );
+ f. setName ( "/proc/cpuinfo" );
if ( f. open ( IO_ReadOnly ) ) {
QTextStream ts ( &f );
- QString model = ts. readLine ( );
- f. close ( );
-
- d-> m_modelstr = QString("Zaurus ") + model;
- if ( model == "SL-5500" )
- d-> m_model = Model_Zaurus_SL5500;
- else if ( model == "SL-C700" )
- d-> m_model = Model_Zaurus_SLC700;
- else if ( model == "SL-A300" )
- d-> m_model = Model_Zaurus_SLA300;
- else if ( model == "SL-B600" || model == "SL-5600" )
- d-> m_model = Model_Zaurus_SLB600;
- else
- d-> m_model = Model_Zaurus_SL5000;
+ QString line;
+ while( line = ts. readLine ( ) ) {
+ if ( line. left ( 8 ) == "Hardware" )
+ break;
+ }
+ int loc = line. find ( ":" );
+ if ( loc != -1 )
+ model = line. mid ( loc + 2 ). simplifyWhitespace( );
}
- else {
- d-> m_model = Model_Zaurus_SL5000;
- d-> m_modelstr = "Zaurus (model unknown)";
+
+ if ( model == "SHARP Corgi" ) {
+ d-> m_model = Model_Zaurus_SLC700;
+ d-> m_modelstr = "Zaurus SL-C700";
+ } else if ( model == "SHARP Poodle" ) {
+ d-> m_model = Model_Zaurus_SLB600;
+ d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
+ } else if ( model = "Sharp-Collie" ) {
+ d-> m_model = Model_Zaurus_SL5500;
+ d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
+ } else {
+ d-> m_model = Model_Zaurus_SL5500;
+ d-> m_modelstr = "Zaurus (Model unknown)";
}
bool flipstate = false;
switch ( d-> m_model ) {
case Model_Zaurus_SLA300:
d-> m_rotation = Rot0;
break;
case Model_Zaurus_SLC700:
// Note: need to 1) set flipstate based on physical screen orientation
// and 2) check to see if the user overrode the rotation direction
// using appearance, and if so, remove that item from the Config to
// ensure the rotate applet flips us back to the previous state.
if ( flipstate ) {
// 480x640
d-> m_rotation = Rot0;
d-> m_direction = CW;
} else {
// 640x480
d-> m_rotation = Rot270;
d-> m_direction = CCW;
}
break;
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default:
d-> m_rotation = Rot270;
break;
}
m_leds [0] = Led_Off;
}
void Zaurus::initButtons ( )
{
if ( d-> m_buttons )
return;
d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
d-> m_buttons = new QValueList <ODeviceButton>;
struct z_button * pz_buttons;
int buttoncount;
switch ( d-> m_model ) {
case Model_Zaurus_SLC700:
pz_buttons = z_buttons_c700;
buttoncount = ARRAY_SIZE(z_buttons_c700);
break;
default:
pz_buttons = z_buttons;
buttoncount = ARRAY_SIZE(z_buttons);
break;
}
for ( int i = 0; i < buttoncount; i++ ) {
struct z_button *zb = pz_buttons + i;
ODeviceButton b;
b. setKeycode ( zb-> code );
b. setUserText ( QObject::tr ( "Button", zb-> utext ));
b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));