summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp136
-rw-r--r--libopie/odevice.h14
2 files changed, 113 insertions, 37 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index e24e043..bc09e92 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -95,99 +95,102 @@ public:
95 virtual OLedState ledState ( OLed led ) const; 95 virtual OLedState ledState ( OLed led ) const;
96 virtual bool setLedState ( OLed led, OLedState st ); 96 virtual bool setLedState ( OLed led, OLedState st );
97 97
98 virtual bool hasLightSensor ( ) const; 98 virtual bool hasLightSensor ( ) const;
99 virtual int readLightSensor ( ); 99 virtual int readLightSensor ( );
100 virtual int lightSensorResolution ( ) const; 100 virtual int lightSensorResolution ( ) const;
101 101
102protected: 102protected:
103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
104 virtual void timerEvent ( QTimerEvent *te ); 104 virtual void timerEvent ( QTimerEvent *te );
105 105
106 int m_power_timer; 106 int m_power_timer;
107 107
108 OLedState m_leds [2]; 108 OLedState m_leds [2];
109}; 109};
110 110
111class Jornada : public ODevice { 111class Jornada : public ODevice {
112protected: 112protected:
113 virtual void init ( ); 113 virtual void init ( );
114 //virtual void initButtons ( ); 114 //virtual void initButtons ( );
115public: 115public:
116 virtual bool setSoftSuspend ( bool soft ); 116 virtual bool setSoftSuspend ( bool soft );
117 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
119 static bool isJornada(); 119 static bool isJornada();
120 120
121}; 121};
122 122
123class Zaurus : public ODevice { 123class Zaurus : public ODevice {
124protected: 124protected:
125 virtual void init ( ); 125 virtual void init ( );
126 virtual void initButtons ( ); 126 virtual void initButtons ( );
127 127
128public: 128public:
129 virtual bool setSoftSuspend ( bool soft ); 129 virtual bool setSoftSuspend ( bool soft );
130 130
131 virtual bool setDisplayBrightness ( int b ); 131 virtual bool setDisplayBrightness ( int b );
132 virtual int displayBrightnessResolution ( ) const; 132 virtual int displayBrightnessResolution ( ) const;
133 133
134 virtual void alarmSound ( ); 134 virtual void alarmSound ( );
135 virtual void keySound ( ); 135 virtual void keySound ( );
136 virtual void touchSound ( ); 136 virtual void touchSound ( );
137 137
138 virtual QValueList <OLed> ledList ( ) const; 138 virtual QValueList <OLed> ledList ( ) const;
139 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 139 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
140 virtual OLedState ledState ( OLed led ) const; 140 virtual OLedState ledState ( OLed led ) const;
141 virtual bool setLedState ( OLed led, OLedState st ); 141 virtual bool setLedState ( OLed led, OLedState st );
142 142
143 virtual bool hasHingeSensor() const;
144 virtual OHingeStatus readHingeSensor();
145
143 static bool isZaurus(); 146 static bool isZaurus();
144 147
145 // Does this break BC? 148 // Does this break BC?
146 virtual bool suspend ( ); 149 virtual bool suspend ( );
147 virtual Transformation rotation ( ) const; 150 virtual Transformation rotation ( ) const;
148 virtual ODirection direction ( ) const; 151 virtual ODirection direction ( ) const;
149 152
150protected: 153protected:
151 virtual void buzzer ( int snd ); 154 virtual void buzzer ( int snd );
152 155
153 OLedState m_leds [1]; 156 OLedState m_leds [1];
154 bool m_embedix; 157 bool m_embedix;
155}; 158};
156 159
157class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 160class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
158protected: 161protected:
159 virtual void init ( ); 162 virtual void init ( );
160 virtual void initButtons ( ); 163 virtual void initButtons ( );
161 164
162public: 165public:
163 virtual bool setSoftSuspend ( bool soft ); 166 virtual bool setSoftSuspend ( bool soft );
164 virtual bool suspend(); 167 virtual bool suspend();
165 168
166 virtual bool setDisplayStatus( bool on ); 169 virtual bool setDisplayStatus( bool on );
167 virtual bool setDisplayBrightness ( int b ); 170 virtual bool setDisplayBrightness ( int b );
168 virtual int displayBrightnessResolution ( ) const; 171 virtual int displayBrightnessResolution ( ) const;
169 172
170 virtual void alarmSound ( ); 173 virtual void alarmSound ( );
171 174
172 virtual QValueList <OLed> ledList ( ) const; 175 virtual QValueList <OLed> ledList ( ) const;
173 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 176 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
174 virtual OLedState ledState ( OLed led ) const; 177 virtual OLedState ledState ( OLed led ) const;
175 virtual bool setLedState ( OLed led, OLedState st ); 178 virtual bool setLedState ( OLed led, OLedState st );
176 179
177protected: 180protected:
178 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 181 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
179 virtual void timerEvent ( QTimerEvent *te ); 182 virtual void timerEvent ( QTimerEvent *te );
180 183
181 int m_power_timer; 184 int m_power_timer;
182 185
183 OLedState m_leds [1]; //FIXME check if really only one 186 OLedState m_leds [1]; //FIXME check if really only one
184}; 187};
185 188
186class Ramses : public ODevice, public QWSServer::KeyboardFilter { 189class Ramses : public ODevice, public QWSServer::KeyboardFilter {
187protected: 190protected:
188 virtual void init ( ); 191 virtual void init ( );
189 192
190public: 193public:
191 virtual bool setSoftSuspend ( bool soft ); 194 virtual bool setSoftSuspend ( bool soft );
192 virtual bool suspend ( ); 195 virtual bool suspend ( );
193 196
@@ -488,97 +491,97 @@ ODevice::ODevice ( )
488 d-> m_cpu_frequencies = new QStrList; 491 d-> m_cpu_frequencies = new QStrList;
489} 492}
490 493
491void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 494void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
492{ 495{
493 if ( msg == "deviceButtonMappingChanged()" ) { 496 if ( msg == "deviceButtonMappingChanged()" ) {
494 reloadButtonMapping ( ); 497 reloadButtonMapping ( );
495 } 498 }
496} 499}
497 500
498void ODevice::init ( ) 501void ODevice::init ( )
499{ 502{
500} 503}
501 504
502/** 505/**
503 * This method initialises the button mapping 506 * This method initialises the button mapping
504 */ 507 */
505void ODevice::initButtons ( ) 508void ODevice::initButtons ( )
506{ 509{
507 if ( d-> m_buttons ) 510 if ( d-> m_buttons )
508 return; 511 return;
509 512
510 // Simulation uses iPAQ 3660 device buttons 513 // Simulation uses iPAQ 3660 device buttons
511 514
512 qDebug ( "init Buttons" ); 515 qDebug ( "init Buttons" );
513 d-> m_buttons = new QValueList <ODeviceButton>; 516 d-> m_buttons = new QValueList <ODeviceButton>;
514 517
515 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 518 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
516 i_button *ib = ipaq_buttons + i; 519 i_button *ib = ipaq_buttons + i;
517 ODeviceButton b; 520 ODeviceButton b;
518 521
519 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 522 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
520 b. setKeycode ( ib-> code ); 523 b. setKeycode ( ib-> code );
521 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 524 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
522 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 525 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
523 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 526 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
524 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 527 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
525 d-> m_buttons-> append ( b ); 528 d-> m_buttons-> append ( b );
526 } 529 }
527 } 530 }
528 reloadButtonMapping ( ); 531 reloadButtonMapping ( );
529 532
530 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 533 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
531 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 534 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
532} 535}
533 536
534ODevice::~ODevice ( ) 537ODevice::~ODevice ( )
535{ 538{
536// we leak m_devicebuttons and m_cpu_frequency 539// we leak m_devicebuttons and m_cpu_frequency
537// but it's a singleton and it is not so importantant 540// but it's a singleton and it is not so importantant
538// -zecke 541// -zecke
539 delete d; 542 delete d;
540} 543}
541 544
542bool ODevice::setSoftSuspend ( bool /*soft*/ ) 545bool ODevice::setSoftSuspend ( bool /*soft*/ )
543{ 546{
544 return false; 547 return false;
545} 548}
546 549
547//#include <linux/apm_bios.h> 550//#include <linux/apm_bios.h>
548 551
549#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 552#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
550 553
551/** 554/**
552 * This method will try to suspend the device 555 * This method will try to suspend the device
553 * It only works if the user is the QWS Server and the apm application 556 * It only works if the user is the QWS Server and the apm application
554 * is installed. 557 * is installed.
555 * It tries to suspend and then waits some time cause some distributions 558 * It tries to suspend and then waits some time cause some distributions
556 * do have asynchronus apm implementations. 559 * do have asynchronus apm implementations.
557 * This method will either fail and return false or it'll suspend the 560 * This method will either fail and return false or it'll suspend the
558 * device and return once the device got woken up 561 * device and return once the device got woken up
559 * 562 *
560 * @return if the device got suspended 563 * @return if the device got suspended
561 */ 564 */
562bool ODevice::suspend ( ) 565bool ODevice::suspend ( )
563{ 566{
564 qDebug("ODevice::suspend"); 567 qDebug("ODevice::suspend");
565 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 568 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
566 return false; 569 return false;
567 570
568 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 571 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
569 return false; 572 return false;
570 573
571 bool res = false; 574 bool res = false;
572 575
573 struct timeval tvs, tvn; 576 struct timeval tvs, tvn;
574 ::gettimeofday ( &tvs, 0 ); 577 ::gettimeofday ( &tvs, 0 );
575 578
576 ::sync ( ); // flush fs caches 579 ::sync ( ); // flush fs caches
577 res = ( ::system ( "apm --suspend" ) == 0 ); 580 res = ( ::system ( "apm --suspend" ) == 0 );
578 581
579 // This is needed because the iPAQ apm implementation is asynchronous and we 582 // This is needed because the iPAQ apm implementation is asynchronous and we
580 // can not be sure when exactly the device is really suspended 583 // can not be sure when exactly the device is really suspended
581 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 584 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
582 585
583 if ( res ) { 586 if ( res ) {
584 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 587 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
@@ -778,123 +781,139 @@ void ODevice::touchSound ( )
778/** 781/**
779 * This method will return a list of leds 782 * This method will return a list of leds
780 * available on this device 783 * available on this device
781 * @return a list of LEDs. 784 * @return a list of LEDs.
782 */ 785 */
783QValueList <OLed> ODevice::ledList ( ) const 786QValueList <OLed> ODevice::ledList ( ) const
784{ 787{
785 return QValueList <OLed> ( ); 788 return QValueList <OLed> ( );
786} 789}
787 790
788/** 791/**
789 * This does return the state of the LEDs 792 * This does return the state of the LEDs
790 */ 793 */
791QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 794QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
792{ 795{
793 return QValueList <OLedState> ( ); 796 return QValueList <OLedState> ( );
794} 797}
795 798
796/** 799/**
797 * @return the state for a given OLed 800 * @return the state for a given OLed
798 */ 801 */
799OLedState ODevice::ledState ( OLed /*which*/ ) const 802OLedState ODevice::ledState ( OLed /*which*/ ) const
800{ 803{
801 return Led_Off; 804 return Led_Off;
802} 805}
803 806
804/** 807/**
805 * Set the state for a LED 808 * Set the state for a LED
806 * @param which Which OLed to use 809 * @param which Which OLed to use
807 * @param st The state to set 810 * @param st The state to set
808 * @return success or failure 811 * @return success or failure
809 */ 812 */
810bool ODevice::setLedState ( OLed which, OLedState st ) 813bool ODevice::setLedState ( OLed which, OLedState st )
811{ 814{
812 Q_UNUSED( which ) 815 Q_UNUSED( which )
813 Q_UNUSED( st ) 816 Q_UNUSED( st )
814 return false; 817 return false;
815} 818}
816 819
817/** 820/**
818 * @return if the device has a light sensor 821 * @return if the device has a light sensor
819 */ 822 */
820bool ODevice::hasLightSensor ( ) const 823bool ODevice::hasLightSensor ( ) const
821{ 824{
822 return false; 825 return false;
823} 826}
824 827
825/** 828/**
826 * @return a value from the light senso 829 * @return a value from the light sensor
827 */ 830 */
828int ODevice::readLightSensor ( ) 831int ODevice::readLightSensor ( )
829{ 832{
830 return -1; 833 return -1;
831} 834}
832 835
833/** 836/**
834 * @return the light sensor resolution whatever that is ;) 837 * @return the light sensor resolution
835 */ 838 */
836int ODevice::lightSensorResolution ( ) const 839int ODevice::lightSensorResolution ( ) const
837{ 840{
838 return 0; 841 return 0;
839} 842}
840 843
841/** 844/**
845 * @return if the device has a hinge sensor
846 */
847bool ODevice::hasHingeSensor ( ) const
848{
849 return false;
850}
851
852/**
853 * @return a value from the hinge sensor
854 */
855OHingeStatus ODevice::readHingeSensor ( )
856{
857 return CASE_UNKNOWN;
858}
859
860/**
842 * @return a list with CPU frequencies supported by the hardware 861 * @return a list with CPU frequencies supported by the hardware
843 */ 862 */
844const QStrList &ODevice::allowedCpuFrequencies ( ) const 863const QStrList &ODevice::allowedCpuFrequencies ( ) const
845{ 864{
846 return *d->m_cpu_frequencies; 865 return *d->m_cpu_frequencies;
847} 866}
848 867
849 868
850/** 869/**
851 * Set desired CPU frequency 870 * Set desired CPU frequency
852 * 871 *
853 * @param index index into d->m_cpu_frequencies of the frequency to be set 872 * @param index index into d->m_cpu_frequencies of the frequency to be set
854 */ 873 */
855bool ODevice::setCurrentCpuFrequency(uint index) 874bool ODevice::setCurrentCpuFrequency(uint index)
856{ 875{
857 if (index >= d->m_cpu_frequencies->count()) 876 if (index >= d->m_cpu_frequencies->count())
858 return false; 877 return false;
859 878
860 char *freq = d->m_cpu_frequencies->at(index); 879 char *freq = d->m_cpu_frequencies->at(index);
861 qWarning("set freq to %s", freq); 880 qWarning("set freq to %s", freq);
862 881
863 int fd; 882 int fd;
864 883
865 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 884 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
866 char writeCommand[50]; 885 char writeCommand[50];
867 const int count = sprintf(writeCommand, "%s\n", freq); 886 const int count = sprintf(writeCommand, "%s\n", freq);
868 int res = (::write(fd, writeCommand, count) != -1); 887 int res = (::write(fd, writeCommand, count) != -1);
869 ::close(fd); 888 ::close(fd);
870 return res; 889 return res;
871 } 890 }
872 891
873 return false; 892 return false;
874} 893}
875 894
876 895
877/** 896/**
878 * @return a list of hardware buttons 897 * @return a list of hardware buttons
879 */ 898 */
880const QValueList <ODeviceButton> &ODevice::buttons ( ) 899const QValueList <ODeviceButton> &ODevice::buttons ( )
881{ 900{
882 initButtons ( ); 901 initButtons ( );
883 902
884 return *d-> m_buttons; 903 return *d-> m_buttons;
885} 904}
886 905
887/** 906/**
888 * @return The amount of time that would count as a hold 907 * @return The amount of time that would count as a hold
889 */ 908 */
890uint ODevice::buttonHoldTime ( ) const 909uint ODevice::buttonHoldTime ( ) const
891{ 910{
892 return d-> m_holdtime; 911 return d-> m_holdtime;
893} 912}
894 913
895/** 914/**
896 * This method return a ODeviceButton for a key code 915 * This method return a ODeviceButton for a key code
897 * or 0 if no special hardware button is available for the device 916 * or 0 if no special hardware button is available for the device
898 * 917 *
899 * @return The devicebutton or 0l 918 * @return The devicebutton or 0l
900 * @see ODeviceButton 919 * @see ODeviceButton
@@ -1737,97 +1756,97 @@ void Zaurus::initButtons ( )
1737// 1756//
1738 1757
1739 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1758 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1740#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1759#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1741 1760
1742#define SHARP_IOCTL_GET_ROTATION 0x413c 1761#define SHARP_IOCTL_GET_ROTATION 0x413c
1743 1762
1744typedef struct sharp_led_status { 1763typedef struct sharp_led_status {
1745 int which; /* select which LED status is wanted. */ 1764 int which; /* select which LED status is wanted. */
1746 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1765 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1747} sharp_led_status; 1766} sharp_led_status;
1748 1767
1749#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1768#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1750 1769
1751#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1770#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1752#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1771#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1753#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1772#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1754 1773
1755// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1774// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1756 1775
1757#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1776#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1758#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1777#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1759#define APM_EVT_POWER_BUTTON (1 << 0) 1778#define APM_EVT_POWER_BUTTON (1 << 0)
1760 1779
1761#define FL_IOCTL_STEP_CONTRAST 100 1780#define FL_IOCTL_STEP_CONTRAST 100
1762 1781
1763 1782
1764void Zaurus::buzzer ( int sound ) 1783void Zaurus::buzzer ( int sound )
1765{ 1784{
1766#ifndef QT_NO_SOUND 1785#ifndef QT_NO_SOUND
1767 QString soundname; 1786 QString soundname;
1768 1787
1769 // Not all devices have real sound 1788 // Not all devices have real sound
1770 if ( d->m_model == Model_Zaurus_SLC7x0 1789 if ( d->m_model == Model_Zaurus_SLC7x0
1771 || d->m_model == Model_Zaurus_SLB600 ){ 1790 || d->m_model == Model_Zaurus_SLB600 ){
1772 1791
1773 switch ( sound ){ 1792 switch ( sound ){
1774 case SHARP_BUZ_SCHEDULE_ALARM: 1793 case SHARP_BUZ_SCHEDULE_ALARM:
1775 soundname = "alarm"; 1794 soundname = "alarm";
1776 break; 1795 break;
1777 case SHARP_BUZ_TOUCHSOUND: 1796 case SHARP_BUZ_TOUCHSOUND:
1778 soundname = "touchsound"; 1797 soundname = "touchsound";
1779 break; 1798 break;
1780 case SHARP_BUZ_KEYSOUND: 1799 case SHARP_BUZ_KEYSOUND:
1781 soundname = "keysound"; 1800 soundname = "keysound";
1782 break; 1801 break;
1783 default: 1802 default:
1784 soundname = "alarm"; 1803 soundname = "alarm";
1785 1804
1786 } 1805 }
1787 } 1806 }
1788 1807
1789 // If a soundname is defined, we expect that this device has 1808 // If a soundname is defined, we expect that this device has
1790 // sound capabilities.. Otherwise we expect to have the buzzer 1809 // sound capabilities.. Otherwise we expect to have the buzzer
1791 // device.. 1810 // device..
1792 if ( !soundname.isEmpty() ){ 1811 if ( !soundname.isEmpty() ){
1793 int fd; 1812 int fd;
1794 int vol; 1813 int vol;
1795 bool vol_reset = false; 1814 bool vol_reset = false;
1796 1815
1797 Sound snd ( soundname ); 1816 Sound snd ( soundname );
1798 1817
1799 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1818 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1800 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1819 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1801 Config cfg ( "qpe" ); 1820 Config cfg ( "qpe" );
1802 cfg. setGroup ( "Volume" ); 1821 cfg. setGroup ( "Volume" );
1803 1822
1804 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1823 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1805 if ( volalarm < 0 ) 1824 if ( volalarm < 0 )
1806 volalarm = 0; 1825 volalarm = 0;
1807 else if ( volalarm > 100 ) 1826 else if ( volalarm > 100 )
1808 volalarm = 100; 1827 volalarm = 100;
1809 volalarm |= ( volalarm << 8 ); 1828 volalarm |= ( volalarm << 8 );
1810 1829
1811 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1830 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1812 vol_reset = true; 1831 vol_reset = true;
1813 } 1832 }
1814 } 1833 }
1815 1834
1816 snd. play ( ); 1835 snd. play ( );
1817 while ( !snd. isFinished ( )) 1836 while ( !snd. isFinished ( ))
1818 qApp-> processEvents ( ); 1837 qApp-> processEvents ( );
1819 1838
1820 if ( fd >= 0 ) { 1839 if ( fd >= 0 ) {
1821 if ( vol_reset ) 1840 if ( vol_reset )
1822 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1841 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1823 ::close ( fd ); 1842 ::close ( fd );
1824 } 1843 }
1825 } else { 1844 } else {
1826 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1845 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1827 1846
1828 if ( fd >= 0 ) { 1847 if ( fd >= 0 ) {
1829 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1848 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1830 ::close ( fd ); 1849 ::close ( fd );
1831 } 1850 }
1832 1851
1833 } 1852 }
@@ -1900,123 +1919,139 @@ bool Zaurus::setLedState ( OLed which, OLedState st )
1900 m_leds [0] = st; 1919 m_leds [0] = st;
1901 return true; 1920 return true;
1902 } 1921 }
1903 } 1922 }
1904 } 1923 }
1905 return false; 1924 return false;
1906} 1925}
1907 1926
1908bool Zaurus::setSoftSuspend ( bool soft ) 1927bool Zaurus::setSoftSuspend ( bool soft )
1909{ 1928{
1910 if (!m_embedix) { 1929 if (!m_embedix) {
1911 /* non-Embedix kernels dont have kernel autosuspend */ 1930 /* non-Embedix kernels dont have kernel autosuspend */
1912 return ODevice::setSoftSuspend( soft ); 1931 return ODevice::setSoftSuspend( soft );
1913 } 1932 }
1914 1933
1915 bool res = false; 1934 bool res = false;
1916 int fd; 1935 int fd;
1917 1936
1918 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1937 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1919 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1938 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1920 1939
1921 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1940 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1922 1941
1923 if ( sources >= 0 ) { 1942 if ( sources >= 0 ) {
1924 if ( soft ) 1943 if ( soft )
1925 sources &= ~APM_EVT_POWER_BUTTON; 1944 sources &= ~APM_EVT_POWER_BUTTON;
1926 else 1945 else
1927 sources |= APM_EVT_POWER_BUTTON; 1946 sources |= APM_EVT_POWER_BUTTON;
1928 1947
1929 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1948 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1930 res = true; 1949 res = true;
1931 else 1950 else
1932 perror ( "APM_IOCGEVTSRC" ); 1951 perror ( "APM_IOCGEVTSRC" );
1933 } 1952 }
1934 else 1953 else
1935 perror ( "APM_IOCGEVTSRC" ); 1954 perror ( "APM_IOCGEVTSRC" );
1936 1955
1937 ::close ( fd ); 1956 ::close ( fd );
1938 } 1957 }
1939 else 1958 else
1940 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1959 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1941 1960
1942 return res; 1961 return res;
1943} 1962}
1944 1963
1945 1964
1946bool Zaurus::setDisplayBrightness ( int bright ) 1965bool Zaurus::setDisplayBrightness ( int bright )
1947{ 1966{
1948// FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which 1967 bool res = false;
1949// is nice to use. Currently it exposes 16+1 levels. Implement this! 1968 int fd;
1950// (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) 1969
1951 bool res = false; 1970 if ( bright > 255 ) bright = 255;
1952 int fd; 1971 if ( bright < 0 ) bright = 0;
1953 1972
1954 if ( bright > 255 ) 1973 if ( m_embedix )
1955 bright = 255; 1974 {
1956 if ( bright < 0 ) 1975 if ( d->m_model == Model_Zaurus_SLC7x0 )
1957 bright = 0; 1976 {
1958 1977 // special treatment for devices with the corgi backlight interface
1959 if (m_embedix) { 1978 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
1960 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1979 {
1961 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1980 if ( bright > 0x11 ) bright = 0x11;
1962 if ( bright && !bl ) 1981 char writeCommand[100];
1963 bl = 1; 1982 const int count = sprintf( writeCommand, "0x%x\n", bright );
1964 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1983 res = ( ::write ( fd, writeCommand, count ) != -1 );
1965 ::close ( fd ); 1984 ::close ( fd );
1966 } 1985 }
1967 } else { 1986 return res;
1968#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 1987 }
1969 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 1988 else
1970 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 1989 {
1971 ::close ( fd ); 1990 // standard treatment for devices with the dumb embedix frontlight interface
1972 } 1991 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1973 } 1992 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1974 return res; 1993 if ( bright && !bl )
1994 bl = 1;
1995 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1996 ::close ( fd );
1997 }
1998 }
1999 }
2000 else
2001 {
2002 // special treatment for the OpenZaurus unified interface
2003 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
2004 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
2005 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
2006 ::close ( fd );
2007 }
2008 }
2009 return res;
1975} 2010}
1976 2011
1977bool Zaurus::suspend ( ) 2012bool Zaurus::suspend ( )
1978{ 2013{
1979 qDebug("ODevice::suspend"); 2014 qDebug("ODevice::suspend");
1980 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2015 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1981 return false; 2016 return false;
1982 2017
1983 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 2018 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
1984 return false; 2019 return false;
1985 2020
1986 bool res = false; 2021 bool res = false;
1987 2022
1988 struct timeval tvs, tvn; 2023 struct timeval tvs, tvn;
1989 ::gettimeofday ( &tvs, 0 ); 2024 ::gettimeofday ( &tvs, 0 );
1990 2025
1991 ::sync ( ); // flush fs caches 2026 ::sync ( ); // flush fs caches
1992 res = ( ::system ( "apm --suspend" ) == 0 ); 2027 res = ( ::system ( "apm --suspend" ) == 0 );
1993 2028
1994 // This is needed because the iPAQ apm implementation is asynchronous and we 2029 // This is needed because the iPAQ apm implementation is asynchronous and we
1995 // can not be sure when exactly the device is really suspended 2030 // can not be sure when exactly the device is really suspended
1996 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 2031 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
1997 2032
1998 if ( res ) { 2033 if ( res ) {
1999 do { // Yes, wait 15 seconds. This APM bug sucks big time. 2034 do { // Yes, wait 15 seconds. This APM bug sucks big time.
2000 ::usleep ( 200 * 1000 ); 2035 ::usleep ( 200 * 1000 );
2001 ::gettimeofday ( &tvn, 0 ); 2036 ::gettimeofday ( &tvn, 0 );
2002 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 2037 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
2003 } 2038 }
2004 2039
2005 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 2040 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
2006 return res; 2041 return res;
2007} 2042}
2008 2043
2009 2044
2010Transformation Zaurus::rotation ( ) const 2045Transformation Zaurus::rotation ( ) const
2011{ 2046{
2012 Transformation rot; 2047 Transformation rot;
2013 int handle = 0; 2048 int handle = 0;
2014 int retval = 0; 2049 int retval = 0;
2015 2050
2016 switch ( d-> m_model ) { 2051 switch ( d-> m_model ) {
2017 case Model_Zaurus_SLC7x0: 2052 case Model_Zaurus_SLC7x0:
2018 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2053 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2019 if (handle == -1) { 2054 if (handle == -1) {
2020 return Rot270; 2055 return Rot270;
2021 } else { 2056 } else {
2022 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2057 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
@@ -2028,101 +2063,132 @@ Transformation Zaurus::rotation ( ) const
2028 rot = Rot270; 2063 rot = Rot270;
2029 } 2064 }
2030 break; 2065 break;
2031 case Model_Zaurus_SLA300: 2066 case Model_Zaurus_SLA300:
2032 case Model_Zaurus_SLB600: 2067 case Model_Zaurus_SLB600:
2033 case Model_Zaurus_SL5500: 2068 case Model_Zaurus_SL5500:
2034 case Model_Zaurus_SL5000: 2069 case Model_Zaurus_SL5000:
2035 default: 2070 default:
2036 rot = d-> m_rotation; 2071 rot = d-> m_rotation;
2037 break; 2072 break;
2038 } 2073 }
2039 2074
2040 return rot; 2075 return rot;
2041} 2076}
2042ODirection Zaurus::direction ( ) const 2077ODirection Zaurus::direction ( ) const
2043{ 2078{
2044 ODirection dir; 2079 ODirection dir;
2045 int handle = 0; 2080 int handle = 0;
2046 int retval = 0; 2081 int retval = 0;
2047 switch ( d-> m_model ) { 2082 switch ( d-> m_model ) {
2048 case Model_Zaurus_SLC7x0: 2083 case Model_Zaurus_SLC7x0:
2049 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2084 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2050 if (handle == -1) { 2085 if (handle == -1) {
2051 dir = CW; 2086 dir = CW;
2052 } else { 2087 } else {
2053 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2088 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2054 ::close (handle); 2089 ::close (handle);
2055 if (retval == 2 ) 2090 if (retval == 2 )
2056 dir = CCW; 2091 dir = CCW;
2057 else 2092 else
2058 dir = CW; 2093 dir = CW;
2059 } 2094 }
2060 break; 2095 break;
2061 case Model_Zaurus_SLA300: 2096 case Model_Zaurus_SLA300:
2062 case Model_Zaurus_SLB600: 2097 case Model_Zaurus_SLB600:
2063 case Model_Zaurus_SL5500: 2098 case Model_Zaurus_SL5500:
2064 case Model_Zaurus_SL5000: 2099 case Model_Zaurus_SL5000:
2065 default: 2100 default:
2066 dir = d-> m_direction; 2101 dir = d-> m_direction;
2067 break; 2102 break;
2068 } 2103 }
2069 return dir; 2104 return dir;
2070 2105
2071} 2106}
2072 2107
2073int Zaurus::displayBrightnessResolution ( ) const 2108int Zaurus::displayBrightnessResolution ( ) const
2074{ 2109{
2075 if (m_embedix) 2110 if (m_embedix)
2076 return 5; 2111 return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5;
2077 else 2112 else
2078 return 256; 2113 return 256;
2079} 2114}
2080 2115
2116bool Zaurus::hasHingeSensor() const
2117{
2118 return d->m_model == Model_Zaurus_SLC7x0;
2119}
2120
2121OHingeStatus Zaurus::readHingeSensor()
2122{
2123 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2124 if (handle == -1)
2125 {
2126 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
2127 return CASE_UNKNOWN;
2128 }
2129 else
2130 {
2131 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2132 ::close (handle);
2133 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
2134 {
2135 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
2136 return static_cast<OHingeStatus>( retval );
2137 }
2138 else
2139 {
2140 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
2141 return CASE_UNKNOWN;
2142 }
2143 }
2144}
2145
2146
2081/************************************************** 2147/**************************************************
2082 * 2148 *
2083 * SIMpad 2149 * SIMpad
2084 * 2150 *
2085 **************************************************/ 2151 **************************************************/
2086 2152
2087void SIMpad::init ( ) 2153void SIMpad::init ( )
2088{ 2154{
2089 d-> m_vendorstr = "SIEMENS"; 2155 d-> m_vendorstr = "SIEMENS";
2090 d-> m_vendor = Vendor_SIEMENS; 2156 d-> m_vendor = Vendor_SIEMENS;
2091 2157
2092 QFile f ( "/proc/hal/model" ); 2158 QFile f ( "/proc/hal/model" );
2093 2159
2094 //TODO Implement model checking 2160 //TODO Implement model checking
2095 //FIXME For now we assume an SL4 2161 //FIXME For now we assume an SL4
2096 2162
2097 d-> m_modelstr = "SL4"; 2163 d-> m_modelstr = "SL4";
2098 d-> m_model = Model_SIMpad_SL4; 2164 d-> m_model = Model_SIMpad_SL4;
2099 2165
2100 switch ( d-> m_model ) { 2166 switch ( d-> m_model ) {
2101 default: 2167 default:
2102 d-> m_rotation = Rot0; 2168 d-> m_rotation = Rot0;
2103 d-> m_direction = CCW; 2169 d-> m_direction = CCW;
2104 d-> m_holdtime = 1000; // 1000ms 2170 d-> m_holdtime = 1000; // 1000ms
2105 2171
2106 break; 2172 break;
2107 } 2173 }
2108 2174
2109 f. setName ( "/etc/familiar-version" ); 2175 f. setName ( "/etc/familiar-version" );
2110 if ( f. open ( IO_ReadOnly )) { 2176 if ( f. open ( IO_ReadOnly )) {
2111 d-> m_systemstr = "Familiar"; 2177 d-> m_systemstr = "Familiar";
2112 d-> m_system = System_Familiar; 2178 d-> m_system = System_Familiar;
2113 2179
2114 QTextStream ts ( &f ); 2180 QTextStream ts ( &f );
2115 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 2181 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
2116 2182
2117 f. close ( ); 2183 f. close ( );
2118 } else { 2184 } else {
2119 f. setName ( "/etc/oz_version" ); 2185 f. setName ( "/etc/oz_version" );
2120 2186
2121 if ( f. open ( IO_ReadOnly )) { 2187 if ( f. open ( IO_ReadOnly )) {
2122 d-> m_systemstr = "OpenEmbedded/SIMpad"; 2188 d-> m_systemstr = "OpenEmbedded/SIMpad";
2123 d-> m_system = System_OpenZaurus; 2189 d-> m_system = System_OpenZaurus;
2124 2190
2125 QTextStream ts ( &f ); 2191 QTextStream ts ( &f );
2126 ts.setDevice ( &f ); 2192 ts.setDevice ( &f );
2127 d-> m_sysverstr = ts. readLine ( ); 2193 d-> m_sysverstr = ts. readLine ( );
2128 f. close ( ); 2194 f. close ( );
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 8273761..ee0b0ec 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -98,175 +98,185 @@ enum OVendor {
98 Vendor_GMate, 98 Vendor_GMate,
99}; 99};
100 100
101/** 101/**
102 * The System used 102 * The System used
103 */ 103 */
104enum OSystem { 104enum OSystem {
105 System_Unknown, 105 System_Unknown,
106 106
107 System_Familiar, 107 System_Familiar,
108 System_Zaurus, 108 System_Zaurus,
109 System_OpenZaurus, 109 System_OpenZaurus,
110 System_Linupy, 110 System_Linupy,
111}; 111};
112 112
113enum OLedState { 113enum OLedState {
114 Led_Off, 114 Led_Off,
115 Led_On, 115 Led_On,
116 Led_BlinkSlow, 116 Led_BlinkSlow,
117 Led_BlinkFast 117 Led_BlinkFast
118}; 118};
119 119
120enum OLed { 120enum OLed {
121 Led_Mail, 121 Led_Mail,
122 Led_Power, 122 Led_Power,
123 Led_BlueTooth 123 Led_BlueTooth
124}; 124};
125 125
126enum OHardKey { 126enum OHardKey {
127 HardKey_Datebook = Qt::Key_F9, 127 HardKey_Datebook = Qt::Key_F9,
128 HardKey_Contacts = Qt::Key_F10, 128 HardKey_Contacts = Qt::Key_F10,
129 HardKey_Menu = Qt::Key_F11, 129 HardKey_Menu = Qt::Key_F11,
130 HardKey_Home = Qt::Key_F12, 130 HardKey_Home = Qt::Key_F12,
131 HardKey_Mail = Qt::Key_F13, 131 HardKey_Mail = Qt::Key_F13,
132 HardKey_Record = Qt::Key_F24, 132 HardKey_Record = Qt::Key_F24,
133 HardKey_Suspend = Qt::Key_F34, 133 HardKey_Suspend = Qt::Key_F34,
134 HardKey_Backlight = Qt::Key_F35, 134 HardKey_Backlight = Qt::Key_F35,
135 HardKey_Action = Qt::Key_F10, 135 HardKey_Action = Qt::Key_F10,
136 HardKey_OK = Qt::Key_F11, 136 HardKey_OK = Qt::Key_F11,
137 HardKey_End = Qt::Key_F12, 137 HardKey_End = Qt::Key_F12,
138}; 138};
139 139
140enum ODirection { 140enum ODirection {
141 CW = 0, 141 CW = 0,
142 CCW = 1, 142 CCW = 1,
143 Flip = 2, 143 Flip = 2,
144}; 144};
145 145
146enum OHingeStatus {
147 CASE_CLOSED = 3,
148 CASE_PORTRAIT = 2,
149 CASE_LANDSCAPE = 0,
150 CASE_UNKNOWN = 1,
151};
152
146/** 153/**
147 * A singleton which gives informations about device specefic option 154 * A singleton which gives informations about device specefic option
148 * like the Hardware used, LEDs, the Base Distribution and 155 * like the Hardware used, LEDs, the Base Distribution and
149 * hardware key mappings. 156 * hardware key mappings.
150 * 157 *
151 * @short A small class for device specefic options 158 * @short A small class for device specefic options
152 * @see QObject 159 * @see QObject
153 * @author Robert Griebl 160 * @author Robert Griebl
154 * @version 1.0 161 * @version 1.0
155 */ 162 */
156class ODevice : public QObject { 163class ODevice : public QObject {
157 Q_OBJECT 164 Q_OBJECT
158 165
159private: 166private:
160 /* disable copy */ 167 /* disable copy */
161 ODevice ( const ODevice & ); 168 ODevice ( const ODevice & );
162 169
163protected: 170protected:
164 ODevice ( ); 171 ODevice ( );
165 virtual void init ( ); 172 virtual void init ( );
166 virtual void initButtons ( ); 173 virtual void initButtons ( );
167 174
168 ODeviceData *d; 175 ODeviceData *d;
169 176
170public: 177public:
171 // sandman do we want to allow destructions? -zecke? 178 // sandman do we want to allow destructions? -zecke?
172 virtual ~ODevice ( ); 179 virtual ~ODevice ( );
173 180
174 static ODevice *inst ( ); 181 static ODevice *inst ( );
175 182
176 // information 183 // information
177 184
178 QString modelString ( ) const; 185 QString modelString ( ) const;
179 OModel model ( ) const; 186 OModel model ( ) const;
180 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 187 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
181 188
182 QString vendorString ( ) const; 189 QString vendorString ( ) const;
183 OVendor vendor ( ) const; 190 OVendor vendor ( ) const;
184 191
185 QString systemString ( ) const; 192 QString systemString ( ) const;
186 OSystem system ( ) const; 193 OSystem system ( ) const;
187 194
188 QString systemVersionString ( ) const; 195 QString systemVersionString ( ) const;
189 196
190 virtual Transformation rotation ( ) const; 197 virtual Transformation rotation ( ) const;
191 virtual ODirection direction ( ) const; 198 virtual ODirection direction ( ) const;
192 199
193// system 200// system
194 201
195 virtual bool setSoftSuspend ( bool on ); 202 virtual bool setSoftSuspend ( bool on );
196 virtual bool suspend ( ); 203 virtual bool suspend ( );
197 204
198 virtual bool setDisplayStatus ( bool on ); 205 virtual bool setDisplayStatus ( bool on );
199 virtual bool setDisplayBrightness ( int brightness ); 206 virtual bool setDisplayBrightness ( int brightness );
200 virtual int displayBrightnessResolution ( ) const; 207 virtual int displayBrightnessResolution ( ) const;
201 virtual bool setDisplayContrast ( int contrast ); 208 virtual bool setDisplayContrast ( int contrast );
202 virtual int displayContrastResolution ( ) const; 209 virtual int displayContrastResolution ( ) const;
203 210
204 // don't add new virtual methods, use this: 211 // don't add new virtual methods, use this:
205 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); }; 212 ///*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
206 // and in your subclass do do overwrite 213 // and in your subclass do do overwrite
207 //protected virtual int virtual_hook(int, void *) 214 //protected virtual int virtual_hook(int, void *)
208 // which is defined below 215 // which is defined below
209 216
210// input / output 217 // input / output
211 //FIXME playAlarmSound and al might be better -zecke 218 //FIXME playAlarmSound and al might be better -zecke
212 virtual void alarmSound ( ); 219 virtual void alarmSound ( );
213 virtual void keySound ( ); 220 virtual void keySound ( );
214 virtual void touchSound ( ); 221 virtual void touchSound ( );
215 222
216 virtual QValueList <OLed> ledList ( ) const; 223 virtual QValueList <OLed> ledList ( ) const;
217 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 224 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
218 virtual OLedState ledState ( OLed led ) const; 225 virtual OLedState ledState ( OLed led ) const;
219 virtual bool setLedState ( OLed led, OLedState st ); 226 virtual bool setLedState ( OLed led, OLedState st );
220 227
221 virtual bool hasLightSensor ( ) const; 228 virtual bool hasLightSensor ( ) const;
222 virtual int readLightSensor ( ); 229 virtual int readLightSensor ( );
223 virtual int lightSensorResolution ( ) const; 230 virtual int lightSensorResolution ( ) const;
224 231
232 virtual bool hasHingeSensor ( ) const;
233 virtual OHingeStatus readHingeSensor ( );
234
225 const QStrList &allowedCpuFrequencies() const; 235 const QStrList &allowedCpuFrequencies() const;
226 bool setCurrentCpuFrequency(uint index); 236 bool setCurrentCpuFrequency(uint index);
227 237
228 /** 238 /**
229 * Returns the available buttons on this device. The number and location 239 * Returns the available buttons on this device. The number and location
230 * of buttons will vary depending on the device. Button numbers will be assigned 240 * of buttons will vary depending on the device. Button numbers will be assigned
231 * by the device manufacturer and will be from most preferred button to least preffered 241 * by the device manufacturer and will be from most preferred button to least preffered
232 * button. Note that this list only contains "user mappable" buttons. 242 * button. Note that this list only contains "user mappable" buttons.
233 */ 243 */
234 const QValueList<ODeviceButton> &buttons ( ) /* ### make const */; 244 const QValueList<ODeviceButton> &buttons ( ) /* ### make const */;
235 245
236 /** 246 /**
237 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 247 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
238 * returns 0L 248 * returns 0L
239 */ 249 */
240 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 250 const ODeviceButton *buttonForKeycode ( ushort keyCode );
241 251
242 /** 252 /**
243 * Reassigns the pressed action for \a button. To return to the factory 253 * Reassigns the pressed action for \a button. To return to the factory
244 * default pass an empty string as \a qcopMessage. 254 * default pass an empty string as \a qcopMessage.
245 */ 255 */
246 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 256 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
247 257
248 /** 258 /**
249 * Reassigns the held action for \a button. To return to the factory 259 * Reassigns the held action for \a button. To return to the factory
250 * default pass an empty string as \a qcopMessage. 260 * default pass an empty string as \a qcopMessage.
251 */ 261 */
252 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 262 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
253 263
254 /** 264 /**
255 * How long (in ms) you have to press a button for a "hold" action 265 * How long (in ms) you have to press a button for a "hold" action
256 */ 266 */
257 uint buttonHoldTime ( ) const; 267 uint buttonHoldTime ( ) const;
258 268
259signals: 269signals:
260 void buttonMappingChanged ( ); 270 void buttonMappingChanged ( );
261 271
262private slots: 272private slots:
263 void systemMessage ( const QCString &, const QByteArray & ); 273 void systemMessage ( const QCString &, const QByteArray & );
264 274
265protected: 275protected:
266 void reloadButtonMapping ( ); 276 void reloadButtonMapping ( );
267 /* ugly virtual hook */ 277 /* ugly virtual hook */
268 virtual void virtual_hook( int id, void* data ); 278 virtual void virtual_hook( int id, void* data );
269}; 279};
270 280
271} 281}
272 282