summaryrefslogtreecommitdiff
path: root/libopie
authorsandman <sandman>2003-03-26 23:53:14 (UTC)
committer sandman <sandman>2003-03-26 23:53:14 (UTC)
commit9d291e88efa5b33bbf34112cdee8b0e516150dd6 (patch) (side-by-side diff)
tree6059b942d98691d7882d5290d5aa854b187f13ce /libopie
parenteda6fffbe8ad7e3635985d9b2a8f7b46964aa271 (diff)
downloadopie-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
Diffstat (limited to 'libopie') (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:
OSystem m_system;
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 );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution ( ) const;
@@ -103,12 +104,13 @@ protected:
OLedState m_leds [2];
};
class Zaurus : public ODevice {
protected:
virtual void init ( );
+ virtual void initButtons ( );
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution ( ) const;
@@ -251,42 +253,53 @@ ODevice::ODevice ( )
d-> m_systemstr = "Unknown";
d-> m_system = System_Unknown;
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 & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping ( );
}
}
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;
if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
b. setKeycode ( ib-> code );
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 ( )
{
delete d;
}
@@ -471,37 +484,43 @@ int ODevice::readLightSensor ( )
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
{
return d-> m_holdtime;
}
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;
QByteArray pdata, hdata;
@@ -521,19 +540,20 @@ void ODevice::reloadButtonMapping ( )
b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
}
}
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 ( );
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
@@ -544,16 +564,18 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
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 ));
buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
@@ -625,32 +647,44 @@ 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;
if (( ib-> model & d-> m_model ) == d-> m_model ) {
b. setKeycode ( ib-> code );
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 ( );
+ 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 */
unsigned char TotalTime; /* Units of 5 seconds */
unsigned char OnTime; /* units of 100m/s */
@@ -990,28 +1024,39 @@ void Zaurus::init ( )
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
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;
b. setKeycode ( zb-> code );
b. setUserText ( QObject::tr ( "Button", zb-> utext ));
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>
#include <sys/ioctl.h>
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 {
private:
ODevice ( const ODevice & );
protected:
ODevice ( );
virtual void init ( );
+ virtual void initButtons ( );
ODeviceData *d;
public:
virtual ~ODevice ( );
@@ -154,13 +155,13 @@ public:
/**
* Returns the available buttons on this device. The number and location
* 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
*/
const ODeviceButton *buttonForKeycode ( ushort keyCode );