summaryrefslogtreecommitdiff
Side-by-side diff
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
@@ -67,16 +67,17 @@ public:
QString m_sysverstr;
Transformation m_rotation;
- QValueList <ODeviceButton> m_buttons;
- uint m_holdtime;
+ QValueList <ODeviceButton> *m_buttons;
+ uint m_holdtime;
};
class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
protected:
virtual void init ( );
+ virtual void initButtons ( );
public:
virtual bool setSoftSuspend ( bool soft );
@@ -105,8 +106,9 @@ protected:
class Zaurus : public ODevice {
protected:
virtual void init ( );
+ virtual void initButtons ( );
public:
virtual bool setSoftSuspend ( bool soft );
@@ -253,11 +255,9 @@ ODevice::ODevice ( )
d-> m_sysverstr = "0.0";
d-> m_rotation = Rot0;
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;
}
void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
{
@@ -267,10 +267,20 @@ 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;
ODeviceButton b;
@@ -279,12 +289,15 @@ void ODevice::init ( )
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
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 & )));
}
ODevice::~ODevice ( )
{
@@ -473,11 +486,13 @@ int ODevice::lightSensorResolution ( ) const
{
return 0;
}
-const QValueList <ODeviceButton> &ODevice::buttons ( ) const
+const QValueList <ODeviceButton> &ODevice::buttons ( )
{
- return d-> m_buttons;
+ initButtons ( );
+
+ return *d-> m_buttons;
}
uint ODevice::buttonHoldTime ( ) const
{
@@ -485,21 +500,25 @@ 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);
}
return 0;
}
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 );
QCString pch, hch;
QCString pm, hm;
@@ -523,15 +542,16 @@ 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 );
mb_chan=b. pressedAction ( ). channel ( );
@@ -546,12 +566,14 @@ 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 );
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
@@ -627,8 +649,19 @@ void iPAQ::init ( )
m_leds [0] = m_leds [1] = Led_Off;
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;
ODeviceButton b;
@@ -638,17 +671,18 @@ void iPAQ::init ( )
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
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 ( );
+ 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 ...
typedef struct {
unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
@@ -992,8 +1026,17 @@ void Zaurus::init ( )
default:
d-> m_rotation = Rot270;
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++ ) {
z_button *zb = z_buttons + i;
ODeviceButton b;
@@ -1003,13 +1046,15 @@ void Zaurus::init ( )
b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
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 & )));
}
#include <unistd.h>
#include <fcntl.h>
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 575e1fe..ff578d8 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -102,8 +102,9 @@ private:
protected:
ODevice ( );
virtual void init ( );
+ virtual void initButtons ( );
ODeviceData *d;
public:
@@ -156,9 +157,9 @@ public:
* of buttons will vary depending on the device. Button numbers will be assigned
* by the device manufacturer and will be from most preferred button to least preffered
* button. Note that this list only contains "user mappable" buttons.
*/
- const QValueList<ODeviceButton> &buttons ( ) const;
+ const QValueList<ODeviceButton> &buttons ( );
/**
* Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
* returns 0L