-rw-r--r-- | libopie/odevice.cpp | 4 | ||||
-rw-r--r-- | libopie/odevice.h | 2 |
2 files changed, 5 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index d6e6892..993aedf 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -660,392 +660,394 @@ QString ODevice::systemVersionString ( ) const | |||
660 | * @return the current Transformation | 660 | * @return the current Transformation |
661 | */ | 661 | */ |
662 | Transformation ODevice::rotation ( ) const | 662 | Transformation ODevice::rotation ( ) const |
663 | { | 663 | { |
664 | return d-> m_rotation; | 664 | return d-> m_rotation; |
665 | } | 665 | } |
666 | 666 | ||
667 | /** | 667 | /** |
668 | * @return the current rotation direction | 668 | * @return the current rotation direction |
669 | */ | 669 | */ |
670 | ODirection ODevice::direction ( ) const | 670 | ODirection ODevice::direction ( ) const |
671 | { | 671 | { |
672 | return d-> m_direction; | 672 | return d-> m_direction; |
673 | } | 673 | } |
674 | 674 | ||
675 | /** | 675 | /** |
676 | * This plays an alarmSound | 676 | * This plays an alarmSound |
677 | */ | 677 | */ |
678 | void ODevice::alarmSound ( ) | 678 | void ODevice::alarmSound ( ) |
679 | { | 679 | { |
680 | #ifndef QT_NO_SOUND | 680 | #ifndef QT_NO_SOUND |
681 | static Sound snd ( "alarm" ); | 681 | static Sound snd ( "alarm" ); |
682 | 682 | ||
683 | if ( snd. isFinished ( )) | 683 | if ( snd. isFinished ( )) |
684 | snd. play ( ); | 684 | snd. play ( ); |
685 | #endif | 685 | #endif |
686 | } | 686 | } |
687 | 687 | ||
688 | /** | 688 | /** |
689 | * This plays a key sound | 689 | * This plays a key sound |
690 | */ | 690 | */ |
691 | void ODevice::keySound ( ) | 691 | void ODevice::keySound ( ) |
692 | { | 692 | { |
693 | #ifndef QT_NO_SOUND | 693 | #ifndef QT_NO_SOUND |
694 | static Sound snd ( "keysound" ); | 694 | static Sound snd ( "keysound" ); |
695 | 695 | ||
696 | if ( snd. isFinished ( )) | 696 | if ( snd. isFinished ( )) |
697 | snd. play ( ); | 697 | snd. play ( ); |
698 | #endif | 698 | #endif |
699 | } | 699 | } |
700 | 700 | ||
701 | /** | 701 | /** |
702 | * This plays a touch sound | 702 | * This plays a touch sound |
703 | */ | 703 | */ |
704 | void ODevice::touchSound ( ) | 704 | void ODevice::touchSound ( ) |
705 | { | 705 | { |
706 | #ifndef QT_NO_SOUND | 706 | #ifndef QT_NO_SOUND |
707 | static Sound snd ( "touchsound" ); | 707 | static Sound snd ( "touchsound" ); |
708 | 708 | ||
709 | if ( snd. isFinished ( )) | 709 | if ( snd. isFinished ( )) |
710 | snd. play ( ); | 710 | snd. play ( ); |
711 | #endif | 711 | #endif |
712 | } | 712 | } |
713 | 713 | ||
714 | /** | 714 | /** |
715 | * This method will return a list of leds | 715 | * This method will return a list of leds |
716 | * available on this device | 716 | * available on this device |
717 | * @return a list of LEDs. | 717 | * @return a list of LEDs. |
718 | */ | 718 | */ |
719 | QValueList <OLed> ODevice::ledList ( ) const | 719 | QValueList <OLed> ODevice::ledList ( ) const |
720 | { | 720 | { |
721 | return QValueList <OLed> ( ); | 721 | return QValueList <OLed> ( ); |
722 | } | 722 | } |
723 | 723 | ||
724 | /** | 724 | /** |
725 | * This does return the state of the LEDs | 725 | * This does return the state of the LEDs |
726 | */ | 726 | */ |
727 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 727 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
728 | { | 728 | { |
729 | return QValueList <OLedState> ( ); | 729 | return QValueList <OLedState> ( ); |
730 | } | 730 | } |
731 | 731 | ||
732 | /** | 732 | /** |
733 | * @return the state for a given OLed | 733 | * @return the state for a given OLed |
734 | */ | 734 | */ |
735 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 735 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
736 | { | 736 | { |
737 | return Led_Off; | 737 | return Led_Off; |
738 | } | 738 | } |
739 | 739 | ||
740 | /** | 740 | /** |
741 | * Set the state for a LED | 741 | * Set the state for a LED |
742 | * @param which Which OLed to use | 742 | * @param which Which OLed to use |
743 | * @param st The state to set | 743 | * @param st The state to set |
744 | * @return success or failure | 744 | * @return success or failure |
745 | */ | 745 | */ |
746 | bool ODevice::setLedState ( OLed which, OLedState st ) | 746 | bool ODevice::setLedState ( OLed which, OLedState st ) |
747 | { | 747 | { |
748 | Q_UNUSED( which ) | 748 | Q_UNUSED( which ) |
749 | Q_UNUSED( st ) | 749 | Q_UNUSED( st ) |
750 | return false; | 750 | return false; |
751 | } | 751 | } |
752 | 752 | ||
753 | /** | 753 | /** |
754 | * @return if the device has a light sensor | 754 | * @return if the device has a light sensor |
755 | */ | 755 | */ |
756 | bool ODevice::hasLightSensor ( ) const | 756 | bool ODevice::hasLightSensor ( ) const |
757 | { | 757 | { |
758 | return false; | 758 | return false; |
759 | } | 759 | } |
760 | 760 | ||
761 | /** | 761 | /** |
762 | * @return a value from the light senso | 762 | * @return a value from the light senso |
763 | */ | 763 | */ |
764 | int ODevice::readLightSensor ( ) | 764 | int ODevice::readLightSensor ( ) |
765 | { | 765 | { |
766 | return -1; | 766 | return -1; |
767 | } | 767 | } |
768 | 768 | ||
769 | /** | 769 | /** |
770 | * @return the light sensor resolution whatever that is ;) | 770 | * @return the light sensor resolution whatever that is ;) |
771 | */ | 771 | */ |
772 | int ODevice::lightSensorResolution ( ) const | 772 | int ODevice::lightSensorResolution ( ) const |
773 | { | 773 | { |
774 | return 0; | 774 | return 0; |
775 | } | 775 | } |
776 | 776 | ||
777 | /** | 777 | /** |
778 | * @return a list with CPU frequencies supported by the hardware | 778 | * @return a list with CPU frequencies supported by the hardware |
779 | */ | 779 | */ |
780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 780 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
781 | { | 781 | { |
782 | return *d->m_cpu_frequencies; | 782 | return *d->m_cpu_frequencies; |
783 | } | 783 | } |
784 | 784 | ||
785 | 785 | ||
786 | /** | 786 | /** |
787 | * Set desired CPU frequency | 787 | * Set desired CPU frequency |
788 | * | 788 | * |
789 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 789 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
790 | */ | 790 | */ |
791 | bool ODevice::setCurrentCpuFrequency(uint index) | 791 | bool ODevice::setCurrentCpuFrequency(uint index) |
792 | { | 792 | { |
793 | if (index >= d->m_cpu_frequencies->count()) | 793 | if (index >= d->m_cpu_frequencies->count()) |
794 | return false; | 794 | return false; |
795 | 795 | ||
796 | char *freq = d->m_cpu_frequencies->at(index); | 796 | char *freq = d->m_cpu_frequencies->at(index); |
797 | qWarning("set freq to %s", freq); | 797 | qWarning("set freq to %s", freq); |
798 | 798 | ||
799 | int fd; | 799 | int fd; |
800 | 800 | ||
801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 801 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
802 | char writeCommand[50]; | 802 | char writeCommand[50]; |
803 | const int count = sprintf(writeCommand, "%s\n", freq); | 803 | const int count = sprintf(writeCommand, "%s\n", freq); |
804 | int res = (::write(fd, writeCommand, count) != -1); | 804 | int res = (::write(fd, writeCommand, count) != -1); |
805 | ::close(fd); | 805 | ::close(fd); |
806 | return res; | 806 | return res; |
807 | } | 807 | } |
808 | 808 | ||
809 | return false; | 809 | return false; |
810 | } | 810 | } |
811 | 811 | ||
812 | 812 | ||
813 | /** | 813 | /** |
814 | * @return a list of hardware buttons | 814 | * @return a list of hardware buttons |
815 | */ | 815 | */ |
816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 816 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
817 | { | 817 | { |
818 | initButtons ( ); | 818 | initButtons ( ); |
819 | 819 | ||
820 | return *d-> m_buttons; | 820 | return *d-> m_buttons; |
821 | } | 821 | } |
822 | 822 | ||
823 | /** | 823 | /** |
824 | * @return The amount of time that would count as a hold | 824 | * @return The amount of time that would count as a hold |
825 | */ | 825 | */ |
826 | uint ODevice::buttonHoldTime ( ) const | 826 | uint ODevice::buttonHoldTime ( ) const |
827 | { | 827 | { |
828 | return d-> m_holdtime; | 828 | return d-> m_holdtime; |
829 | } | 829 | } |
830 | 830 | ||
831 | /** | 831 | /** |
832 | * This method return a ODeviceButton for a key code | 832 | * This method return a ODeviceButton for a key code |
833 | * or 0 if no special hardware button is available for the device | 833 | * or 0 if no special hardware button is available for the device |
834 | * | 834 | * |
835 | * @return The devicebutton or 0l | 835 | * @return The devicebutton or 0l |
836 | * @see ODeviceButton | 836 | * @see ODeviceButton |
837 | */ | 837 | */ |
838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 838 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
839 | { | 839 | { |
840 | initButtons ( ); | 840 | initButtons ( ); |
841 | 841 | ||
842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 842 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
843 | if ( (*it). keycode ( ) == code ) | 843 | if ( (*it). keycode ( ) == code ) |
844 | return &(*it); | 844 | return &(*it); |
845 | } | 845 | } |
846 | return 0; | 846 | return 0; |
847 | } | 847 | } |
848 | 848 | ||
849 | void ODevice::reloadButtonMapping ( ) | 849 | void ODevice::reloadButtonMapping ( ) |
850 | { | 850 | { |
851 | initButtons ( ); | 851 | initButtons ( ); |
852 | 852 | ||
853 | Config cfg ( "ButtonSettings" ); | 853 | Config cfg ( "ButtonSettings" ); |
854 | 854 | ||
855 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 855 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
856 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 856 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
857 | QString group = "Button" + QString::number ( i ); | 857 | QString group = "Button" + QString::number ( i ); |
858 | 858 | ||
859 | QCString pch, hch; | 859 | QCString pch, hch; |
860 | QCString pm, hm; | 860 | QCString pm, hm; |
861 | QByteArray pdata, hdata; | 861 | QByteArray pdata, hdata; |
862 | 862 | ||
863 | if ( cfg. hasGroup ( group )) { | 863 | if ( cfg. hasGroup ( group )) { |
864 | cfg. setGroup ( group ); | 864 | cfg. setGroup ( group ); |
865 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 865 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
866 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 866 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
867 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 867 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
868 | 868 | ||
869 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 869 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
870 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 870 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
871 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 871 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
872 | } | 872 | } |
873 | 873 | ||
874 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 874 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
875 | 875 | ||
876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 876 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
877 | } | 877 | } |
878 | } | 878 | } |
879 | 879 | ||
880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 880 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
881 | { | 881 | { |
882 | initButtons ( ); | 882 | initButtons ( ); |
883 | 883 | ||
884 | QString mb_chan; | 884 | QString mb_chan; |
885 | 885 | ||
886 | if ( button >= (int) d-> m_buttons-> count ( )) | 886 | if ( button >= (int) d-> m_buttons-> count ( )) |
887 | return; | 887 | return; |
888 | 888 | ||
889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 889 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
890 | b. setPressedAction ( action ); | 890 | b. setPressedAction ( action ); |
891 | 891 | ||
892 | mb_chan=b. pressedAction ( ). channel ( ); | 892 | mb_chan=b. pressedAction ( ). channel ( ); |
893 | 893 | ||
894 | Config buttonFile ( "ButtonSettings" ); | 894 | Config buttonFile ( "ButtonSettings" ); |
895 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 895 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 896 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 897 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
898 | 898 | ||
899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 899 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
900 | 900 | ||
901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 901 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
902 | } | 902 | } |
903 | 903 | ||
904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 904 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
905 | { | 905 | { |
906 | initButtons ( ); | 906 | initButtons ( ); |
907 | 907 | ||
908 | if ( button >= (int) d-> m_buttons-> count ( )) | 908 | if ( button >= (int) d-> m_buttons-> count ( )) |
909 | return; | 909 | return; |
910 | 910 | ||
911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 911 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
912 | b. setHeldAction ( action ); | 912 | b. setHeldAction ( action ); |
913 | 913 | ||
914 | Config buttonFile ( "ButtonSettings" ); | 914 | Config buttonFile ( "ButtonSettings" ); |
915 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 915 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 916 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 917 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
918 | 918 | ||
919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 919 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
920 | 920 | ||
921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 921 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
922 | } | 922 | } |
923 | void ODevice::virtual_hook( int id, void* data ) { | ||
923 | 924 | ||
925 | } | ||
924 | 926 | ||
925 | 927 | ||
926 | 928 | ||
927 | /************************************************** | 929 | /************************************************** |
928 | * | 930 | * |
929 | * iPAQ | 931 | * iPAQ |
930 | * | 932 | * |
931 | **************************************************/ | 933 | **************************************************/ |
932 | 934 | ||
933 | void iPAQ::init ( ) | 935 | void iPAQ::init ( ) |
934 | { | 936 | { |
935 | d-> m_vendorstr = "HP"; | 937 | d-> m_vendorstr = "HP"; |
936 | d-> m_vendor = Vendor_HP; | 938 | d-> m_vendor = Vendor_HP; |
937 | 939 | ||
938 | QFile f ( "/proc/hal/model" ); | 940 | QFile f ( "/proc/hal/model" ); |
939 | 941 | ||
940 | if ( f. open ( IO_ReadOnly )) { | 942 | if ( f. open ( IO_ReadOnly )) { |
941 | QTextStream ts ( &f ); | 943 | QTextStream ts ( &f ); |
942 | 944 | ||
943 | d-> m_modelstr = "H" + ts. readLine ( ); | 945 | d-> m_modelstr = "H" + ts. readLine ( ); |
944 | 946 | ||
945 | if ( d-> m_modelstr == "H3100" ) | 947 | if ( d-> m_modelstr == "H3100" ) |
946 | d-> m_model = Model_iPAQ_H31xx; | 948 | d-> m_model = Model_iPAQ_H31xx; |
947 | else if ( d-> m_modelstr == "H3600" ) | 949 | else if ( d-> m_modelstr == "H3600" ) |
948 | d-> m_model = Model_iPAQ_H36xx; | 950 | d-> m_model = Model_iPAQ_H36xx; |
949 | else if ( d-> m_modelstr == "H3700" ) | 951 | else if ( d-> m_modelstr == "H3700" ) |
950 | d-> m_model = Model_iPAQ_H37xx; | 952 | d-> m_model = Model_iPAQ_H37xx; |
951 | else if ( d-> m_modelstr == "H3800" ) | 953 | else if ( d-> m_modelstr == "H3800" ) |
952 | d-> m_model = Model_iPAQ_H38xx; | 954 | d-> m_model = Model_iPAQ_H38xx; |
953 | else if ( d-> m_modelstr == "H3900" ) | 955 | else if ( d-> m_modelstr == "H3900" ) |
954 | d-> m_model = Model_iPAQ_H39xx; | 956 | d-> m_model = Model_iPAQ_H39xx; |
955 | else | 957 | else |
956 | d-> m_model = Model_Unknown; | 958 | d-> m_model = Model_Unknown; |
957 | 959 | ||
958 | f. close ( ); | 960 | f. close ( ); |
959 | } | 961 | } |
960 | 962 | ||
961 | switch ( d-> m_model ) { | 963 | switch ( d-> m_model ) { |
962 | case Model_iPAQ_H31xx: | 964 | case Model_iPAQ_H31xx: |
963 | case Model_iPAQ_H38xx: | 965 | case Model_iPAQ_H38xx: |
964 | d-> m_rotation = Rot90; | 966 | d-> m_rotation = Rot90; |
965 | break; | 967 | break; |
966 | case Model_iPAQ_H36xx: | 968 | case Model_iPAQ_H36xx: |
967 | case Model_iPAQ_H37xx: | 969 | case Model_iPAQ_H37xx: |
968 | case Model_iPAQ_H39xx: | 970 | case Model_iPAQ_H39xx: |
969 | default: | 971 | default: |
970 | d-> m_rotation = Rot270; | 972 | d-> m_rotation = Rot270; |
971 | break; | 973 | break; |
972 | } | 974 | } |
973 | 975 | ||
974 | f. setName ( "/etc/familiar-version" ); | 976 | f. setName ( "/etc/familiar-version" ); |
975 | if ( f. open ( IO_ReadOnly )) { | 977 | if ( f. open ( IO_ReadOnly )) { |
976 | d-> m_systemstr = "Familiar"; | 978 | d-> m_systemstr = "Familiar"; |
977 | d-> m_system = System_Familiar; | 979 | d-> m_system = System_Familiar; |
978 | 980 | ||
979 | QTextStream ts ( &f ); | 981 | QTextStream ts ( &f ); |
980 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 982 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
981 | 983 | ||
982 | f. close ( ); | 984 | f. close ( ); |
983 | } else { | 985 | } else { |
984 | f. setName ( "/etc/oz_version" ); | 986 | f. setName ( "/etc/oz_version" ); |
985 | 987 | ||
986 | if ( f. open ( IO_ReadOnly )) { | 988 | if ( f. open ( IO_ReadOnly )) { |
987 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 989 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
988 | d-> m_system = System_Familiar; | 990 | d-> m_system = System_Familiar; |
989 | 991 | ||
990 | QTextStream ts ( &f ); | 992 | QTextStream ts ( &f ); |
991 | ts.setDevice ( &f ); | 993 | ts.setDevice ( &f ); |
992 | d-> m_sysverstr = ts. readLine ( ); | 994 | d-> m_sysverstr = ts. readLine ( ); |
993 | f. close ( ); | 995 | f. close ( ); |
994 | } | 996 | } |
995 | } | 997 | } |
996 | 998 | ||
997 | 999 | ||
998 | 1000 | ||
999 | 1001 | ||
1000 | 1002 | ||
1001 | m_leds [0] = m_leds [1] = Led_Off; | 1003 | m_leds [0] = m_leds [1] = Led_Off; |
1002 | 1004 | ||
1003 | m_power_timer = 0; | 1005 | m_power_timer = 0; |
1004 | 1006 | ||
1005 | } | 1007 | } |
1006 | 1008 | ||
1007 | void iPAQ::initButtons ( ) | 1009 | void iPAQ::initButtons ( ) |
1008 | { | 1010 | { |
1009 | if ( d-> m_buttons ) | 1011 | if ( d-> m_buttons ) |
1010 | return; | 1012 | return; |
1011 | 1013 | ||
1012 | if ( isQWS( ) ) | 1014 | if ( isQWS( ) ) |
1013 | QWSServer::setKeyboardFilter ( this ); | 1015 | QWSServer::setKeyboardFilter ( this ); |
1014 | 1016 | ||
1015 | d-> m_buttons = new QValueList <ODeviceButton>; | 1017 | d-> m_buttons = new QValueList <ODeviceButton>; |
1016 | 1018 | ||
1017 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1019 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1018 | i_button *ib = ipaq_buttons + i; | 1020 | i_button *ib = ipaq_buttons + i; |
1019 | ODeviceButton b; | 1021 | ODeviceButton b; |
1020 | 1022 | ||
1021 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1023 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1022 | b. setKeycode ( ib-> code ); | 1024 | b. setKeycode ( ib-> code ); |
1023 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1025 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1024 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1026 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1025 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1027 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1026 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1028 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1027 | 1029 | ||
1028 | d-> m_buttons-> append ( b ); | 1030 | d-> m_buttons-> append ( b ); |
1029 | } | 1031 | } |
1030 | } | 1032 | } |
1031 | reloadButtonMapping ( ); | 1033 | reloadButtonMapping ( ); |
1032 | 1034 | ||
1033 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1035 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1034 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1036 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1035 | } | 1037 | } |
1036 | 1038 | ||
1037 | 1039 | ||
1038 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1040 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1039 | 1041 | ||
1040 | typedef struct { | 1042 | typedef struct { |
1041 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1043 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1042 | unsigned char TotalTime; /* Units of 5 seconds */ | 1044 | unsigned char TotalTime; /* Units of 5 seconds */ |
1043 | unsigned char OnTime; /* units of 100m/s */ | 1045 | unsigned char OnTime; /* units of 100m/s */ |
1044 | unsigned char OffTime; /* units of 100m/s */ | 1046 | unsigned char OffTime; /* units of 100m/s */ |
1045 | } LED_IN; | 1047 | } LED_IN; |
1046 | 1048 | ||
1047 | typedef struct { | 1049 | typedef struct { |
1048 | unsigned char mode; | 1050 | unsigned char mode; |
1049 | unsigned char pwr; | 1051 | unsigned char pwr; |
1050 | unsigned char brightness; | 1052 | unsigned char brightness; |
1051 | } FLITE_IN; | 1053 | } FLITE_IN; |
diff --git a/libopie/odevice.h b/libopie/odevice.h index f2f6467..a232d69 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -115,134 +115,136 @@ enum OHardKey { | |||
115 | HardKey_Home = Qt::Key_F12, | 115 | HardKey_Home = Qt::Key_F12, |
116 | HardKey_Mail = Qt::Key_F13, | 116 | HardKey_Mail = Qt::Key_F13, |
117 | HardKey_Record = Qt::Key_F24, | 117 | HardKey_Record = Qt::Key_F24, |
118 | HardKey_Suspend = Qt::Key_F34, | 118 | HardKey_Suspend = Qt::Key_F34, |
119 | HardKey_Backlight = Qt::Key_F35, | 119 | HardKey_Backlight = Qt::Key_F35, |
120 | }; | 120 | }; |
121 | 121 | ||
122 | enum ODirection { | 122 | enum ODirection { |
123 | CW = 0, | 123 | CW = 0, |
124 | CCW = 1, | 124 | CCW = 1, |
125 | Flip = 2, | 125 | Flip = 2, |
126 | }; | 126 | }; |
127 | 127 | ||
128 | /** | 128 | /** |
129 | * A singleton which gives informations about device specefic option | 129 | * A singleton which gives informations about device specefic option |
130 | * like the Hardware used, LEDs, the Base Distribution and | 130 | * like the Hardware used, LEDs, the Base Distribution and |
131 | * hardware key mappings. | 131 | * hardware key mappings. |
132 | * | 132 | * |
133 | * @short A small class for device specefic options | 133 | * @short A small class for device specefic options |
134 | * @see QObject | 134 | * @see QObject |
135 | * @author Robert Griebl | 135 | * @author Robert Griebl |
136 | * @version 1.0 | 136 | * @version 1.0 |
137 | */ | 137 | */ |
138 | class ODevice : public QObject { | 138 | class ODevice : public QObject { |
139 | Q_OBJECT | 139 | Q_OBJECT |
140 | 140 | ||
141 | private: | 141 | private: |
142 | /* disable copy */ | 142 | /* disable copy */ |
143 | ODevice ( const ODevice & ); | 143 | ODevice ( const ODevice & ); |
144 | 144 | ||
145 | protected: | 145 | protected: |
146 | ODevice ( ); | 146 | ODevice ( ); |
147 | virtual void init ( ); | 147 | virtual void init ( ); |
148 | virtual void initButtons ( ); | 148 | virtual void initButtons ( ); |
149 | 149 | ||
150 | ODeviceData *d; | 150 | ODeviceData *d; |
151 | 151 | ||
152 | public: | 152 | public: |
153 | // sandman do we want to allow destructions? -zecke? | 153 | // sandman do we want to allow destructions? -zecke? |
154 | virtual ~ODevice ( ); | 154 | virtual ~ODevice ( ); |
155 | 155 | ||
156 | static ODevice *inst ( ); | 156 | static ODevice *inst ( ); |
157 | 157 | ||
158 | // information | 158 | // information |
159 | 159 | ||
160 | QString modelString ( ) const; | 160 | QString modelString ( ) const; |
161 | OModel model ( ) const; | 161 | OModel model ( ) const; |
162 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 162 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
163 | 163 | ||
164 | QString vendorString ( ) const; | 164 | QString vendorString ( ) const; |
165 | OVendor vendor ( ) const; | 165 | OVendor vendor ( ) const; |
166 | 166 | ||
167 | QString systemString ( ) const; | 167 | QString systemString ( ) const; |
168 | OSystem system ( ) const; | 168 | OSystem system ( ) const; |
169 | 169 | ||
170 | QString systemVersionString ( ) const; | 170 | QString systemVersionString ( ) const; |
171 | 171 | ||
172 | Transformation rotation ( ) const; | 172 | Transformation rotation ( ) const; |
173 | ODirection direction ( ) const; | 173 | ODirection direction ( ) const; |
174 | 174 | ||
175 | // system | 175 | // system |
176 | 176 | ||
177 | virtual bool setSoftSuspend ( bool on ); | 177 | virtual bool setSoftSuspend ( bool on ); |
178 | virtual bool suspend ( ); | 178 | virtual bool suspend ( ); |
179 | 179 | ||
180 | virtual bool setDisplayStatus ( bool on ); | 180 | virtual bool setDisplayStatus ( bool on ); |
181 | virtual bool setDisplayBrightness ( int brightness ); | 181 | virtual bool setDisplayBrightness ( int brightness ); |
182 | virtual int displayBrightnessResolution ( ) const; | 182 | virtual int displayBrightnessResolution ( ) const; |
183 | virtual bool setDisplayContrast ( int contrast ); | 183 | virtual bool setDisplayContrast ( int contrast ); |
184 | virtual int displayContrastResolution ( ) const; | 184 | virtual int displayContrastResolution ( ) const; |
185 | 185 | ||
186 | // input / output | 186 | // input / output |
187 | //FIXME playAlarmSound and al might be better -zecke | 187 | //FIXME playAlarmSound and al might be better -zecke |
188 | virtual void alarmSound ( ); | 188 | virtual void alarmSound ( ); |
189 | virtual void keySound ( ); | 189 | virtual void keySound ( ); |
190 | virtual void touchSound ( ); | 190 | virtual void touchSound ( ); |
191 | 191 | ||
192 | virtual QValueList <OLed> ledList ( ) const; | 192 | virtual QValueList <OLed> ledList ( ) const; |
193 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 193 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
194 | virtual OLedState ledState ( OLed led ) const; | 194 | virtual OLedState ledState ( OLed led ) const; |
195 | virtual bool setLedState ( OLed led, OLedState st ); | 195 | virtual bool setLedState ( OLed led, OLedState st ); |
196 | 196 | ||
197 | virtual bool hasLightSensor ( ) const; | 197 | virtual bool hasLightSensor ( ) const; |
198 | virtual int readLightSensor ( ); | 198 | virtual int readLightSensor ( ); |
199 | virtual int lightSensorResolution ( ) const; | 199 | virtual int lightSensorResolution ( ) const; |
200 | 200 | ||
201 | const QStrList &allowedCpuFrequencies() const; | 201 | const QStrList &allowedCpuFrequencies() const; |
202 | bool setCurrentCpuFrequency(uint index); | 202 | bool setCurrentCpuFrequency(uint index); |
203 | 203 | ||
204 | /** | 204 | /** |
205 | * Returns the available buttons on this device. The number and location | 205 | * Returns the available buttons on this device. The number and location |
206 | * of buttons will vary depending on the device. Button numbers will be assigned | 206 | * of buttons will vary depending on the device. Button numbers will be assigned |
207 | * by the device manufacturer and will be from most preferred button to least preffered | 207 | * by the device manufacturer and will be from most preferred button to least preffered |
208 | * button. Note that this list only contains "user mappable" buttons. | 208 | * button. Note that this list only contains "user mappable" buttons. |
209 | */ | 209 | */ |
210 | const QValueList<ODeviceButton> &buttons ( ); | 210 | const QValueList<ODeviceButton> &buttons ( ); |
211 | 211 | ||
212 | /** | 212 | /** |
213 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 213 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
214 | * returns 0L | 214 | * returns 0L |
215 | */ | 215 | */ |
216 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 216 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
217 | 217 | ||
218 | /** | 218 | /** |
219 | * Reassigns the pressed action for \a button. To return to the factory | 219 | * Reassigns the pressed action for \a button. To return to the factory |
220 | * default pass an empty string as \a qcopMessage. | 220 | * default pass an empty string as \a qcopMessage. |
221 | */ | 221 | */ |
222 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 222 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
223 | 223 | ||
224 | /** | 224 | /** |
225 | * Reassigns the held action for \a button. To return to the factory | 225 | * Reassigns the held action for \a button. To return to the factory |
226 | * default pass an empty string as \a qcopMessage. | 226 | * default pass an empty string as \a qcopMessage. |
227 | */ | 227 | */ |
228 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 228 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
229 | 229 | ||
230 | /** | 230 | /** |
231 | * How long (in ms) you have to press a button for a "hold" action | 231 | * How long (in ms) you have to press a button for a "hold" action |
232 | */ | 232 | */ |
233 | uint buttonHoldTime ( ) const; | 233 | uint buttonHoldTime ( ) const; |
234 | 234 | ||
235 | signals: | 235 | signals: |
236 | void buttonMappingChanged ( ); | 236 | void buttonMappingChanged ( ); |
237 | 237 | ||
238 | private slots: | 238 | private slots: |
239 | void systemMessage ( const QCString &, const QByteArray & ); | 239 | void systemMessage ( const QCString &, const QByteArray & ); |
240 | 240 | ||
241 | protected: | 241 | protected: |
242 | void reloadButtonMapping ( ); | 242 | void reloadButtonMapping ( ); |
243 | /* ugly virtual hook */ | ||
244 | virtual void virtual_hook( int id, void* data ); | ||
243 | }; | 245 | }; |
244 | 246 | ||
245 | } | 247 | } |
246 | 248 | ||
247 | #endif | 249 | #endif |
248 | 250 | ||