author | zecke <zecke> | 2004-02-19 20:29:53 (UTC) |
---|---|---|
committer | zecke <zecke> | 2004-02-19 20:29:53 (UTC) |
commit | f6f89c9fad356f91f1ad63402757335f7fb4fed2 (patch) (side-by-side diff) | |
tree | 9646358fb1b6bdec12fa29971936cbe63ad8f06b | |
parent | c2eb77f6b8933b02bd8bd59ec7325da0bfc956cb (diff) | |
download | opie-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
-rw-r--r-- | libopie/odevice.cpp | 82 | ||||
-rw-r--r-- | libopie/odevice.h | 24 |
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 @@ -66,24 +66,25 @@ public: QString m_systemstr; OSystem m_system; QString m_sysverstr; Transformation m_rotation; ODirection m_direction; QValueList <ODeviceButton> *m_buttons; uint m_holdtime; QStrList *m_cpu_frequencies; + }; 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; @@ -131,39 +132,40 @@ public: virtual bool setDisplayBrightness ( int b ); virtual int displayBrightnessResolution ( ) const; virtual void alarmSound ( ); virtual void keySound ( ); virtual void touchSound ( ); 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 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 { protected: virtual void init ( ); virtual void initButtons ( ); public: virtual bool setSoftSuspend ( bool soft ); virtual bool suspend(); virtual bool setDisplayStatus( bool on ); @@ -719,33 +721,39 @@ OSystem ODevice::system ( ) const * @return the version string of the base system */ QString ODevice::systemVersionString ( ) const { return d-> m_sysverstr; } /** * @return the current Transformation */ Transformation ODevice::rotation ( ) const { - return d-> m_rotation; + VirtRotation rot; + ODevice* that =(ODevice* )this; + that->virtual_hook( VIRTUAL_ROTATION, &rot ); + return rot.trans; } /** * @return the current rotation direction */ ODirection ODevice::direction ( ) const { - return d-> m_direction; + VirtDirection dir; + ODevice* that =(ODevice* )this; + that->virtual_hook( VIRTUAL_DIRECTION, &dir ); + return dir.direct; } /** * This plays an alarmSound */ void ODevice::alarmSound ( ) { #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); if ( snd. isFinished ( )) snd. play ( ); @@ -837,33 +845,38 @@ int ODevice::readLightSensor ( ) * @return the light sensor resolution */ int ODevice::lightSensorResolution ( ) const { return 0; } /** * @return if the device has a hinge sensor */ bool ODevice::hasHingeSensor ( ) const { - return false; + VirtHasHinge hing; + ODevice* that =(ODevice* )this; + that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); + return hing.hasHinge; } /** * @return a value from the hinge sensor */ OHingeStatus ODevice::readHingeSensor ( ) { - return CASE_UNKNOWN; + VirtHingeStatus hing; + virtual_hook( VIRTUAL_HINGE, &hing ); + return hing.hingeStat; } /** * @return a list with CPU frequencies supported by the hardware */ const QStrList &ODevice::allowedCpuFrequencies ( ) const { return *d->m_cpu_frequencies; } /** @@ -994,26 +1007,47 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 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 ( ))); 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; + } + } } /************************************************** * * Yopy 3500/3700 * **************************************************/ bool Yopy::isYopy ( ) { QFile f( "/proc/cpuinfo" ); if ( f. open ( IO_ReadOnly ) ) { @@ -2144,24 +2178,52 @@ OHingeStatus Zaurus::readHingeSensor() qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); return static_cast<OHingeStatus>( retval ); } else { qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); return CASE_UNKNOWN; } } } +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 * **************************************************/ void SIMpad::init ( ) { d-> m_vendorstr = "SIEMENS"; d-> m_vendor = Vendor_SIEMENS; QFile f ( "/proc/hal/model" ); diff --git a/libopie/odevice.h b/libopie/odevice.h index 791d358..fc41079 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h @@ -185,26 +185,26 @@ public: QString modelString ( ) const; OModel model ( ) const; inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } QString vendorString ( ) const; OVendor vendor ( ) const; QString systemString ( ) const; OSystem system ( ) const; QString systemVersionString ( ) const; - virtual Transformation rotation ( ) const; - virtual ODirection direction ( ) 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; @@ -220,26 +220,26 @@ public: virtual void keySound ( ); virtual void touchSound ( ); 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 ( ); + /*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 * 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. * * @todo ### make const */ @@ -269,18 +269,34 @@ public: uint buttonHoldTime ( ) const; signals: void buttonMappingChanged ( ); private slots: void systemMessage ( const QCString &, const QByteArray & ); 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; + }; }; } #endif |