-rw-r--r-- | libopie/odevice.cpp | 8 | ||||
-rw-r--r-- | libopie/odevice.h | 2 |
2 files changed, 3 insertions, 7 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index f93d1ed..a3c30cb 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -92,129 +92,129 @@ public: | |||
92 | virtual int readLightSensor ( ); | 92 | virtual int readLightSensor ( ); |
93 | virtual int lightSensorResolution ( ) const; | 93 | virtual int lightSensorResolution ( ) const; |
94 | 94 | ||
95 | protected: | 95 | protected: |
96 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 96 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
97 | virtual void timerEvent ( QTimerEvent *te ); | 97 | virtual void timerEvent ( QTimerEvent *te ); |
98 | 98 | ||
99 | int m_power_timer; | 99 | int m_power_timer; |
100 | 100 | ||
101 | OLedState m_leds [2]; | 101 | OLedState m_leds [2]; |
102 | }; | 102 | }; |
103 | 103 | ||
104 | class Zaurus : public ODevice { | 104 | class Zaurus : public ODevice { |
105 | protected: | 105 | protected: |
106 | virtual void init ( ); | 106 | virtual void init ( ); |
107 | 107 | ||
108 | public: | 108 | public: |
109 | virtual bool setSoftSuspend ( bool soft ); | 109 | virtual bool setSoftSuspend ( bool soft ); |
110 | 110 | ||
111 | virtual bool setDisplayBrightness ( int b ); | 111 | virtual bool setDisplayBrightness ( int b ); |
112 | virtual int displayBrightnessResolution ( ) const; | 112 | virtual int displayBrightnessResolution ( ) const; |
113 | 113 | ||
114 | virtual void alarmSound ( ); | 114 | virtual void alarmSound ( ); |
115 | virtual void keySound ( ); | 115 | virtual void keySound ( ); |
116 | virtual void touchSound ( ); | 116 | virtual void touchSound ( ); |
117 | 117 | ||
118 | virtual QValueList <OLed> ledList ( ) const; | 118 | virtual QValueList <OLed> ledList ( ) const; |
119 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 119 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
120 | virtual OLedState ledState ( OLed led ) const; | 120 | virtual OLedState ledState ( OLed led ) const; |
121 | virtual bool setLedState ( OLed led, OLedState st ); | 121 | virtual bool setLedState ( OLed led, OLedState st ); |
122 | 122 | ||
123 | protected: | 123 | protected: |
124 | virtual void buzzer ( int snd ); | 124 | virtual void buzzer ( int snd ); |
125 | 125 | ||
126 | OLedState m_leds [1]; | 126 | OLedState m_leds [1]; |
127 | }; | 127 | }; |
128 | 128 | ||
129 | 129 | ||
130 | struct i_button { | 130 | struct i_button { |
131 | uint model; | 131 | uint model; |
132 | Qt::Key code; | 132 | Qt::Key code; |
133 | char *utext; | 133 | char *utext; |
134 | char *pix; | 134 | char *pix; |
135 | char *fpressedservice; | 135 | char *fpressedservice; |
136 | char *fpressedaction; | 136 | char *fpressedaction; |
137 | char *fheldservice; | 137 | char *fheldservice; |
138 | char *fheldaction; | 138 | char *fheldaction; |
139 | } ipaq_buttons [] = { | 139 | } ipaq_buttons [] = { |
140 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 140 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
141 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 141 | Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
142 | "devicebuttons/ipaq_calendar", | 142 | "devicebuttons/ipaq_calendar", |
143 | "datebook", "nextView()", | 143 | "datebook", "nextView()", |
144 | "today", "raise()" }, | 144 | "today", "raise()" }, |
145 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 145 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
146 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 146 | Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
147 | "devicebuttons/ipaq_contact", | 147 | "devicebuttons/ipaq_contact", |
148 | "addressbook", "raise()", | 148 | "addressbook", "raise()", |
149 | "addressbook", "beamBusinessCard()" }, | 149 | "addressbook", "beamBusinessCard()" }, |
150 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, | 150 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, |
151 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 151 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
152 | "devicebuttons/ipaq_menu", | 152 | "devicebuttons/ipaq_menu", |
153 | "QPE/TaskBar", "toggleMenu()", | 153 | "QPE/TaskBar", "toggleMenu()", |
154 | "QPE/TaskBar", "toggleStartMenu()" }, | 154 | "QPE/TaskBar", "toggleStartMenu()" }, |
155 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 155 | { Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
156 | Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 156 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
157 | "devicebuttons/ipaq_mail", | 157 | "devicebuttons/ipaq_mail", |
158 | "mail", "raise()", | 158 | "mail", "raise()", |
159 | "mail", "newMail()" }, | 159 | "mail", "newMail()" }, |
160 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 160 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
161 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 161 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
162 | "devicebuttons/ipaq_home", | 162 | "devicebuttons/ipaq_home", |
163 | "QPE/Launcher", "home()", | 163 | "QPE/Launcher", "home()", |
164 | "buttonsettings", "raise()" }, | 164 | "buttonsettings", "raise()" }, |
165 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, | 165 | { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, |
166 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), | 166 | Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), |
167 | "devicebuttons/ipaq_record", | 167 | "devicebuttons/ipaq_record", |
168 | "QPE/VMemo", "toggleRecord()", | 168 | "QPE/VMemo", "toggleRecord()", |
169 | "sound", "raise()" }, | 169 | "sound", "raise()" }, |
170 | }; | 170 | }; |
171 | 171 | ||
172 | struct z_button { | 172 | struct z_button { |
173 | Qt::Key code; | 173 | Qt::Key code; |
174 | char *utext; | 174 | char *utext; |
175 | char *pix; | 175 | char *pix; |
176 | char *fpressedservice; | 176 | char *fpressedservice; |
177 | char *fpressedaction; | 177 | char *fpressedaction; |
178 | char *fheldservice; | 178 | char *fheldservice; |
179 | char *fheldaction; | 179 | char *fheldaction; |
180 | } z_buttons [] = { | 180 | } z_buttons [] = { |
181 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), | 181 | { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), |
182 | "devicebuttons/z_calendar", | 182 | "devicebuttons/z_calendar", |
183 | "datebook", "nextView()", | 183 | "datebook", "nextView()", |
184 | "today", "raise()" }, | 184 | "today", "raise()" }, |
185 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), | 185 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), |
186 | "devicebuttons/z_contact", | 186 | "devicebuttons/z_contact", |
187 | "addressbook", "raise()", | 187 | "addressbook", "raise()", |
188 | "addressbook", "beamBusinessCard()" }, | 188 | "addressbook", "beamBusinessCard()" }, |
189 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), | 189 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), |
190 | "devicebuttons/z_home", | 190 | "devicebuttons/z_home", |
191 | "QPE/Launcher", "home()", | 191 | "QPE/Launcher", "home()", |
192 | "buttonsettings", "raise()" }, | 192 | "buttonsettings", "raise()" }, |
193 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), | 193 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), |
194 | "devicebuttons/z_menu", | 194 | "devicebuttons/z_menu", |
195 | "QPE/TaskBar", "toggleMenu()", | 195 | "QPE/TaskBar", "toggleMenu()", |
196 | "QPE/TaskBar", "toggleStartMenu()" }, | 196 | "QPE/TaskBar", "toggleStartMenu()" }, |
197 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), | 197 | { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), |
198 | "devicebuttons/z_mail", | 198 | "devicebuttons/z_mail", |
199 | "mail", "raise()", | 199 | "mail", "raise()", |
200 | "mail", "newMail()" }, | 200 | "mail", "newMail()" }, |
201 | }; | 201 | }; |
202 | 202 | ||
203 | static QCString makeChannel ( const char *str ) | 203 | static QCString makeChannel ( const char *str ) |
204 | { | 204 | { |
205 | if ( str && !::strchr ( str, '/' )) | 205 | if ( str && !::strchr ( str, '/' )) |
206 | return QCString ( "QPE/Application/" ) + str; | 206 | return QCString ( "QPE/Application/" ) + str; |
207 | else | 207 | else |
208 | return str; | 208 | return str; |
209 | } | 209 | } |
210 | 210 | ||
211 | 211 | ||
212 | 212 | ||
213 | 213 | ||
214 | ODevice *ODevice::inst ( ) | 214 | ODevice *ODevice::inst ( ) |
215 | { | 215 | { |
216 | static ODevice *dev = 0; | 216 | static ODevice *dev = 0; |
217 | 217 | ||
218 | if ( !dev ) { | 218 | if ( !dev ) { |
219 | if ( QFile::exists ( "/proc/hal/model" )) | 219 | if ( QFile::exists ( "/proc/hal/model" )) |
220 | dev = new iPAQ ( ); | 220 | dev = new iPAQ ( ); |
@@ -545,140 +545,136 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
545 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 545 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
546 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 546 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
547 | 547 | ||
548 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 548 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
549 | 549 | ||
550 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 550 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
551 | } | 551 | } |
552 | 552 | ||
553 | 553 | ||
554 | 554 | ||
555 | 555 | ||
556 | /************************************************** | 556 | /************************************************** |
557 | * | 557 | * |
558 | * iPAQ | 558 | * iPAQ |
559 | * | 559 | * |
560 | **************************************************/ | 560 | **************************************************/ |
561 | 561 | ||
562 | void iPAQ::init ( ) | 562 | void iPAQ::init ( ) |
563 | { | 563 | { |
564 | d-> m_vendorstr = "HP"; | 564 | d-> m_vendorstr = "HP"; |
565 | d-> m_vendor = Vendor_HP; | 565 | d-> m_vendor = Vendor_HP; |
566 | 566 | ||
567 | QFile f ( "/proc/hal/model" ); | 567 | QFile f ( "/proc/hal/model" ); |
568 | 568 | ||
569 | if ( f. open ( IO_ReadOnly )) { | 569 | if ( f. open ( IO_ReadOnly )) { |
570 | QTextStream ts ( &f ); | 570 | QTextStream ts ( &f ); |
571 | 571 | ||
572 | d-> m_modelstr = "H" + ts. readLine ( ); | 572 | d-> m_modelstr = "H" + ts. readLine ( ); |
573 | 573 | ||
574 | if ( d-> m_modelstr == "H3100" ) | 574 | if ( d-> m_modelstr == "H3100" ) |
575 | d-> m_model = Model_iPAQ_H31xx; | 575 | d-> m_model = Model_iPAQ_H31xx; |
576 | else if ( d-> m_modelstr == "H3600" ) | 576 | else if ( d-> m_modelstr == "H3600" ) |
577 | d-> m_model = Model_iPAQ_H36xx; | 577 | d-> m_model = Model_iPAQ_H36xx; |
578 | else if ( d-> m_modelstr == "H3700" ) | 578 | else if ( d-> m_modelstr == "H3700" ) |
579 | d-> m_model = Model_iPAQ_H37xx; | 579 | d-> m_model = Model_iPAQ_H37xx; |
580 | else if ( d-> m_modelstr == "H3800" ) | 580 | else if ( d-> m_modelstr == "H3800" ) |
581 | d-> m_model = Model_iPAQ_H38xx; | 581 | d-> m_model = Model_iPAQ_H38xx; |
582 | else if ( d-> m_modelstr == "H3900" ) | 582 | else if ( d-> m_modelstr == "H3900" ) |
583 | d-> m_model = Model_iPAQ_H39xx; | 583 | d-> m_model = Model_iPAQ_H39xx; |
584 | else | 584 | else |
585 | d-> m_model = Model_Unknown; | 585 | d-> m_model = Model_Unknown; |
586 | 586 | ||
587 | f. close ( ); | 587 | f. close ( ); |
588 | } | 588 | } |
589 | 589 | ||
590 | f. setName ( "/etc/familiar-version" ); | 590 | f. setName ( "/etc/familiar-version" ); |
591 | if ( f. open ( IO_ReadOnly )) { | 591 | if ( f. open ( IO_ReadOnly )) { |
592 | d-> m_systemstr = "Familiar"; | 592 | d-> m_systemstr = "Familiar"; |
593 | d-> m_system = System_Familiar; | 593 | d-> m_system = System_Familiar; |
594 | 594 | ||
595 | QTextStream ts ( &f ); | 595 | QTextStream ts ( &f ); |
596 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 596 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
597 | 597 | ||
598 | f. close ( ); | 598 | f. close ( ); |
599 | } | 599 | } |
600 | 600 | ||
601 | m_leds [0] = m_leds [1] = Led_Off; | 601 | m_leds [0] = m_leds [1] = Led_Off; |
602 | 602 | ||
603 | m_power_timer = 0; | 603 | m_power_timer = 0; |
604 | 604 | ||
605 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 605 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
606 | i_button *ib = ipaq_buttons + i; | 606 | i_button *ib = ipaq_buttons + i; |
607 | ODeviceButton b; | 607 | ODeviceButton b; |
608 | 608 | ||
609 | qDebug ( "%d: %d", i, ib-> model ); | ||
610 | |||
611 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 609 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
612 | b. setKeycode ( ib-> code ); | 610 | b. setKeycode ( ib-> code ); |
613 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); | 611 | b. setUserText ( qApp-> translate ( "Button", ib-> utext )); |
614 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 612 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
615 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 613 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
616 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 614 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
617 | 615 | ||
618 | d-> m_buttons. append ( b ); | 616 | d-> m_buttons. append ( b ); |
619 | |||
620 | qDebug ( "code: %d", ib-> code ); | ||
621 | } | 617 | } |
622 | } | 618 | } |
623 | reloadButtonMapping ( ); | 619 | reloadButtonMapping ( ); |
624 | 620 | ||
625 | if ( d-> m_qwsserver ) | 621 | if ( d-> m_qwsserver ) |
626 | QWSServer::setKeyboardFilter ( this ); | 622 | QWSServer::setKeyboardFilter ( this ); |
627 | } | 623 | } |
628 | 624 | ||
629 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 625 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
630 | 626 | ||
631 | typedef struct { | 627 | typedef struct { |
632 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 628 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
633 | unsigned char TotalTime; /* Units of 5 seconds */ | 629 | unsigned char TotalTime; /* Units of 5 seconds */ |
634 | unsigned char OnTime; /* units of 100m/s */ | 630 | unsigned char OnTime; /* units of 100m/s */ |
635 | unsigned char OffTime; /* units of 100m/s */ | 631 | unsigned char OffTime; /* units of 100m/s */ |
636 | } LED_IN; | 632 | } LED_IN; |
637 | 633 | ||
638 | typedef struct { | 634 | typedef struct { |
639 | unsigned char mode; | 635 | unsigned char mode; |
640 | unsigned char pwr; | 636 | unsigned char pwr; |
641 | unsigned char brightness; | 637 | unsigned char brightness; |
642 | } FLITE_IN; | 638 | } FLITE_IN; |
643 | 639 | ||
644 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 640 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
645 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 641 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
646 | 642 | ||
647 | 643 | ||
648 | 644 | ||
649 | QValueList <OLed> iPAQ::ledList ( ) const | 645 | QValueList <OLed> iPAQ::ledList ( ) const |
650 | { | 646 | { |
651 | QValueList <OLed> vl; | 647 | QValueList <OLed> vl; |
652 | vl << Led_Power; | 648 | vl << Led_Power; |
653 | 649 | ||
654 | if ( d-> m_model == Model_iPAQ_H38xx ) | 650 | if ( d-> m_model == Model_iPAQ_H38xx ) |
655 | vl << Led_BlueTooth; | 651 | vl << Led_BlueTooth; |
656 | return vl; | 652 | return vl; |
657 | } | 653 | } |
658 | 654 | ||
659 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 655 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
660 | { | 656 | { |
661 | QValueList <OLedState> vl; | 657 | QValueList <OLedState> vl; |
662 | 658 | ||
663 | if ( l == Led_Power ) | 659 | if ( l == Led_Power ) |
664 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 660 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
665 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 661 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
666 | vl << Led_Off; // << Led_On << ??? | 662 | vl << Led_Off; // << Led_On << ??? |
667 | 663 | ||
668 | return vl; | 664 | return vl; |
669 | } | 665 | } |
670 | 666 | ||
671 | OLedState iPAQ::ledState ( OLed l ) const | 667 | OLedState iPAQ::ledState ( OLed l ) const |
672 | { | 668 | { |
673 | switch ( l ) { | 669 | switch ( l ) { |
674 | case Led_Power: | 670 | case Led_Power: |
675 | return m_leds [0]; | 671 | return m_leds [0]; |
676 | case Led_BlueTooth: | 672 | case Led_BlueTooth: |
677 | return m_leds [1]; | 673 | return m_leds [1]; |
678 | default: | 674 | default: |
679 | return Led_Off; | 675 | return Led_Off; |
680 | } | 676 | } |
681 | } | 677 | } |
682 | 678 | ||
683 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 679 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
684 | { | 680 | { |
@@ -693,129 +689,129 @@ bool iPAQ::setLedState ( OLed l, OLedState st ) | |||
693 | leds. OffTime = 1; | 689 | leds. OffTime = 1; |
694 | leds. OffOnBlink = 2; | 690 | leds. OffOnBlink = 2; |
695 | 691 | ||
696 | switch ( st ) { | 692 | switch ( st ) { |
697 | case Led_Off : leds. OffOnBlink = 0; break; | 693 | case Led_Off : leds. OffOnBlink = 0; break; |
698 | case Led_On : leds. OffOnBlink = 1; break; | 694 | case Led_On : leds. OffOnBlink = 1; break; |
699 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 695 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
700 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 696 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
701 | } | 697 | } |
702 | 698 | ||
703 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 699 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
704 | m_leds [0] = st; | 700 | m_leds [0] = st; |
705 | return true; | 701 | return true; |
706 | } | 702 | } |
707 | } | 703 | } |
708 | } | 704 | } |
709 | return false; | 705 | return false; |
710 | } | 706 | } |
711 | 707 | ||
712 | 708 | ||
713 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 709 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
714 | { | 710 | { |
715 | int newkeycode = keycode; | 711 | int newkeycode = keycode; |
716 | 712 | ||
717 | switch ( keycode ) { | 713 | switch ( keycode ) { |
718 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 714 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
719 | case HardKey_Menu: { | 715 | case HardKey_Menu: { |
720 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 716 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
721 | ( d-> m_model == Model_iPAQ_H39xx )) { | 717 | ( d-> m_model == Model_iPAQ_H39xx )) { |
722 | newkeycode = HardKey_Mail; | 718 | newkeycode = HardKey_Mail; |
723 | } | 719 | } |
724 | break; | 720 | break; |
725 | } | 721 | } |
726 | 722 | ||
727 | // Rotate cursor keys 180° | 723 | // Rotate cursor keys 180° |
728 | case Key_Left : | 724 | case Key_Left : |
729 | case Key_Right: | 725 | case Key_Right: |
730 | case Key_Up : | 726 | case Key_Up : |
731 | case Key_Down : { | 727 | case Key_Down : { |
732 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 728 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
733 | ( d-> m_model == Model_iPAQ_H38xx )) { | 729 | ( d-> m_model == Model_iPAQ_H38xx )) { |
734 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 730 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
735 | } | 731 | } |
736 | break; | 732 | break; |
737 | } | 733 | } |
738 | 734 | ||
739 | // map Power Button short/long press to F34/F35 | 735 | // map Power Button short/long press to F34/F35 |
740 | case Key_SysReq: { | 736 | case Key_SysReq: { |
741 | if ( isPress ) { | 737 | if ( isPress ) { |
742 | if ( m_power_timer ) | 738 | if ( m_power_timer ) |
743 | killTimer ( m_power_timer ); | 739 | killTimer ( m_power_timer ); |
744 | m_power_timer = startTimer ( 500 ); | 740 | m_power_timer = startTimer ( 500 ); |
745 | } | 741 | } |
746 | else if ( m_power_timer ) { | 742 | else if ( m_power_timer ) { |
747 | killTimer ( m_power_timer ); | 743 | killTimer ( m_power_timer ); |
748 | m_power_timer = 0; | 744 | m_power_timer = 0; |
749 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 745 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
750 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 746 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
751 | } | 747 | } |
752 | newkeycode = Key_unknown; | 748 | newkeycode = Key_unknown; |
753 | break; | 749 | break; |
754 | } | 750 | } |
755 | } | 751 | } |
756 | 752 | ||
757 | if ( newkeycode != keycode ) { | 753 | kif ( newkeycode != keycode ) { |
758 | if ( newkeycode != Key_unknown ) | 754 | if ( newkeycode != Key_unknown ) |
759 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 755 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
760 | return true; | 756 | return true; |
761 | } | 757 | } |
762 | else | 758 | else |
763 | return false; | 759 | return false; |
764 | } | 760 | } |
765 | 761 | ||
766 | void iPAQ::timerEvent ( QTimerEvent * ) | 762 | void iPAQ::timerEvent ( QTimerEvent * ) |
767 | { | 763 | { |
768 | killTimer ( m_power_timer ); | 764 | killTimer ( m_power_timer ); |
769 | m_power_timer = 0; | 765 | m_power_timer = 0; |
770 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 766 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
771 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 767 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
772 | } | 768 | } |
773 | 769 | ||
774 | 770 | ||
775 | void iPAQ::alarmSound ( ) | 771 | void iPAQ::alarmSound ( ) |
776 | { | 772 | { |
777 | #ifndef QT_NO_SOUND | 773 | #ifndef QT_NO_SOUND |
778 | static Sound snd ( "alarm" ); | 774 | static Sound snd ( "alarm" ); |
779 | int fd; | 775 | int fd; |
780 | int vol; | 776 | int vol; |
781 | bool vol_reset = false; | 777 | bool vol_reset = false; |
782 | 778 | ||
783 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 779 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
784 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 780 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
785 | Config cfg ( "qpe" ); | 781 | Config cfg ( "qpe" ); |
786 | cfg. setGroup ( "Volume" ); | 782 | cfg. setGroup ( "Volume" ); |
787 | 783 | ||
788 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 784 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
789 | if ( volalarm < 0 ) | 785 | if ( volalarm < 0 ) |
790 | volalarm = 0; | 786 | volalarm = 0; |
791 | else if ( volalarm > 100 ) | 787 | else if ( volalarm > 100 ) |
792 | volalarm = 100; | 788 | volalarm = 100; |
793 | volalarm |= ( volalarm << 8 ); | 789 | volalarm |= ( volalarm << 8 ); |
794 | 790 | ||
795 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 791 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
796 | vol_reset = true; | 792 | vol_reset = true; |
797 | } | 793 | } |
798 | } | 794 | } |
799 | 795 | ||
800 | snd. play ( ); | 796 | snd. play ( ); |
801 | while ( !snd. isFinished ( )) | 797 | while ( !snd. isFinished ( )) |
802 | qApp-> processEvents ( ); | 798 | qApp-> processEvents ( ); |
803 | 799 | ||
804 | if ( fd >= 0 ) { | 800 | if ( fd >= 0 ) { |
805 | if ( vol_reset ) | 801 | if ( vol_reset ) |
806 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 802 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
807 | ::close ( fd ); | 803 | ::close ( fd ); |
808 | } | 804 | } |
809 | #endif | 805 | #endif |
810 | } | 806 | } |
811 | 807 | ||
812 | 808 | ||
813 | bool iPAQ::setSoftSuspend ( bool soft ) | 809 | bool iPAQ::setSoftSuspend ( bool soft ) |
814 | { | 810 | { |
815 | bool res = false; | 811 | bool res = false; |
816 | int fd; | 812 | int fd; |
817 | 813 | ||
818 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 814 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
819 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 815 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
820 | res = true; | 816 | res = true; |
821 | else | 817 | else |
diff --git a/libopie/odevice.h b/libopie/odevice.h index ce62f1a..54b85a2 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -22,129 +22,129 @@ | |||
22 | 22 | ||
23 | #include <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qnamespace.h> | 25 | #include <qnamespace.h> |
26 | 26 | ||
27 | #include <opie/odevicebutton.h> | 27 | #include <opie/odevicebutton.h> |
28 | 28 | ||
29 | class ODeviceData; | 29 | class ODeviceData; |
30 | 30 | ||
31 | namespace Opie { | 31 | namespace Opie { |
32 | 32 | ||
33 | enum OModel { | 33 | enum OModel { |
34 | Model_Unknown, | 34 | Model_Unknown, |
35 | 35 | ||
36 | Model_Series_Mask = 0xff000000, | 36 | Model_Series_Mask = 0xff000000, |
37 | 37 | ||
38 | Model_iPAQ = ( 1 << 24 ), | 38 | Model_iPAQ = ( 1 << 24 ), |
39 | 39 | ||
40 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 40 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
41 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 41 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
42 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 42 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
43 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 43 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
44 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 44 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
45 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 45 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
46 | 46 | ||
47 | Model_Zaurus = ( 2 << 24 ), | 47 | Model_Zaurus = ( 2 << 24 ), |
48 | 48 | ||
49 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 49 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
50 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 50 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
51 | }; | 51 | }; |
52 | 52 | ||
53 | enum OVendor { | 53 | enum OVendor { |
54 | Vendor_Unknown, | 54 | Vendor_Unknown, |
55 | 55 | ||
56 | Vendor_HP, | 56 | Vendor_HP, |
57 | Vendor_Sharp | 57 | Vendor_Sharp |
58 | }; | 58 | }; |
59 | 59 | ||
60 | enum OSystem { | 60 | enum OSystem { |
61 | System_Unknown, | 61 | System_Unknown, |
62 | 62 | ||
63 | System_Familiar, | 63 | System_Familiar, |
64 | System_Zaurus, | 64 | System_Zaurus, |
65 | System_OpenZaurus | 65 | System_OpenZaurus |
66 | }; | 66 | }; |
67 | 67 | ||
68 | enum OLedState { | 68 | enum OLedState { |
69 | Led_Off, | 69 | Led_Off, |
70 | Led_On, | 70 | Led_On, |
71 | Led_BlinkSlow, | 71 | Led_BlinkSlow, |
72 | Led_BlinkFast | 72 | Led_BlinkFast |
73 | }; | 73 | }; |
74 | 74 | ||
75 | enum OLed { | 75 | enum OLed { |
76 | Led_Mail, | 76 | Led_Mail, |
77 | Led_Power, | 77 | Led_Power, |
78 | Led_BlueTooth | 78 | Led_BlueTooth |
79 | }; | 79 | }; |
80 | 80 | ||
81 | enum OHardKey { | 81 | enum OHardKey { |
82 | HardKey_Datebook = Qt::Key_F9, | 82 | HardKey_Datebook = Qt::Key_F9, |
83 | HardKey_Contacts = Qt::Key_F10, | 83 | HardKey_Contacts = Qt::Key_F10, |
84 | HardKey_Menu = Qt::Key_F11, | 84 | HardKey_Menu = Qt::Key_F11, |
85 | HardKey_Home = Qt::Key_F12, | 85 | HardKey_Home = Qt::Key_F12, |
86 | HardKey_Mail = Qt::Key_F14, | 86 | HardKey_Mail = Qt::Key_F13, |
87 | HardKey_Record = Qt::Key_F24, | 87 | HardKey_Record = Qt::Key_F24, |
88 | HardKey_Suspend = Qt::Key_F34, | 88 | HardKey_Suspend = Qt::Key_F34, |
89 | HardKey_Backlight = Qt::Key_F35, | 89 | HardKey_Backlight = Qt::Key_F35, |
90 | }; | 90 | }; |
91 | 91 | ||
92 | 92 | ||
93 | class ODevice : public QObject { | 93 | class ODevice : public QObject { |
94 | Q_OBJECT | 94 | Q_OBJECT |
95 | 95 | ||
96 | private: | 96 | private: |
97 | ODevice ( const ODevice & ); | 97 | ODevice ( const ODevice & ); |
98 | 98 | ||
99 | protected: | 99 | protected: |
100 | ODevice ( ); | 100 | ODevice ( ); |
101 | virtual void init ( ); | 101 | virtual void init ( ); |
102 | 102 | ||
103 | ODeviceData *d; | 103 | ODeviceData *d; |
104 | 104 | ||
105 | public: | 105 | public: |
106 | virtual ~ODevice ( ); | 106 | virtual ~ODevice ( ); |
107 | 107 | ||
108 | static ODevice *inst ( ); | 108 | static ODevice *inst ( ); |
109 | 109 | ||
110 | 110 | ||
111 | 111 | ||
112 | // information | 112 | // information |
113 | 113 | ||
114 | QString modelString ( ) const; | 114 | QString modelString ( ) const; |
115 | OModel model ( ) const; | 115 | OModel model ( ) const; |
116 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 116 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
117 | 117 | ||
118 | QString vendorString ( ) const; | 118 | QString vendorString ( ) const; |
119 | OVendor vendor ( ) const; | 119 | OVendor vendor ( ) const; |
120 | 120 | ||
121 | QString systemString ( ) const; | 121 | QString systemString ( ) const; |
122 | OSystem system ( ) const; | 122 | OSystem system ( ) const; |
123 | 123 | ||
124 | QString systemVersionString ( ) const; | 124 | QString systemVersionString ( ) const; |
125 | 125 | ||
126 | // system | 126 | // system |
127 | 127 | ||
128 | virtual bool setSoftSuspend ( bool on ); | 128 | virtual bool setSoftSuspend ( bool on ); |
129 | virtual bool suspend ( ); | 129 | virtual bool suspend ( ); |
130 | 130 | ||
131 | virtual bool setDisplayStatus ( bool on ); | 131 | virtual bool setDisplayStatus ( bool on ); |
132 | virtual bool setDisplayBrightness ( int brightness ); | 132 | virtual bool setDisplayBrightness ( int brightness ); |
133 | virtual int displayBrightnessResolution ( ) const; | 133 | virtual int displayBrightnessResolution ( ) const; |
134 | 134 | ||
135 | // input / output | 135 | // input / output |
136 | 136 | ||
137 | virtual void alarmSound ( ); | 137 | virtual void alarmSound ( ); |
138 | virtual void keySound ( ); | 138 | virtual void keySound ( ); |
139 | virtual void touchSound ( ); | 139 | virtual void touchSound ( ); |
140 | 140 | ||
141 | virtual QValueList <OLed> ledList ( ) const; | 141 | virtual QValueList <OLed> ledList ( ) const; |
142 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 142 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
143 | virtual OLedState ledState ( OLed led ) const; | 143 | virtual OLedState ledState ( OLed led ) const; |
144 | virtual bool setLedState ( OLed led, OLedState st ); | 144 | virtual bool setLedState ( OLed led, OLedState st ); |
145 | 145 | ||
146 | virtual bool hasLightSensor ( ) const; | 146 | virtual bool hasLightSensor ( ) const; |
147 | virtual int readLightSensor ( ); | 147 | virtual int readLightSensor ( ); |
148 | virtual int lightSensorResolution ( ) const; | 148 | virtual int lightSensorResolution ( ) const; |
149 | 149 | ||
150 | /** | 150 | /** |