summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp91
1 files changed, 68 insertions, 23 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 80975c9..377945d 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -70,4 +70,4 @@ public:
70 70
71 QValueList <ODeviceButton> m_buttons; 71 QValueList <ODeviceButton> *m_buttons;
72 uint m_holdtime; 72 uint m_holdtime;
73}; 73};
@@ -78,2 +78,3 @@ protected:
78 virtual void init ( ); 78 virtual void init ( );
79 virtual void initButtons ( );
79 80
@@ -108,2 +109,3 @@ protected:
108 virtual void init ( ); 109 virtual void init ( );
110 virtual void initButtons ( );
109 111
@@ -256,5 +258,3 @@ ODevice::ODevice ( )
256 d-> m_holdtime = 1000; // 1000ms 258 d-> m_holdtime = 1000; // 1000ms
257 259 d-> m_buttons = 0;
258 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
259 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
260} 260}
@@ -270,4 +270,14 @@ void ODevice::init ( )
270{ 270{
271}
272
273void ODevice::initButtons ( )
274{
275 if ( d-> m_buttons )
276 return;
277
271 // Simulation uses iPAQ 3660 device buttons 278 // Simulation uses iPAQ 3660 device buttons
272 279
280 qDebug ( "init Buttons" );
281 d-> m_buttons = new QValueList <ODeviceButton>;
282
273 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 283 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
@@ -282,3 +292,3 @@ void ODevice::init ( )
282 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 292 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
283 d-> m_buttons. append ( b ); 293 d-> m_buttons-> append ( b );
284 } 294 }
@@ -286,2 +296,5 @@ void ODevice::init ( )
286 reloadButtonMapping ( ); 296 reloadButtonMapping ( );
297
298 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
299 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
287} 300}
@@ -476,5 +489,7 @@ int ODevice::lightSensorResolution ( ) const
476 489
477const QValueList <ODeviceButton> &ODevice::buttons ( ) const 490const QValueList <ODeviceButton> &ODevice::buttons ( )
478{ 491{
479 return d-> m_buttons; 492 initButtons ( );
493
494 return *d-> m_buttons;
480} 495}
@@ -488,3 +503,5 @@ const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
488{ 503{
489 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) { 504 initButtons ( );
505
506 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
490 if ( (*it). keycode ( ) == code ) 507 if ( (*it). keycode ( ) == code )
@@ -497,6 +514,8 @@ void ODevice::reloadButtonMapping ( )
497{ 514{
515 initButtons ( );
516
498 Config cfg ( "ButtonSettings" ); 517 Config cfg ( "ButtonSettings" );
499 518
500 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) { 519 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
501 ODeviceButton &b = d-> m_buttons [i]; 520 ODeviceButton &b = ( *d-> m_buttons ) [i];
502 QString group = "Button" + QString::number ( i ); 521 QString group = "Button" + QString::number ( i );
@@ -526,9 +545,10 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
526{ 545{
546 initButtons ( );
547
527 QString mb_chan; 548 QString mb_chan;
528 549
529 if ( button >= (int) d-> m_buttons. count ( )) 550 if ( button >= (int) d-> m_buttons-> count ( ))
530 return; 551 return;
531
532 552
533 ODeviceButton &b = d-> m_buttons [button]; 553 ODeviceButton &b = ( *d-> m_buttons ) [button];
534 b. setPressedAction ( action ); 554 b. setPressedAction ( action );
@@ -549,6 +569,8 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
549{ 569{
550 if ( button >= (int) d-> m_buttons. count ( )) 570 initButtons ( );
571
572 if ( button >= (int) d-> m_buttons-> count ( ))
551 return; 573 return;
552 574
553 ODeviceButton &b = d-> m_buttons [button]; 575 ODeviceButton &b = ( *d-> m_buttons ) [button];
554 b. setHeldAction ( action ); 576 b. setHeldAction ( action );
@@ -630,2 +652,13 @@ void iPAQ::init ( )
630 652
653 if ( d-> m_qwsserver )
654 QWSServer::setKeyboardFilter ( this );
655}
656
657void iPAQ::initButtons ( )
658{
659 if ( d-> m_buttons )
660 return;
661
662 d-> m_buttons = new QValueList <ODeviceButton>;
663
631 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 664 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
@@ -641,11 +674,12 @@ void iPAQ::init ( )
641 674
642 d-> m_buttons. append ( b ); 675 d-> m_buttons-> append ( b );
643 } 676 }
644 } 677 }
645 reloadButtonMapping ( ); 678 reloadButtonMapping ( );
646 679
647 if ( d-> m_qwsserver ) 680 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
648 QWSServer::setKeyboardFilter ( this ); 681 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
649} 682}
650 683
684
651//#include <linux/h3600_ts.h> // including kernel headers is evil ... 685//#include <linux/h3600_ts.h> // including kernel headers is evil ...
@@ -995,2 +1029,11 @@ void Zaurus::init ( )
995 } 1029 }
1030 m_leds [0] = Led_Off;
1031}
1032
1033void Zaurus::initButtons ( )
1034{
1035 if ( d-> m_buttons )
1036 return;
1037
1038 d-> m_buttons = new QValueList <ODeviceButton>;
996 1039
@@ -1006,7 +1049,9 @@ void Zaurus::init ( )
1006 1049
1007 d-> m_buttons. append ( b ); 1050 d-> m_buttons-> append ( b );
1008 } 1051 }
1052
1009 reloadButtonMapping ( ); 1053 reloadButtonMapping ( );
1010 1054
1011 m_leds [0] = Led_Off; 1055 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1056 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1012} 1057}