summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp91
-rw-r--r--libopie/odevice.h3
2 files changed, 70 insertions, 24 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 80975c9..377945d 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -65,20 +65,21 @@ public:
65 OSystem m_system; 65 OSystem m_system;
66 66
67 QString m_sysverstr; 67 QString m_sysverstr;
68 68
69 Transformation m_rotation; 69 Transformation m_rotation;
70 70
71 QValueList <ODeviceButton> m_buttons; 71 QValueList <ODeviceButton> *m_buttons;
72 uint m_holdtime; 72 uint m_holdtime;
73}; 73};
74 74
75 75
76class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 76class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
77protected: 77protected:
78 virtual void init ( ); 78 virtual void init ( );
79 virtual void initButtons ( );
79 80
80public: 81public:
81 virtual bool setSoftSuspend ( bool soft ); 82 virtual bool setSoftSuspend ( bool soft );
82 83
83 virtual bool setDisplayBrightness ( int b ); 84 virtual bool setDisplayBrightness ( int b );
84 virtual int displayBrightnessResolution ( ) const; 85 virtual int displayBrightnessResolution ( ) const;
@@ -103,12 +104,13 @@ protected:
103 OLedState m_leds [2]; 104 OLedState m_leds [2];
104}; 105};
105 106
106class Zaurus : public ODevice { 107class Zaurus : public ODevice {
107protected: 108protected:
108 virtual void init ( ); 109 virtual void init ( );
110 virtual void initButtons ( );
109 111
110 public: 112 public:
111 virtual bool setSoftSuspend ( bool soft ); 113 virtual bool setSoftSuspend ( bool soft );
112 114
113 virtual bool setDisplayBrightness ( int b ); 115 virtual bool setDisplayBrightness ( int b );
114 virtual int displayBrightnessResolution ( ) const; 116 virtual int displayBrightnessResolution ( ) const;
@@ -251,42 +253,53 @@ ODevice::ODevice ( )
251 d-> m_systemstr = "Unknown"; 253 d-> m_systemstr = "Unknown";
252 d-> m_system = System_Unknown; 254 d-> m_system = System_Unknown;
253 d-> m_sysverstr = "0.0"; 255 d-> m_sysverstr = "0.0";
254 d-> m_rotation = Rot0; 256 d-> m_rotation = Rot0;
255 257
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}
261 261
262void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 262void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
263{ 263{
264 if ( msg == "deviceButtonMappingChanged()" ) { 264 if ( msg == "deviceButtonMappingChanged()" ) {
265 reloadButtonMapping ( ); 265 reloadButtonMapping ( );
266 } 266 }
267} 267}
268 268
269void ODevice::init ( ) 269void 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++ ) {
274 i_button *ib = ipaq_buttons + i; 284 i_button *ib = ipaq_buttons + i;
275 ODeviceButton b; 285 ODeviceButton b;
276 286
277 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 287 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
278 b. setKeycode ( ib-> code ); 288 b. setKeycode ( ib-> code );
279 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 289 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
280 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 290 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
281 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 291 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
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 }
285 } 295 }
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}
288 301
289ODevice::~ODevice ( ) 302ODevice::~ODevice ( )
290{ 303{
291 delete d; 304 delete d;
292} 305}
@@ -471,37 +484,43 @@ int ODevice::readLightSensor ( )
471 484
472int ODevice::lightSensorResolution ( ) const 485int ODevice::lightSensorResolution ( ) const
473{ 486{
474 return 0; 487 return 0;
475} 488}
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}
481 496
482uint ODevice::buttonHoldTime ( ) const 497uint ODevice::buttonHoldTime ( ) const
483{ 498{
484 return d-> m_holdtime; 499 return d-> m_holdtime;
485} 500}
486 501
487const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 502const 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 )
491 return &(*it); 508 return &(*it);
492 } 509 }
493 return 0; 510 return 0;
494} 511}
495 512
496void ODevice::reloadButtonMapping ( ) 513void 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 );
503 522
504 QCString pch, hch; 523 QCString pch, hch;
505 QCString pm, hm; 524 QCString pm, hm;
506 QByteArray pdata, hdata; 525 QByteArray pdata, hdata;
507 526
@@ -521,19 +540,20 @@ void ODevice::reloadButtonMapping ( )
521 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 540 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
522 } 541 }
523} 542}
524 543
525void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 544void 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 );
535 555
536 mb_chan=b. pressedAction ( ). channel ( ); 556 mb_chan=b. pressedAction ( ). channel ( );
537 557
538 Config buttonFile ( "ButtonSettings" ); 558 Config buttonFile ( "ButtonSettings" );
539 buttonFile. setGroup ( "Button" + QString::number ( button )); 559 buttonFile. setGroup ( "Button" + QString::number ( button ));
@@ -544,16 +564,18 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
544 564
545 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 565 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
546} 566}
547 567
548void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 568void 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 );
555 577
556 Config buttonFile ( "ButtonSettings" ); 578 Config buttonFile ( "ButtonSettings" );
557 buttonFile. setGroup ( "Button" + QString::number ( button )); 579 buttonFile. setGroup ( "Button" + QString::number ( button ));
558 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 580 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
559 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 581 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
@@ -625,32 +647,44 @@ void iPAQ::init ( )
625 } 647 }
626 648
627 m_leds [0] = m_leds [1] = Led_Off; 649 m_leds [0] = m_leds [1] = Led_Off;
628 650
629 m_power_timer = 0; 651 m_power_timer = 0;
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++ ) {
632 i_button *ib = ipaq_buttons + i; 665 i_button *ib = ipaq_buttons + i;
633 ODeviceButton b; 666 ODeviceButton b;
634 667
635 if (( ib-> model & d-> m_model ) == d-> m_model ) { 668 if (( ib-> model & d-> m_model ) == d-> m_model ) {
636 b. setKeycode ( ib-> code ); 669 b. setKeycode ( ib-> code );
637 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 670 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
638 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 671 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
639 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 672 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
640 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 673 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
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 ...
652 686
653typedef struct { 687typedef struct {
654 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 688 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
655 unsigned char TotalTime; /* Units of 5 seconds */ 689 unsigned char TotalTime; /* Units of 5 seconds */
656 unsigned char OnTime; /* units of 100m/s */ 690 unsigned char OnTime; /* units of 100m/s */
@@ -990,28 +1024,39 @@ void Zaurus::init ( )
990 case Model_Zaurus_SL5500: 1024 case Model_Zaurus_SL5500:
991 case Model_Zaurus_SL5000: 1025 case Model_Zaurus_SL5000:
992 default: 1026 default:
993 d-> m_rotation = Rot270; 1027 d-> m_rotation = Rot270;
994 break; 1028 break;
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
997 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { 1040 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
998 z_button *zb = z_buttons + i; 1041 z_button *zb = z_buttons + i;
999 ODeviceButton b; 1042 ODeviceButton b;
1000 1043
1001 b. setKeycode ( zb-> code ); 1044 b. setKeycode ( zb-> code );
1002 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1045 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1003 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1046 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1004 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1047 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1005 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1048 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
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}
1013 1058
1014#include <unistd.h> 1059#include <unistd.h>
1015#include <fcntl.h> 1060#include <fcntl.h>
1016#include <sys/ioctl.h> 1061#include <sys/ioctl.h>
1017 1062
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 575e1fe..ff578d8 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -100,12 +100,13 @@ class ODevice : public QObject {
100private: 100private:
101 ODevice ( const ODevice & ); 101 ODevice ( const ODevice & );
102 102
103protected: 103protected:
104 ODevice ( ); 104 ODevice ( );
105 virtual void init ( ); 105 virtual void init ( );
106 virtual void initButtons ( );
106 107
107 ODeviceData *d; 108 ODeviceData *d;
108 109
109public: 110public:
110 virtual ~ODevice ( ); 111 virtual ~ODevice ( );
111 112
@@ -154,13 +155,13 @@ public:
154 /** 155 /**
155 * Returns the available buttons on this device. The number and location 156 * Returns the available buttons on this device. The number and location
156 * of buttons will vary depending on the device. Button numbers will be assigned 157 * of buttons will vary depending on the device. Button numbers will be assigned
157 * by the device manufacturer and will be from most preferred button to least preffered 158 * by the device manufacturer and will be from most preferred button to least preffered
158 * button. Note that this list only contains "user mappable" buttons. 159 * button. Note that this list only contains "user mappable" buttons.
159 */ 160 */
160 const QValueList<ODeviceButton> &buttons ( ) const; 161 const QValueList<ODeviceButton> &buttons ( );
161 162
162 /** 163 /**
163 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 164 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
164 * returns 0L 165 * returns 0L
165 */ 166 */
166 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 167 const ODeviceButton *buttonForKeycode ( ushort keyCode );