-rw-r--r-- | libopie/odevice.cpp | 85 |
1 files changed, 65 insertions, 20 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 & ))); } |