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 | 73 | ||||
-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 | 82 | ||||
-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 | 239 | ||||
-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, 602 insertions, 511 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 @@ -1,197 +1,196 @@ /* 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. */ -#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> /* 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 - - /* - 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; } 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"; d->m_system = System_Unknown; d->m_sysverstr = "0.0"; d->m_rotation = Rot0; d->m_direction = CW; d->m_holdtime = 1000; // 1000ms d->m_buttons = 0; d->m_cpu_frequencies = new QStrList; } void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) { if ( msg == "deviceButtonMappingChanged()" ) { reloadButtonMapping(); } } void ODevice::init() { } /** * This method initialises the button mapping */ void ODevice::initButtons() { if ( d->m_buttons ) return; qDebug ( "init Buttons" ); d->m_buttons = new QValueList <ODeviceButton>; reloadButtonMapping(); QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); } ODevice::~ODevice() { // we leak m_devicebuttons and m_cpu_frequency // but it's a singleton and it is not so importantant // -zecke delete d; } bool ODevice::setSoftSuspend ( bool /*soft*/ ) { return false; } //#include <linux/apm_bios.h> #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) /** * This method will try to suspend the device * It only works if the user is the QWS Server and the apm application * is installed. * It tries to suspend and then waits some time cause some distributions * do have asynchronus apm implementations. * This method will either fail and return false or it'll suspend the * device and return once the device got woken up * * @return if the device got suspended */ bool ODevice::suspend() { qDebug("ODevice::suspend"); if ( !isQWS( ) ) // only qwsserver is allowed to suspend return false; if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices return false; bool res = false; struct timeval tvs, tvn; ::gettimeofday ( &tvs, 0 ); ::sync(); // flush fs caches res = ( ::system ( "apm --suspend" ) == 0 ); // This is needed because the iPAQ apm implementation is asynchronous and we 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 @@ -1,138 +1,138 @@ /* 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_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 ), Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000011 ), Model_Jornada = ( 6 << 24 ), Model_Jornada_56x = ( Model_Jornada | 0x000001 ), Model_Zaurus = ( 2 << 24 ), Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), Model_SIMpad = ( 3 << 24 ), Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), Model_Ramses = ( 4 << 24 ), Model_Ramses_All = ( Model_Ramses | 0xffffff ), Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), Model_Yopy = ( 5 << 24 ), Model_Yopy_All = ( Model_Yopy | 0xffffff ), Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), Model_Yopy_3500 = ( Model_Yopy | 0x000002 ), Model_Yopy_3700 = ( Model_Yopy | 0x000003 ), }; /** * The vendor of the device */ enum OVendor { Vendor_Unknown, Vendor_HP, Vendor_Sharp, Vendor_SIEMENS, Vendor_MundN, Vendor_GMate, }; /** * The System used */ enum OSystem { System_Unknown, System_Familiar, System_Zaurus, System_OpenZaurus, System_Linupy, }; enum OLedState { Led_Off, Led_On, Led_BlinkSlow, Led_BlinkFast }; enum OLed { Led_Mail, Led_Power, Led_BlueTooth }; enum OHardKey { HardKey_Datebook = Qt::Key_F9, HardKey_Contacts = Qt::Key_F10, HardKey_Menu = Qt::Key_F11, 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 @@ -1,225 +1,176 @@ /* 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. */ -#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> /* 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"), "devicebuttons/ipaq_menu", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), "devicebuttons/ipaq_mail", "mail", "raise()", "mail", "newMail()" }, { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), "devicebuttons/ipaq_home", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), "devicebuttons/ipaq_record", "QPE/VMemo", "toggleRecord()", "sound", "raise()" }, }; void iPAQ::init() { d->m_vendorstr = "HP"; d->m_vendor = Vendor_HP; QFile f ( "/proc/hal/model" ); if ( f. open ( IO_ReadOnly )) { QTextStream ts ( &f ); d->m_modelstr = "H" + ts. readLine(); if ( d->m_modelstr == "H3100" ) d->m_model = Model_iPAQ_H31xx; else if ( d->m_modelstr == "H3600" ) d->m_model = Model_iPAQ_H36xx; else if ( d->m_modelstr == "H3700" ) d->m_model = Model_iPAQ_H37xx; else if ( d->m_modelstr == "H3800" ) d->m_model = Model_iPAQ_H38xx; else if ( d->m_modelstr == "H3900" ) d->m_model = Model_iPAQ_H39xx; else if ( d->m_modelstr == "H5400" ) d->m_model = Model_iPAQ_H5xxx; else d->m_model = Model_Unknown; f. close(); } switch ( d->m_model ) { case Model_iPAQ_H31xx: case Model_iPAQ_H38xx: d->m_rotation = Rot90; break; case Model_iPAQ_H36xx: case Model_iPAQ_H37xx: case Model_iPAQ_H39xx: default: d->m_rotation = Rot270; break; case Model_iPAQ_H5xxx: d->m_rotation = Rot0; } f. setName ( "/etc/familiar-version" ); if ( f. open ( IO_ReadOnly )) { d->m_systemstr = "Familiar"; d->m_system = System_Familiar; QTextStream ts ( &f ); d->m_sysverstr = ts. readLine(). mid ( 10 ); f. close(); } else { f. setName ( "/etc/oz_version" ); if ( f. open ( IO_ReadOnly )) { d->m_systemstr = "OpenEmbedded/iPaq"; d->m_system = System_Familiar; QTextStream ts ( &f ); ts.setDevice ( &f ); 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 @@ -1,214 +1,150 @@ /* 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. */ -#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> /* 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 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 )) { + 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 <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 @@ -1,198 +1,152 @@ /* 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. */ -#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> /* 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()" }, }; void Ramses::init() { d->m_vendorstr = "M und N"; d->m_vendor = Vendor_MundN; QFile f("/proc/sys/board/ramses"); d->m_modelstr = "Ramses"; d->m_model = Model_Ramses_MNCI; d->m_rotation = Rot0; d->m_holdtime = 1000; f.setName("/etc/oz_version"); if (f.open(IO_ReadOnly)) { d->m_systemstr = "OpenEmbedded/Ramses"; d->m_system = System_OpenZaurus; QTextStream ts(&f); ts.setDevice(&f); d->m_sysverstr = ts.readLine(); f.close(); } m_power_timer = 0; #ifdef QT_QWS_ALLOW_OVERCLOCK #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** #define OC(x...) x #else #define OC(x...) #endif // This table is true for a Intel XScale PXA 255 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus } bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) { Q_UNUSED( keycode ); Q_UNUSED( modifiers ); Q_UNUSED( isPress ); Q_UNUSED( autoRepeat ); return false; } void Ramses::timerEvent(QTimerEvent *) { killTimer(m_power_timer); m_power_timer = 0; QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); } bool Ramses::setSoftSuspend(bool soft) { qDebug("Ramses::setSoftSuspend(%d)", soft); #if 0 bool res = false; int fd; if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources if (sources >= 0) { if (soft) sources &= ~APM_EVT_POWER_BUTTON; else sources |= APM_EVT_POWER_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 @@ -1,206 +1,154 @@ /* 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. */ -#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> /* 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"), "devicebuttons/simpad_lower_right", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), "devicebuttons/simpad_lower_left", "mail", "raise()", "mail", "newMail()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), "devicebuttons/simpad_upper_up", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), "devicebuttons/simpad_upper_down", "addressbook", "raise()", "addressbook", "beamBusinessCard()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), "devicebuttons/simpad_upper_right", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), "devicebuttons/simpad_upper_left", "QPE/Rotation", "flip()", "QPE/Rotation", "flip()" }, /* { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), "devicebuttons/simpad_lower_upper", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), "devicebuttons/simpad_upper_lower", "QPE/Launcher", "home()", "buttonsettings", "raise()" }, */ }; void SIMpad::init() { d->m_vendorstr = "SIEMENS"; d->m_vendor = Vendor_SIEMENS; QFile f ( "/proc/hal/model" ); //TODO Implement model checking //FIXME For now we assume an SL4 d->m_modelstr = "SL4"; d->m_model = Model_SIMpad_SL4; switch ( d->m_model ) { default: d->m_rotation = Rot0; d->m_direction = CCW; d->m_holdtime = 1000; // 1000ms break; } f. setName ( "/etc/familiar-version" ); if ( f. open ( IO_ReadOnly )) { d->m_systemstr = "Familiar"; d->m_system = System_Familiar; QTextStream ts ( &f ); d->m_sysverstr = ts. readLine(). mid ( 10 ); f. close(); } else { f. setName ( "/etc/oz_version" ); if ( f. open ( IO_ReadOnly )) { d->m_systemstr = "OpenEmbedded/SIMpad"; d->m_system = System_OpenZaurus; QTextStream ts ( &f ); ts.setDevice ( &f ); d->m_sysverstr = ts. readLine(); 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,212 +1,163 @@ /* - 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 + 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 +- . .-<_> .<> 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. +: = ...= . :.=- +-. .:....=;==+<; 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> /* 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 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 <ODeviceButton>; + 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; + 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 <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 @@ -1,311 +1,212 @@ /* 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. */ -#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> /* 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()" }, { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/z_menu", "QPE/TaskBar", "toggleMenu()", "QPE/TaskBar", "toggleStartMenu()" }, { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), "devicebuttons/z_mail", "mail", "raise()", "mail", "newMail()" }, }; struct z_button z_buttons_c700 [] = { { 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()" }, { 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 // because it uses a jffs2 filesystem.. // (eilers) // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read(). find ( "\tjffs2\n" ) >= 0 )) { QFile f ("/etc/oz_version"); if ( f.exists() ){ d->m_vendorstr = "OpenZaurus Team"; d->m_systemstr = "OpenZaurus"; d->m_system = System_OpenZaurus; if ( f. open ( IO_ReadOnly )) { QTextStream ts ( &f ); d->m_sysverstr = ts. readLine();//. mid ( 10 ); f. close(); } // Openzaurus sometimes uses the embedix kernel! // => Check whether this is an embedix kernel FILE *uname = popen("uname -r", "r"); QString line; if ( f.open(IO_ReadOnly, uname) ) { QTextStream ts ( &f ); line = ts. readLine(); int loc = line. find ( "embedix" ); if ( loc != -1 ) m_embedix = true; else m_embedix = false; f. close(); } pclose(uname); } else { d->m_systemstr = "Zaurus"; d->m_system = System_Zaurus; } f. setName ( "/proc/cpuinfo" ); if ( f. open ( IO_ReadOnly ) ) { 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 Corgi" ) { d->m_model = Model_Zaurus_SLC7x0; d->m_modelstr = "Zaurus SL-C700"; } else if ( model == "SHARP Shepherd" ) { d->m_model = Model_Zaurus_SLC7x0; d->m_modelstr = "Zaurus SL-C750"; } else if ( model == "SHARP Husky" ) { d->m_model = Model_Zaurus_SLC7x0; d->m_modelstr = "Zaurus SL-C760"; } else if ( model == "SHARP Poodle" ) { d->m_model = Model_Zaurus_SLB600; d->m_modelstr = "Zaurus SL-B500 or SL-5600"; } else if ( model == "Sharp-Collie" || model == "Collie" ) { d->m_model = Model_Zaurus_SL5500; d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; } else { d->m_model = Model_Zaurus_SL5500; d->m_modelstr = "Zaurus (Model unknown)"; } bool flipstate = false; switch ( d->m_model ) { case Model_Zaurus_SLA300: d->m_rotation = Rot0; break; case Model_Zaurus_SLC7x0: d->m_rotation = rotation(); d->m_direction = direction(); break; case Model_Zaurus_SLB600: case Model_Zaurus_SL5500: case Model_Zaurus_SL5000: default: d->m_rotation = Rot270; break; 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,49 +1,55 @@ 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 \ odevice_jornada.cpp \ odevice_ramses.cpp \ odevice_simpad.cpp \ odevice_zaurus.cpp \ odevice_yopy.cpp \ oglobal.cpp \ oglobalsettings.cpp \ oprocess.cpp \ oprocctrl.cpp \ ostorageinfo.cpp INTERFACES = TARGET = opiecore2 VERSION = 1.8.3 INCLUDEPATH += $(OPIEDIR)/include DEPENDPATH += $(OPIEDIR)/include MOC_DIR = moc OBJECTS_DIR = obj !contains( platform, x11 ) { LIBS = -lqpe include ( $(OPIEDIR)/include.pro ) } contains( platform, x11 ) { LIBS = -L$(OPIEDIR)/lib -Wl,-rpath,$(OPIEDIR)/lib } |