summaryrefslogtreecommitdiff
authorzecke <zecke>2004-02-19 20:29:53 (UTC)
committer zecke <zecke>2004-02-19 20:29:53 (UTC)
commitf6f89c9fad356f91f1ad63402757335f7fb4fed2 (patch) (side-by-side diff)
tree9646358fb1b6bdec12fa29971936cbe63ad8f06b
parentc2eb77f6b8933b02bd8bd59ec7325da0bfc956cb (diff)
downloadopie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.zip
opie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.tar.gz
opie-f6f89c9fad356f91f1ad63402757335f7fb4fed2.tar.bz2
Restore binary compatibility and make use of the virtual_hook
Yeah it is ugly... but will work for libopie... Now onto libopie2! development
Diffstat (more/less context) (show whitespace changes)
-rw-r--r--libopie/odevice.cpp82
-rw-r--r--libopie/odevice.h24
2 files changed, 92 insertions, 14 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c5a916b..c5342e1 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -75,6 +75,7 @@ public:
QValueList <ODeviceButton> *m_buttons;
uint m_holdtime;
QStrList *m_cpu_frequencies;
+
};
class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
@@ -140,21 +141,22 @@ public:
virtual OLedState ledState ( OLed led ) const;
virtual bool setLedState ( OLed led, OLedState st );
- virtual bool hasHingeSensor() const;
- virtual OHingeStatus readHingeSensor();
+ bool hasHingeSensor() const;
+ OHingeStatus readHingeSensor();
static bool isZaurus();
// Does this break BC?
virtual bool suspend ( );
- virtual Transformation rotation ( ) const;
- virtual ODirection direction ( ) const;
+ Transformation rotation ( ) const;
+ ODirection direction ( ) const;
protected:
virtual void buzzer ( int snd );
OLedState m_leds [1];
bool m_embedix;
+ void virtual_hook( int id, void *data );
};
class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
@@ -728,7 +730,10 @@ QString ODevice::systemVersionString ( ) const
*/
Transformation ODevice::rotation ( ) const
{
- return d-> m_rotation;
+ VirtRotation rot;
+ ODevice* that =(ODevice* )this;
+ that->virtual_hook( VIRTUAL_ROTATION, &rot );
+ return rot.trans;
}
/**
@@ -736,7 +741,10 @@ Transformation ODevice::rotation ( ) const
*/
ODirection ODevice::direction ( ) const
{
- return d-> m_direction;
+ VirtDirection dir;
+ ODevice* that =(ODevice* )this;
+ that->virtual_hook( VIRTUAL_DIRECTION, &dir );
+ return dir.direct;
}
/**
@@ -846,7 +854,10 @@ int ODevice::lightSensorResolution ( ) const
*/
bool ODevice::hasHingeSensor ( ) const
{
- return false;
+ VirtHasHinge hing;
+ ODevice* that =(ODevice* )this;
+ that->virtual_hook( VIRTUAL_HAS_HINGE, &hing );
+ return hing.hasHinge;
}
/**
@@ -854,7 +865,9 @@ bool ODevice::hasHingeSensor ( ) const
*/
OHingeStatus ODevice::readHingeSensor ( )
{
- return CASE_UNKNOWN;
+ VirtHingeStatus hing;
+ virtual_hook( VIRTUAL_HINGE, &hing );
+ return hing.hingeStat;
}
/**
@@ -1003,8 +1016,29 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
}
-void ODevice::virtual_hook(int, void* ){
-
+void ODevice::virtual_hook(int id, void* data){
+ switch( id ) {
+ case VIRTUAL_ROTATION:{
+ VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
+ rot->trans = d->m_rotation;
+ break;
+ }
+ case VIRTUAL_DIRECTION:{
+ VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
+ dir->direct = d->m_direction;
+ break;
+ }
+ case VIRTUAL_HAS_HINGE:{
+ VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
+ hin->hasHinge = false;
+ break;
+ }
+ case VIRTUAL_HINGE:{
+ VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
+ hin->hingeStat = CASE_UNKNOWN;
+ break;
+ }
+ }
}
/**************************************************
@@ -2153,6 +2187,34 @@ OHingeStatus Zaurus::readHingeSensor()
}
+void Zaurus::virtual_hook( int id, void *data ) {
+ switch( id ) {
+ case VIRTUAL_ROTATION:{
+ VirtRotation* rot = reinterpret_cast<VirtRotation*>( data );
+ rot->trans = rotation();
+ break;
+ }
+ case VIRTUAL_DIRECTION:{
+ VirtDirection *dir = reinterpret_cast<VirtDirection*>( data );
+ dir->direct = direction();
+ break;
+ }
+ case VIRTUAL_HAS_HINGE:{
+ VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data );
+ hin->hasHinge = hasHingeSensor();
+ break;
+ }
+ case VIRTUAL_HINGE:{
+ VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data );
+ hin->hingeStat = readHingeSensor();
+ break;
+ }
+ default:
+ ODevice::virtual_hook( id, data );
+ break;
+ }
+}
+
/**************************************************
*
* SIMpad
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 791d358..fc41079 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -194,8 +194,8 @@ public:
QString systemVersionString ( ) const;
- virtual Transformation rotation ( ) const;
- virtual ODirection direction ( ) const;
+ /*virtual*/ Transformation rotation ( ) const;
+ /*virtual*/ ODirection direction ( ) const;
// system
@@ -229,8 +229,8 @@ public:
virtual int readLightSensor ( );
virtual int lightSensorResolution ( ) const;
- virtual bool hasHingeSensor ( ) const;
- virtual OHingeStatus readHingeSensor ( );
+ /*virtual*/ bool hasHingeSensor ( ) const;
+ /*virtual*/ OHingeStatus readHingeSensor ( );
const QStrList &allowedCpuFrequencies() const;
bool setCurrentCpuFrequency(uint index);
@@ -278,6 +278,22 @@ protected:
void reloadButtonMapping ( );
/* ugly virtual hook */
virtual void virtual_hook( int id, void* data );
+
+protected:
+ enum { VIRTUAL_ROTATION = 0x200, VIRTUAL_DIRECTION,
+ VIRTUAL_HAS_HINGE, VIRTUAL_HINGE };
+ struct VirtRotation {
+ Transformation trans;
+ };
+ struct VirtDirection {
+ ODirection direct;
+ };
+ struct VirtHasHinge {
+ bool hasHinge;
+ };
+ struct VirtHingeStatus {
+ OHingeStatus hingeStat;
+ };
};
}