author | sandman <sandman> | 2003-03-26 23:53:14 (UTC) |
---|---|---|
committer | sandman <sandman> | 2003-03-26 23:53:14 (UTC) |
commit | 9d291e88efa5b33bbf34112cdee8b0e516150dd6 (patch) (side-by-side diff) | |
tree | 6059b942d98691d7882d5290d5aa854b187f13ce | |
parent | eda6fffbe8ad7e3635985d9b2a8f7b46964aa271 (diff) | |
download | opie-9d291e88efa5b33bbf34112cdee8b0e516150dd6.zip opie-9d291e88efa5b33bbf34112cdee8b0e516150dd6.tar.gz opie-9d291e88efa5b33bbf34112cdee8b0e516150dd6.tar.bz2 |
delay the initialization of the button information:
- faster startup for apps that are not accessing the HW buttons
- the basic ODevice stuff is useable without a QApplication object
-rw-r--r-- | libopie/odevice.cpp | 85 | ||||
-rw-r--r-- | libopie/odevice.h | 3 |
2 files changed, 67 insertions, 21 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 80975c9..377945d 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp @@ -69,5 +69,5 @@ public: Transformation m_rotation; - QValueList <ODeviceButton> m_buttons; + QValueList <ODeviceButton> *m_buttons; uint m_holdtime; }; @@ -77,4 +77,5 @@ class iPAQ : public ODevice, public QWSServer::KeyboardFilter { protected: virtual void init ( ); + virtual void initButtons ( ); public: @@ -107,4 +108,5 @@ class Zaurus : public ODevice { protected: virtual void init ( ); + virtual void initButtons ( ); public: @@ -255,7 +257,5 @@ ODevice::ODevice ( ) d-> m_holdtime = 1000; // 1000ms - - QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); - connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); + d-> m_buttons = 0; } @@ -269,6 +269,16 @@ void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) void ODevice::init ( ) { +} + +void ODevice::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; @@ -281,8 +291,11 @@ void ODevice::init ( ) b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); - d-> m_buttons. append ( b ); + 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 & ))); } @@ -475,7 +488,9 @@ int ODevice::lightSensorResolution ( ) const } -const QValueList <ODeviceButton> &ODevice::buttons ( ) const +const QValueList <ODeviceButton> &ODevice::buttons ( ) { - return d-> m_buttons; + initButtons ( ); + + return *d-> m_buttons; } @@ -487,5 +502,7 @@ uint ODevice::buttonHoldTime ( ) const const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) { - for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { + initButtons ( ); + + for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { if ( (*it). keycode ( ) == code ) return &(*it); @@ -496,8 +513,10 @@ const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) void ODevice::reloadButtonMapping ( ) { + initButtons ( ); + Config cfg ( "ButtonSettings" ); - for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { - ODeviceButton &b = d-> m_buttons [i]; + for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { + ODeviceButton &b = ( *d-> m_buttons ) [i]; QString group = "Button" + QString::number ( i ); @@ -525,11 +544,12 @@ void ODevice::reloadButtonMapping ( ) void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) { + initButtons ( ); + QString mb_chan; - if ( button >= (int) d-> m_buttons. count ( )) + if ( button >= (int) d-> m_buttons-> count ( )) return; - - ODeviceButton &b = d-> m_buttons [button]; + ODeviceButton &b = ( *d-> m_buttons ) [button]; b. setPressedAction ( action ); @@ -548,8 +568,10 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) { - if ( button >= (int) d-> m_buttons. count ( )) + initButtons ( ); + + if ( button >= (int) d-> m_buttons-> count ( )) return; - ODeviceButton &b = d-> m_buttons [button]; + ODeviceButton &b = ( *d-> m_buttons ) [button]; b. setHeldAction ( action ); @@ -629,4 +651,15 @@ void iPAQ::init ( ) m_power_timer = 0; + if ( d-> m_qwsserver ) + QWSServer::setKeyboardFilter ( this ); +} + +void iPAQ::initButtons ( ) +{ + if ( d-> m_buttons ) + return; + + d-> m_buttons = new QValueList <ODeviceButton>; + for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { i_button *ib = ipaq_buttons + i; @@ -640,13 +673,14 @@ void iPAQ::init ( ) b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); - d-> m_buttons. append ( b ); + d-> m_buttons-> append ( b ); } } reloadButtonMapping ( ); - if ( d-> m_qwsserver ) - QWSServer::setKeyboardFilter ( this ); + QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); + connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); } + //#include <linux/h3600_ts.h> // including kernel headers is evil ... @@ -994,4 +1028,13 @@ void Zaurus::init ( ) break; } + m_leds [0] = Led_Off; +} + +void Zaurus::initButtons ( ) +{ + if ( d-> m_buttons ) + return; + + d-> m_buttons = new QValueList <ODeviceButton>; for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { @@ -1005,9 +1048,11 @@ void Zaurus::init ( ) b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); - d-> m_buttons. append ( b ); + d-> m_buttons-> append ( b ); } + reloadButtonMapping ( ); - m_leds [0] = Led_Off; + QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); + connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); } diff --git a/libopie/odevice.h b/libopie/odevice.h index 575e1fe..ff578d8 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h @@ -104,4 +104,5 @@ protected: ODevice ( ); virtual void init ( ); + virtual void initButtons ( ); ODeviceData *d; @@ -158,5 +159,5 @@ public: * button. Note that this list only contains "user mappable" buttons. */ - const QValueList<ODeviceButton> &buttons ( ) const; + const QValueList<ODeviceButton> &buttons ( ); /** |