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) (unidiff)
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
@@ -546,18 +546,10 @@ Transformation Zaurus::rotation() const
546 switch ( d->m_model ) { 546 switch ( d->m_model ) {
547 case Model_Zaurus_SLC3000: // fallthrough 547 case Model_Zaurus_SLC3000: // fallthrough
548 case Model_Zaurus_SLC7x0: 548 case Model_Zaurus_SLC7x0:
549 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 549 OHingeStatus hs = readHingeSensor();
550 if (handle == -1) { 550 if ( hs == CASE_PORTRAIT ) rot = Rot0;
551 return Rot270; 551 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
552 } else { 552 else rot = Rot270;
553 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
554 ::close (handle);
555
556 if (retval == 2 )
557 rot = Rot0;
558 else
559 rot = Rot270;
560 }
561 break; 553 break;
562 case Model_Zaurus_SL6000: 554 case Model_Zaurus_SL6000:
563 case Model_Zaurus_SLB600: 555 case Model_Zaurus_SLB600:
@@ -579,17 +571,10 @@ ODirection Zaurus::direction() const
579 switch ( d->m_model ) { 571 switch ( d->m_model ) {
580 case Model_Zaurus_SLC3000: // fallthrough 572 case Model_Zaurus_SLC3000: // fallthrough
581 case Model_Zaurus_SLC7x0: 573 case Model_Zaurus_SLC7x0:
582 handle = ::open( "/dev/apm_bios", O_RDWR|O_NONBLOCK ); 574 OHingeStatus hs = readHingeSensor();
583 if (handle == -1) { 575 if ( hs == CASE_PORTRAIT ) dir = CCW;
584 dir = CW; 576 else if ( hs == CASE_UNKNOWN ) dir = CCW;
585 } else { 577 else dir = CW;
586 retval = ::ioctl( handle, SHARP_IOCTL_GET_ROTATION );
587 ::close (handle);
588 if (retval == 2 )
589 dir = CCW;
590 else
591 dir = CW;
592 }
593 break; 578 break;
594 case Model_Zaurus_SL6000: 579 case Model_Zaurus_SL6000:
595 case Model_Zaurus_SLA300: 580 case Model_Zaurus_SLA300:
@@ -608,7 +593,7 @@ bool Zaurus::hasHingeSensor() const
608 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; 593 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
609} 594}
610 595
611OHingeStatus Zaurus::readHingeSensor() 596OHingeStatus Zaurus::readHingeSensor() const
612{ 597{
613 if (m_embedix) 598 if (m_embedix)
614 { 599 {
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
@@ -110,7 +110,7 @@ class Zaurus : public ODevice
110 virtual bool setLedState( OLed led, OLedState st ); 110 virtual bool setLedState( OLed led, OLedState st );
111 111
112 virtual bool hasHingeSensor() const; 112 virtual bool hasHingeSensor() const;
113 virtual OHingeStatus readHingeSensor(); 113 virtual OHingeStatus readHingeSensor() const;
114 114
115 virtual bool suspend(); 115 virtual bool suspend();
116 virtual Transformation rotation() const; 116 virtual Transformation rotation() const;