-rw-r--r-- | libopie/odevice.cpp | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 58bd663..44fe35f 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -22,128 +22,131 @@ | |||
22 | #include <fcntl.h> | 22 | #include <fcntl.h> |
23 | #include <sys/ioctl.h> | 23 | #include <sys/ioctl.h> |
24 | #include <signal.h> | 24 | #include <signal.h> |
25 | #include <sys/time.h> | 25 | #include <sys/time.h> |
26 | #include <linux/soundcard.h> | 26 | #include <linux/soundcard.h> |
27 | #include <math.h> | 27 | #include <math.h> |
28 | 28 | ||
29 | #include <qapplication.h> | 29 | #include <qapplication.h> |
30 | 30 | ||
31 | #include <qfile.h> | 31 | #include <qfile.h> |
32 | #include <qtextstream.h> | 32 | #include <qtextstream.h> |
33 | #include <qpe/sound.h> | 33 | #include <qpe/sound.h> |
34 | #include <qpe/resource.h> | 34 | #include <qpe/resource.h> |
35 | #include <qpe/config.h> | 35 | #include <qpe/config.h> |
36 | 36 | ||
37 | #include "odevice.h" | 37 | #include "odevice.h" |
38 | 38 | ||
39 | #include <qwindowsystem_qws.h> | 39 | #include <qwindowsystem_qws.h> |
40 | 40 | ||
41 | 41 | ||
42 | // _IO and friends are only defined in kernel headers ... | 42 | // _IO and friends are only defined in kernel headers ... |
43 | 43 | ||
44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) | 44 | #define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) |
45 | 45 | ||
46 | #define OD_IO(type,number) OD_IOC(0,type,number,0) | 46 | #define OD_IO(type,number) OD_IOC(0,type,number,0) |
47 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) | 47 | #define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) |
48 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) | 48 | #define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) |
49 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) | 49 | #define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) |
50 | 50 | ||
51 | using namespace Opie; | 51 | using namespace Opie; |
52 | 52 | ||
53 | class ODeviceData { | 53 | class ODeviceData { |
54 | public: | 54 | public: |
55 | bool m_qwsserver; | 55 | bool m_qwsserver; |
56 | 56 | ||
57 | QString m_vendorstr; | 57 | QString m_vendorstr; |
58 | OVendor m_vendor; | 58 | OVendor m_vendor; |
59 | 59 | ||
60 | QString m_modelstr; | 60 | QString m_modelstr; |
61 | OModel m_model; | 61 | OModel m_model; |
62 | 62 | ||
63 | QString m_systemstr; | 63 | QString m_systemstr; |
64 | OSystem m_system; | 64 | OSystem m_system; |
65 | 65 | ||
66 | QString m_sysverstr; | 66 | QString m_sysverstr; |
67 | }; | 67 | }; |
68 | 68 | ||
69 | 69 | ||
70 | class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { | 70 | class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { |
71 | protected: | 71 | protected: |
72 | virtual void init ( ); | 72 | virtual void init ( ); |
73 | 73 | ||
74 | public: | 74 | public: |
75 | virtual bool setSoftSuspend ( bool soft ); | 75 | virtual bool setSoftSuspend ( bool soft ); |
76 | 76 | ||
77 | virtual bool setDisplayBrightness ( int b ); | 77 | virtual bool setDisplayBrightness ( int b ); |
78 | virtual int displayBrightnessResolution ( ) const; | 78 | virtual int displayBrightnessResolution ( ) const; |
79 | 79 | ||
80 | virtual void alarmSound ( ); | 80 | virtual void alarmSound ( ); |
81 | 81 | ||
82 | virtual QValueList <OLed> ledList ( ) const; | 82 | virtual QValueList <OLed> ledList ( ) const; |
83 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 83 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
84 | virtual OLedState ledState ( OLed led ) const; | 84 | virtual OLedState ledState ( OLed led ) const; |
85 | virtual bool setLedState ( OLed led, OLedState st ); | 85 | virtual bool setLedState ( OLed led, OLedState st ); |
86 | |||
87 | virtual bool hasLightSensor ( ) const; | ||
88 | virtual int readLightSensor ( ); | ||
86 | 89 | ||
87 | //virtual QValueList <int> keyList ( ) const; | 90 | //virtual QValueList <int> keyList ( ) const; |
88 | 91 | ||
89 | protected: | 92 | protected: |
90 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); | 93 | virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); |
91 | virtual void timerEvent ( QTimerEvent *te ); | 94 | virtual void timerEvent ( QTimerEvent *te ); |
92 | 95 | ||
93 | int m_power_timer; | 96 | int m_power_timer; |
94 | 97 | ||
95 | OLedState m_leds [2]; | 98 | OLedState m_leds [2]; |
96 | }; | 99 | }; |
97 | 100 | ||
98 | class Zaurus : public ODevice { | 101 | class Zaurus : public ODevice { |
99 | protected: | 102 | protected: |
100 | virtual void init ( ); | 103 | virtual void init ( ); |
101 | 104 | ||
102 | public: | 105 | public: |
103 | virtual bool setSoftSuspend ( bool soft ); | 106 | virtual bool setSoftSuspend ( bool soft ); |
104 | 107 | ||
105 | virtual bool setDisplayBrightness ( int b ); | 108 | virtual bool setDisplayBrightness ( int b ); |
106 | virtual int displayBrightnessResolution ( ) const; | 109 | virtual int displayBrightnessResolution ( ) const; |
107 | 110 | ||
108 | virtual void alarmSound ( ); | 111 | virtual void alarmSound ( ); |
109 | virtual void keySound ( ); | 112 | virtual void keySound ( ); |
110 | virtual void touchSound ( ); | 113 | virtual void touchSound ( ); |
111 | 114 | ||
112 | virtual QValueList <OLed> ledList ( ) const; | 115 | virtual QValueList <OLed> ledList ( ) const; |
113 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 116 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
114 | virtual OLedState ledState ( OLed led ) const; | 117 | virtual OLedState ledState ( OLed led ) const; |
115 | virtual bool setLedState ( OLed led, OLedState st ); | 118 | virtual bool setLedState ( OLed led, OLedState st ); |
116 | 119 | ||
117 | //virtual QValueList <int> keyList ( ) const; | 120 | //virtual QValueList <int> keyList ( ) const; |
118 | 121 | ||
119 | protected: | 122 | protected: |
120 | virtual void buzzer ( int snd ); | 123 | virtual void buzzer ( int snd ); |
121 | 124 | ||
122 | OLedState m_leds [1]; | 125 | OLedState m_leds [1]; |
123 | }; | 126 | }; |
124 | 127 | ||
125 | 128 | ||
126 | 129 | ||
127 | 130 | ||
128 | 131 | ||
129 | 132 | ||
130 | 133 | ||
131 | ODevice *ODevice::inst ( ) | 134 | ODevice *ODevice::inst ( ) |
132 | { | 135 | { |
133 | static ODevice *dev = 0; | 136 | static ODevice *dev = 0; |
134 | 137 | ||
135 | if ( !dev ) { | 138 | if ( !dev ) { |
136 | if ( QFile::exists ( "/proc/hal/model" )) | 139 | if ( QFile::exists ( "/proc/hal/model" )) |
137 | dev = new iPAQ ( ); | 140 | dev = new iPAQ ( ); |
138 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) | 141 | else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) |
139 | dev = new Zaurus ( ); | 142 | dev = new Zaurus ( ); |
140 | else | 143 | else |
141 | dev = new ODevice ( ); | 144 | dev = new ODevice ( ); |
142 | 145 | ||
143 | dev-> init ( ); | 146 | dev-> init ( ); |
144 | } | 147 | } |
145 | return dev; | 148 | return dev; |
146 | } | 149 | } |
147 | 150 | ||
148 | 151 | ||
149 | /************************************************** | 152 | /************************************************** |
@@ -295,128 +298,137 @@ OSystem ODevice::system ( ) const | |||
295 | 298 | ||
296 | QString ODevice::systemVersionString ( ) const | 299 | QString ODevice::systemVersionString ( ) const |
297 | { | 300 | { |
298 | return d-> m_sysverstr; | 301 | return d-> m_sysverstr; |
299 | } | 302 | } |
300 | 303 | ||
301 | void ODevice::alarmSound ( ) | 304 | void ODevice::alarmSound ( ) |
302 | { | 305 | { |
303 | #ifndef QT_QWS_EBX | 306 | #ifndef QT_QWS_EBX |
304 | #ifndef QT_NO_SOUND | 307 | #ifndef QT_NO_SOUND |
305 | static Sound snd ( "alarm" ); | 308 | static Sound snd ( "alarm" ); |
306 | 309 | ||
307 | if ( snd. isFinished ( )) | 310 | if ( snd. isFinished ( )) |
308 | snd. play ( ); | 311 | snd. play ( ); |
309 | #endif | 312 | #endif |
310 | #endif | 313 | #endif |
311 | } | 314 | } |
312 | 315 | ||
313 | void ODevice::keySound ( ) | 316 | void ODevice::keySound ( ) |
314 | { | 317 | { |
315 | #ifndef QT_QWS_EBX | 318 | #ifndef QT_QWS_EBX |
316 | #ifndef QT_NO_SOUND | 319 | #ifndef QT_NO_SOUND |
317 | static Sound snd ( "keysound" ); | 320 | static Sound snd ( "keysound" ); |
318 | 321 | ||
319 | if ( snd. isFinished ( )) | 322 | if ( snd. isFinished ( )) |
320 | snd. play ( ); | 323 | snd. play ( ); |
321 | #endif | 324 | #endif |
322 | #endif | 325 | #endif |
323 | } | 326 | } |
324 | 327 | ||
325 | void ODevice::touchSound ( ) | 328 | void ODevice::touchSound ( ) |
326 | { | 329 | { |
327 | 330 | ||
328 | #ifndef QT_QWS_EBX | 331 | #ifndef QT_QWS_EBX |
329 | #ifndef QT_NO_SOUND | 332 | #ifndef QT_NO_SOUND |
330 | static Sound snd ( "touchsound" ); | 333 | static Sound snd ( "touchsound" ); |
331 | 334 | ||
332 | if ( snd. isFinished ( )) | 335 | if ( snd. isFinished ( )) |
333 | snd. play ( ); | 336 | snd. play ( ); |
334 | #endif | 337 | #endif |
335 | #endif | 338 | #endif |
336 | } | 339 | } |
337 | 340 | ||
338 | 341 | ||
339 | QValueList <OLed> ODevice::ledList ( ) const | 342 | QValueList <OLed> ODevice::ledList ( ) const |
340 | { | 343 | { |
341 | return QValueList <OLed> ( ); | 344 | return QValueList <OLed> ( ); |
342 | } | 345 | } |
343 | 346 | ||
344 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 347 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
345 | { | 348 | { |
346 | return QValueList <OLedState> ( ); | 349 | return QValueList <OLedState> ( ); |
347 | } | 350 | } |
348 | 351 | ||
349 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 352 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
350 | { | 353 | { |
351 | return Led_Off; | 354 | return Led_Off; |
352 | } | 355 | } |
353 | 356 | ||
354 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 357 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
355 | { | 358 | { |
356 | return false; | 359 | return false; |
357 | } | 360 | } |
358 | 361 | ||
362 | bool ODevice::hasLightSensor ( ) const | ||
363 | { | ||
364 | return false; | ||
365 | } | ||
366 | |||
367 | int ODevice::readLightSensor ( ) | ||
368 | { | ||
369 | return -1; | ||
370 | } | ||
359 | 371 | ||
360 | 372 | ||
361 | //QValueList <int> ODevice::keyList ( ) const | 373 | //QValueList <int> ODevice::keyList ( ) const |
362 | //{ | 374 | //{ |
363 | //return QValueList <int> ( ); | 375 | //return QValueList <int> ( ); |
364 | //} | 376 | //} |
365 | 377 | ||
366 | 378 | ||
367 | 379 | ||
368 | /************************************************** | 380 | /************************************************** |
369 | * | 381 | * |
370 | * iPAQ | 382 | * iPAQ |
371 | * | 383 | * |
372 | **************************************************/ | 384 | **************************************************/ |
373 | 385 | ||
374 | void iPAQ::init ( ) | 386 | void iPAQ::init ( ) |
375 | { | 387 | { |
376 | d-> m_vendorstr = "HP"; | 388 | d-> m_vendorstr = "HP"; |
377 | d-> m_vendor = Vendor_HP; | 389 | d-> m_vendor = Vendor_HP; |
378 | 390 | ||
379 | QFile f ( "/proc/hal/model" ); | 391 | QFile f ( "/proc/hal/model" ); |
380 | 392 | ||
381 | if ( f. open ( IO_ReadOnly )) { | 393 | if ( f. open ( IO_ReadOnly )) { |
382 | QTextStream ts ( &f ); | 394 | QTextStream ts ( &f ); |
383 | 395 | ||
384 | d-> m_modelstr = "H" + ts. readLine ( ); | 396 | d-> m_modelstr = "H" + ts. readLine ( ); |
385 | 397 | ||
386 | if ( d-> m_modelstr == "H3100" ) | 398 | if ( d-> m_modelstr == "H3100" ) |
387 | d-> m_model = Model_iPAQ_H31xx; | 399 | d-> m_model = Model_iPAQ_H31xx; |
388 | else if ( d-> m_modelstr == "H3600" ) | 400 | else if ( d-> m_modelstr == "H3600" ) |
389 | d-> m_model = Model_iPAQ_H36xx; | 401 | d-> m_model = Model_iPAQ_H36xx; |
390 | else if ( d-> m_modelstr == "H3700" ) | 402 | else if ( d-> m_modelstr == "H3700" ) |
391 | d-> m_model = Model_iPAQ_H37xx; | 403 | d-> m_model = Model_iPAQ_H37xx; |
392 | else if ( d-> m_modelstr == "H3800" ) | 404 | else if ( d-> m_modelstr == "H3800" ) |
393 | d-> m_model = Model_iPAQ_H38xx; | 405 | d-> m_model = Model_iPAQ_H38xx; |
394 | else | 406 | else |
395 | d-> m_model = Model_Unknown; | 407 | d-> m_model = Model_Unknown; |
396 | 408 | ||
397 | f. close ( ); | 409 | f. close ( ); |
398 | } | 410 | } |
399 | 411 | ||
400 | f. setName ( "/etc/familiar-version" ); | 412 | f. setName ( "/etc/familiar-version" ); |
401 | if ( f. open ( IO_ReadOnly )) { | 413 | if ( f. open ( IO_ReadOnly )) { |
402 | d-> m_systemstr = "Familiar"; | 414 | d-> m_systemstr = "Familiar"; |
403 | d-> m_system = System_Familiar; | 415 | d-> m_system = System_Familiar; |
404 | 416 | ||
405 | QTextStream ts ( &f ); | 417 | QTextStream ts ( &f ); |
406 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 418 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
407 | 419 | ||
408 | f. close ( ); | 420 | f. close ( ); |
409 | } | 421 | } |
410 | 422 | ||
411 | m_leds [0] = m_leds [1] = Led_Off; | 423 | m_leds [0] = m_leds [1] = Led_Off; |
412 | 424 | ||
413 | m_power_timer = 0; | 425 | m_power_timer = 0; |
414 | 426 | ||
415 | if ( d-> m_qwsserver ) | 427 | if ( d-> m_qwsserver ) |
416 | QWSServer::setKeyboardFilter ( this ); | 428 | QWSServer::setKeyboardFilter ( this ); |
417 | } | 429 | } |
418 | 430 | ||
419 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 431 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
420 | 432 | ||
421 | typedef struct { | 433 | typedef struct { |
422 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 434 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
@@ -605,128 +617,158 @@ void iPAQ::alarmSound ( ) | |||
605 | 617 | ||
606 | if ( fd >= 0 ) { | 618 | if ( fd >= 0 ) { |
607 | if ( vol_reset ) | 619 | if ( vol_reset ) |
608 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 620 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
609 | ::close ( fd ); | 621 | ::close ( fd ); |
610 | } | 622 | } |
611 | #endif | 623 | #endif |
612 | #endif | 624 | #endif |
613 | } | 625 | } |
614 | 626 | ||
615 | 627 | ||
616 | bool iPAQ::setSoftSuspend ( bool soft ) | 628 | bool iPAQ::setSoftSuspend ( bool soft ) |
617 | { | 629 | { |
618 | bool res = false; | 630 | bool res = false; |
619 | int fd; | 631 | int fd; |
620 | 632 | ||
621 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 633 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
622 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 634 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
623 | res = true; | 635 | res = true; |
624 | else | 636 | else |
625 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 637 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
626 | 638 | ||
627 | ::close ( fd ); | 639 | ::close ( fd ); |
628 | } | 640 | } |
629 | else | 641 | else |
630 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 642 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
631 | 643 | ||
632 | return res; | 644 | return res; |
633 | } | 645 | } |
634 | 646 | ||
635 | 647 | ||
636 | bool iPAQ::setDisplayBrightness ( int bright ) | 648 | bool iPAQ::setDisplayBrightness ( int bright ) |
637 | { | 649 | { |
638 | bool res = false; | 650 | bool res = false; |
639 | int fd; | 651 | int fd; |
640 | 652 | ||
641 | if ( bright > 255 ) | 653 | if ( bright > 255 ) |
642 | bright = 255; | 654 | bright = 255; |
643 | if ( bright < 0 ) | 655 | if ( bright < 0 ) |
644 | bright = 0; | 656 | bright = 0; |
645 | 657 | ||
646 | // 128 is the maximum if you want a decent lifetime for the LCD | 658 | // 128 is the maximum if you want a decent lifetime for the LCD |
647 | 659 | ||
648 | if ( bright > 1 ) | 660 | if ( bright > 1 ) |
649 | bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic | 661 | bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic |
650 | //bright = ( bright + 1 ) / 2; | 662 | //bright = ( bright + 1 ) / 2; |
651 | 663 | ||
652 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 664 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
653 | FLITE_IN bl; | 665 | FLITE_IN bl; |
654 | bl. mode = 1; | 666 | bl. mode = 1; |
655 | bl. pwr = bright ? 1 : 0; | 667 | bl. pwr = bright ? 1 : 0; |
656 | bl. brightness = bright; | 668 | bl. brightness = bright; |
657 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 669 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
658 | ::close ( fd ); | 670 | ::close ( fd ); |
659 | } | 671 | } |
660 | return res; | 672 | return res; |
661 | } | 673 | } |
662 | 674 | ||
663 | int iPAQ::displayBrightnessResolution ( ) const | 675 | int iPAQ::displayBrightnessResolution ( ) const |
664 | { | 676 | { |
665 | return 255; // really 128, but logarithmic control is smoother this way | 677 | return 255; // really 128, but logarithmic control is smoother this way |
666 | } | 678 | } |
667 | 679 | ||
668 | 680 | ||
681 | bool iPAQ::hasLightSensor ( ) const | ||
682 | { | ||
683 | return true; | ||
684 | } | ||
685 | |||
686 | int iPAQ::readLightSensor ( ) | ||
687 | { | ||
688 | int fd; | ||
689 | int val = -1; | ||
690 | |||
691 | if (( fd = ::open ( "/proc/hal/lightsensor", O_RDONLY )) >= 0 ) { | ||
692 | char buffer [5]; | ||
693 | |||
694 | if ( ::read ( fd, buffer, 4 ) == 4 ) { | ||
695 | char *endptr; | ||
696 | |||
697 | buffer [4] = 0; | ||
698 | val = ::strtol ( buffer + 2, &endptr, 16 ); | ||
699 | |||
700 | if ( *endptr != 0 ) | ||
701 | val = -1; | ||
702 | } | ||
703 | |||
704 | ::close ( fd ); | ||
705 | } | ||
706 | |||
707 | return val; | ||
708 | } | ||
709 | |||
710 | |||
669 | /************************************************** | 711 | /************************************************** |
670 | * | 712 | * |
671 | * Zaurus | 713 | * Zaurus |
672 | * | 714 | * |
673 | **************************************************/ | 715 | **************************************************/ |
674 | 716 | ||
675 | 717 | ||
676 | 718 | ||
677 | void Zaurus::init ( ) | 719 | void Zaurus::init ( ) |
678 | { | 720 | { |
679 | d-> m_modelstr = "Zaurus SL5000"; | 721 | d-> m_modelstr = "Zaurus SL5000"; |
680 | d-> m_model = Model_Zaurus_SL5000; | 722 | d-> m_model = Model_Zaurus_SL5000; |
681 | d-> m_vendorstr = "Sharp"; | 723 | d-> m_vendorstr = "Sharp"; |
682 | d-> m_vendor = Vendor_Sharp; | 724 | d-> m_vendor = Vendor_Sharp; |
683 | 725 | ||
684 | QFile f ( "/proc/filesystems" ); | 726 | QFile f ( "/proc/filesystems" ); |
685 | 727 | ||
686 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 728 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
687 | d-> m_systemstr = "OpenZaurus"; | 729 | d-> m_systemstr = "OpenZaurus"; |
688 | d-> m_system = System_OpenZaurus; | 730 | d-> m_system = System_OpenZaurus; |
689 | 731 | ||
690 | f. close ( ); | 732 | f. close ( ); |
691 | 733 | ||
692 | f. setName ( "/etc/oz_version" ); | 734 | f. setName ( "/etc/oz_version" ); |
693 | if ( f. open ( IO_ReadOnly )) { | 735 | if ( f. open ( IO_ReadOnly )) { |
694 | QTextStream ts ( &f ); | 736 | QTextStream ts ( &f ); |
695 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 737 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
696 | f. close ( ); | 738 | f. close ( ); |
697 | } | 739 | } |
698 | } | 740 | } |
699 | else { | 741 | else { |
700 | d-> m_systemstr = "Zaurus"; | 742 | d-> m_systemstr = "Zaurus"; |
701 | d-> m_system = System_Zaurus; | 743 | d-> m_system = System_Zaurus; |
702 | } | 744 | } |
703 | 745 | ||
704 | 746 | ||
705 | m_leds [0] = Led_Off; | 747 | m_leds [0] = Led_Off; |
706 | } | 748 | } |
707 | 749 | ||
708 | #include <unistd.h> | 750 | #include <unistd.h> |
709 | #include <fcntl.h> | 751 | #include <fcntl.h> |
710 | #include <sys/ioctl.h> | 752 | #include <sys/ioctl.h> |
711 | 753 | ||
712 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 754 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
713 | 755 | ||
714 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 756 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
715 | 757 | ||
716 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 758 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
717 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 759 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
718 | 760 | ||
719 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 761 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
720 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 762 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
721 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 763 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
722 | 764 | ||
723 | /* --- for SHARP_BUZZER device --- */ | 765 | /* --- for SHARP_BUZZER device --- */ |
724 | 766 | ||
725 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 767 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
726 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 768 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
727 | 769 | ||
728 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 770 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
729 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 771 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
730 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 772 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
731 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 773 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
732 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 774 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |