summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp57
-rw-r--r--libopie2/opiecore/device/odevice.h49
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp3
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp3
-rw-r--r--libopie2/opiecore/okeyfilter.h7
5 files changed, 63 insertions, 56 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index 0068d88..cd3a84c 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,71 +1,72 @@
/*
-                 This file is part of the Opie Project
-              Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ This file is part of the Opie Project
+ Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
-    : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
- :     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+ .>+-=
+_;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+- . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+: = ...= . :.=-
+-. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#include "odevice_ipaq.h"
#include "odevice_jornada.h"
#include "odevice_ramses.h"
#include "odevice_simpad.h"
#include "odevice_yopy.h"
#include "odevice_zaurus.h"
/* QT */
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qwindowsystem_qws.h>
/* OPIE */
#include <qpe/config.h>
#include <qpe/resource.h>
#include <qpe/sound.h>
#include <qpe/qcopenvelope_qws.h>
+#include <opie2/okeyfilter.h>
/* STD */
#include <fcntl.h>
#include <math.h>
#include <stdlib.h>
#include <signal.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <unistd.h>
#ifndef QT_NO_SOUND
#include <linux/soundcard.h>
#endif
namespace Opie {
namespace Core {
static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
/* STATIC and common implementation */
/* EXPORT */ ODistribution distributions[] = {
{ System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
{ System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
{ System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
@@ -655,63 +656,73 @@ 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())
return;
ODeviceButton &b = ( *d->m_buttons ) [button];
b. setPressedAction ( action );
mb_chan=b. pressedAction(). channel();
Config buttonFile ( "ButtonSettings" );
buttonFile. setGroup ( "Button" + QString::number ( button ));
buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
-// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
+// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
{
initButtons();
if ( button >= (int) d->m_buttons->count())
return;
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());
-// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
+// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
void ODevice::virtual_hook(int, void* ){
}
void ODevice::sendSuspendmsg()
{
if ( isQWS() )
return;
QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
}
+void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
+{
+ Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
+}
+
+void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
+{
+ Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
+}
+
}
}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index 0465d7e..762d3f1 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,65 +1,66 @@
/*
-                 This file is part of the Opie Project
-              Copyright (C) The Opie Team <opie-devel@handhelds.org>
+ This file is part of the Opie Project
+ Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
-           .>+-=
- _;:,     .>    :=|. This program is free software; you can
-.> <`_,   >  .   <= redistribute it and/or modify it under
-:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
-.="- .-=="i,     .._ License as published by the Free Software
- - .   .-<_>     .<> Foundation; either version 2 of the License,
-     ._= =}       : or (at your option) any later version.
-    .%`+i>       _;_.
-    .i_,=:_.      -<s. This program is distributed in the hope that
-     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
-    : ..    .:,     . . . without even the implied warranty of
-    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
-  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
-..}^=.=       =       ; Library General Public License for more
-++=   -.     .`     .: details.
- :     =  ...= . :.=-
- -.   .:....=;==+<; You should have received a copy of the GNU
-  -_. . .   )=.  = Library General Public License along with
-    --        :-=` this library; see the file COPYING.LIB.
+ .>+-=
+_;:, .> :=|. This program is free software; you can
+.> <`_, > . <= redistribute it and/or modify it under
+:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
+.="- .-=="i, .._ License as published by the Free Software
+- . .-<_> .<> Foundation; either version 2 of the License,
+ ._= =} : or (at your option) any later version.
+ .%`+i> _;_.
+ .i_,=:_. -<s. This program is distributed in the hope that
+ + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
+ : .. .:, . . . without even the implied warranty of
+ =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
+ _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
+..}^=.= = ; Library General Public License for more
+++= -. .` .: details.
+: = ...= . :.=-
+-. .:....=;==+<; You should have received a copy of the GNU
+ -_. . . )=. = Library General Public License along with
+ -- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_H_
#define ODEVICE_H_
/* OPIE */
#include <opie2/odevicebutton.h>
#include <qpe/qpeapplication.h> /* for Transformation enum.. */
/* QT */
#include <qnamespace.h>
#include <qobject.h>
#include <qstring.h>
#include <qstrlist.h>
+#include <qwindowsystem_qws.h>
namespace Opie{
namespace Core{
class ODeviceData;
/**
* The available devices
*/
enum OModel {
Model_Unknown, // = 0
Model_Series_Mask = 0xff000000,
Model_iPAQ = ( 1 << 24 ),
Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
@@ -232,51 +233,51 @@ public:
QString vendorString() const;
OVendor vendor() const;
QString systemString() const;
OSystem system() const;
QString systemVersionString() const;
virtual Transformation rotation() const;
virtual ODirection direction() const;
// system
virtual bool setSoftSuspend ( bool on );
virtual bool suspend();
virtual bool setDisplayStatus ( bool on );
virtual bool setDisplayBrightness ( int brightness );
virtual int displayBrightnessResolution() const;
virtual bool setDisplayContrast ( int contrast );
virtual int displayContrastResolution() const;
// don't add new virtual methods, use this:
- // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
+ // /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
// and in your subclass do do overwrite
- // protected virtual int virtual_hook(int, void *)
+ // protected virtual int virtual_hook(int, void *)
// which is defined below
// input / output
virtual void playAlarmSound();
virtual void playKeySound();
virtual void playTouchSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState ( OLed led ) const;
virtual bool setLedState ( OLed led, OLedState st );
virtual bool hasLightSensor() const;
virtual int readLightSensor();
virtual int lightSensorResolution() const;
virtual bool hasHingeSensor() const;
virtual OHingeStatus readHingeSensor();
const QStrList &allowedCpuFrequencies() const;
bool setCurrentCpuFrequency(uint index);
/**
* Returns the available buttons on this device. The number and location
@@ -298,48 +299,50 @@ public:
/**
* Reassigns the pressed action for \a button. To return to the factory
* default pass an empty string as \a qcopMessage.
*/
void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
/**
* Reassigns the held action for \a button. To return to the factory
* default pass an empty string as \a qcopMessage.
*/
void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
/**
* How long (in ms) you have to press a button for a "hold" action
*/
uint buttonHoldTime() const;
signals:
void buttonMappingChanged();
private slots:
void systemMessage ( const QCString &, const QByteArray & );
protected:
+ void addPreHandler(QWSServer::KeyboardFilter*aFilter);
+ void remPreHandler(QWSServer::KeyboardFilter*aFilter);
void reloadButtonMapping();
/* ugly virtual hook */
virtual void virtual_hook( int id, void* data );
};
class ODeviceData {
public:
QString m_vendorstr;
OVendor m_vendor;
QString m_modelstr;
OModel m_model;
QString m_systemstr;
OSystem m_system;
QString m_sysverstr;
Transformation m_rotation;
ODirection m_direction;
QValueList <ODeviceButton> *m_buttons;
uint m_holdtime;
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 791e409..21fed99 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -148,50 +148,49 @@ void iPAQ::init(const QString& model)
case Model_iPAQ_H22xx:
d->m_rotation = Rot0;
break;
case Model_iPAQ_H36xx:
case Model_iPAQ_H37xx:
case Model_iPAQ_H39xx:
default:
d->m_rotation = Rot270;
break;
}
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void iPAQ::initButtons()
{
if ( d->m_buttons )
return;
if ( isQWS( ) ) {
- Opie::Core::OKeyFilter::inst()->addPreHandler(this);
- //QWSServer::setKeyboardFilter ( this );
+ addPreHandler(this);
}
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 );
}
}
reloadButtonMapping();
QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&)));
}
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index 6c3253c..bf46e43 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -126,50 +126,49 @@ void SIMpad::init(const QString&)
d->m_model = Model_SIMpad_SL4;
switch ( d->m_model ) {
default:
d->m_rotation = Rot0;
d->m_direction = CCW;
d->m_holdtime = 1000; // 1000ms
break;
}
//Distribution detecting code is now in base class
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
}
void SIMpad::initButtons()
{
if ( d->m_buttons )
return;
if ( isQWS( ) ) {
- Opie::Core::OKeyFilter::inst()->addPreHandler(this);
-// QWSServer::setKeyboardFilter ( this );
+ addPreHandler(this);
}
d->m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
s_button *sb = simpad_buttons + i;
ODeviceButton b;
if (( sb->model & d->m_model ) == d->m_model ) {
b. setKeycode ( sb->code );
b. setUserText ( QObject::tr ( "Button", sb->utext ));
b. setPixmap ( Resource::loadPixmap ( sb->pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb->fpressedservice ), sb->fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb->fheldservice ), sb->fheldaction ));
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&)));
}
diff --git a/libopie2/opiecore/okeyfilter.h b/libopie2/opiecore/okeyfilter.h
index a65bc48..d183641 100644
--- a/libopie2/opiecore/okeyfilter.h
+++ b/libopie2/opiecore/okeyfilter.h
@@ -12,67 +12,62 @@ _;:, .> :=|. This program is free software; you can
.%`+i> _;_.
.i_,=:_. -<s. This program is distributed in the hope that
+ . -:. = it will be useful, but WITHOUT ANY WARRANTY;
: .. .:, . . . without even the implied warranty of
=_ + =;=|` MERCHANTABILITY or FITNESS FOR A
_.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.= = ; Library General Public License for more
++= -. .` .: details.
: = ...= . :.=-
-. .:....=;==+<; You should have received a copy of the GNU
-_. . . )=. = Library General Public License along with
-- :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
/* QT */
#include <qwindowsystem_qws.h>
#include <qvaluelist.h>
namespace Opie {
namespace Core {
class ODevice;
-namespace Internal {
- class iPAQ;
- class SIMpad;
-}
+
/**
* A singleton which will manage all possible keyboard filters inside opie.
* It makes sure that key handlers of odevice are checked first than the
* keyfilters of software.
* @short a keyfilter proxy
* @see QWSServer::KeyboardFilter
* @author Rajko Albrecht
* @version 1.0
*/
class OKeyFilter
{
friend class Opie::Core::ODevice;
- friend class Opie::Core::Internal::iPAQ;
- friend class Opie::Core::Internal::SIMpad;
protected:
/**
* Protected constructor - generate class via inst()
* @see inst()
*/
OKeyFilter();
/**
* Protected constructor - generate class via inst()
* @see inst()
*/
OKeyFilter(const OKeyFilter&){};
/**
* Append filter to the primary list.
* This is only allowed for friend classes from odevice
* @param aFilter a filter to append
* @see addHandler
*/
virtual void addPreHandler(QWSServer::KeyboardFilter*aFilter)=0;
/**
* Remove the specified filter from list and give back ownership.
* This is only allowed for friend classes from odevice
* @param aFilter a filter to remove
* @see remHandler