-rw-r--r-- | libopie/odevice.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 8f954b1..0e1c0dd 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -217,128 +217,130 @@ static QCString makeChannel ( const char *str ) | |||
217 | 217 | ||
218 | ODevice *ODevice::inst ( ) | 218 | ODevice *ODevice::inst ( ) |
219 | { | 219 | { |
220 | static ODevice *dev = 0; | 220 | static ODevice *dev = 0; |
221 | 221 | ||
222 | if ( !dev ) { | 222 | if ( !dev ) { |
223 | if ( QFile::exists ( "/proc/hal/model" )) | 223 | if ( QFile::exists ( "/proc/hal/model" )) |
224 | dev = new iPAQ ( ); | 224 | dev = new iPAQ ( ); |
225 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 225 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
226 | dev = new Zaurus ( ); | 226 | dev = new Zaurus ( ); |
227 | else | 227 | else |
228 | dev = new ODevice ( ); | 228 | dev = new ODevice ( ); |
229 | 229 | ||
230 | dev-> init ( ); | 230 | dev-> init ( ); |
231 | } | 231 | } |
232 | return dev; | 232 | return dev; |
233 | } | 233 | } |
234 | 234 | ||
235 | 235 | ||
236 | /************************************************** | 236 | /************************************************** |
237 | * | 237 | * |
238 | * common | 238 | * common |
239 | * | 239 | * |
240 | **************************************************/ | 240 | **************************************************/ |
241 | 241 | ||
242 | 242 | ||
243 | ODevice::ODevice ( ) | 243 | ODevice::ODevice ( ) |
244 | { | 244 | { |
245 | d = new ODeviceData; | 245 | d = new ODeviceData; |
246 | 246 | ||
247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 247 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
248 | 248 | ||
249 | d-> m_modelstr = "Unknown"; | 249 | d-> m_modelstr = "Unknown"; |
250 | d-> m_model = Model_Unknown; | 250 | d-> m_model = Model_Unknown; |
251 | d-> m_vendorstr = "Unknown"; | 251 | d-> m_vendorstr = "Unknown"; |
252 | d-> m_vendor = Vendor_Unknown; | 252 | d-> m_vendor = Vendor_Unknown; |
253 | d-> m_systemstr = "Unknown"; | 253 | d-> m_systemstr = "Unknown"; |
254 | d-> m_system = System_Unknown; | 254 | d-> m_system = System_Unknown; |
255 | d-> m_sysverstr = "0.0"; | 255 | d-> m_sysverstr = "0.0"; |
256 | d-> m_rotation = Rot0; | 256 | d-> m_rotation = Rot0; |
257 | 257 | ||
258 | d-> m_holdtime = 1000; // 1000ms | 258 | d-> m_holdtime = 1000; // 1000ms |
259 | d-> m_buttons = 0; | 259 | d-> m_buttons = 0; |
260 | } | 260 | } |
261 | 261 | ||
262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 262 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
263 | { | 263 | { |
264 | if ( msg == "deviceButtonMappingChanged()" ) { | 264 | if ( msg == "deviceButtonMappingChanged()" ) { |
265 | reloadButtonMapping ( ); | 265 | reloadButtonMapping ( ); |
266 | } | 266 | } |
267 | } | 267 | } |
268 | 268 | ||
269 | void ODevice::init ( ) | 269 | void ODevice::init ( ) |
270 | { | 270 | { |
271 | } | 271 | } |
272 | 272 | ||
273 | /** | 273 | /** |
274 | * This method initialises the button mapping | 274 | * This method initialises the button mapping |
275 | */ | 275 | */ |
276 | void ODevice::initButtons ( ) | 276 | void ODevice::initButtons ( ) |
277 | { | 277 | { |
278 | if ( d-> m_buttons ) | 278 | if ( d-> m_buttons ) |
279 | return; | 279 | return; |
280 | 280 | ||
281 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | ||
282 | |||
281 | // Simulation uses iPAQ 3660 device buttons | 283 | // Simulation uses iPAQ 3660 device buttons |
282 | 284 | ||
283 | qDebug ( "init Buttons" ); | 285 | qDebug ( "init Buttons" ); |
284 | d-> m_buttons = new QValueList <ODeviceButton>; | 286 | d-> m_buttons = new QValueList <ODeviceButton>; |
285 | 287 | ||
286 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 288 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
287 | i_button *ib = ipaq_buttons + i; | 289 | i_button *ib = ipaq_buttons + i; |
288 | ODeviceButton b; | 290 | ODeviceButton b; |
289 | 291 | ||
290 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 292 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
291 | b. setKeycode ( ib-> code ); | 293 | b. setKeycode ( ib-> code ); |
292 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 294 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
293 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 295 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
294 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 296 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
295 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 297 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
296 | d-> m_buttons-> append ( b ); | 298 | d-> m_buttons-> append ( b ); |
297 | } | 299 | } |
298 | } | 300 | } |
299 | reloadButtonMapping ( ); | 301 | reloadButtonMapping ( ); |
300 | 302 | ||
301 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 303 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
302 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 304 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
303 | } | 305 | } |
304 | 306 | ||
305 | ODevice::~ODevice ( ) | 307 | ODevice::~ODevice ( ) |
306 | { | 308 | { |
307 | delete d; | 309 | delete d; |
308 | } | 310 | } |
309 | 311 | ||
310 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 312 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
311 | { | 313 | { |
312 | return false; | 314 | return false; |
313 | } | 315 | } |
314 | 316 | ||
315 | //#include <linux/apm_bios.h> | 317 | //#include <linux/apm_bios.h> |
316 | 318 | ||
317 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 319 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
318 | 320 | ||
319 | /** | 321 | /** |
320 | * This method will try to suspend the device | 322 | * This method will try to suspend the device |
321 | * It only works if the user is the QWS Server and the apm application | 323 | * It only works if the user is the QWS Server and the apm application |
322 | * is installed. | 324 | * is installed. |
323 | * It tries to suspend and then waits some time cause some distributions | 325 | * It tries to suspend and then waits some time cause some distributions |
324 | * do have asynchronus apm implementations. | 326 | * do have asynchronus apm implementations. |
325 | * This method will either fail and return false or it'll suspend the | 327 | * This method will either fail and return false or it'll suspend the |
326 | * device and return once the device got woken up | 328 | * device and return once the device got woken up |
327 | * | 329 | * |
328 | * @return if the device got suspended | 330 | * @return if the device got suspended |
329 | */ | 331 | */ |
330 | bool ODevice::suspend ( ) | 332 | bool ODevice::suspend ( ) |
331 | { | 333 | { |
332 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend | 334 | if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend |
333 | return false; | 335 | return false; |
334 | 336 | ||
335 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 337 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
336 | return false; | 338 | return false; |
337 | 339 | ||
338 | bool res = false; | 340 | bool res = false; |
339 | 341 | ||
340 | struct timeval tvs, tvn; | 342 | struct timeval tvs, tvn; |
341 | ::gettimeofday ( &tvs, 0 ); | 343 | ::gettimeofday ( &tvs, 0 ); |
342 | 344 | ||
343 | ::sync ( ); // flush fs caches | 345 | ::sync ( ); // flush fs caches |
344 | res = ( ::system ( "apm --suspend" ) == 0 ); | 346 | res = ( ::system ( "apm --suspend" ) == 0 ); |
@@ -701,137 +703,140 @@ void iPAQ::init ( ) | |||
701 | QTextStream ts ( &f ); | 703 | QTextStream ts ( &f ); |
702 | 704 | ||
703 | d-> m_modelstr = "H" + ts. readLine ( ); | 705 | d-> m_modelstr = "H" + ts. readLine ( ); |
704 | 706 | ||
705 | if ( d-> m_modelstr == "H3100" ) | 707 | if ( d-> m_modelstr == "H3100" ) |
706 | d-> m_model = Model_iPAQ_H31xx; | 708 | d-> m_model = Model_iPAQ_H31xx; |
707 | else if ( d-> m_modelstr == "H3600" ) | 709 | else if ( d-> m_modelstr == "H3600" ) |
708 | d-> m_model = Model_iPAQ_H36xx; | 710 | d-> m_model = Model_iPAQ_H36xx; |
709 | else if ( d-> m_modelstr == "H3700" ) | 711 | else if ( d-> m_modelstr == "H3700" ) |
710 | d-> m_model = Model_iPAQ_H37xx; | 712 | d-> m_model = Model_iPAQ_H37xx; |
711 | else if ( d-> m_modelstr == "H3800" ) | 713 | else if ( d-> m_modelstr == "H3800" ) |
712 | d-> m_model = Model_iPAQ_H38xx; | 714 | d-> m_model = Model_iPAQ_H38xx; |
713 | else if ( d-> m_modelstr == "H3900" ) | 715 | else if ( d-> m_modelstr == "H3900" ) |
714 | d-> m_model = Model_iPAQ_H39xx; | 716 | d-> m_model = Model_iPAQ_H39xx; |
715 | else | 717 | else |
716 | d-> m_model = Model_Unknown; | 718 | d-> m_model = Model_Unknown; |
717 | 719 | ||
718 | f. close ( ); | 720 | f. close ( ); |
719 | } | 721 | } |
720 | 722 | ||
721 | switch ( d-> m_model ) { | 723 | switch ( d-> m_model ) { |
722 | case Model_iPAQ_H31xx: | 724 | case Model_iPAQ_H31xx: |
723 | case Model_iPAQ_H38xx: | 725 | case Model_iPAQ_H38xx: |
724 | d-> m_rotation = Rot90; | 726 | d-> m_rotation = Rot90; |
725 | break; | 727 | break; |
726 | case Model_iPAQ_H36xx: | 728 | case Model_iPAQ_H36xx: |
727 | case Model_iPAQ_H37xx: | 729 | case Model_iPAQ_H37xx: |
728 | case Model_iPAQ_H39xx: | 730 | case Model_iPAQ_H39xx: |
729 | default: | 731 | default: |
730 | d-> m_rotation = Rot270; | 732 | d-> m_rotation = Rot270; |
731 | break; | 733 | break; |
732 | } | 734 | } |
733 | 735 | ||
734 | f. setName ( "/etc/familiar-version" ); | 736 | f. setName ( "/etc/familiar-version" ); |
735 | if ( f. open ( IO_ReadOnly )) { | 737 | if ( f. open ( IO_ReadOnly )) { |
736 | d-> m_systemstr = "Familiar"; | 738 | d-> m_systemstr = "Familiar"; |
737 | d-> m_system = System_Familiar; | 739 | d-> m_system = System_Familiar; |
738 | 740 | ||
739 | QTextStream ts ( &f ); | 741 | QTextStream ts ( &f ); |
740 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 742 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
741 | 743 | ||
742 | f. close ( ); | 744 | f. close ( ); |
743 | } else { | 745 | } else { |
744 | f. setName ( "/etc/oz_version" ); | 746 | f. setName ( "/etc/oz_version" ); |
745 | 747 | ||
746 | if ( f. open ( IO_ReadOnly )) { | 748 | if ( f. open ( IO_ReadOnly )) { |
747 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 749 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
748 | d-> m_system = System_Familiar; | 750 | d-> m_system = System_Familiar; |
749 | 751 | ||
750 | QTextStream ts ( &f ); | 752 | QTextStream ts ( &f ); |
751 | ts.setDevice ( &f ); | 753 | ts.setDevice ( &f ); |
752 | d-> m_sysverstr = ts. readLine ( ); | 754 | d-> m_sysverstr = ts. readLine ( ); |
753 | f. close ( ); | 755 | f. close ( ); |
754 | } | 756 | } |
755 | } | 757 | } |
756 | 758 | ||
757 | 759 | ||
758 | 760 | ||
759 | 761 | ||
760 | 762 | ||
761 | m_leds [0] = m_leds [1] = Led_Off; | 763 | m_leds [0] = m_leds [1] = Led_Off; |
762 | 764 | ||
763 | m_power_timer = 0; | 765 | m_power_timer = 0; |
764 | 766 | ||
765 | if ( d-> m_qwsserver ) | ||
766 | QWSServer::setKeyboardFilter ( this ); | ||
767 | } | 767 | } |
768 | 768 | ||
769 | void iPAQ::initButtons ( ) | 769 | void iPAQ::initButtons ( ) |
770 | { | 770 | { |
771 | if ( d-> m_buttons ) | 771 | if ( d-> m_buttons ) |
772 | return; | 772 | return; |
773 | 773 | ||
774 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | ||
775 | |||
776 | if ( d-> m_qwsserver ) | ||
777 | QWSServer::setKeyboardFilter ( this ); | ||
778 | |||
774 | d-> m_buttons = new QValueList <ODeviceButton>; | 779 | d-> m_buttons = new QValueList <ODeviceButton>; |
775 | 780 | ||
776 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 781 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
777 | i_button *ib = ipaq_buttons + i; | 782 | i_button *ib = ipaq_buttons + i; |
778 | ODeviceButton b; | 783 | ODeviceButton b; |
779 | 784 | ||
780 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 785 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
781 | b. setKeycode ( ib-> code ); | 786 | b. setKeycode ( ib-> code ); |
782 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 787 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
783 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 788 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
784 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 789 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
785 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 790 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
786 | 791 | ||
787 | d-> m_buttons-> append ( b ); | 792 | d-> m_buttons-> append ( b ); |
788 | } | 793 | } |
789 | } | 794 | } |
790 | reloadButtonMapping ( ); | 795 | reloadButtonMapping ( ); |
791 | 796 | ||
792 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 797 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
793 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 798 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
794 | } | 799 | } |
795 | 800 | ||
796 | 801 | ||
797 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 802 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
798 | 803 | ||
799 | typedef struct { | 804 | typedef struct { |
800 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 805 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
801 | unsigned char TotalTime; /* Units of 5 seconds */ | 806 | unsigned char TotalTime; /* Units of 5 seconds */ |
802 | unsigned char OnTime; /* units of 100m/s */ | 807 | unsigned char OnTime; /* units of 100m/s */ |
803 | unsigned char OffTime; /* units of 100m/s */ | 808 | unsigned char OffTime; /* units of 100m/s */ |
804 | } LED_IN; | 809 | } LED_IN; |
805 | 810 | ||
806 | typedef struct { | 811 | typedef struct { |
807 | unsigned char mode; | 812 | unsigned char mode; |
808 | unsigned char pwr; | 813 | unsigned char pwr; |
809 | unsigned char brightness; | 814 | unsigned char brightness; |
810 | } FLITE_IN; | 815 | } FLITE_IN; |
811 | 816 | ||
812 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 817 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
813 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 818 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
814 | 819 | ||
815 | 820 | ||
816 | QValueList <OLed> iPAQ::ledList ( ) const | 821 | QValueList <OLed> iPAQ::ledList ( ) const |
817 | { | 822 | { |
818 | QValueList <OLed> vl; | 823 | QValueList <OLed> vl; |
819 | vl << Led_Power; | 824 | vl << Led_Power; |
820 | 825 | ||
821 | if ( d-> m_model == Model_iPAQ_H38xx ) | 826 | if ( d-> m_model == Model_iPAQ_H38xx ) |
822 | vl << Led_BlueTooth; | 827 | vl << Led_BlueTooth; |
823 | return vl; | 828 | return vl; |
824 | } | 829 | } |
825 | 830 | ||
826 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 831 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
827 | { | 832 | { |
828 | QValueList <OLedState> vl; | 833 | QValueList <OLedState> vl; |
829 | 834 | ||
830 | if ( l == Led_Power ) | 835 | if ( l == Led_Power ) |
831 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 836 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
832 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 837 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
833 | vl << Led_Off; // << Led_On << ??? | 838 | vl << Led_Off; // << Led_On << ??? |
834 | 839 | ||
835 | return vl; | 840 | return vl; |
836 | } | 841 | } |
837 | 842 | ||
@@ -1088,128 +1093,130 @@ void Zaurus::init ( ) | |||
1088 | d-> m_vendorstr = "OpenZaurus Team"; | 1093 | d-> m_vendorstr = "OpenZaurus Team"; |
1089 | d-> m_systemstr = "OpenZaurus"; | 1094 | d-> m_systemstr = "OpenZaurus"; |
1090 | d-> m_system = System_OpenZaurus; | 1095 | d-> m_system = System_OpenZaurus; |
1091 | 1096 | ||
1092 | f. close ( ); | 1097 | f. close ( ); |
1093 | 1098 | ||
1094 | f. setName ( "/etc/oz_version" ); | 1099 | f. setName ( "/etc/oz_version" ); |
1095 | if ( f. open ( IO_ReadOnly )) { | 1100 | if ( f. open ( IO_ReadOnly )) { |
1096 | QTextStream ts ( &f ); | 1101 | QTextStream ts ( &f ); |
1097 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1102 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1098 | f. close ( ); | 1103 | f. close ( ); |
1099 | } | 1104 | } |
1100 | } | 1105 | } |
1101 | else { | 1106 | else { |
1102 | d-> m_systemstr = "Zaurus"; | 1107 | d-> m_systemstr = "Zaurus"; |
1103 | d-> m_system = System_Zaurus; | 1108 | d-> m_system = System_Zaurus; |
1104 | } | 1109 | } |
1105 | 1110 | ||
1106 | f. setName ( "/proc/deviceinfo/product" ); | 1111 | f. setName ( "/proc/deviceinfo/product" ); |
1107 | if ( f. open ( IO_ReadOnly ) ) { | 1112 | if ( f. open ( IO_ReadOnly ) ) { |
1108 | QTextStream ts ( &f ); | 1113 | QTextStream ts ( &f ); |
1109 | QString model = ts. readLine ( ); | 1114 | QString model = ts. readLine ( ); |
1110 | f. close ( ); | 1115 | f. close ( ); |
1111 | 1116 | ||
1112 | d-> m_modelstr = QString("Zaurus ") + model; | 1117 | d-> m_modelstr = QString("Zaurus ") + model; |
1113 | if ( model == "SL-5500" ) | 1118 | if ( model == "SL-5500" ) |
1114 | d-> m_model = Model_Zaurus_SL5500; | 1119 | d-> m_model = Model_Zaurus_SL5500; |
1115 | else if ( model == "SL-C700" ) | 1120 | else if ( model == "SL-C700" ) |
1116 | d-> m_model = Model_Zaurus_SLC700; | 1121 | d-> m_model = Model_Zaurus_SLC700; |
1117 | else if ( model == "SL-A300" ) | 1122 | else if ( model == "SL-A300" ) |
1118 | d-> m_model = Model_Zaurus_SLA300; | 1123 | d-> m_model = Model_Zaurus_SLA300; |
1119 | else if ( model == "SL-B600" || model == "SL-5600" ) | 1124 | else if ( model == "SL-B600" || model == "SL-5600" ) |
1120 | d-> m_model = Model_Zaurus_SLB600; | 1125 | d-> m_model = Model_Zaurus_SLB600; |
1121 | else | 1126 | else |
1122 | d-> m_model = Model_Zaurus_SL5000; | 1127 | d-> m_model = Model_Zaurus_SL5000; |
1123 | } | 1128 | } |
1124 | else { | 1129 | else { |
1125 | d-> m_model = Model_Zaurus_SL5000; | 1130 | d-> m_model = Model_Zaurus_SL5000; |
1126 | d-> m_modelstr = "Zaurus (model unknown)"; | 1131 | d-> m_modelstr = "Zaurus (model unknown)"; |
1127 | } | 1132 | } |
1128 | 1133 | ||
1129 | switch ( d-> m_model ) { | 1134 | switch ( d-> m_model ) { |
1130 | case Model_Zaurus_SLA300: | 1135 | case Model_Zaurus_SLA300: |
1131 | d-> m_rotation = Rot0; | 1136 | d-> m_rotation = Rot0; |
1132 | break; | 1137 | break; |
1133 | case Model_Zaurus_SLC700: | 1138 | case Model_Zaurus_SLC700: |
1134 | /* note for C700, we must check the display rotation | 1139 | /* note for C700, we must check the display rotation |
1135 | * sensor to set an appropriate value | 1140 | * sensor to set an appropriate value |
1136 | */ | 1141 | */ |
1137 | case Model_Zaurus_SLB600: | 1142 | case Model_Zaurus_SLB600: |
1138 | case Model_Zaurus_SL5500: | 1143 | case Model_Zaurus_SL5500: |
1139 | case Model_Zaurus_SL5000: | 1144 | case Model_Zaurus_SL5000: |
1140 | default: | 1145 | default: |
1141 | d-> m_rotation = Rot270; | 1146 | d-> m_rotation = Rot270; |
1142 | break; | 1147 | break; |
1143 | } | 1148 | } |
1144 | m_leds [0] = Led_Off; | 1149 | m_leds [0] = Led_Off; |
1145 | } | 1150 | } |
1146 | 1151 | ||
1147 | void Zaurus::initButtons ( ) | 1152 | void Zaurus::initButtons ( ) |
1148 | { | 1153 | { |
1149 | if ( d-> m_buttons ) | 1154 | if ( d-> m_buttons ) |
1150 | return; | 1155 | return; |
1151 | 1156 | ||
1157 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | ||
1158 | |||
1152 | d-> m_buttons = new QValueList <ODeviceButton>; | 1159 | d-> m_buttons = new QValueList <ODeviceButton>; |
1153 | 1160 | ||
1154 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 1161 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
1155 | z_button *zb = z_buttons + i; | 1162 | z_button *zb = z_buttons + i; |
1156 | ODeviceButton b; | 1163 | ODeviceButton b; |
1157 | 1164 | ||
1158 | b. setKeycode ( zb-> code ); | 1165 | b. setKeycode ( zb-> code ); |
1159 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1166 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1160 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1167 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1161 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1168 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1162 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1169 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1163 | 1170 | ||
1164 | d-> m_buttons-> append ( b ); | 1171 | d-> m_buttons-> append ( b ); |
1165 | } | 1172 | } |
1166 | 1173 | ||
1167 | reloadButtonMapping ( ); | 1174 | reloadButtonMapping ( ); |
1168 | 1175 | ||
1169 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1176 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1170 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1177 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1171 | } | 1178 | } |
1172 | 1179 | ||
1173 | #include <unistd.h> | 1180 | #include <unistd.h> |
1174 | #include <fcntl.h> | 1181 | #include <fcntl.h> |
1175 | #include <sys/ioctl.h> | 1182 | #include <sys/ioctl.h> |
1176 | 1183 | ||
1177 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1184 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1178 | 1185 | ||
1179 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1186 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1180 | 1187 | ||
1181 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1188 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1182 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1189 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1183 | 1190 | ||
1184 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1191 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1185 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1192 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1186 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1193 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1187 | 1194 | ||
1188 | /* --- for SHARP_BUZZER device --- */ | 1195 | /* --- for SHARP_BUZZER device --- */ |
1189 | 1196 | ||
1190 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1197 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1191 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1198 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1192 | 1199 | ||
1193 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1200 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1194 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1201 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1195 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1202 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1196 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1203 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1197 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1204 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1198 | 1205 | ||
1199 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1206 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1200 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1207 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1201 | 1208 | ||
1202 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1209 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1203 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1210 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1204 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1211 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1205 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1212 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1206 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1213 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1207 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1214 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1208 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1215 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1209 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1216 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1210 | 1217 | ||
1211 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1218 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1212 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1219 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1213 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1220 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1214 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1221 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1215 | // | 1222 | // |