-rw-r--r-- | libopie/odevice.cpp | 232 |
1 files changed, 124 insertions, 108 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index cea4f35..9b2a954 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -59,3 +59,3 @@ public: OVendor m_vendor; - + QString m_modelstr; @@ -65,3 +65,3 @@ public: OSystem m_system; - + QString m_sysverstr; @@ -69,3 +69,3 @@ public: Transformation m_rotation; - + QValueList <ODeviceButton> *m_buttons; @@ -76,6 +76,6 @@ public: class iPAQ : public ODevice, public QWSServer::KeyboardFilter { -protected: +protected: virtual void init ( ); virtual void initButtons ( ); - + public: @@ -87,3 +87,3 @@ public: virtual void alarmSound ( ); - + virtual QValueList <OLed> ledList ( ) const; @@ -96,3 +96,3 @@ public: virtual int lightSensorResolution ( ) const; - + protected: @@ -100,5 +100,5 @@ protected: virtual void timerEvent ( QTimerEvent *te ); - + int m_power_timer; - + OLedState m_leds [2]; @@ -111,3 +111,3 @@ protected: -public: +public: virtual bool setSoftSuspend ( bool soft ); @@ -119,3 +119,3 @@ public: virtual void keySound ( ); - virtual void touchSound ( ); + virtual void touchSound ( ); @@ -125,6 +125,6 @@ public: virtual bool setLedState ( OLed led, OLedState st ); - + protected: virtual void buzzer ( int snd ); - + OLedState m_leds [1]; @@ -143,14 +143,14 @@ struct i_button { } ipaq_buttons [] = { - { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, - Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), - "devicebuttons/ipaq_calendar", - "datebook", "nextView()", + { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, + 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, - Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), - "devicebuttons/ipaq_contact", + 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"), + { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, + Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), "devicebuttons/ipaq_menu", @@ -159,3 +159,3 @@ struct i_button { { Model_iPAQ_H38xx | Model_iPAQ_H39xx, - Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), + Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), "devicebuttons/ipaq_mail", @@ -164,4 +164,4 @@ struct i_button { { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, - Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), - "devicebuttons/ipaq_home", + Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), + "devicebuttons/ipaq_home", "QPE/Launcher", "home()", @@ -169,4 +169,4 @@ struct i_button { { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, - Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), - "devicebuttons/ipaq_record", + Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), + "devicebuttons/ipaq_record", "QPE/VMemo", "toggleRecord()", @@ -220,3 +220,3 @@ ODevice *ODevice::inst ( ) static ODevice *dev = 0; - + if ( !dev ) { @@ -228,3 +228,3 @@ ODevice *ODevice::inst ( ) dev = new ODevice ( ); - + dev-> init ( ); @@ -256,3 +256,3 @@ ODevice::ODevice ( ) d-> m_rotation = Rot0; - + d-> m_holdtime = 1000; // 1000ms @@ -265,3 +265,3 @@ void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) reloadButtonMapping ( ); - } + } } @@ -283,6 +283,6 @@ void ODevice::initButtons ( ) for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { - i_button *ib = ipaq_buttons + i; + i_button *ib = ipaq_buttons + i; ODeviceButton b; - - if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { + + if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { b. setKeycode ( ib-> code ); @@ -296,5 +296,5 @@ void ODevice::initButtons ( ) reloadButtonMapping ( ); - + QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); - connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); + connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); } @@ -325,6 +325,6 @@ bool ODevice::suspend ( ) bool res = false; - + struct timeval tvs, tvn; ::gettimeofday ( &tvs, 0 ); - + ::sync ( ); // flush fs caches @@ -336,9 +336,9 @@ bool ODevice::suspend ( ) - if ( res ) { + if ( res ) { do { // wait at most 1.5 sec: either suspend didn't work or the device resumed ::usleep ( 200 * 1000 ); - ::gettimeofday ( &tvn, 0 ); + ::gettimeofday ( &tvn, 0 ); } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); } - + return res; @@ -364,3 +364,3 @@ bool ODevice::setDisplayStatus ( bool on ) int fd; - + if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { @@ -368,3 +368,3 @@ bool ODevice::setDisplayStatus ( bool on ) ::close ( fd ); - } + } return res; @@ -517,3 +517,3 @@ void ODevice::reloadButtonMapping ( ) Config cfg ( "ButtonSettings" ); - + for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { @@ -525,3 +525,3 @@ void ODevice::reloadButtonMapping ( ) QByteArray pdata, hdata; - + if ( cfg. hasGroup ( group )) { @@ -536,5 +536,5 @@ void ODevice::reloadButtonMapping ( ) } - + b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); - + b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); @@ -548,6 +548,6 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) QString mb_chan; - + if ( button >= (int) d-> m_buttons-> count ( )) return; - + ODeviceButton &b = ( *d-> m_buttons ) [button]; @@ -573,3 +573,3 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) return; - + ODeviceButton &b = ( *d-> m_buttons ) [button]; @@ -638,18 +638,34 @@ void iPAQ::init ( ) f. setName ( "/etc/familiar-version" ); - if ( f. open ( IO_ReadOnly )) { + 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 ); + d-> m_sysverstr = ts. readLine ( ); + f. close ( ); + } + } + + + + m_leds [0] = m_leds [1] = Led_Off; - + m_power_timer = 0; - + if ( d-> m_qwsserver ) - QWSServer::setKeyboardFilter ( this ); + QWSServer::setKeyboardFilter ( this ); } @@ -664,6 +680,6 @@ void iPAQ::initButtons ( ) for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { - i_button *ib = ipaq_buttons + i; + i_button *ib = ipaq_buttons + i; ODeviceButton b; - - if (( ib-> model & d-> m_model ) == d-> m_model ) { + + if (( ib-> model & d-> m_model ) == d-> m_model ) { b. setKeycode ( ib-> code ); @@ -673,3 +689,3 @@ void iPAQ::initButtons ( ) b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); - + d-> m_buttons-> append ( b ); @@ -677,4 +693,4 @@ void iPAQ::initButtons ( ) } - reloadButtonMapping ( ); - + reloadButtonMapping ( ); + QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); @@ -721,3 +737,3 @@ QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const vl << Led_Off; // << Led_On << ??? - + return vl; @@ -726,3 +742,3 @@ QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const OLedState iPAQ::ledState ( OLed l ) const -{ +{ switch ( l ) { @@ -737,3 +753,3 @@ OLedState iPAQ::ledState ( OLed l ) const -bool iPAQ::setLedState ( OLed l, OLedState st ) +bool iPAQ::setLedState ( OLed l, OLedState st ) { @@ -775,3 +791,3 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b if (( d-> m_model == Model_iPAQ_H38xx ) || - ( d-> m_model == Model_iPAQ_H39xx )) { + ( d-> m_model == Model_iPAQ_H39xx )) { newkeycode = HardKey_Mail; @@ -780,10 +796,10 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b } - + // Rotate cursor keys 180° - case Key_Left : - case Key_Right: - case Key_Up : + case Key_Left : + case Key_Right: + case Key_Up : case Key_Down : { if (( d-> m_model == Model_iPAQ_H31xx ) || - ( d-> m_model == Model_iPAQ_H38xx )) { + ( d-> m_model == Model_iPAQ_H38xx )) { newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; @@ -806,7 +822,7 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b } - newkeycode = Key_unknown; - break; + newkeycode = Key_unknown; + break; } } - + if ( newkeycode != keycode ) { @@ -871,3 +887,3 @@ bool iPAQ::setSoftSuspend ( bool soft ) int fd; - + if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { @@ -877,3 +893,3 @@ bool iPAQ::setSoftSuspend ( bool soft ) ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); - + ::close ( fd ); @@ -882,3 +898,3 @@ bool iPAQ::setSoftSuspend ( bool soft ) ::perror ( "/proc/sys/ts/suspend_button_mode" ); - + return res; @@ -891,3 +907,3 @@ bool iPAQ::setDisplayBrightness ( int bright ) int fd; - + if ( bright > 255 ) @@ -915,3 +931,3 @@ int iPAQ::displayBrightnessResolution ( ) const return 128; // really 256, but >128 could damage the LCD - + case Model_iPAQ_H38xx: @@ -919,6 +935,6 @@ int iPAQ::displayBrightnessResolution ( ) const return 64; - + default: return 2; - } + } } @@ -935,15 +951,15 @@ int iPAQ::readLightSensor ( ) int val = -1; - + if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { char buffer [8]; - + if ( ::read ( fd, buffer, 5 ) == 5 ) { char *endptr; - + buffer [4] = 0; val = ::strtol ( buffer + 2, &endptr, 16 ); - + if ( *endptr != 0 ) val = -1; - } + } ::close ( fd ); @@ -982,3 +998,3 @@ void Zaurus::init ( ) f. setName ( "/etc/oz_version" ); - if ( f. open ( IO_ReadOnly )) { + if ( f. open ( IO_ReadOnly )) { QTextStream ts ( &f ); @@ -1038,3 +1054,3 @@ void Zaurus::initButtons ( ) return; - + d-> m_buttons = new QValueList <ODeviceButton>; @@ -1042,5 +1058,5 @@ void Zaurus::initButtons ( ) for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { - z_button *zb = z_buttons + i; + z_button *zb = z_buttons + i; ODeviceButton b; - + b. setKeycode ( zb-> code ); @@ -1050,8 +1066,8 @@ void Zaurus::initButtons ( ) b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); - + d-> m_buttons-> append ( b ); } - + reloadButtonMapping ( ); - + QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); @@ -1130,3 +1146,3 @@ void Zaurus::buzzer ( int sound ) static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); - + if ( fd >= 0 ) { @@ -1138,3 +1154,3 @@ void Zaurus::buzzer ( int sound ) -void Zaurus::alarmSound ( ) +void Zaurus::alarmSound ( ) { @@ -1143,3 +1159,3 @@ void Zaurus::alarmSound ( ) -void Zaurus::touchSound ( ) +void Zaurus::touchSound ( ) { @@ -1148,3 +1164,3 @@ void Zaurus::touchSound ( ) -void Zaurus::keySound ( ) +void Zaurus::keySound ( ) { @@ -1164,3 +1180,3 @@ QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const QValueList <OLedState> vl; - + if ( l == Led_Mail ) @@ -1174,3 +1190,3 @@ OLedState Zaurus::ledState ( OLed which ) const return m_leds [0]; - else + else return Led_Off; @@ -1180,3 +1196,3 @@ bool Zaurus::setLedState ( OLed which, OLedState st ) { - static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); + static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); @@ -1188,3 +1204,3 @@ bool Zaurus::setLedState ( OLed which, OLedState st ) bool ok = true; - + switch ( st ) { @@ -1195,3 +1211,3 @@ bool Zaurus::setLedState ( OLed which, OLedState st ) } - + if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { @@ -1200,3 +1216,3 @@ bool Zaurus::setLedState ( OLed which, OLedState st ) } - } + } } @@ -1228,3 +1244,3 @@ bool Zaurus::setSoftSuspend ( bool soft ) perror ( "APM_IOCGEVTSRC" ); - + ::close ( fd ); @@ -1233,3 +1249,3 @@ bool Zaurus::setSoftSuspend ( bool soft ) perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); - + return res; @@ -1242,3 +1258,3 @@ bool Zaurus::setDisplayBrightness ( int bright ) int fd; - + if ( bright > 255 ) @@ -1247,3 +1263,3 @@ bool Zaurus::setDisplayBrightness ( int bright ) bright = 0; - + if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { @@ -1259,3 +1275,3 @@ bool Zaurus::setDisplayBrightness ( int bright ) -int Zaurus::displayBrightnessResolution ( ) const +int Zaurus::displayBrightnessResolution ( ) const { |