author | mickeyl <mickeyl> | 2004-01-13 18:32:19 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2004-01-13 18:32:19 (UTC) |
commit | 061ccf5b9d384b1f24d203e96f1f04ccf1dcf133 (patch) (side-by-side diff) | |
tree | ec1fc064f001edba92e58116cdc35fc909b5cdd6 | |
parent | 59f7fa0a480bf921a67ad42fc1fe018b1be44192 (diff) | |
download | opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.zip opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.tar.gz opie-061ccf5b9d384b1f24d203e96f1f04ccf1dcf133.tar.bz2 |
- 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.
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 71 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 55 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.h | 84 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.cpp | 76 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_jornada.h | 50 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.cpp | 50 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.h | 72 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 56 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 81 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.cpp | 107 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.h | 62 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 103 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 96 | ||||
-rw-r--r-- | libopie2/opiecore/opiecore.pro | 6 |
15 files changed, 532 insertions, 441 deletions
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 @@ -28,5 +28,10 @@ */ -#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 */ @@ -54,50 +59,44 @@ #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 + // rewrite this to only use /proc/cpuinfo 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(); + 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 @@ -31,5 +31,7 @@ #define ODEVICE_H_ +/* OPIE */ #include <opie2/odevicebutton.h> +#include <qpe/qpeapplication.h> /* for Transformation enum.. */ /* QT */ @@ -39,6 +41,4 @@ #include <qstrlist.h> -#include <qpe/qpeapplication.h> /* for Transformation enum.. */ - namespace Opie { 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 @@ -28,5 +28,5 @@ */ -#include "odevice.h" +#include "odevice_ipaq.h" /* QT */ @@ -54,10 +54,5 @@ #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 )) @@ -83,49 +78,5 @@ typedef struct { #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 <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; - - 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"), 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 <opie-devel@handhelds.org> + =. + .=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_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: 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 <qwindowsystem_qws.h> + +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 <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; + + 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 @@ -28,5 +28,5 @@ */ -#include "odevice.h" +#include "odevice_jornada.h" /* QT */ @@ -54,10 +54,5 @@ #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 )) @@ -85,37 +80,4 @@ 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() { @@ -139,39 +101,11 @@ void Jornada::init() } -#if 0 -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 & ))); -} -#endif int Jornada::displayBrightnessResolution() const { + return 0; } + bool Jornada::setDisplayBrightness( int bright ) { @@ -195,4 +129,5 @@ bool Jornada::setDisplayBrightness( int bright ) } + bool Jornada::setSoftSuspend( bool soft ) { @@ -213,2 +148,3 @@ 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 <opie-devel@handhelds.org> + =. + .=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_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: 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 <opie2/odevice.h> + +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 @@ -28,5 +28,5 @@ */ -#include "odevice.h" +#include "odevice_ramses.h" /* QT */ @@ -54,51 +54,5 @@ #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"), 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 <opie-devel@handhelds.org> + =. + .=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_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: 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 <opie2/odevice.h> +/* QT */ +#include <qwindowsystem_qws.h> + +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 @@ -28,5 +28,5 @@ */ -#include "odevice.h" +#include "odevice_simpad.h" /* QT */ @@ -54,59 +54,7 @@ #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 <OLed> ledList() const; - virtual QValueList <OLedState> 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"), 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 <opie-devel@handhelds.org> + =. + .=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_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: 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 <opie2/odevice.h> + +/* QT */ +#include <qwindowsystem_qws.h> + +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 <OLed> ledList() const; + virtual QValueList <OLedState> 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,26 +1,26 @@ /* This file is part of the Opie Project - Copyright (C) The Opie Team <opie-devel@handhelds.org> + Copyright (C) The Opie Team <opie-devel@handhelds.org> =. .=l. - .>+-= - _;:, .> :=|. This program is free software; you can + .>+-= +_;:, .> :=|. 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_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +- . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: 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. +: = ...= . :.=- +-. .:....=;==+<; 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, @@ -28,5 +28,5 @@ */ -#include "odevice.h" +#include "odevice_yopy.h" /* QT */ @@ -54,44 +54,7 @@ #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 { - Qt::Key code; - char *utext; - char *pix; - char *fpressedservice; - char *fpressedaction; - char *fheldservice; - char *fheldaction; -} yopy_buttons [] = { +struct yopy_button yopy_buttons [] = { { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), "devicebuttons/yopy_action", @@ -108,24 +71,4 @@ struct yopy_button { }; -bool Yopy::isYopy() -{ -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" ); - } - } - } -} -return false; -} - void Yopy::init() { @@ -140,5 +83,6 @@ d->m_system = System_Linupy; QFile f ( "/etc/issue" ); -if ( f. open ( IO_ReadOnly )) { + if ( f. open ( IO_ReadOnly ) ) + { QTextStream ts ( &f ); ts.readLine(); @@ -148,4 +92,5 @@ if ( f. open ( IO_ReadOnly )) { } + void Yopy::initButtons() { @@ -155,5 +100,6 @@ if ( d->m_buttons ) d->m_buttons = new QValueList <ODeviceButton>; -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; @@ -178,4 +124,5 @@ connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), } + bool Yopy::suspend() { @@ -186,4 +133,5 @@ return false; } + bool Yopy::setDisplayBrightness(int bright) { @@ -191,7 +139,9 @@ bool Yopy::setDisplayBrightness(int bright) parallel to X, and relies on the existing backlight demon. */ #if 0 -if ( QFile::exists("/proc/sys/pm/light") ) { + if ( QFile::exists( "/proc/sys/pm/light" ) ) + { int fd = ::open("/proc/sys/pm/light", O_WRONLY); - if (fd >= 0 ) { + if ( fd >= 0 ) + { if (bright) ::write(fd, "1\n", 2); @@ -206,4 +156,5 @@ return false; } + int Yopy::displayBrightnessResolution() const { 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 <opie-devel@handhelds.org> + =. + .=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_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: 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 <opie2/odevice.h> + +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 @@ -28,5 +28,5 @@ */ -#include "odevice.h" +#include "odevice_zaurus.h" /* QT */ @@ -54,66 +54,7 @@ #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 <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 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", @@ -161,5 +102,4 @@ struct z_button z_buttons_c700 [] = { }; -// 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 @@ -175,43 +115,4 @@ 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() { 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 <opie-devel@handhelds.org> + =. + .=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_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: 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 <opie2/odevice.h> + +#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 <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 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 @@ -7,4 +7,10 @@ HEADERS = oapplication.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 \ |