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
@@ -525,111 +525,96 @@ bool Zaurus::suspend()
525 525
526 // This is needed because the apm implementation is asynchronous and we 526 // This is needed because the apm implementation is asynchronous and we
527 // can not be sure when exactly the device is really suspended 527 // can not be sure when exactly the device is really suspended
528 if ( res ) { 528 if ( res ) {
529 do { // Yes, wait 15 seconds. This APM sucks big time. 529 do { // Yes, wait 15 seconds. This APM sucks big time.
530 ::usleep ( 200 * 1000 ); 530 ::usleep ( 200 * 1000 );
531 ::gettimeofday ( &tvn, 0 ); 531 ::gettimeofday ( &tvn, 0 );
532 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 532 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
533 } 533 }
534 534
535 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 535 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
536 return res; 536 return res;
537} 537}
538 538
539 539
540Transformation Zaurus::rotation() const 540Transformation Zaurus::rotation() const
541{ 541{
542 Transformation rot; 542 Transformation rot;
543 int handle = 0; 543 int handle = 0;
544 int retval = 0; 544 int retval = 0;
545 545
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:
564 case Model_Zaurus_SLA300: 556 case Model_Zaurus_SLA300:
565 case Model_Zaurus_SL5500: 557 case Model_Zaurus_SL5500:
566 case Model_Zaurus_SL5000: 558 case Model_Zaurus_SL5000:
567 default: 559 default:
568 rot = d->m_rotation; 560 rot = d->m_rotation;
569 break; 561 break;
570 } 562 }
571 563
572 return rot; 564 return rot;
573} 565}
574ODirection Zaurus::direction() const 566ODirection Zaurus::direction() const
575{ 567{
576 ODirection dir; 568 ODirection dir;
577 int handle = 0; 569 int handle = 0;
578 int retval = 0; 570 int retval = 0;
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:
596 case Model_Zaurus_SLB600: 581 case Model_Zaurus_SLB600:
597 case Model_Zaurus_SL5500: 582 case Model_Zaurus_SL5500:
598 case Model_Zaurus_SL5000: 583 case Model_Zaurus_SL5000:
599 default: dir = d->m_direction; 584 default: dir = d->m_direction;
600 break; 585 break;
601 } 586 }
602 return dir; 587 return dir;
603 588
604} 589}
605 590
606bool Zaurus::hasHingeSensor() const 591bool Zaurus::hasHingeSensor() const
607{ 592{
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 {
615 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 600 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
616 if (handle == -1) 601 if (handle == -1)
617 { 602 {
618 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 603 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
619 return CASE_UNKNOWN; 604 return CASE_UNKNOWN;
620 } 605 }
621 else 606 else
622 { 607 {
623 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 608 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
624 ::close (handle); 609 ::close (handle);
625 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 610 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
626 { 611 {
627 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 612 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
628 return static_cast<OHingeStatus>( retval ); 613 return static_cast<OHingeStatus>( retval );
629 } 614 }
630 else 615 else
631 { 616 {
632 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 617 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
633 return CASE_UNKNOWN; 618 return CASE_UNKNOWN;
634 } 619 }
635 } 620 }
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 {
89 89
90class Zaurus : public ODevice 90class Zaurus : public ODevice
91{ 91{
92 protected: 92 protected:
93 virtual void init(const QString&); 93 virtual void init(const QString&);
94 virtual void initButtons(); 94 virtual void initButtons();
95 95
96 public: 96 public:
97 virtual bool setSoftSuspend( bool soft ); 97 virtual bool setSoftSuspend( bool soft );
98 98
99 virtual bool setDisplayBrightness( int b ); 99 virtual bool setDisplayBrightness( int b );
100 virtual bool setDisplayStatus( bool on ); 100 virtual bool setDisplayStatus( bool on );
101 virtual int displayBrightnessResolution() const; 101 virtual int displayBrightnessResolution() const;
102 102
103 virtual void playAlarmSound(); 103 virtual void playAlarmSound();
104 virtual void playKeySound(); 104 virtual void playKeySound();
105 virtual void playTouchSound(); 105 virtual void playTouchSound();
106 106
107 virtual QValueList <OLed> ledList() const; 107 virtual QValueList <OLed> ledList() const;
108 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 108 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
109 virtual OLedState ledState( OLed led ) const; 109 virtual OLedState ledState( OLed led ) const;
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;
117 virtual ODirection direction() const; 117 virtual ODirection direction() const;
118 118
119 protected: 119 protected:
120 virtual void buzzer( int snd ); 120 virtual void buzzer( int snd );
121 121
122 OLedState m_leds[1]; 122 OLedState m_leds[1];
123 bool m_embedix; 123 bool m_embedix;
124}; 124};
125 125
126struct z_button { 126struct z_button {
127 Qt::Key code; 127 Qt::Key code;
128 char *utext; 128 char *utext;
129 char *pix; 129 char *pix;
130 char *fpressedservice; 130 char *fpressedservice;
131 char *fpressedaction; 131 char *fpressedaction;
132 char *fheldservice; 132 char *fheldservice;
133 char *fheldaction; 133 char *fheldaction;
134}; 134};
135} 135}
136} 136}
137} 137}