-rw-r--r-- | libopie/odevice.cpp | 126 | ||||
-rw-r--r-- | libopie/odevice.h | 3 |
2 files changed, 129 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index aadd0bf..8624016 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -108,2 +108,14 @@ protected: +class Jornada : public ODevice { +protected: + virtual void init ( ); + virtual void initButtons ( ); +public: + virtual bool setSoftSuspend ( bool soft ); + virtual bool setDisplayBrightness ( int b ); + virtual int displayBrightnessResolution ( ) const; + static bool isJornada(); + +}; + class Zaurus : public ODevice { @@ -435,2 +447,4 @@ ODevice *ODevice::inst ( ) dev = new Yopy ( ); + else if ( Jornada::isJornada() ) + dev = new Jornada ( ); else @@ -2454 +2468,113 @@ int Ramses::displayContrastResolution() const } + + +/************************************************** + * * + * Jornada * + * * + **************************************************/ + + +bool Jornada::isJornada ( ) +{ + QFile f( "/proc/cpuinfo" ); + if ( f. open ( IO_ReadOnly ) ) { + QTextStream ts ( &f ); + QString line; + while( line = ts. readLine ( ) ) { + if ( line. left ( 8 ) == "Hardware" ) { + int loc = line. find ( ":" ); + if ( loc != -1 ) { + QString model = + line. mid ( loc + 2 ). simplifyWhiteSpace( ); + return ( model == "HP Jornada 56x" ); + } + } + } + } + return false; +} + +void Jornada::init ( ) +{ + d-> m_vendorstr = "HP"; + d-> m_vendor = Vendor_HP; + d-> m_modelstr = "Jornada 56x"; + d-> m_model = Model_Jornada_56x; + d-> m_systemstr = "Familiar"; + d-> m_system = System_Familiar; + d-> m_rotation = Rot0; +} + +void Jornada::initButtons ( ) +{ + if ( d-> m_buttons ) + return; + + // Simulation uses iPAQ 3660 device buttons + + qDebug ( "init Buttons" ); + d-> m_buttons = new QValueList <ODeviceButton>; + + for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { + i_button *ib = ipaq_buttons + i; + ODeviceButton b; + + if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { + b. setKeycode ( ib-> code ); + b. setUserText ( QObject::tr ( "Button", ib-> utext )); + b. setPixmap ( Resource::loadPixmap ( ib-> pix )); + b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); + b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); + d-> m_buttons-> append ( b ); + } + } + reloadButtonMapping ( ); + + QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); + connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); +} + +int Jornada::displayBrightnessResolution ( ) const +{ +} + +bool Jornada::setDisplayBrightness ( int bright ) +{ + bool res = false; + int fd; + + if ( bright > 255 ) + bright = 255; + if ( bright < 0 ) + bright = 0; + + if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { + FLITE_IN bl; + bl. mode = 1; + bl. pwr = bright ? 1 : 0; + bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; + res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); + ::close ( fd ); + } + return res; +} + +bool Jornada::setSoftSuspend ( bool soft ) +{ + bool res = false; + int fd; + + if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { + if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) + res = true; + else + ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); + + ::close ( fd ); + } + else + ::perror ( "/proc/sys/ts/suspend_button_mode" ); + + return res; +} diff --git a/libopie/odevice.h b/libopie/odevice.h index 2a5e494..35e3eff 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h @@ -53,2 +53,5 @@ enum OModel { + Model_Jornada = ( 6 << 24 ), + Model_Jornada_56x = ( Model_Jornada | 0x000001 ), + Model_Zaurus = ( 2 << 24 ), |