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 @@ -18,25 +18,30 @@ _.=:. : :=>`: 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. */ -#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 <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -44,70 +49,64 @@ /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #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; } ODevice::ODevice() { d = new ODeviceData; d->m_modelstr = "Unknown"; d->m_model = Model_Unknown; d->m_vendorstr = "Unknown"; d->m_vendor = Vendor_Unknown; d->m_systemstr = "Unknown"; 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 @@ -21,34 +21,34 @@ : = ...= . :.=- -. .:....=;==+<; 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_H_ #define ODEVICE_H_ +/* OPIE */ #include <opie2/odevicebutton.h> +#include <qpe/qpeapplication.h> /* for Transformation enum.. */ /* QT */ #include <qnamespace.h> #include <qobject.h> #include <qstring.h> #include <qstrlist.h> -#include <qpe/qpeapplication.h> /* for Transformation enum.. */ - namespace Opie { class ODeviceData; /** * The available devices */ enum OModel { Model_Unknown, // = 0 Model_Series_Mask = 0xff000000, Model_iPAQ = ( 1 << 24 ), 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 @@ -18,25 +18,25 @@ _.=:. : :=>`: 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. */ -#include "odevice.h" +#include "odevice_ipaq.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -44,98 +44,49 @@ /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #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) #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)) typedef struct { unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ unsigned char TotalTime; /* Units of 5 seconds */ unsigned char OnTime; /* units of 100m/s */ unsigned char OffTime; /* units of 100m/s */ } LED_IN; typedef struct { unsigned char mode; unsigned char pwr; unsigned char brightness; } FLITE_IN; #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 <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"), "devicebuttons/ipaq_calendar", "datebook", "nextView()", "today", "raise()" }, { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), "devicebuttons/ipaq_contact", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu 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 @@ -18,25 +18,25 @@ _.=:. : :=>`: 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. */ -#include "odevice.h" +#include "odevice_jornada.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -44,30 +44,25 @@ /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #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) #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)) typedef struct { unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ unsigned char TotalTime; /* Units of 5 seconds */ unsigned char OnTime; /* units of 100m/s */ unsigned char OffTime; /* units of 100m/s */ @@ -75,140 +70,81 @@ typedef struct { typedef struct { unsigned char mode; unsigned char pwr; unsigned char brightness; } FLITE_IN; #define LED_ON OD_IOW( 'f', 5, LED_IN ) #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 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"; 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; QFile f ( "/etc/familiar-version" ); f. setName ( "/etc/familiar-version" ); if ( f. open ( IO_ReadOnly )) { QTextStream ts ( &f ); 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 <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 ) { 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/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 @@ -18,25 +18,25 @@ _.=:. : :=>`: 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. */ -#include "odevice.h" +#include "odevice_ramses.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -44,71 +44,25 @@ /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #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", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Model_Ramses_MNCI, Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), "devicebuttons/ipaq_home", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, }; 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 @@ -18,25 +18,25 @@ _.=:. : :=>`: 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. */ -#include "odevice.h" +#include "odevice_simpad.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -44,79 +44,27 @@ /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #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"), "devicebuttons/simpad_lower_up", "datebook", "nextView()", "today", "raise()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), "devicebuttons/simpad_lower_down", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 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,42 +1,42 @@ /* 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, Boston, MA 02111-1307, USA. */ -#include "odevice.h" +#include "odevice_yopy.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -44,169 +44,120 @@ /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #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", "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() -{ -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() { 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 )) { + 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; 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; 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)); 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 & ))); } + 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; } + 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. */ #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); else ::write(fd, "0\n", 2); ::close(fd); return true; } } #endif 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 <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 @@ -18,25 +18,25 @@ _.=:. : :=>`: 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. */ -#include "odevice.h" +#include "odevice_zaurus.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> @@ -44,86 +44,27 @@ /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> #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", "datebook", "nextView()", "today", "raise()" }, { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), "devicebuttons/z_contact", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), "devicebuttons/z_home", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, @@ -151,77 +92,37 @@ struct z_button z_buttons_c700 [] = { "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/z_menu", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Qt::Key_F14, QT_TRANSLATE_NOOP("Button", "Display Rotate"), "devicebuttons/z_hinge", "QPE/Rotation", "rotateDefault()", "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 // // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) // // Only question right now is: Do we really need to do it? Because as soon // as the OpenZaurus kernel is ready, there will be a unified interface for all // Zaurus models (concerning apm, backlight, buttons, etc.) // // 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"; d->m_vendor = Vendor_Sharp; m_embedix = true; // Not openzaurus means: It has an embedix kernel ! // QFile f ( "/proc/filesystems" ); QString model; // It isn't a good idea to check the system configuration to // detect the distribution ! // Otherwise it may happen that any other distribution is detected as openzaurus, just 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 @@ -1,20 +1,26 @@ TEMPLATE = lib CONFIG += qt warn_on debug DESTDIR = $(OPIEDIR)/lib HEADERS = oapplication.h \ oconfig.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 \ oprocctrl.h \ ostorageinfo.h SOURCES = oapplication.cpp \ oconfig.cpp \ odebug.cpp \ odevice.cpp \ odevicebutton.cpp \ odevice_ipaq.cpp \ |