-rw-r--r-- | libopie/odevice.cpp | 3 |
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 | |||
@@ -586,129 +586,130 @@ void iPAQ::alarmSound ( ) | |||
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 | ||
618 | bool iPAQ::setSoftSuspend ( bool soft ) | 618 | bool 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 | ||
638 | bool iPAQ::setDisplayBrightness ( int bright ) | 638 | bool 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 | ||
665 | int iPAQ::displayBrightnessResolution ( ) const | 666 | int 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 | ||
679 | void Zaurus::init ( ) | 680 | void 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 ... |