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) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp112
-rw-r--r--libopie/odevice.h24
2 files changed, 107 insertions, 29 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c5a916b..c5342e1 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -72,12 +72,13 @@ public:
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 ( );
@@ -137,27 +138,28 @@ public:
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 ( );
@@ -441,13 +443,13 @@ static inline bool isQWS()
}
ODevice *ODevice::inst ( )
{
static ODevice *dev = 0;
- if ( !dev ) {
+ if ( !dev ) {
if ( QFile::exists ( "/proc/hal/model" ))
dev = new iPAQ ( );
else if ( Zaurus::isZaurus() )
dev = new Zaurus ( );
else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
dev = new SIMpad ( );
@@ -725,21 +727,27 @@ QString ODevice::systemVersionString ( ) const
/**
* @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 ( )
@@ -843,21 +851,26 @@ int ODevice::lightSensorResolution ( ) const
/**
* @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
@@ -1000,14 +1013,35 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
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
*
@@ -1037,16 +1071,16 @@ void Yopy::init ( )
{
d-> m_vendorstr = "G.Mate";
d-> m_vendor = Vendor_GMate;
d-> m_modelstr = "Yopy3700";
d-> m_model = Model_Yopy_3700;
d-> m_rotation = Rot0;
-
+
d-> m_systemstr = "Linupy";
d-> m_system = System_Linupy;
-
+
QFile f ( "/etc/issue" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
ts.readLine();
d-> m_sysverstr = ts. readLine ( );
f. close ( );
@@ -1060,13 +1094,13 @@ void Yopy::initButtons ( )
d-> m_buttons = new QValueList <ODeviceButton>;
for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
yopy_button *ib = yopy_buttons + i;
-
+
ODeviceButton b;
b. setKeycode ( ib-> code );
b. setUserText ( QObject::tr ( "Button", ib-> utext ));
b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
b. setFactoryPresetPressedAction
@@ -1074,22 +1108,22 @@ void Yopy::initButtons ( )
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 & )),
+ connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
this, SLOT(systemMessage(const QCString &, const QByteArray & )));
}
bool Yopy::suspend()
{
- /* Opie for Yopy does not implement its own power management at the
- moment. The public version runs parallel to X, and relies on the
+ /* Opie for Yopy does not implement its own power management at the
+ moment. The public version runs parallel to X, and relies on the
existing power management features. */
return false;
}
bool Yopy::setDisplayBrightness(int bright)
{
@@ -1540,13 +1574,13 @@ int iPAQ::lightSensorResolution ( ) const
bool Zaurus::isZaurus()
{
// If the special devices by embedix exist, it is quite simple: it is a Zaurus !
if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
return true;
- }
+ }
// On non-embedix kernels, we have to look closer.
bool is_zaurus = false;
QFile f ( "/proc/cpuinfo" );
if ( f. open ( IO_ReadOnly ) ) {
QString model;
@@ -1818,13 +1852,13 @@ void Zaurus::buzzer ( int sound )
if ( !soundname.isEmpty() ){
int fd;
int vol;
bool vol_reset = false;
Sound snd ( soundname );
-
+
if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
Config cfg ( "qpe" );
cfg. setGroup ( "Volume" );
int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
@@ -1845,21 +1879,21 @@ void Zaurus::buzzer ( int sound )
if ( fd >= 0 ) {
if ( vol_reset )
::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
::close ( fd );
}
- } else {
+ } else {
int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
-
+
if ( fd >= 0 ) {
::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
::close ( fd );
}
- }
+ }
#endif
}
void Zaurus::alarmSound ( )
{
@@ -2063,15 +2097,15 @@ Transformation Zaurus::rotation ( ) const
if (handle == -1) {
return Rot270;
} else {
retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
::close (handle);
- if (retval == 2 )
+ if (retval == 2 )
rot = Rot0;
- else
+ else
rot = Rot270;
}
break;
case Model_Zaurus_SLA300:
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
@@ -2150,12 +2184,40 @@ OHingeStatus Zaurus::readHingeSensor()
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
*
**************************************************/
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 791d358..fc41079 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -191,14 +191,14 @@ public:
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 ( );
@@ -226,14 +226,14 @@ public:
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
@@ -275,12 +275,28 @@ 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