summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authorsandman <sandman>2002-10-01 16:14:39 (UTC)
committer sandman <sandman>2002-10-01 16:14:39 (UTC)
commit70d2cbd97a6b39b1738e3e6580f916dcf0fbc787 (patch) (unidiff)
treeff6ab6c52a7dc886a61de659dd2860a587b953a0 /libopie/odevice.cpp
parent657eeb18141838eeb0d18351a6755d7fa686f9d9 (diff)
downloadopie-70d2cbd97a6b39b1738e3e6580f916dcf0fbc787.zip
opie-70d2cbd97a6b39b1738e3e6580f916dcf0fbc787.tar.gz
opie-70d2cbd97a6b39b1738e3e6580f916dcf0fbc787.tar.bz2
Small bug fix for iPAQ only: screensaver "dim" didn't work anymore -
the backlight was already powered off at level 0
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c84312e..75426f9 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -458,385 +458,386 @@ QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
458 return vl; 458 return vl;
459} 459}
460 460
461OLedState iPAQ::ledState ( OLed l ) const 461OLedState iPAQ::ledState ( OLed l ) const
462 { 462 {
463 switch ( l ) { 463 switch ( l ) {
464 case Led_Power: 464 case Led_Power:
465 return m_leds [0]; 465 return m_leds [0];
466 case Led_BlueTooth: 466 case Led_BlueTooth:
467 return m_leds [1]; 467 return m_leds [1];
468 default: 468 default:
469 return Led_Off; 469 return Led_Off;
470 } 470 }
471} 471}
472 472
473bool iPAQ::setLedState ( OLed l, OLedState st ) 473bool iPAQ::setLedState ( OLed l, OLedState st )
474{ 474{
475 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 475 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
476 476
477 if ( l == Led_Power ) { 477 if ( l == Led_Power ) {
478 if ( fd >= 0 ) { 478 if ( fd >= 0 ) {
479 LED_IN leds; 479 LED_IN leds;
480 ::memset ( &leds, 0, sizeof( leds )); 480 ::memset ( &leds, 0, sizeof( leds ));
481 leds. TotalTime = 0; 481 leds. TotalTime = 0;
482 leds. OnTime = 0; 482 leds. OnTime = 0;
483 leds. OffTime = 1; 483 leds. OffTime = 1;
484 leds. OffOnBlink = 2; 484 leds. OffOnBlink = 2;
485 485
486 switch ( st ) { 486 switch ( st ) {
487 case Led_Off : leds. OffOnBlink = 0; break; 487 case Led_Off : leds. OffOnBlink = 0; break;
488 case Led_On : leds. OffOnBlink = 1; break; 488 case Led_On : leds. OffOnBlink = 1; break;
489 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 489 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
490 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 490 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
491 } 491 }
492 492
493 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 493 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
494 m_leds [0] = st; 494 m_leds [0] = st;
495 return true; 495 return true;
496 } 496 }
497 } 497 }
498 } 498 }
499 return false; 499 return false;
500} 500}
501 501
502 502
503//QValueList <int> iPAQ::keyList ( ) const 503//QValueList <int> iPAQ::keyList ( ) const
504//{ 504//{
505 //QValueList <int> vl; 505 //QValueList <int> vl;
506 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; 506 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight;
507 //return vl; 507 //return vl;
508//} 508//}
509 509
510bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 510bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
511{ 511{
512 int newkeycode = keycode; 512 int newkeycode = keycode;
513 513
514 514
515 // simple susbstitutions 515 // simple susbstitutions
516 switch ( d-> m_model ) { 516 switch ( d-> m_model ) {
517 case Model_iPAQ_H38xx: 517 case Model_iPAQ_H38xx:
518 // H38xx has no "Q" key anymore - this is now the Mail key 518 // H38xx has no "Q" key anymore - this is now the Mail key
519 if ( keycode == HardKey_Menu ) 519 if ( keycode == HardKey_Menu )
520 newkeycode = HardKey_Mail; 520 newkeycode = HardKey_Mail;
521 //nobreak 521 //nobreak
522 522
523 case Model_iPAQ_H31xx: 523 case Model_iPAQ_H31xx:
524 // Rotate cursor keys 180° 524 // Rotate cursor keys 180°
525 switch ( keycode ) { 525 switch ( keycode ) {
526 case Key_Left : newkeycode = Key_Right; break; 526 case Key_Left : newkeycode = Key_Right; break;
527 case Key_Right: newkeycode = Key_Left; break; 527 case Key_Right: newkeycode = Key_Left; break;
528 case Key_Up : newkeycode = Key_Down; break; 528 case Key_Up : newkeycode = Key_Down; break;
529 case Key_Down : newkeycode = Key_Up; break; 529 case Key_Down : newkeycode = Key_Up; break;
530 } 530 }
531 break; 531 break;
532 532
533 case Model_iPAQ_H36xx: 533 case Model_iPAQ_H36xx:
534 case Model_iPAQ_H37xx: 534 case Model_iPAQ_H37xx:
535 // map Power Button short/long press to F34/F35 535 // map Power Button short/long press to F34/F35
536 if ( keycode == Key_SysReq ) { 536 if ( keycode == Key_SysReq ) {
537 if ( isPress ) { 537 if ( isPress ) {
538 if ( m_power_timer ) 538 if ( m_power_timer )
539 killTimer ( m_power_timer ); 539 killTimer ( m_power_timer );
540 m_power_timer = startTimer ( 500 ); 540 m_power_timer = startTimer ( 500 );
541 } 541 }
542 else if ( m_power_timer ) { 542 else if ( m_power_timer ) {
543 killTimer ( m_power_timer ); 543 killTimer ( m_power_timer );
544 m_power_timer = 0; 544 m_power_timer = 0;
545 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 545 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
546 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 546 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
547 } 547 }
548 newkeycode = Key_unknown; 548 newkeycode = Key_unknown;
549 } 549 }
550 break; 550 break;
551 551
552 default: 552 default:
553 break; 553 break;
554 } 554 }
555 555
556 if ( newkeycode != keycode ) { 556 if ( newkeycode != keycode ) {
557 if ( newkeycode != Key_unknown ) 557 if ( newkeycode != Key_unknown )
558 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 558 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
559 return true; 559 return true;
560 } 560 }
561 else 561 else
562 return false; 562 return false;
563} 563}
564 564
565void iPAQ::timerEvent ( QTimerEvent * ) 565void iPAQ::timerEvent ( QTimerEvent * )
566{ 566{
567 killTimer ( m_power_timer ); 567 killTimer ( m_power_timer );
568 m_power_timer = 0; 568 m_power_timer = 0;
569 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 569 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
570 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 570 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
571} 571}
572 572
573 573
574void iPAQ::alarmSound ( ) 574void iPAQ::alarmSound ( )
575{ 575{
576#if defined( QT_QWS_IPAQ ) // IPAQ 576#if defined( QT_QWS_IPAQ ) // IPAQ
577#ifndef QT_NO_SOUND 577#ifndef QT_NO_SOUND
578 static Sound snd ( "alarm" ); 578 static Sound snd ( "alarm" );
579 int fd; 579 int fd;
580 int vol; 580 int vol;
581 bool vol_reset = false; 581 bool vol_reset = false;
582 582
583 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || 583 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) ||
584 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { 584 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) {
585 585
586 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 586 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
587 Config cfg ( "qpe" ); 587 Config cfg ( "qpe" );
588 cfg. setGroup ( "Volume" ); 588 cfg. setGroup ( "Volume" );
589 589
590 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 590 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
591 if ( volalarm < 0 ) 591 if ( volalarm < 0 )
592 volalarm = 0; 592 volalarm = 0;
593 else if ( volalarm > 100 ) 593 else if ( volalarm > 100 )
594 volalarm = 100; 594 volalarm = 100;
595 volalarm |= ( volalarm << 8 ); 595 volalarm |= ( volalarm << 8 );
596 596
597 if (( volalarm & 0xff ) > ( vol & 0xff )) { 597 if (( volalarm & 0xff ) > ( vol & 0xff )) {
598 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 598 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
599 vol_reset = true; 599 vol_reset = true;
600 } 600 }
601 } 601 }
602 } 602 }
603 603
604 snd. play ( ); 604 snd. play ( );
605 while ( !snd. isFinished ( )) 605 while ( !snd. isFinished ( ))
606 qApp-> processEvents ( ); 606 qApp-> processEvents ( );
607 607
608 if ( fd >= 0 ) { 608 if ( fd >= 0 ) {
609 if ( vol_reset ) 609 if ( vol_reset )
610 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 610 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
611 ::close ( fd ); 611 ::close ( fd );
612 } 612 }
613#endif 613#endif
614#endif 614#endif
615} 615}
616 616
617 617
618bool iPAQ::setSoftSuspend ( bool soft ) 618bool iPAQ::setSoftSuspend ( bool soft )
619{ 619{
620 bool res = false; 620 bool res = false;
621 int fd; 621 int fd;
622 622
623 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 623 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
624 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 624 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
625 res = true; 625 res = true;
626 else 626 else
627 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 627 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
628 628
629 ::close ( fd ); 629 ::close ( fd );
630 } 630 }
631 else 631 else
632 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 632 ::perror ( "/proc/sys/ts/suspend_button_mode" );
633 633
634 return res; 634 return res;
635} 635}
636 636
637 637
638bool iPAQ::setDisplayBrightness ( int bright ) 638bool iPAQ::setDisplayBrightness ( int bright )
639{ 639{
640 bool res = false; 640 bool res = false;
641 int fd; 641 int fd;
642 642
643 if ( bright > 255 ) 643 if ( bright > 255 )
644 bright = 255; 644 bright = 255;
645 if ( bright < 0 ) 645 if ( bright < 0 )
646 bright = 0; 646 bright = 0;
647 647
648 // 128 is the maximum if you want a decent lifetime for the LCD 648 // 128 is the maximum if you want a decent lifetime for the LCD
649 649
650 bright = (int) (( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic 650 if ( bright > 1 )
651 bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic
651 //bright = ( bright + 1 ) / 2; 652 //bright = ( bright + 1 ) / 2;
652 653
653 if ((( fd = ::open ( "/dev/ts", O_WRONLY )) >= 0 ) || 654 if ((( fd = ::open ( "/dev/ts", O_WRONLY )) >= 0 ) ||
654 (( fd = ::open ( "/dev/h3600_ts", O_WRONLY )) >= 0 )) { 655 (( fd = ::open ( "/dev/h3600_ts", O_WRONLY )) >= 0 )) {
655 FLITE_IN bl; 656 FLITE_IN bl;
656 bl. mode = 1; 657 bl. mode = 1;
657 bl. pwr = bright ? 1 : 0; 658 bl. pwr = bright ? 1 : 0;
658 bl. brightness = bright; 659 bl. brightness = bright;
659 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 660 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
660 ::close ( fd ); 661 ::close ( fd );
661 } 662 }
662 return res; 663 return res;
663} 664}
664 665
665int iPAQ::displayBrightnessResolution ( ) const 666int iPAQ::displayBrightnessResolution ( ) const
666{ 667{
667 return 255; // really 128, but logarithmic control is smoother this way 668 return 255; // really 128, but logarithmic control is smoother this way
668} 669}
669 670
670 671
671/************************************************** 672/**************************************************
672 * 673 *
673 * Zaurus 674 * Zaurus
674 * 675 *
675 **************************************************/ 676 **************************************************/
676 677
677 678
678 679
679void Zaurus::init ( ) 680void Zaurus::init ( )
680{ 681{
681 d-> m_modelstr = "Zaurus SL5000"; 682 d-> m_modelstr = "Zaurus SL5000";
682 d-> m_model = Model_Zaurus_SL5000; 683 d-> m_model = Model_Zaurus_SL5000;
683 d-> m_vendorstr = "Sharp"; 684 d-> m_vendorstr = "Sharp";
684 d-> m_vendor = Vendor_Sharp; 685 d-> m_vendor = Vendor_Sharp;
685 686
686 QFile f ( "/proc/filesystems" ); 687 QFile f ( "/proc/filesystems" );
687 688
688 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 689 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
689 d-> m_systemstr = "OpenZaurus"; 690 d-> m_systemstr = "OpenZaurus";
690 d-> m_system = System_OpenZaurus; 691 d-> m_system = System_OpenZaurus;
691 692
692 f. close ( ); 693 f. close ( );
693 694
694 f. setName ( "/etc/oz_version" ); 695 f. setName ( "/etc/oz_version" );
695 if ( f. open ( IO_ReadOnly )) { 696 if ( f. open ( IO_ReadOnly )) {
696 QTextStream ts ( &f ); 697 QTextStream ts ( &f );
697 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 698 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
698 f. close ( ); 699 f. close ( );
699 } 700 }
700 } 701 }
701 else { 702 else {
702 d-> m_systemstr = "Zaurus"; 703 d-> m_systemstr = "Zaurus";
703 d-> m_system = System_Zaurus; 704 d-> m_system = System_Zaurus;
704 } 705 }
705 706
706 707
707 m_leds [0] = Led_Off; 708 m_leds [0] = Led_Off;
708} 709}
709 710
710#include <unistd.h> 711#include <unistd.h>
711#include <fcntl.h> 712#include <fcntl.h>
712#include <sys/ioctl.h> 713#include <sys/ioctl.h>
713 714
714//#include <asm/sharp_char.h> // including kernel headers is evil ... 715//#include <asm/sharp_char.h> // including kernel headers is evil ...
715 716
716#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 717#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
717 718
718 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 719 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
719#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 720#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
720 721
721#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 722#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
722#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 723#define SHARP_BUZ_KEYSOUND 2 /* key sound */
723#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 724#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
724 725
725/* --- for SHARP_BUZZER device --- */ 726/* --- for SHARP_BUZZER device --- */
726 727
727 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 728 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
728//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 729//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
729 730
730#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 731#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
731#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 732#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
732#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 733#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
733#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 734#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
734#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 735#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
735 736
736//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 737//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
737//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 738//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
738 739
739//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 740//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
740//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 741//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
741//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 742//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
742//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 743//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
743//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 744//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
744//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 745//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
745//#define SHARP_PDA_APPSTART 9 /* application start */ 746//#define SHARP_PDA_APPSTART 9 /* application start */
746//#define SHARP_PDA_APPQUIT 10 /* application ends */ 747//#define SHARP_PDA_APPQUIT 10 /* application ends */
747 748
748//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 749//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
749//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 750//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
750//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 751//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
751//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 752//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
752// 753//
753 754
754 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 755 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
755#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 756#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
756 757
757typedef struct sharp_led_status { 758typedef struct sharp_led_status {
758 int which; /* select which LED status is wanted. */ 759 int which; /* select which LED status is wanted. */
759 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 760 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
760} sharp_led_status; 761} sharp_led_status;
761 762
762#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 763#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
763 764
764#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 765#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
765#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 766#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
766#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 767#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
767 768
768// #include <asm/sharp_apm.h> // including kernel headers is evil ... 769// #include <asm/sharp_apm.h> // including kernel headers is evil ...
769 770
770#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 771#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
771#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 772#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
772#define APM_EVT_POWER_BUTTON (1 << 0) 773#define APM_EVT_POWER_BUTTON (1 << 0)
773 774
774#define FL_IOCTL_STEP_CONTRAST 100 775#define FL_IOCTL_STEP_CONTRAST 100
775 776
776 777
777void Zaurus::buzzer ( int sound ) 778void Zaurus::buzzer ( int sound )
778{ 779{
779 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 780 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
780 781
781 if ( fd >= 0 ) 782 if ( fd >= 0 )
782 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 783 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
783} 784}
784 785
785 786
786void Zaurus::alarmSound ( ) 787void Zaurus::alarmSound ( )
787{ 788{
788 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 789 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
789} 790}
790 791
791void Zaurus::touchSound ( ) 792void Zaurus::touchSound ( )
792{ 793{
793 buzzer ( SHARP_BUZ_TOUCHSOUND ); 794 buzzer ( SHARP_BUZ_TOUCHSOUND );
794} 795}
795 796
796void Zaurus::keySound ( ) 797void Zaurus::keySound ( )
797{ 798{
798 buzzer ( SHARP_BUZ_KEYSOUND ); 799 buzzer ( SHARP_BUZ_KEYSOUND );
799} 800}
800 801
801 802
802QValueList <OLed> Zaurus::ledList ( ) const 803QValueList <OLed> Zaurus::ledList ( ) const
803{ 804{
804 QValueList <OLed> vl; 805 QValueList <OLed> vl;
805 vl << Led_Mail; 806 vl << Led_Mail;
806 return vl; 807 return vl;
807} 808}
808 809
809QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 810QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
810{ 811{
811 QValueList <OLedState> vl; 812 QValueList <OLedState> vl;
812 813
813 if ( l == Led_Mail ) 814 if ( l == Led_Mail )
814 vl << Led_Off << Led_On << Led_BlinkSlow; 815 vl << Led_Off << Led_On << Led_BlinkSlow;
815 return vl; 816 return vl;
816} 817}
817 818
818OLedState Zaurus::ledState ( OLed which ) const 819OLedState Zaurus::ledState ( OLed which ) const
819{ 820{
820 if ( which == Led_Mail ) 821 if ( which == Led_Mail )
821 return m_leds [0]; 822 return m_leds [0];
822 else 823 else
823 return Led_Off; 824 return Led_Off;
824} 825}
825 826
826bool Zaurus::setLedState ( OLed which, OLedState st ) 827bool Zaurus::setLedState ( OLed which, OLedState st )
827{ 828{
828 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 829 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
829 830
830 if ( which == Led_Mail ) { 831 if ( which == Led_Mail ) {
831 if ( fd >= 0 ) { 832 if ( fd >= 0 ) {
832 struct sharp_led_status leds; 833 struct sharp_led_status leds;
833 ::memset ( &leds, 0, sizeof( leds )); 834 ::memset ( &leds, 0, sizeof( leds ));
834 leds. which = SHARP_LED_MAIL_EXISTS; 835 leds. which = SHARP_LED_MAIL_EXISTS;
835 bool ok = true; 836 bool ok = true;
836 837
837 switch ( st ) { 838 switch ( st ) {
838 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 839 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
839 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 840 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
840 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 841 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
841 default : ok = false; 842 default : ok = false;
842 } 843 }