summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp126
-rw-r--r--libopie/odevice.h3
2 files changed, 129 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index aadd0bf..8624016 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -61,96 +61,108 @@ public:
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;
};
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];
};
+class Jornada : public ODevice {
+protected:
+ virtual void init ( );
+ virtual void initButtons ( );
+public:
+ virtual bool setSoftSuspend ( bool soft );
+ virtual bool setDisplayBrightness ( int b );
+ virtual int displayBrightnessResolution ( ) const;
+ static bool isJornada();
+
+};
+
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 );
static bool isZaurus();
protected:
virtual void buzzer ( int snd );
OLedState m_leds [1];
bool m_embedix;
};
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 );
@@ -388,96 +400,98 @@ struct yopy_button {
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()" },
};
static QCString makeChannel ( const char *str )
{
if ( str && !::strchr ( str, '/' ))
return QCString ( "QPE/Application/" ) + str;
else
return str;
}
static inline bool isQWS()
{
return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
}
ODevice *ODevice::inst ( )
{
static ODevice *dev = 0;
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 ( );
else
dev = new ODevice ( );
dev-> init ( );
}
return dev;
}
/**************************************************
*
* common
*
**************************************************/
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
*/
@@ -2407,48 +2421,160 @@ bool Ramses::setDisplayBrightness(int bright)
// scale backlight brightness to hardware
bright = 500-(bright * 500 / 255);
if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
qDebug(" %d -> pwm1", bright);
char writeCommand[100];
const int count = sprintf(writeCommand, "%d\n", bright);
res = (::write(fd, writeCommand, count) != -1);
::close(fd);
}
return res;
}
int Ramses::displayBrightnessResolution() const
{
return 32;
}
bool Ramses::setDisplayContrast(int contr)
{
qDebug("Ramses::setDisplayContrast(%d)", contr);
bool res = false;
int fd;
// pwm0 contrast: 20 steps 79..90 (dunkel->hell)
if (contr > 255 )
contr = 255;
if (contr < 0)
contr = 0;
contr = 90 - (contr * 20 / 255);
if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
qDebug(" %d -> pwm0", contr);
char writeCommand[100];
const int count = sprintf(writeCommand, "%d\n", contr);
res = (::write(fd, writeCommand, count) != -1);
res = true;
::close(fd);
}
return res;
}
int Ramses::displayContrastResolution() const
{
return 20;
}
+
+
+/**************************************************
+ * *
+ * Jornada *
+ * *
+ **************************************************/
+
+
+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;
+}
+
+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 & )));
+}
+
+int Jornada::displayBrightnessResolution ( ) const
+{
+}
+
+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/libopie/odevice.h b/libopie/odevice.h
index 2a5e494..35e3eff 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -6,96 +6,99 @@
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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 _LIBOPIE_ODEVICE_H_
#define _LIBOPIE_ODEVICE_H_
#include <qobject.h>
#include <qstring.h>
#include <qnamespace.h>
#include <qstrlist.h>
#include <opie/odevicebutton.h>
#include <qpe/qpeapplication.h> /* for Transformation enum.. */
class ODeviceData;
namespace Opie {
/**
* 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_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_SLC700 = ( 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,