author | sandman <sandman> | 2002-12-23 03:14:22 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-23 03:14:22 (UTC) |
commit | 8bd190d162b538e4226e830f442450f5a95f4434 (patch) (unidiff) | |
tree | 5a0cd0904b11b5d76a09de21db29d77abfe4b176 /libopie | |
parent | 726d2ac455446ee194c8e83df16f48357b619988 (diff) | |
download | opie-8bd190d162b538e4226e830f442450f5a95f4434.zip opie-8bd190d162b538e4226e830f442450f5a95f4434.tar.gz opie-8bd190d162b538e4226e830f442450f5a95f4434.tar.bz2 |
grrr .. somehow joe put a 'k' in the file
-rw-r--r-- | libopie/odevice.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index a3c30cb..0e620ba 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -625,257 +625,257 @@ void iPAQ::init ( ) | |||
625 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 625 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
626 | 626 | ||
627 | typedef struct { | 627 | typedef struct { |
628 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 628 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
629 | unsigned char TotalTime; /* Units of 5 seconds */ | 629 | unsigned char TotalTime; /* Units of 5 seconds */ |
630 | unsigned char OnTime; /* units of 100m/s */ | 630 | unsigned char OnTime; /* units of 100m/s */ |
631 | unsigned char OffTime; /* units of 100m/s */ | 631 | unsigned char OffTime; /* units of 100m/s */ |
632 | } LED_IN; | 632 | } LED_IN; |
633 | 633 | ||
634 | typedef struct { | 634 | typedef struct { |
635 | unsigned char mode; | 635 | unsigned char mode; |
636 | unsigned char pwr; | 636 | unsigned char pwr; |
637 | unsigned char brightness; | 637 | unsigned char brightness; |
638 | } FLITE_IN; | 638 | } FLITE_IN; |
639 | 639 | ||
640 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 640 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
641 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 641 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
642 | 642 | ||
643 | 643 | ||
644 | 644 | ||
645 | QValueList <OLed> iPAQ::ledList ( ) const | 645 | QValueList <OLed> iPAQ::ledList ( ) const |
646 | { | 646 | { |
647 | QValueList <OLed> vl; | 647 | QValueList <OLed> vl; |
648 | vl << Led_Power; | 648 | vl << Led_Power; |
649 | 649 | ||
650 | if ( d-> m_model == Model_iPAQ_H38xx ) | 650 | if ( d-> m_model == Model_iPAQ_H38xx ) |
651 | vl << Led_BlueTooth; | 651 | vl << Led_BlueTooth; |
652 | return vl; | 652 | return vl; |
653 | } | 653 | } |
654 | 654 | ||
655 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 655 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
656 | { | 656 | { |
657 | QValueList <OLedState> vl; | 657 | QValueList <OLedState> vl; |
658 | 658 | ||
659 | if ( l == Led_Power ) | 659 | if ( l == Led_Power ) |
660 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 660 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
661 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 661 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
662 | vl << Led_Off; // << Led_On << ??? | 662 | vl << Led_Off; // << Led_On << ??? |
663 | 663 | ||
664 | return vl; | 664 | return vl; |
665 | } | 665 | } |
666 | 666 | ||
667 | OLedState iPAQ::ledState ( OLed l ) const | 667 | OLedState iPAQ::ledState ( OLed l ) const |
668 | { | 668 | { |
669 | switch ( l ) { | 669 | switch ( l ) { |
670 | case Led_Power: | 670 | case Led_Power: |
671 | return m_leds [0]; | 671 | return m_leds [0]; |
672 | case Led_BlueTooth: | 672 | case Led_BlueTooth: |
673 | return m_leds [1]; | 673 | return m_leds [1]; |
674 | default: | 674 | default: |
675 | return Led_Off; | 675 | return Led_Off; |
676 | } | 676 | } |
677 | } | 677 | } |
678 | 678 | ||
679 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 679 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
680 | { | 680 | { |
681 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 681 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
682 | 682 | ||
683 | if ( l == Led_Power ) { | 683 | if ( l == Led_Power ) { |
684 | if ( fd >= 0 ) { | 684 | if ( fd >= 0 ) { |
685 | LED_IN leds; | 685 | LED_IN leds; |
686 | ::memset ( &leds, 0, sizeof( leds )); | 686 | ::memset ( &leds, 0, sizeof( leds )); |
687 | leds. TotalTime = 0; | 687 | leds. TotalTime = 0; |
688 | leds. OnTime = 0; | 688 | leds. OnTime = 0; |
689 | leds. OffTime = 1; | 689 | leds. OffTime = 1; |
690 | leds. OffOnBlink = 2; | 690 | leds. OffOnBlink = 2; |
691 | 691 | ||
692 | switch ( st ) { | 692 | switch ( st ) { |
693 | case Led_Off : leds. OffOnBlink = 0; break; | 693 | case Led_Off : leds. OffOnBlink = 0; break; |
694 | case Led_On : leds. OffOnBlink = 1; break; | 694 | case Led_On : leds. OffOnBlink = 1; break; |
695 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 695 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
696 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 696 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
697 | } | 697 | } |
698 | 698 | ||
699 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 699 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
700 | m_leds [0] = st; | 700 | m_leds [0] = st; |
701 | return true; | 701 | return true; |
702 | } | 702 | } |
703 | } | 703 | } |
704 | } | 704 | } |
705 | return false; | 705 | return false; |
706 | } | 706 | } |
707 | 707 | ||
708 | 708 | ||
709 | 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 ) |
710 | { | 710 | { |
711 | int newkeycode = keycode; | 711 | int newkeycode = keycode; |
712 | 712 | ||
713 | switch ( keycode ) { | 713 | switch ( keycode ) { |
714 | // 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 |
715 | case HardKey_Menu: { | 715 | case HardKey_Menu: { |
716 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 716 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
717 | ( d-> m_model == Model_iPAQ_H39xx )) { | 717 | ( d-> m_model == Model_iPAQ_H39xx )) { |
718 | newkeycode = HardKey_Mail; | 718 | newkeycode = HardKey_Mail; |
719 | } | 719 | } |
720 | break; | 720 | break; |
721 | } | 721 | } |
722 | 722 | ||
723 | // Rotate cursor keys 180° | 723 | // Rotate cursor keys 180° |
724 | case Key_Left : | 724 | case Key_Left : |
725 | case Key_Right: | 725 | case Key_Right: |
726 | case Key_Up : | 726 | case Key_Up : |
727 | case Key_Down : { | 727 | case Key_Down : { |
728 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 728 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
729 | ( d-> m_model == Model_iPAQ_H38xx )) { | 729 | ( d-> m_model == Model_iPAQ_H38xx )) { |
730 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 730 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
731 | } | 731 | } |
732 | break; | 732 | break; |
733 | } | 733 | } |
734 | 734 | ||
735 | // map Power Button short/long press to F34/F35 | 735 | // map Power Button short/long press to F34/F35 |
736 | case Key_SysReq: { | 736 | case Key_SysReq: { |
737 | if ( isPress ) { | 737 | if ( isPress ) { |
738 | if ( m_power_timer ) | 738 | if ( m_power_timer ) |
739 | killTimer ( m_power_timer ); | 739 | killTimer ( m_power_timer ); |
740 | m_power_timer = startTimer ( 500 ); | 740 | m_power_timer = startTimer ( 500 ); |
741 | } | 741 | } |
742 | else if ( m_power_timer ) { | 742 | else if ( m_power_timer ) { |
743 | killTimer ( m_power_timer ); | 743 | killTimer ( m_power_timer ); |
744 | m_power_timer = 0; | 744 | m_power_timer = 0; |
745 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 745 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
746 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 746 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
747 | } | 747 | } |
748 | newkeycode = Key_unknown; | 748 | newkeycode = Key_unknown; |
749 | break; | 749 | break; |
750 | } | 750 | } |
751 | } | 751 | } |
752 | 752 | ||
753 | kif ( newkeycode != keycode ) { | 753 | if ( newkeycode != keycode ) { |
754 | if ( newkeycode != Key_unknown ) | 754 | if ( newkeycode != Key_unknown ) |
755 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 755 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
756 | return true; | 756 | return true; |
757 | } | 757 | } |
758 | else | 758 | else |
759 | return false; | 759 | return false; |
760 | } | 760 | } |
761 | 761 | ||
762 | void iPAQ::timerEvent ( QTimerEvent * ) | 762 | void iPAQ::timerEvent ( QTimerEvent * ) |
763 | { | 763 | { |
764 | killTimer ( m_power_timer ); | 764 | killTimer ( m_power_timer ); |
765 | m_power_timer = 0; | 765 | m_power_timer = 0; |
766 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 766 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
767 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 767 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
768 | } | 768 | } |
769 | 769 | ||
770 | 770 | ||
771 | void iPAQ::alarmSound ( ) | 771 | void iPAQ::alarmSound ( ) |
772 | { | 772 | { |
773 | #ifndef QT_NO_SOUND | 773 | #ifndef QT_NO_SOUND |
774 | static Sound snd ( "alarm" ); | 774 | static Sound snd ( "alarm" ); |
775 | int fd; | 775 | int fd; |
776 | int vol; | 776 | int vol; |
777 | bool vol_reset = false; | 777 | bool vol_reset = false; |
778 | 778 | ||
779 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 779 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
780 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 780 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
781 | Config cfg ( "qpe" ); | 781 | Config cfg ( "qpe" ); |
782 | cfg. setGroup ( "Volume" ); | 782 | cfg. setGroup ( "Volume" ); |
783 | 783 | ||
784 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 784 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
785 | if ( volalarm < 0 ) | 785 | if ( volalarm < 0 ) |
786 | volalarm = 0; | 786 | volalarm = 0; |
787 | else if ( volalarm > 100 ) | 787 | else if ( volalarm > 100 ) |
788 | volalarm = 100; | 788 | volalarm = 100; |
789 | volalarm |= ( volalarm << 8 ); | 789 | volalarm |= ( volalarm << 8 ); |
790 | 790 | ||
791 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 791 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
792 | vol_reset = true; | 792 | vol_reset = true; |
793 | } | 793 | } |
794 | } | 794 | } |
795 | 795 | ||
796 | snd. play ( ); | 796 | snd. play ( ); |
797 | while ( !snd. isFinished ( )) | 797 | while ( !snd. isFinished ( )) |
798 | qApp-> processEvents ( ); | 798 | qApp-> processEvents ( ); |
799 | 799 | ||
800 | if ( fd >= 0 ) { | 800 | if ( fd >= 0 ) { |
801 | if ( vol_reset ) | 801 | if ( vol_reset ) |
802 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 802 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
803 | ::close ( fd ); | 803 | ::close ( fd ); |
804 | } | 804 | } |
805 | #endif | 805 | #endif |
806 | } | 806 | } |
807 | 807 | ||
808 | 808 | ||
809 | bool iPAQ::setSoftSuspend ( bool soft ) | 809 | bool iPAQ::setSoftSuspend ( bool soft ) |
810 | { | 810 | { |
811 | bool res = false; | 811 | bool res = false; |
812 | int fd; | 812 | int fd; |
813 | 813 | ||
814 | 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 ) { |
815 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 815 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
816 | res = true; | 816 | res = true; |
817 | else | 817 | else |
818 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 818 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
819 | 819 | ||
820 | ::close ( fd ); | 820 | ::close ( fd ); |
821 | } | 821 | } |
822 | else | 822 | else |
823 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 823 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
824 | 824 | ||
825 | return res; | 825 | return res; |
826 | } | 826 | } |
827 | 827 | ||
828 | 828 | ||
829 | bool iPAQ::setDisplayBrightness ( int bright ) | 829 | bool iPAQ::setDisplayBrightness ( int bright ) |
830 | { | 830 | { |
831 | bool res = false; | 831 | bool res = false; |
832 | int fd; | 832 | int fd; |
833 | 833 | ||
834 | if ( bright > 255 ) | 834 | if ( bright > 255 ) |
835 | bright = 255; | 835 | bright = 255; |
836 | if ( bright < 0 ) | 836 | if ( bright < 0 ) |
837 | bright = 0; | 837 | bright = 0; |
838 | 838 | ||
839 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 839 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
840 | FLITE_IN bl; | 840 | FLITE_IN bl; |
841 | bl. mode = 1; | 841 | bl. mode = 1; |
842 | bl. pwr = bright ? 1 : 0; | 842 | bl. pwr = bright ? 1 : 0; |
843 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 843 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
844 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 844 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
845 | ::close ( fd ); | 845 | ::close ( fd ); |
846 | } | 846 | } |
847 | return res; | 847 | return res; |
848 | } | 848 | } |
849 | 849 | ||
850 | int iPAQ::displayBrightnessResolution ( ) const | 850 | int iPAQ::displayBrightnessResolution ( ) const |
851 | { | 851 | { |
852 | switch ( model ( )) { | 852 | switch ( model ( )) { |
853 | case Model_iPAQ_H31xx: | 853 | case Model_iPAQ_H31xx: |
854 | case Model_iPAQ_H36xx: | 854 | case Model_iPAQ_H36xx: |
855 | case Model_iPAQ_H37xx: | 855 | case Model_iPAQ_H37xx: |
856 | return 128; // really 256, but >128 could damage the LCD | 856 | return 128; // really 256, but >128 could damage the LCD |
857 | 857 | ||
858 | case Model_iPAQ_H38xx: | 858 | case Model_iPAQ_H38xx: |
859 | case Model_iPAQ_H39xx: | 859 | case Model_iPAQ_H39xx: |
860 | return 64; | 860 | return 64; |
861 | 861 | ||
862 | default: | 862 | default: |
863 | return 2; | 863 | return 2; |
864 | } | 864 | } |
865 | } | 865 | } |
866 | 866 | ||
867 | 867 | ||
868 | bool iPAQ::hasLightSensor ( ) const | 868 | bool iPAQ::hasLightSensor ( ) const |
869 | { | 869 | { |
870 | return true; | 870 | return true; |
871 | } | 871 | } |
872 | 872 | ||
873 | int iPAQ::readLightSensor ( ) | 873 | int iPAQ::readLightSensor ( ) |
874 | { | 874 | { |
875 | int fd; | 875 | int fd; |
876 | int val = -1; | 876 | int val = -1; |
877 | 877 | ||
878 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 878 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
879 | char buffer [8]; | 879 | char buffer [8]; |
880 | 880 | ||
881 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 881 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |