summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authorocheong <ocheong>2003-10-09 10:57:25 (UTC)
committer ocheong <ocheong>2003-10-09 10:57:25 (UTC)
commit5103b92c2fc7e28f87dcbdc3650820494359dcca (patch) (unidiff)
tree0236f032f6b30adfbe208f3303e50ddccc772db6 /libopie/odevice.cpp
parentc37ffc2854d1c968eb28d4ae185b5c64877c6e9d (diff)
downloadopie-5103b92c2fc7e28f87dcbdc3650820494359dcca.zip
opie-5103b92c2fc7e28f87dcbdc3650820494359dcca.tar.gz
opie-5103b92c2fc7e28f87dcbdc3650820494359dcca.tar.bz2
Added class for Yopy devices.
It doesn't really do much, as power and backlight is still handled by the demons running under X (Opie is meant to be used without terminating X).
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp149
1 files changed, 147 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 3ff029e..aadd0bf 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -75,7 +75,6 @@ public:
75 QStrList *m_cpu_frequencies; 75 QStrList *m_cpu_frequencies;
76}; 76};
77 77
78
79class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 78class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
80protected: 79protected:
81 virtual void init ( ); 80 virtual void init ( );
@@ -369,6 +368,43 @@ struct r_button {
369 "buttonsettings", "raise()" }, 368 "buttonsettings", "raise()" },
370}; 369};
371 370
371class Yopy : public ODevice {
372protected:
373 virtual void init ( );
374 virtual void initButtons ( );
375
376public:
377 virtual bool suspend ( );
378
379 virtual bool setDisplayBrightness ( int b );
380 virtual int displayBrightnessResolution ( ) const;
381
382 static bool isYopy ( );
383};
384
385struct yopy_button {
386 Qt::Key code;
387 char *utext;
388 char *pix;
389 char *fpressedservice;
390 char *fpressedaction;
391 char *fheldservice;
392 char *fheldaction;
393} yopy_buttons [] = {
394 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
395 "devicebuttons/yopy_action",
396 "datebook", "nextView()",
397 "today", "raise()" },
398 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
399 "devicebuttons/yopy_ok",
400 "addressbook", "raise()",
401 "addressbook", "beamBusinessCard()" },
402 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
403 "devicebuttons/yopy_end",
404 "QPE/Launcher", "home()",
405 "buttonsettings", "raise()" },
406};
407
372static QCString makeChannel ( const char *str ) 408static QCString makeChannel ( const char *str )
373{ 409{
374 if ( str && !::strchr ( str, '/' )) 410 if ( str && !::strchr ( str, '/' ))
@@ -395,9 +431,10 @@ ODevice *ODevice::inst ( )
395 dev = new SIMpad ( ); 431 dev = new SIMpad ( );
396 else if ( QFile::exists ( "/proc/sys/board/name" )) 432 else if ( QFile::exists ( "/proc/sys/board/name" ))
397 dev = new Ramses ( ); 433 dev = new Ramses ( );
434 else if ( Yopy::isYopy() )
435 dev = new Yopy ( );
398 else 436 else
399 dev = new ODevice ( ); 437 dev = new ODevice ( );
400
401 dev-> init ( ); 438 dev-> init ( );
402 } 439 }
403 return dev; 440 return dev;
@@ -930,6 +967,114 @@ void ODevice::virtual_hook(int, void* ){
930 967
931} 968}
932 969
970/**************************************************
971 *
972 * Yopy 3500/3700
973 *
974 **************************************************/
975
976bool Yopy::isYopy ( )
977{
978 QFile f( "/proc/cpuinfo" );
979 if ( f. open ( IO_ReadOnly ) ) {
980 QTextStream ts ( &f );
981 QString line;
982 while( line = ts. readLine ( ) ) {
983 if ( line. left ( 8 ) == "Hardware" ) {
984 int loc = line. find ( ":" );
985 if ( loc != -1 ) {
986 QString model =
987 line. mid ( loc + 2 ). simplifyWhiteSpace( );
988 return ( model == "Yopy" );
989 }
990 }
991 }
992 }
993 return false;
994}
995
996void Yopy::init ( )
997{
998 d-> m_vendorstr = "G.Mate";
999 d-> m_vendor = Vendor_GMate;
1000 d-> m_modelstr = "Yopy3700";
1001 d-> m_model = Model_Yopy_3700;
1002 d-> m_rotation = Rot0;
1003
1004 d-> m_systemstr = "Linupy";
1005 d-> m_system = System_Linupy;
1006
1007 QFile f ( "/etc/issue" );
1008 if ( f. open ( IO_ReadOnly )) {
1009 QTextStream ts ( &f );
1010 ts.readLine();
1011 d-> m_sysverstr = ts. readLine ( );
1012 f. close ( );
1013 }
1014}
1015
1016void Yopy::initButtons ( )
1017{
1018 if ( d-> m_buttons )
1019 return;
1020
1021 d-> m_buttons = new QValueList <ODeviceButton>;
1022
1023 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1024
1025 yopy_button *ib = yopy_buttons + i;
1026
1027 ODeviceButton b;
1028
1029 b. setKeycode ( ib-> code );
1030 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1031 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1032 b. setFactoryPresetPressedAction
1033 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1034 b. setFactoryPresetHeldAction
1035 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1036
1037 d-> m_buttons-> append ( b );
1038 }
1039 reloadButtonMapping ( );
1040
1041 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1042 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1043 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1044}
1045
1046bool Yopy::suspend()
1047{
1048 /* Opie for Yopy does not implement its own power management at the
1049 moment. The public version runs parallel to X, and relies on the
1050 existing power management features. */
1051 return false;
1052}
1053
1054bool Yopy::setDisplayBrightness(int bright)
1055{
1056 /* The code here works, but is disabled as the current version runs
1057 parallel to X, and relies on the existing backlight demon. */
1058#if 0
1059 if ( QFile::exists("/proc/sys/pm/light") ) {
1060 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1061 if (fd >= 0 ) {
1062 if (bright)
1063 ::write(fd, "1\n", 2);
1064 else
1065 ::write(fd, "0\n", 2);
1066 ::close(fd);
1067 return true;
1068 }
1069 }
1070#endif
1071 return false;
1072}
1073
1074int Yopy::displayBrightnessResolution() const
1075{
1076 return 2;
1077}
933 1078
934/************************************************** 1079/**************************************************
935 * 1080 *