author | wimpie <wimpie> | 2005-01-04 01:29:55 (UTC) |
---|---|---|
committer | wimpie <wimpie> | 2005-01-04 01:29:55 (UTC) |
commit | 5199338e990284244b8fe540d3fb4a36b24bae82 (patch) (side-by-side diff) | |
tree | bbd17e6ab0998379a1a032851d27d78bd5db201f | |
parent | 1708efc66ceab63d93960a523e247bcbfafe6e7f (diff) | |
download | opie-5199338e990284244b8fe540d3fb4a36b24bae82.zip opie-5199338e990284244b8fe540d3fb4a36b24bae82.tar.gz opie-5199338e990284244b8fe540d3fb4a36b24bae82.tar.bz2 |
added odevice_genuine for pure INTEL based CPU
-> needed for system dependend applications. being LIKE
-> an IPAQ is not enough
-rw-r--r-- | libopie2/opiecore/device/device.pro | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 8 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 4 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_genuineintel.cpp | 193 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_genuineintel.h | 84 |
5 files changed, 291 insertions, 0 deletions
diff --git a/libopie2/opiecore/device/device.pro b/libopie2/opiecore/device/device.pro index 2c9e770..9a409e1 100644 --- a/libopie2/opiecore/device/device.pro +++ b/libopie2/opiecore/device/device.pro @@ -1,20 +1,22 @@ HEADERS += device/odevice.h \ device/odevicebutton.h \ device/odevice_beagle.h \ device/odevice_ipaq.h \ device/odevice_jornada.h \ device/odevice_ramses.h \ device/odevice_simpad.h \ device/odevice_zaurus.h \ + device/odevice_genuineintel.h \ device/odevice_yopy.h SOURCES += device/odevice.cpp \ device/odevicebutton.cpp \ device/odevice_beagle.cpp \ device/odevice_ipaq.cpp \ device/odevice_jornada.cpp\ device/odevice_ramses.cpp \ device/odevice_simpad.cpp \ device/odevice_zaurus.cpp \ + device/odevice_genuineintel.cpp \ device/odevice_yopy.cpp diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp index 39b37cd..a824392 100644 --- a/libopie2/opiecore/device/odevice.cpp +++ b/libopie2/opiecore/device/odevice.cpp @@ -1,860 +1,868 @@ /* 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_beagle.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" +#include "odevice_genuineintel.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> #include <qpe/sound.h> #include <opie2/okeyfilter.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 namespace Opie { namespace Core { static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; /* STATIC and common implementation */ /* EXPORT */ ODistribution distributions[] = { { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, { System_Unknown, "Linux", "/etc/issue" }, }; /* EXPORT */ bool isQWS(){ return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; } /* EXPORT */ QCString makeChannel ( const char *str ){ if ( str && !::strchr ( str, '/' )) return QCString ( "QPE/Application/" ) + str; else return str; } /* Now the default implementation of ODevice */ struct default_button default_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", "opiemail", "raise()", "opiemail", "newMail()" }, }; ODevice *ODevice::inst() { static ODevice *dev = 0; // rewrite this to only use /proc/cpuinfo or so QString cpu_info; 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 ); cpu_info = line; if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); else if ( line.contains( "Tradesquare.NL", false ) ) dev = new Internal::Beagle(); else qWarning( "ODevice() - unknown hardware - using default." ); break; + } else if ( line.startsWith( "vendor_id" ) ) { + qDebug( "ODevice() - found '%s'", (const char*) line ); + cpu_info = line; + if( line.contains( "genuineintel", false ) ) { + dev = new Internal::GenuineIntel(); + break; + } } } } else { qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); } if ( !dev ) dev = new ODevice(); dev->init(cpu_info); } 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; /* mixer */ d->m_sound = d->m_vol = d->m_mixer = -1; /* System QCopChannel created */ d->m_initializedButtonQcop = false; // New distribution detection code first checks for legacy distributions, // identified by /etc/familiar-version or /etc/oz_version. // Then check for OpenEmbedded and lastly, read /etc/issue for ( unsigned int i = 0; i < sizeof distributions; ++i ) { if ( QFile::exists( distributions[i].sysvfile ) ) { d->m_systemstr = distributions[i].sysstr; d->m_system = distributions[i].system; d->m_sysverstr = "<Unknown>"; QFile f( distributions[i].sysvfile ); if ( f.open( IO_ReadOnly ) ) { QTextStream ts( &f ); d->m_sysverstr = ts.readLine().replace( QRegExp( "\\\\." ), "" ); } break; } } } void ODevice::systemMessage( const QCString &msg, const QByteArray & ) { if ( msg == "deviceButtonMappingChanged()" ) { reloadButtonMapping(); } } void ODevice::init(const QString&) { } /** * This method initialises the button mapping */ void ODevice::initButtons() { if ( d->m_buttons ) return; qDebug ( "init Buttons" ); d->m_buttons = new QValueList <ODeviceButton>; for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { default_button *db = default_buttons + i; ODeviceButton b; b. setKeycode ( db->code ); b. setUserText ( QObject::tr ( "Button", db->utext )); b. setPixmap ( Resource::loadPixmap ( db->pix )); b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction )); d->m_buttons->append ( b ); } reloadButtonMapping(); } 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() { 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; ODevice::sendSuspendmsg(); 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 // can not be sure when exactly the device is really suspended // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. if ( res ) { do { // wait at most 1.5 sec: either suspend didn't work or the device resumed ::usleep ( 200 * 1000 ); ::gettimeofday ( &tvn, 0 ); } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); } return res; } //#include <linux/fb.h> better not rely on kernel headers in userspace ... #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 /* VESA Blanking Levels */ #define VESA_NO_BLANKING 0 #define VESA_VSYNC_SUSPEND 1 #define VESA_HSYNC_SUSPEND 2 #define VESA_POWERDOWN 3 /** * This sets the display on or off */ bool ODevice::setDisplayStatus ( bool on ) { qDebug("ODevice::setDisplayStatus(%d)", on); if ( d->m_model == Model_Unknown ) return false; bool res = false; int fd; #ifdef QT_QWS_DEVFS if (( fd = ::open ( "/dev/fb/0", O_RDWR )) >= 0 ) { #else if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { #endif res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); ::close ( fd ); } return res; } /** * This sets the display brightness * * @param b The brightness to be set on a scale from 0 to 255 * @return success or failure */ bool ODevice::setDisplayBrightness ( int b) { Q_UNUSED( b ) return false; } /** * * @return Returns the number of steppings on the brightness slider * in the Light-'n-Power settings. Values smaller zero and bigger * than 255 do not make sense. * * \sa QSlider::setLineStep * \sa QSlider::setPageStep */ int ODevice::displayBrightnessResolution() const { return 16; } /** * This sets the display contrast * @param p The contrast to be set on a scale from 0 to 255 * @return success or failure */ bool ODevice::setDisplayContrast ( int p) { Q_UNUSED( p ) return false; } /** * @return return the max value for the brightness settings slider * or 0 if the device doesn't support setting of a contrast */ int ODevice::displayContrastResolution() const { return 0; } /** * This returns the vendor as string * @return Vendor as QString */ QString ODevice::vendorString() const { return d->m_vendorstr; } /** * This returns the vendor as one of the values of OVendor * @return OVendor */ OVendor ODevice::vendor() const { return d->m_vendor; } /** * This returns the model as a string * @return A string representing the model */ QString ODevice::modelString() const { return d->m_modelstr; } /** * This does return the OModel used */ OModel ODevice::model() const { return d->m_model; } /** * This does return the systen name */ QString ODevice::systemString() const { return d->m_systemstr; } /** * Return System as OSystem value */ OSystem ODevice::system() const { return d->m_system; } /** * @return the version string of the base system */ QString ODevice::systemVersionString() const { return d->m_sysverstr; } /** * @return the current Transformation */ Transformation ODevice::rotation() const { return d->m_rotation; } /** * @return the current rotation direction */ ODirection ODevice::direction() const { return d->m_direction; } /** * This plays an alarm sound */ void ODevice::playAlarmSound() { #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); if ( snd. isFinished()) snd. play(); #endif } /** * This plays a key sound */ void ODevice::playKeySound() { #ifndef QT_NO_SOUND static Sound snd ( "keysound" ); if ( snd. isFinished()) snd. play(); #endif } /** * This plays a touch sound */ void ODevice::playTouchSound() { #ifndef QT_NO_SOUND static Sound snd ( "touchsound" ); if ( snd. isFinished()) snd. play(); #endif } /** * This method will return a list of leds * available on this device * @return a list of LEDs. */ QValueList <OLed> ODevice::ledList() const { return QValueList <OLed>(); } /** * This does return the state of the LEDs */ QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const { return QValueList <OLedState>(); } /** * @return the state for a given OLed */ OLedState ODevice::ledState ( OLed /*which*/ ) const { return Led_Off; } /** * Set the state for a LED * @param which Which OLed to use * @param st The state to set * @return success or failure */ bool ODevice::setLedState ( OLed which, OLedState st ) { Q_UNUSED( which ) Q_UNUSED( st ) return false; } /** * @return if the device has a light sensor */ bool ODevice::hasLightSensor() const { return false; } /** * @return a value from the light sensor */ int ODevice::readLightSensor() { return -1; } /** * @return the light sensor resolution */ int ODevice::lightSensorResolution() const { return 0; } /** * @return if the device has a hinge sensor */ bool ODevice::hasHingeSensor() const { return false; } /** * @return a value from the hinge sensor */ OHingeStatus ODevice::readHingeSensor() { return CASE_UNKNOWN; } /** * @return a list with CPU frequencies supported by the hardware */ const QStrList &ODevice::allowedCpuFrequencies() const { return *d->m_cpu_frequencies; } /** * Set desired CPU frequency * * @param index index into d->m_cpu_frequencies of the frequency to be set */ bool ODevice::setCurrentCpuFrequency(uint index) { if (index >= d->m_cpu_frequencies->count()) return false; char *freq = d->m_cpu_frequencies->at(index); qWarning("set freq to %s", freq); int fd; if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { char writeCommand[50]; const int count = sprintf(writeCommand, "%s\n", freq); int res = (::write(fd, writeCommand, count) != -1); ::close(fd); return res; } return false; } /** * @return a list of hardware buttons */ const QValueList <ODeviceButton> &ODevice::buttons() { initButtons(); return *d->m_buttons; } /** * @return The amount of time that would count as a hold */ uint ODevice::buttonHoldTime() const { return d->m_holdtime; } /** * This method return a ODeviceButton for a key code * or 0 if no special hardware button is available for the device * * @return The devicebutton or 0l * @see ODeviceButton */ const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) { initButtons(); for ( QValueListConstIterator<ODeviceButton> it = d->m_buttons->begin(); it != d->m_buttons->end(); ++it ) { if ( (*it). keycode() == code ) return &(*it); } return 0; } void ODevice::reloadButtonMapping() { if(!d->m_buttons) initButtons(); if(!d->m_initializedButtonQcop) { QCopChannel *chan = new QCopChannel("QPE/System", this, "ODevice button channel"); connect(chan,SIGNAL(received(const QCString&,const QByteArray&)), this,SLOT(systemMessage(const QCString&,const QByteArray&))); d->m_initializedButtonQcop = true; } Config cfg ( "ButtonSettings" ); for ( uint i = 0; i < d->m_buttons->count(); i++ ) { ODeviceButton &b = ( *d->m_buttons ) [i]; QString group = "Button" + QString::number ( i ); QCString pch, hch; QCString pm, hm; QByteArray pdata, hdata; if ( cfg. hasGroup ( group )) { cfg. setGroup ( group ); pch = cfg. readEntry ( "PressedActionChannel" ). latin1(); pm = cfg. readEntry ( "PressedActionMessage" ). latin1(); // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); hch = cfg. readEntry ( "HeldActionChannel" ). latin1(); hm = cfg. readEntry ( "HeldActionMessage" ). latin1(); // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); } b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); } } void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) { initButtons(); QString mb_chan; if ( button >= (int) d->m_buttons->count()) return; ODeviceButton &b = ( *d->m_buttons ) [button]; b. setPressedAction ( action ); mb_chan=b. pressedAction(). channel(); Config buttonFile ( "ButtonSettings" ); buttonFile. setGroup ( "Button" + QString::number ( button )); buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); // buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) { initButtons(); if ( button >= (int) d->m_buttons->count()) return; ODeviceButton &b = ( *d->m_buttons ) [button]; b. setHeldAction ( action ); Config buttonFile ( "ButtonSettings" ); buttonFile. setGroup ( "Button" + QString::number ( button )); buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } /** * @internal */ void ODevice::virtual_hook(int, void* ){ } /** * \brief Send a QCOP Message before suspending * * Sends a QCOP message to channel QPE/System * with the message "aboutToSuspend()" if this * is the windowing server. * * Call this in your custom \sa suspend() Method * before going to suspend. * */ void ODevice::sendSuspendmsg() { if ( isQWS() ) return; QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); } /** * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters * * Prepend a QWSServer::KeyboardFilter to the List of Keyboard * Filters. This function is the only way to prepend a KeyFilter. * * @param aFilter The KeyFilter to be prepended to the list of filters * * @see Opie::Core::OKeyFilter * @see Opie::Core::OKeyFilter::inst() */ void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) { Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); } /** * \brief Remove the QWSServer::KeyboardFilter in the param from the list * * Remove the QWSServer::KeyboardFilter \par aFilter from the List * of Keyfilters. Call this when you delete the KeyFilter! * * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter * @see Opie::Core::ODevice::addPreHandler */ void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) { Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); } /** * @internal * * @see changeMixerForAlarm */ void ODevice::playingStopped() { if ( sender() ) const_cast<QObject*>(sender())->disconnect( this ); #ifndef QT_NO_SOUND if ( d->m_sound >= 0 ) { ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); ::close ( d->m_sound ); } #endif } /** * \brief Change the Volume for the Alarm and set it back after playing is finished * * If you play an Alarm Sound you might want to change the Mixer to * full volume and ignore the user setting. After it \sa Sound::isFinished * you would turn the volume back to the user preference. * The problem is that we used to enter the event loop while waiting * for the sound to be finished triggering all kind of reentrance * problems what a library shouldn't introduce. * Instead of manually waiting for the sound to be finished use * this Method and it will automatically restore the Mixer to * the user configuration after the sound finished playing. * * Note: The onwership of \param snd is not transfered and playing * is not started in this method. If 'snd' gets deleted before * playing is finished the volume doesn't get set back to * the user preference! * * \code * static Sound snd("alarm"); * if(!snd.isFinished()) * return; * * changeMixerForAlarm( my_channel, "/dev/mixer", &snd ); * snd.play() * \endcode * * * * @param mixer The mixer number/channel to use * @param file The file name. If you convert from QString use QFile::encodeName * @param snd The sound to wait for finishing * */ void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { #ifndef QT_NO_SOUND if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { Config cfg ( "qpe" ); cfg. setGroup ( "Volume" ); int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); if ( volalarm < 0 ) volalarm = 0; else if ( volalarm > 100 ) volalarm = 100; volalarm |= ( volalarm << 8 ); if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) register_qpe_sound_finished(snd, this, SLOT(playingStopped())); } d->m_mixer = mixer; } #endif } } } diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h index 21fcc3f..93d7d22 100644 --- a/libopie2/opiecore/device/odevice.h +++ b/libopie2/opiecore/device/odevice.h @@ -1,375 +1,379 @@ /* 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 <qwindowsystem_qws.h> class Sound; namespace Opie{ namespace Core{ 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 | 0x000020 ), Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 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_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), 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_Ramses_MNCIRX = ( Model_Ramses | 0x000002 ), 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 ), Model_Beagle = ( 6 << 24 ), Model_Beagle_All = ( Model_Beagle | 0xffffff ), Model_Beagle_PA100 = ( Model_Beagle | 0x000001 ), + Model_GenuineIntel = ( 7 << 24 ) + }; /** * The vendor of the device */ enum OVendor { Vendor_Unknown, Vendor_HP, Vendor_Sharp, Vendor_SIEMENS, Vendor_MundN, Vendor_GMate, Vendor_MasterIA, + Vendor_GenuineIntel }; /** * The System used */ enum OSystem { System_Unknown, System_Familiar, System_Zaurus, System_OpenZaurus, System_Linupy, System_OpenEmbedded, + System_PC }; typedef struct { OSystem system; char* sysstr; char* sysvfile; } ODistribution; extern ODistribution distributions[]; 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, HardKey_Home = Qt::Key_F12, HardKey_Mail = Qt::Key_F13, HardKey_Record = Qt::Key_F24, HardKey_Suspend = Qt::Key_F34, HardKey_Backlight = Qt::Key_F35, HardKey_Action = Qt::Key_F10, HardKey_OK = Qt::Key_F11, HardKey_End = Qt::Key_F12, }; enum ODirection { CW = 0, CCW = 1, Flip = 2, }; enum OHingeStatus { CASE_CLOSED = 3, CASE_PORTRAIT = 2, CASE_LANDSCAPE = 0, CASE_UNKNOWN = 1, }; /* default button for qvfb or such * see odevice.cpp for details. * hint: manage a user defined button for qvfb? * alwin */ struct default_button { Qt::Key code; char *utext; char *pix; char *fpressedservice; char *fpressedaction; char *fheldservice; char *fheldaction; }; /** * A singleton which gives informations about device specefic option * like the Hardware used, LEDs, the Base Distribution and * hardware key mappings. * * @short A small class for device specefic options * @see QObject * @author Robert Griebl * @version 1.0 */ class ODevice : public QObject { Q_OBJECT private: /* disable copy */ ODevice ( const ODevice & ); protected: ODevice(); virtual void init(const QString&); virtual void initButtons(); static void sendSuspendmsg(); ODeviceData *d; public: // sandman do we want to allow destructions? -zecke? virtual ~ODevice(); static ODevice *inst(); // information QString modelString() const; OModel model() const; inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); } QString vendorString() const; OVendor vendor() const; QString systemString() const; OSystem system() const; QString systemVersionString() const; virtual Transformation rotation() const; virtual ODirection direction() const; // system virtual bool setSoftSuspend ( bool on ); virtual bool suspend(); virtual bool setDisplayStatus ( bool on ); virtual bool setDisplayBrightness ( int brightness ); virtual int displayBrightnessResolution() const; virtual bool setDisplayContrast ( int contrast ); virtual int displayContrastResolution() const; // don't add new virtual methods, use this: // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; // and in your subclass do overwrite // protected virtual int virtual_hook(int, void *) // which is defined below // input / output virtual void playAlarmSound(); virtual void playKeySound(); virtual void playTouchSound(); 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; virtual bool hasHingeSensor() const; virtual OHingeStatus readHingeSensor(); const QStrList &allowedCpuFrequencies() const; bool setCurrentCpuFrequency(uint index); /** * Returns the available buttons on this device. The number and location * of buttons will vary depending on the device. Button numbers will be assigned * by the device manufacturer and will be from most preferred button to least preffered * button. Note that this list only contains "user mappable" buttons. * * @todo Make method const and take care of calling initButtons or make that const too * */ const QValueList<ODeviceButton> &buttons(); /** * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it * returns 0L */ const ODeviceButton *buttonForKeycode ( ushort keyCode ); /** * Reassigns the pressed action for \a button. To return to the factory * default pass an empty string as \a qcopMessage. */ void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); /** * Reassigns the held action for \a button. To return to the factory * default pass an empty string as \a qcopMessage. */ void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); /** * How long (in ms) you have to press a button for a "hold" action */ uint buttonHoldTime() const; signals: void buttonMappingChanged(); private slots: void systemMessage ( const QCString &, const QByteArray & ); void playingStopped(); protected: void addPreHandler(QWSServer::KeyboardFilter*aFilter); void remPreHandler(QWSServer::KeyboardFilter*aFilter); void reloadButtonMapping(); void changeMixerForAlarm( int mixer, const char* file, Sound *snd); /* ugly virtual hook */ virtual void virtual_hook( int id, void* data ); }; class ODeviceData { public: QString m_vendorstr; OVendor m_vendor; QString m_modelstr; OModel m_model; QString m_systemstr; OSystem m_system; QString m_sysverstr; Transformation m_rotation; ODirection m_direction; QValueList <ODeviceButton> *m_buttons; uint m_holdtime; QStrList *m_cpu_frequencies; bool m_initializedButtonQcop : 1; /* values for changeMixerForAlarm */ int m_sound, m_vol, m_mixer; }; extern bool isQWS(); extern QCString makeChannel ( const char *str ); } } #endif diff --git a/libopie2/opiecore/device/odevice_genuineintel.cpp b/libopie2/opiecore/device/odevice_genuineintel.cpp new file mode 100644 index 0000000..61ba052 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_genuineintel.cpp @@ -0,0 +1,193 @@ +/* + This file is part of the Opie Project + Copyright (C) 2002,2003,2004 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_genuineintel.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> +#include <opie2/okeyfilter.h> + +#ifndef QT_NO_SOUND +#include <linux/soundcard.h> +#endif + +using namespace Opie::Core; +using namespace Opie::Core::Internal; + +struct gi_button genuineintel_buttons [] = { + { + Qt::Key_F1, QT_TRANSLATE_NOOP("Button", "Calendar Button"), + "devicebuttons/ipaq_calendar", + "datebook", "nextView()", + "today", "raise()" }, + { + Qt::Key_F2, QT_TRANSLATE_NOOP("Button", "Contacts Button"), + "devicebuttons/ipaq_contact", + "addressbook", "raise()", + "addressbook", "beamBusinessCard()" }, + { + Qt::Key_F3, QT_TRANSLATE_NOOP("Button", "Menu Button"), + "devicebuttons/ipaq_menu", + "QPE/TaskBar", "toggleMenu()", + "QPE/TaskBar", "toggleStartMenu()" }, + { + Qt::Key_F4, QT_TRANSLATE_NOOP("Button", "Mail Button"), + "devicebuttons/ipaq_mail", + "opiemail", "raise()", + "opiemail", "newMail()" }, + { + Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Home Button"), + "devicebuttons/ipaq_home", + "QPE/Launcher", "home()", + "buttonsettings", "raise()" }, + { + Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Record Button"), + "devicebuttons/ipaq_record", + "QPE/VMemo", "toggleRecord()", + "sound", "raise()" }, +}; + +void GenuineIntel::init(const QString& model) +{ + d->m_vendorstr = "Intel"; + d->m_vendor = Vendor_GenuineIntel; + + QStringList SL = QStringList::split( " ", model ); + + d->m_model = Model_GenuineIntel; + d->m_rotation = Rot0; +} + +void GenuineIntel::initButtons() +{ + if ( d->m_buttons ) + return; + + if ( isQWS( ) ) { + addPreHandler(this); + } + + d->m_buttons = new QValueList <ODeviceButton>; + + for ( uint i = 0; i < ( sizeof( genuineintel_buttons ) / sizeof( gi_button )); i++ ) { + gi_button *ib = genuineintel_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(); +} + +QValueList <OLed> GenuineIntel::ledList() const +{ + QValueList <OLed> vl; + return vl; //none +} + +QValueList <OLedState> GenuineIntel::ledStateList ( OLed ) const +{ + QValueList <OLedState> vl; + return vl; // none +} + +OLedState GenuineIntel::ledState ( OLed ) const +{ + return Led_Off; +} + +bool GenuineIntel::setLedState ( OLed , OLedState ) +{ + return false; +} + + +bool GenuineIntel::filter ( int /*unicode*/, int , int , bool , bool ) +{ + return false; +} + +void GenuineIntel::playAlarmSound() +{ +#ifndef QT_NO_SOUND + static Sound snd ( "alarm" ); + if(!snd.isFinished()) + return; + + changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); + snd. play(); +#endif +} + + +bool GenuineIntel::setSoftSuspend ( bool ) +{ + return false; +} + + +bool GenuineIntel::setDisplayBrightness ( int ) +{ + return false; +} + +int GenuineIntel::displayBrightnessResolution() const +{ + return 1; // perhaps to avoid division by zero +} + + +bool GenuineIntel::hasLightSensor() const +{ + return false; +} + +int GenuineIntel::readLightSensor() +{ + return 0; +} + +int GenuineIntel::lightSensorResolution() const +{ + return 1; // see above +} diff --git a/libopie2/opiecore/device/odevice_genuineintel.h b/libopie2/opiecore/device/odevice_genuineintel.h new file mode 100644 index 0000000..52c5fc6 --- a/dev/null +++ b/libopie2/opiecore/device/odevice_genuineintel.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_GENUINEINTEL +#define ODEVICE_GENUINEINTEL + +#include "odevice.h" + +/* QT */ +#include <qwindowsystem_qws.h> + +namespace Opie { +namespace Core { +namespace Internal { + +class GenuineIntel : public ODevice, public QWSServer::KeyboardFilter +{ + + protected: + virtual void init(const QString&); + virtual void initButtons(); + + public: + virtual bool setSoftSuspend( bool soft ); + + virtual bool setDisplayBrightness( int b ); + virtual int displayBrightnessResolution() const; + + virtual void playAlarmSound(); + + 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 ); + +}; + +struct gi_button { + Qt::Key code; + char *utext; + char *pix; + char *fpressedservice; + char *fpressedaction; + char *fheldservice; + char *fheldaction; +}; + +} +} +} + +#endif |