From 061ccf5b9d384b1f24d203e96f1f04ccf1dcf133 Mon Sep 17 00:00:00 2001 From: mickeyl Date: Tue, 13 Jan 2004 18:32:19 +0000 Subject: - rewrite device detection - cleanup - split odevice stuff into header and cpp files - Note for next buildsystem: Don't link all header files but distinguish between public and private headers, e.g. odevice.h is public while odevice_ipaq.h is private. --- (limited to 'libopie2/opiecore') diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 0f88c3c..6c8432f 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp @@ -27,7 +27,12 @@ Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_ipaq.h" +#include "odevice_jornada.h" +#include "odevice_ramses.h" +#include "odevice_simpad.h" +#include "odevice_yopy.h" +#include "odevice_zaurus.h" /* QT */ #include @@ -53,52 +58,46 @@ #include #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -// _IO and friends are only defined in kernel headers ... - -#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) - -#define OD_IO(type,number) OD_IOC(0,type,number,0) -#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) -#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) -#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) +const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; using namespace Opie; -class iPAQ; -class Zaurus; -class SIMpad; -class Ramses; -class Jornada; - ODevice *ODevice::inst() { static ODevice *dev = 0; - // rewrite this to only use /proc/devinfo or so - - /* - if ( !dev ) { - if ( QFile::exists ( "/proc/hal/model" )) - dev = new iPAQ(); - else if ( Zaurus::isZaurus() ) - dev = new Zaurus(); - else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) - dev = new SIMpad(); - else if ( QFile::exists ( "/proc/sys/board/name" )) - dev = new Ramses(); - else if ( Yopy::isYopy() ) - dev = new Yopy(); - else if ( Jornada::isJornada() ) - dev = new Jornada(); + // rewrite this to only use /proc/cpuinfo or so + + if ( !dev ) + { + QFile f( PATH_PROC_CPUINFO ); + if ( f.open( IO_ReadOnly ) ) + { + QTextStream s( &f ); + while ( !s.atEnd() ) + { + QString line; + line = s.readLine(); + if ( line.startsWith( "Hardware" ) ) + { + qDebug( "ODevice() - found '%s'", (const char*) line ); + if ( line.contains( "sharp", false ) ) dev = new Zaurus(); + else if ( line.contains( "ipaq", false ) ) dev = new iPAQ(); + else if ( line.contains( "simpad", false ) ) dev = new SIMpad(); + else if ( line.contains( "jornada", false ) ) dev = new Jornada(); + else if ( line.contains( "ramses", false ) ) dev = new Ramses(); + else qWarning( "ODevice() - unknown hardware - using default." ); + break; + } + } + } else - dev = new ODevice(); + { + qWarning( "ODevice() - can't open '%s' - unknown hardware - using default." ); + } + if ( !dev ) dev = new ODevice(); dev->init(); } - */ return dev; } diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index bde6411..8ae7ffa 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h @@ -30,7 +30,9 @@ #ifndef ODEVICE_H_ #define ODEVICE_H_ +/* OPIE */ #include +#include /* for Transformation enum.. */ /* QT */ #include @@ -38,8 +40,6 @@ #include #include -#include /* for Transformation enum.. */ - namespace Opie { class ODeviceData; diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index d928806..d68bce1 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_ipaq.h" /* QT */ #include @@ -53,12 +53,7 @@ #include #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -// _IO and friends are only defined in kernel headers ... - +/* KERNEL */ #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) #define OD_IO(type,number) OD_IOC(0,type,number,0) @@ -82,51 +77,7 @@ typedef struct { #define LED_ON OD_IOW( 'f', 5, LED_IN ) #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) -using namespace Opie; - -class iPAQ : public ODevice, public QWSServer::KeyboardFilter -{ - - protected: - virtual void init(); - virtual void initButtons(); - - public: - virtual bool setSoftSuspend( bool soft ); - - virtual bool setDisplayBrightness( int b ); - virtual int displayBrightnessResolution() const; - - virtual void alarmSound(); - - virtual QValueList ledList() const; - virtual QValueList 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; - - 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]; -}; - -struct i_button { - uint model; - Qt::Key code; - char *utext; - char *pix; - char *fpressedservice; - char *fpressedaction; - char *fheldservice; - char *fheldaction; -} ipaq_buttons [] = { +struct i_button ipaq_buttons [] = { { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), "devicebuttons/ipaq_calendar", diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h new file mode 100644 index 0000000..baf7215 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_ipaq.h @@ -0,0 +1,84 @@ +/* +                 This file is part of the Opie Project +              Copyright (C) The Opie Team + =. + .=l. +           .>+-= + _;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software + - .   .-<_>     .<> Foundation; either version 2 of the License, +     ._= =}       : or (at your option) any later version. +    .%`+i>       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. + :     =  ...= . :.=- + -.   .:....=;==+<; You should have received a copy of the GNU +  -_. . .   )=.  = Library General Public License along with +    --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef ODEVICE_IPAQ +#define ODEVICE_IPAQ + +#include "odevice.h" + +/* QT */ +#include + +using namespace Opie; + +class iPAQ : public ODevice, public QWSServer::KeyboardFilter +{ + + protected: + virtual void init(); + virtual void initButtons(); + + public: + virtual bool setSoftSuspend( bool soft ); + + virtual bool setDisplayBrightness( int b ); + virtual int displayBrightnessResolution() const; + + virtual void alarmSound(); + + virtual QValueList ledList() const; + virtual QValueList 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; + + 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]; +}; + +struct i_button { + uint model; + Qt::Key code; + char *utext; + char *pix; + char *fpressedservice; + char *fpressedaction; + char *fheldservice; + char *fheldaction; +}; + +#endif diff --git a/libopie2/opiecore/device/odevice_jornada.cpp b/libopie2/opiecore/device/odevice_jornada.cpp index bcd03ed..37bd6e9 100644 --- a/libopie2/opiecore/device/odevice_jornada.cpp +++ b/libopie2/opiecore/device/odevice_jornada.cpp @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_jornada.h" /* QT */ #include @@ -53,12 +53,7 @@ #include #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -// _IO and friends are only defined in kernel headers ... - +/* KERNEL */ #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) #define OD_IO(type,number) OD_IOC(0,type,number,0) @@ -84,39 +79,6 @@ typedef struct { using namespace Opie; -class Jornada : public ODevice -{ - - protected: - virtual void init(); - - public: - virtual bool setSoftSuspend ( bool soft ); - virtual bool setDisplayBrightness ( int b ); - virtual int displayBrightnessResolution() const; - static bool isJornada(); -}; - - -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"; @@ -128,51 +90,23 @@ void Jornada::init() d->m_rotation = Rot0; QFile f ( "/etc/familiar-version" ); - f. setName ( "/etc/familiar-version" ); - if ( f. open ( IO_ReadOnly )) { + f.setName ( "/etc/familiar-version" ); + if ( f.open ( IO_ReadOnly )) { QTextStream ts ( &f ); - d->m_sysverstr = ts. readLine(). mid ( 10 ); + d->m_sysverstr = ts.readLine().mid( 10 ); f. close(); } } -#if 0 -void Jornada::initButtons() -{ - if ( d->m_buttons ) - return; - - // Simulation uses iPAQ 3660 device buttons - - qDebug ( "init Buttons" ); - d->m_buttons = new QValueList ; - - 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 & ))); -} -#endif int Jornada::displayBrightnessResolution() const { + return 0; } + bool Jornada::setDisplayBrightness( int bright ) { bool res = false; @@ -194,6 +128,7 @@ bool Jornada::setDisplayBrightness( int bright ) return res; } + bool Jornada::setSoftSuspend( bool soft ) { bool res = false; @@ -212,3 +147,4 @@ bool Jornada::setSoftSuspend( bool soft ) return res; } + diff --git a/libopie2/opiecore/device/odevice_jornada.h b/libopie2/opiecore/device/odevice_jornada.h new file mode 100644 index 0000000..59be8da --- a/dev/null +++ b/libopie2/opiecore/device/odevice_jornada.h @@ -0,0 +1,50 @@ +/* +                 This file is part of the Opie Project +              Copyright (C) The Opie Team + =. + .=l. +           .>+-= + _;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software + - .   .-<_>     .<> Foundation; either version 2 of the License, +     ._= =}       : or (at your option) any later version. +    .%`+i>       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. + :     =  ...= . :.=- + -.   .:....=;==+<; You should have received a copy of the GNU +  -_. . .   )=.  = Library General Public License along with +    --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef ODEVICE_JORNADA +#define ODEVICE_JORNADA + +#include + +using namespace Opie; + +class Jornada : public ODevice +{ + + protected: + virtual void init(); + + public: + virtual bool setSoftSuspend ( bool soft ); + virtual bool setDisplayBrightness ( int b ); + virtual int displayBrightnessResolution() const; +}; + +#endif + diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp index a90c3a0..5bcf6a9 100644 --- a/libopie2/opiecore/device/odevice_ramses.cpp +++ b/libopie2/opiecore/device/odevice_ramses.cpp @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_ramses.h" /* QT */ #include @@ -53,53 +53,7 @@ #include #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -// _IO and friends are only defined in kernel headers ... - -#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) - -#define OD_IO(type,number) OD_IOC(0,type,number,0) -#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) -#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) -#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) - -using namespace Opie; - -class Ramses : public ODevice, public QWSServer::KeyboardFilter -{ - protected: - virtual void init(); - - public: - virtual bool setSoftSuspend( bool soft ); - virtual bool suspend(); - - virtual bool setDisplayStatus( bool on ); - virtual bool setDisplayBrightness( int b ); - virtual int displayBrightnessResolution() const; - virtual bool setDisplayContrast( int b ); - virtual int displayContrastResolution() const; - - protected: - virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); - virtual void timerEvent ( QTimerEvent *te ); - - int m_power_timer; -}; - -struct r_button { - uint model; - Qt::Key code; - char *utext; - char *pix; - char *fpressedservice; - char *fpressedaction; - char *fheldservice; - char *fheldaction; -} ramses_buttons [] = { +struct r_button ramses_buttons [] = { { Model_Ramses_MNCI, Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/z_menu", diff --git a/libopie2/opiecore/device/odevice_ramses.h b/libopie2/opiecore/device/odevice_ramses.h new file mode 100644 index 0000000..1b660ab --- a/dev/null +++ b/libopie2/opiecore/device/odevice_ramses.h @@ -0,0 +1,72 @@ +/* +                 This file is part of the Opie Project +              Copyright (C) The Opie Team + =. + .=l. +           .>+-= + _;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software + - .   .-<_>     .<> Foundation; either version 2 of the License, +     ._= =}       : or (at your option) any later version. +    .%`+i>       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. + :     =  ...= . :.=- + -.   .:....=;==+<; You should have received a copy of the GNU +  -_. . .   )=.  = Library General Public License along with +    --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef ODEVICE_RAMSES +#define ODEVICE_RAMSES + +#include +/* QT */ +#include + +using namespace Opie; + +class Ramses : public ODevice, public QWSServer::KeyboardFilter +{ + protected: + virtual void init(); + + public: + virtual bool setSoftSuspend( bool soft ); + virtual bool suspend(); + + virtual bool setDisplayStatus( bool on ); + virtual bool setDisplayBrightness( int b ); + virtual int displayBrightnessResolution() const; + virtual bool setDisplayContrast( int b ); + virtual int displayContrastResolution() const; + + protected: + virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); + virtual void timerEvent ( QTimerEvent *te ); + + int m_power_timer; +}; + +struct r_button { + uint model; + Qt::Key code; + char *utext; + char *pix; + char *fpressedservice; + char *fpressedaction; + char *fheldservice; + char *fheldaction; +}; + +#endif diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index 82dce10..a2cd419 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_simpad.h" /* QT */ #include @@ -53,61 +53,9 @@ #include #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -// _IO and friends are only defined in kernel headers ... - -#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) - -#define OD_IO(type,number) OD_IOC(0,type,number,0) -#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) -#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) -#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) - using namespace Opie; -class SIMpad : public ODevice, public QWSServer::KeyboardFilter -{ - protected: - virtual void init(); - virtual void initButtons(); - - public: - virtual bool setSoftSuspend( bool soft ); - virtual bool suspend(); - - virtual bool setDisplayStatus( bool on ); - virtual bool setDisplayBrightness( int b ); - virtual int displayBrightnessResolution() const; - - virtual void alarmSound(); - - virtual QValueList ledList() const; - virtual QValueList ledStateList( OLed led ) const; - virtual OLedState ledState( OLed led ) const; - virtual bool setLedState( OLed led, OLedState st ); - - 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 [1]; -}; - -struct s_button { - uint model; - Qt::Key code; - char *utext; - char *pix; - char *fpressedservice; - char *fpressedaction; - char *fheldservice; - char *fheldaction; -} simpad_buttons [] = { +struct s_button simpad_buttons [] = { { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), "devicebuttons/simpad_lower_up", diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h new file mode 100644 index 0000000..615effc --- a/dev/null +++ b/libopie2/opiecore/device/odevice_simpad.h @@ -0,0 +1,81 @@ +/* +                 This file is part of the Opie Project +              Copyright (C) The Opie Team + =. + .=l. +           .>+-= + _;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software + - .   .-<_>     .<> Foundation; either version 2 of the License, +     ._= =}       : or (at your option) any later version. +    .%`+i>       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. + :     =  ...= . :.=- + -.   .:....=;==+<; You should have received a copy of the GNU +  -_. . .   )=.  = Library General Public License along with +    --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef ODEVICE_SIMPAD +#define ODEVICE_SIMPAD + +#include + +/* QT */ +#include + +using namespace Opie; + +class SIMpad : public ODevice, public QWSServer::KeyboardFilter +{ + protected: + virtual void init(); + virtual void initButtons(); + + public: + virtual bool setSoftSuspend( bool soft ); + virtual bool suspend(); + + virtual bool setDisplayStatus( bool on ); + virtual bool setDisplayBrightness( int b ); + virtual int displayBrightnessResolution() const; + + virtual void alarmSound(); + + virtual QValueList ledList() const; + virtual QValueList ledStateList( OLed led ) const; + virtual OLedState ledState( OLed led ) const; + virtual bool setLedState( OLed led, OLedState st ); + + 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 [1]; +}; + +struct s_button { + uint model; + Qt::Key code; + char *utext; + char *pix; + char *fpressedservice; + char *fpressedaction; + char *fheldservice; + char *fheldaction; +}; + +#endif diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp index 9d0cdeb..a76f90b 100644 --- a/libopie2/opiecore/device/odevice_yopy.cpp +++ b/libopie2/opiecore/device/odevice_yopy.cpp @@ -1,33 +1,33 @@ /* -                 This file is part of the Opie Project -              Copyright (C) The Opie Team - =. - .=l. -           .>+-= - _;:,     .>    :=|. This program is free software; you can +                This file is part of the Opie Project +             Copyright (C) The Opie Team + =. + .=l. +          .>+-= +_;:,     .>    :=|. This program is free software; you can .> <`_,   >  .   <= redistribute it and/or modify it under :`=1 )Y*s>-.--   : the terms of the GNU Library General Public .="- .-=="i,     .._ License as published by the Free Software - - .   .-<_>     .<> Foundation; either version 2 of the License, -     ._= =}       : or (at your option) any later version. -    .%`+i>       _;_. -    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +- .   .-<_>     .<> Foundation; either version 2 of the License, +    ._= =}       : or (at your option) any later version. +   .%`+i>       _;_. +   .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU ..}^=.=       =       ; Library General Public License for more ++=   -.     .`     .: details. - :     =  ...= . :.=- - -.   .:....=;==+<; You should have received a copy of the GNU -  -_. . .   )=.  = Library General Public License along with -    --        :-=` this library; see the file COPYING.LIB. - If not, write to the Free Software Foundation, - Inc., 59 Temple Place - Suite 330, - Boston, MA 02111-1307, USA. +:     =  ...= . :.=- +-.   .:....=;==+<; You should have received a copy of the GNU + -_. . .   )=.  = Library General Public License along with +   --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_yopy.h" /* QT */ #include @@ -53,158 +53,109 @@ #include #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -// _IO and friends are only defined in kernel headers ... - -#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) - -#define OD_IO(type,number) OD_IOC(0,type,number,0) -#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) -#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) -#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) - using namespace Opie; -class Yopy : public ODevice -{ - protected: - - virtual void init(); - virtual void initButtons(); - - public: - virtual bool suspend(); - - virtual bool setDisplayBrightness ( int b ); - virtual int displayBrightnessResolution() const; - - static bool isYopy(); +struct yopy_button yopy_buttons [] = { + { Qt::Key_F10, QT_TRANSLATE_NOOP( "Button", "Action Button" ), + "devicebuttons/yopy_action", + "datebook", "nextView()", + "today", "raise()" }, + { Qt::Key_F11, QT_TRANSLATE_NOOP( "Button", "OK Button" ), + "devicebuttons/yopy_ok", + "addressbook", "raise()", + "addressbook", "beamBusinessCard()" }, + { Qt::Key_F12, QT_TRANSLATE_NOOP( "Button", "End Button" ), + "devicebuttons/yopy_end", + "QPE/Launcher", "home()", + "buttonsettings", "raise()" }, }; -struct yopy_button { - Qt::Key code; - char *utext; - char *pix; - char *fpressedservice; - char *fpressedaction; - char *fheldservice; - char *fheldaction; -} yopy_buttons [] = { -{ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), - "devicebuttons/yopy_action", - "datebook", "nextView()", - "today", "raise()" }, -{ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), - "devicebuttons/yopy_ok", - "addressbook", "raise()", - "addressbook", "beamBusinessCard()" }, -{ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), - "devicebuttons/yopy_end", - "QPE/Launcher", "home()", - "buttonsettings", "raise()" }, -}; - -bool Yopy::isYopy() +void Yopy::init() { -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 == "Yopy" ); - } - } + d->m_vendorstr = "G.Mate"; + d->m_vendor = Vendor_GMate; + d->m_modelstr = "Yopy3700"; + d->m_model = Model_Yopy_3700; + d->m_rotation = Rot0; + + d->m_systemstr = "Linupy"; + d->m_system = System_Linupy; + + QFile f ( "/etc/issue" ); + if ( f. open ( IO_ReadOnly ) ) + { + QTextStream ts ( &f ); + ts.readLine(); + d->m_sysverstr = ts. readLine(); + f. close(); } } -return false; -} -void Yopy::init() -{ -d->m_vendorstr = "G.Mate"; -d->m_vendor = Vendor_GMate; -d->m_modelstr = "Yopy3700"; -d->m_model = Model_Yopy_3700; -d->m_rotation = Rot0; - -d->m_systemstr = "Linupy"; -d->m_system = System_Linupy; - -QFile f ( "/etc/issue" ); -if ( f. open ( IO_ReadOnly )) { - QTextStream ts ( &f ); - ts.readLine(); - d->m_sysverstr = ts. readLine(); - f. close(); -} -} void Yopy::initButtons() { -if ( d->m_buttons ) - return; + if ( d->m_buttons ) + return ; -d->m_buttons = new QValueList ; + d->m_buttons = new QValueList ; -for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { + for ( uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof( yopy_button ) ); i++ ) + { - yopy_button *ib = yopy_buttons + i; + yopy_button *ib = yopy_buttons + i; - ODeviceButton b; + ODeviceButton b; - 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)); + 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(); + 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 & ))); + QCopChannel *sysch = new QCopChannel( "QPE/System", this ); + connect( sysch, SIGNAL( received( const QCString &, const QByteArray & ) ), + this, SLOT( systemMessage( const QCString &, const QByteArray & ) ) ); } + bool Yopy::suspend() { -/* Opie for Yopy does not implement its own power management at the - moment. The public version runs parallel to X, and relies on the - existing power management features. */ -return false; + /* Opie for Yopy does not implement its own power management at the + moment. The public version runs parallel to X, and relies on the + existing power management features. */ + return false; } -bool Yopy::setDisplayBrightness(int bright) + +bool Yopy::setDisplayBrightness( int bright ) { -/* The code here works, but is disabled as the current version runs - parallel to X, and relies on the existing backlight demon. */ + /* The code here works, but is disabled as the current version runs + parallel to X, and relies on the existing backlight demon. */ #if 0 -if ( QFile::exists("/proc/sys/pm/light") ) { - int fd = ::open("/proc/sys/pm/light", O_WRONLY); - if (fd >= 0 ) { - if (bright) - ::write(fd, "1\n", 2); - else - ::write(fd, "0\n", 2); - ::close(fd); - return true; + if ( QFile::exists( "/proc/sys/pm/light" ) ) + { + int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); + if ( fd >= 0 ) + { + if ( bright ) + ::write( fd, "1\n", 2 ); + else + ::write( fd, "0\n", 2 ); + ::close( fd ); + return true; + } } -} #endif -return false; + return false; } + int Yopy::displayBrightnessResolution() const { return 2; diff --git a/libopie2/opiecore/device/odevice_yopy.h b/libopie2/opiecore/device/odevice_yopy.h new file mode 100644 index 0000000..be8f62c --- a/dev/null +++ b/libopie2/opiecore/device/odevice_yopy.h @@ -0,0 +1,62 @@ +/* +                This file is part of the Opie Project +             Copyright (C) The Opie Team + =. + .=l. +          .>+-= +_;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software +- .   .-<_>     .<> Foundation; either version 2 of the License, +    ._= =}       : or (at your option) any later version. +   .%`+i>       _;_. +   .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. +:     =  ...= . :.=- +-.   .:....=;==+<; You should have received a copy of the GNU + -_. . .   )=.  = Library General Public License along with +   --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef ODEVICE_YOPY +#define ODEVICE_YOPY + +#include + +using namespace Opie; + +class Yopy : public ODevice +{ + protected: + + virtual void init(); + virtual void initButtons(); + + public: + virtual bool suspend(); + + virtual bool setDisplayBrightness ( int b ); + virtual int displayBrightnessResolution() const; +}; + +struct yopy_button +{ + Qt::Key code; + char *utext; + char *pix; + char *fpressedservice; + char *fpressedaction; + char *fheldservice; + char *fheldaction; +}; + +#endif diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index a6e8b82..78bc62e 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp @@ -27,7 +27,7 @@ Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_zaurus.h" /* QT */ #include @@ -53,68 +53,9 @@ #include #endif -#ifndef ARRAY_SIZE -#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) -#endif - -// _IO and friends are only defined in kernel headers ... - -#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) - -#define OD_IO(type,number) OD_IOC(0,type,number,0) -#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) -#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) -#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) - using namespace Opie; -class Zaurus : public ODevice -{ - - protected: - virtual void init(); - virtual void initButtons(); - - public: - virtual bool setSoftSuspend ( bool soft ); - - virtual bool setDisplayBrightness ( int b ); - virtual int displayBrightnessResolution() const; - - virtual void alarmSound(); - virtual void keySound(); - virtual void touchSound(); - - virtual QValueList ledList() const; - virtual QValueList ledStateList ( OLed led ) const; - virtual OLedState ledState( OLed led ) const; - virtual bool setLedState( OLed led, OLedState st ); - - virtual bool hasHingeSensor() const; - virtual OHingeStatus readHingeSensor(); - - static bool isZaurus(); - - virtual bool suspend(); - virtual Transformation rotation() const; - virtual ODirection direction() const; - - protected: - virtual void buzzer ( int snd ); - - OLedState m_leds [1]; - bool m_embedix; -}; - -struct z_button { - Qt::Key code; - char *utext; - char *pix; - char *fpressedservice; - char *fpressedaction; - char *fheldservice; - char *fheldaction; -} z_buttons [] = { +struct z_button z_buttons [] = { { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), "devicebuttons/z_calendar", "datebook", "nextView()", @@ -160,7 +101,6 @@ struct z_button z_buttons_c700 [] = { "QPE/Dummy", "doNothing()" }, }; -// Check whether this device is the sharp zaurus.. // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus // class up into individual classes. We need three classes // @@ -174,45 +114,6 @@ struct z_button z_buttons_c700 [] = { // // Comments? - mickeyl. -bool Zaurus::isZaurus() -{ - - // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! - if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ - return true; - } - - // On non-embedix kernels, we have to look closer. - bool is_zaurus = false; - QFile f ( "/proc/cpuinfo" ); - if ( f. open ( IO_ReadOnly ) ) { - QString model; - QFile f ( "/proc/cpuinfo" ); - - QTextStream ts ( &f ); - 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( ); - - if ( model == "Sharp-Collie" - || model == "Collie" - || model == "SHARP Corgi" - || model == "SHARP Shepherd" - || model == "SHARP Poodle" - || model == "SHARP Husky" - ) - is_zaurus = true; - - } - return is_zaurus; -} - - void Zaurus::init() { d->m_vendorstr = "Sharp"; diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h new file mode 100644 index 0000000..c07fe07 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_zaurus.h @@ -0,0 +1,96 @@ +/* +                 This file is part of the Opie Project +              Copyright (C) The Opie Team + =. + .=l. +           .>+-= + _;:,     .>    :=|. This program is free software; you can +.> <`_,   >  .   <= redistribute it and/or modify it under +:`=1 )Y*s>-.--   : the terms of the GNU Library General Public +.="- .-=="i,     .._ License as published by the Free Software + - .   .-<_>     .<> Foundation; either version 2 of the License, +     ._= =}       : or (at your option) any later version. +    .%`+i>       _;_. +    .i_,=:_.      -`: PARTICULAR PURPOSE. See the GNU +..}^=.=       =       ; Library General Public License for more +++=   -.     .`     .: details. + :     =  ...= . :.=- + -.   .:....=;==+<; You should have received a copy of the GNU +  -_. . .   )=.  = Library General Public License along with +    --        :-=` this library; see the file COPYING.LIB. + If not, write to the Free Software Foundation, + Inc., 59 Temple Place - Suite 330, + Boston, MA 02111-1307, USA. +*/ + +#ifndef ODEVICE_ZAURUS +#define ODEVICE_ZAURUS + +#include + +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) +#endif + +// _IO and friends are only defined in kernel headers ... + +#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) + +#define OD_IO(type,number) OD_IOC(0,type,number,0) +#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) +#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) +#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) + +using namespace Opie; + +class Zaurus : public ODevice +{ + + protected: + virtual void init(); + virtual void initButtons(); + + public: + virtual bool setSoftSuspend ( bool soft ); + + virtual bool setDisplayBrightness ( int b ); + virtual int displayBrightnessResolution() const; + + virtual void alarmSound(); + virtual void keySound(); + virtual void touchSound(); + + virtual QValueList ledList() const; + virtual QValueList ledStateList ( OLed led ) const; + virtual OLedState ledState( OLed led ) const; + virtual bool setLedState( OLed led, OLedState st ); + + virtual bool hasHingeSensor() const; + virtual OHingeStatus readHingeSensor(); + + virtual bool suspend(); + virtual Transformation rotation() const; + virtual ODirection direction() const; + + protected: + virtual void buzzer ( int snd ); + + OLedState m_leds [1]; + bool m_embedix; +}; + +struct z_button { + Qt::Key code; + char *utext; + char *pix; + char *fpressedservice; + char *fpressedaction; + char *fheldservice; + char *fheldaction; +}; + +#endif diff --git a/libopie2/opiecore/opiecore.pro b/libopie2/opiecore/opiecore.pro index 97e8146..98d315f 100644 --- a/libopie2/opiecore/opiecore.pro +++ b/libopie2/opiecore/opiecore.pro @@ -6,6 +6,12 @@ HEADERS = oapplication.h \ odebug.h \ odevice.h \ odevicebutton.h \ + odevice_ipaq.h \ + odevice_jornada.h \ + odevice_ramses.h \ + odevice_simpad.h \ + odevice_zaurus.h \ + odevice_yopy.h \ oglobal.h \ oglobalsettings.h \ oprocess.h \ -- cgit v0.9.0.2