summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-01-23 20:52:18 (UTC)
committer mickeyl <mickeyl>2005-01-23 20:52:18 (UTC)
commitbe26adf324ea0b723cabcd735b0833e16410ceea (patch) (side-by-side diff)
treed196481a0e503fb61ec8fad05d0835b877c186cc /libopie2
parentab0242ff1bbc40ec8bc38c3cb748a44797ffe3db (diff)
downloadopie-be26adf324ea0b723cabcd735b0833e16410ceea.zip
opie-be26adf324ea0b723cabcd735b0833e16410ceea.tar.gz
opie-be26adf324ea0b723cabcd735b0833e16410ceea.tar.bz2
- consolidate reading hinge sensor into one place
- return proper rotation and direction if hinge sensor not present (like in 2.6 atm.)
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp33
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h2
2 files changed, 10 insertions, 25 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index d3ab63a..b22ee70 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -525,111 +525,96 @@ bool Zaurus::suspend()
// This is needed because the apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
if ( res ) {
do { // Yes, wait 15 seconds. This APM sucks big time.
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
}
QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
return res;
}
Transformation Zaurus::rotation() const
{
Transformation rot;
int handle = 0;
int retval = 0;
switch ( d->m_model ) {
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC7x0:
- handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
- if (handle == -1) {
- return Rot270;
- } else {
- retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
- ::close (handle);
-
- if (retval == 2 )
- rot = Rot0;
- else
- rot = Rot270;
- }
+ OHingeStatus hs = readHingeSensor();
+ if ( hs == CASE_PORTRAIT ) rot = Rot0;
+ else if ( hs == CASE_UNKNOWN ) rot = Rot0;
+ else rot = Rot270;
break;
case Model_Zaurus_SL6000:
case Model_Zaurus_SLB600:
case Model_Zaurus_SLA300:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default:
rot = d->m_rotation;
break;
}
return rot;
}
ODirection Zaurus::direction() const
{
ODirection dir;
int handle = 0;
int retval = 0;
switch ( d->m_model ) {
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC7x0:
- handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK );
- if (handle == -1) {
- dir = CW;
- } else {
- retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION );
- ::close (handle);
- if (retval == 2 )
- dir = CCW;
- else
- dir = CW;
- }
+ OHingeStatus hs = readHingeSensor();
+ if ( hs == CASE_PORTRAIT ) dir = CCW;
+ else if ( hs == CASE_UNKNOWN ) dir = CCW;
+ else dir = CW;
break;
case Model_Zaurus_SL6000:
case Model_Zaurus_SLA300:
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default: dir = d->m_direction;
break;
}
return dir;
}
bool Zaurus::hasHingeSensor() const
{
return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
}
-OHingeStatus Zaurus::readHingeSensor()
+OHingeStatus Zaurus::readHingeSensor() const
{
if (m_embedix)
{
int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
if (handle == -1)
{
qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
return CASE_UNKNOWN;
}
else
{
int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
::close (handle);
if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
{
qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
return static_cast<OHingeStatus>( retval );
}
else
{
qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
return CASE_UNKNOWN;
}
}
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index ed9cf67..c763798 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -89,49 +89,49 @@ namespace Internal {
class Zaurus : public ODevice
{
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
virtual bool setSoftSuspend( bool soft );
virtual bool setDisplayBrightness( int b );
virtual bool setDisplayStatus( bool on );
virtual int displayBrightnessResolution() const;
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 hasHingeSensor() const;
- virtual OHingeStatus readHingeSensor();
+ virtual OHingeStatus readHingeSensor() const;
virtual bool suspend();
virtual Transformation rotation() const;
virtual ODirection direction() const;
protected:
virtual void buzzer( int snd );
OLedState m_leds[1];
bool m_embedix;
};
struct z_button {
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
}
}
}