-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 33 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.h | 2 |
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 @@ -543,24 +543,16 @@ Transformation Zaurus::rotation() const 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: @@ -576,23 +568,16 @@ 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: @@ -605,13 +590,13 @@ ODirection Zaurus::direction() const 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) { 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 @@ -107,13 +107,13 @@ class Zaurus : public ODevice 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: |