summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-19 18:06:17 (UTC)
committer kergoth <kergoth>2003-04-19 18:06:17 (UTC)
commiteb276a6663540849ef98819eeaa8f935a7e1b945 (patch) (unidiff)
tree7464e0858a367034f976088021ccec5953a0eddc
parent89ced5d0c4f4ce89a11333d80aac2f8b81d97233 (diff)
downloadopie-eb276a6663540849ef98819eeaa8f935a7e1b945.zip
opie-eb276a6663540849ef98819eeaa8f935a7e1b945.tar.gz
opie-eb276a6663540849ef98819eeaa8f935a7e1b945.tar.bz2
Add note about c700 physical screen orientation handling.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 29c8ad2..713cc90 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -765,630 +765,642 @@ void iPAQ::init ( )
765 f. close ( ); 765 f. close ( );
766 } 766 }
767 } 767 }
768 768
769 769
770 770
771 771
772 772
773 m_leds [0] = m_leds [1] = Led_Off; 773 m_leds [0] = m_leds [1] = Led_Off;
774 774
775 m_power_timer = 0; 775 m_power_timer = 0;
776 776
777} 777}
778 778
779void iPAQ::initButtons ( ) 779void iPAQ::initButtons ( )
780{ 780{
781 if ( d-> m_buttons ) 781 if ( d-> m_buttons )
782 return; 782 return;
783 783
784 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 784 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
785 785
786 if ( d-> m_qwsserver ) 786 if ( d-> m_qwsserver )
787 QWSServer::setKeyboardFilter ( this ); 787 QWSServer::setKeyboardFilter ( this );
788 788
789 d-> m_buttons = new QValueList <ODeviceButton>; 789 d-> m_buttons = new QValueList <ODeviceButton>;
790 790
791 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 791 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
792 i_button *ib = ipaq_buttons + i; 792 i_button *ib = ipaq_buttons + i;
793 ODeviceButton b; 793 ODeviceButton b;
794 794
795 if (( ib-> model & d-> m_model ) == d-> m_model ) { 795 if (( ib-> model & d-> m_model ) == d-> m_model ) {
796 b. setKeycode ( ib-> code ); 796 b. setKeycode ( ib-> code );
797 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 797 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
798 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 798 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
799 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 799 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
800 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 800 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
801 801
802 d-> m_buttons-> append ( b ); 802 d-> m_buttons-> append ( b );
803 } 803 }
804 } 804 }
805 reloadButtonMapping ( ); 805 reloadButtonMapping ( );
806 806
807 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 807 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
808 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 808 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
809} 809}
810 810
811 811
812//#include <linux/h3600_ts.h> // including kernel headers is evil ... 812//#include <linux/h3600_ts.h> // including kernel headers is evil ...
813 813
814typedef struct { 814typedef struct {
815 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 815 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
816 unsigned char TotalTime; /* Units of 5 seconds */ 816 unsigned char TotalTime; /* Units of 5 seconds */
817 unsigned char OnTime; /* units of 100m/s */ 817 unsigned char OnTime; /* units of 100m/s */
818 unsigned char OffTime; /* units of 100m/s */ 818 unsigned char OffTime; /* units of 100m/s */
819} LED_IN; 819} LED_IN;
820 820
821typedef struct { 821typedef struct {
822 unsigned char mode; 822 unsigned char mode;
823 unsigned char pwr; 823 unsigned char pwr;
824 unsigned char brightness; 824 unsigned char brightness;
825} FLITE_IN; 825} FLITE_IN;
826 826
827#define LED_ON OD_IOW( 'f', 5, LED_IN ) 827#define LED_ON OD_IOW( 'f', 5, LED_IN )
828#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 828#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
829 829
830 830
831QValueList <OLed> iPAQ::ledList ( ) const 831QValueList <OLed> iPAQ::ledList ( ) const
832{ 832{
833 QValueList <OLed> vl; 833 QValueList <OLed> vl;
834 vl << Led_Power; 834 vl << Led_Power;
835 835
836 if ( d-> m_model == Model_iPAQ_H38xx ) 836 if ( d-> m_model == Model_iPAQ_H38xx )
837 vl << Led_BlueTooth; 837 vl << Led_BlueTooth;
838 return vl; 838 return vl;
839} 839}
840 840
841QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 841QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
842{ 842{
843 QValueList <OLedState> vl; 843 QValueList <OLedState> vl;
844 844
845 if ( l == Led_Power ) 845 if ( l == Led_Power )
846 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 846 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
847 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 847 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
848 vl << Led_Off; // << Led_On << ??? 848 vl << Led_Off; // << Led_On << ???
849 849
850 return vl; 850 return vl;
851} 851}
852 852
853OLedState iPAQ::ledState ( OLed l ) const 853OLedState iPAQ::ledState ( OLed l ) const
854{ 854{
855 switch ( l ) { 855 switch ( l ) {
856 case Led_Power: 856 case Led_Power:
857 return m_leds [0]; 857 return m_leds [0];
858 case Led_BlueTooth: 858 case Led_BlueTooth:
859 return m_leds [1]; 859 return m_leds [1];
860 default: 860 default:
861 return Led_Off; 861 return Led_Off;
862 } 862 }
863} 863}
864 864
865bool iPAQ::setLedState ( OLed l, OLedState st ) 865bool iPAQ::setLedState ( OLed l, OLedState st )
866{ 866{
867 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 867 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
868 868
869 if ( l == Led_Power ) { 869 if ( l == Led_Power ) {
870 if ( fd >= 0 ) { 870 if ( fd >= 0 ) {
871 LED_IN leds; 871 LED_IN leds;
872 ::memset ( &leds, 0, sizeof( leds )); 872 ::memset ( &leds, 0, sizeof( leds ));
873 leds. TotalTime = 0; 873 leds. TotalTime = 0;
874 leds. OnTime = 0; 874 leds. OnTime = 0;
875 leds. OffTime = 1; 875 leds. OffTime = 1;
876 leds. OffOnBlink = 2; 876 leds. OffOnBlink = 2;
877 877
878 switch ( st ) { 878 switch ( st ) {
879 case Led_Off : leds. OffOnBlink = 0; break; 879 case Led_Off : leds. OffOnBlink = 0; break;
880 case Led_On : leds. OffOnBlink = 1; break; 880 case Led_On : leds. OffOnBlink = 1; break;
881 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 881 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
882 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 882 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
883 } 883 }
884 884
885 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 885 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
886 m_leds [0] = st; 886 m_leds [0] = st;
887 return true; 887 return true;
888 } 888 }
889 } 889 }
890 } 890 }
891 return false; 891 return false;
892} 892}
893 893
894 894
895bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 895bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
896{ 896{
897 int newkeycode = keycode; 897 int newkeycode = keycode;
898 898
899 switch ( keycode ) { 899 switch ( keycode ) {
900 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 900 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
901 case HardKey_Menu: { 901 case HardKey_Menu: {
902 if (( d-> m_model == Model_iPAQ_H38xx ) || 902 if (( d-> m_model == Model_iPAQ_H38xx ) ||
903 ( d-> m_model == Model_iPAQ_H39xx )) { 903 ( d-> m_model == Model_iPAQ_H39xx )) {
904 newkeycode = HardKey_Mail; 904 newkeycode = HardKey_Mail;
905 } 905 }
906 break; 906 break;
907 } 907 }
908 908
909 // Rotate cursor keys 180° 909 // Rotate cursor keys 180°
910 case Key_Left : 910 case Key_Left :
911 case Key_Right: 911 case Key_Right:
912 case Key_Up : 912 case Key_Up :
913 case Key_Down : { 913 case Key_Down : {
914 if (( d-> m_model == Model_iPAQ_H31xx ) || 914 if (( d-> m_model == Model_iPAQ_H31xx ) ||
915 ( d-> m_model == Model_iPAQ_H38xx )) { 915 ( d-> m_model == Model_iPAQ_H38xx )) {
916 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 916 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
917 } 917 }
918 break; 918 break;
919 } 919 }
920 920
921 // map Power Button short/long press to F34/F35 921 // map Power Button short/long press to F34/F35
922 case Key_SysReq: { 922 case Key_SysReq: {
923 if ( isPress ) { 923 if ( isPress ) {
924 if ( m_power_timer ) 924 if ( m_power_timer )
925 killTimer ( m_power_timer ); 925 killTimer ( m_power_timer );
926 m_power_timer = startTimer ( 500 ); 926 m_power_timer = startTimer ( 500 );
927 } 927 }
928 else if ( m_power_timer ) { 928 else if ( m_power_timer ) {
929 killTimer ( m_power_timer ); 929 killTimer ( m_power_timer );
930 m_power_timer = 0; 930 m_power_timer = 0;
931 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 931 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
932 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 932 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
933 } 933 }
934 newkeycode = Key_unknown; 934 newkeycode = Key_unknown;
935 break; 935 break;
936 } 936 }
937 } 937 }
938 938
939 if ( newkeycode != keycode ) { 939 if ( newkeycode != keycode ) {
940 if ( newkeycode != Key_unknown ) 940 if ( newkeycode != Key_unknown )
941 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 941 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
942 return true; 942 return true;
943 } 943 }
944 else 944 else
945 return false; 945 return false;
946} 946}
947 947
948void iPAQ::timerEvent ( QTimerEvent * ) 948void iPAQ::timerEvent ( QTimerEvent * )
949{ 949{
950 killTimer ( m_power_timer ); 950 killTimer ( m_power_timer );
951 m_power_timer = 0; 951 m_power_timer = 0;
952 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 952 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
953 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 953 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
954} 954}
955 955
956 956
957void iPAQ::alarmSound ( ) 957void iPAQ::alarmSound ( )
958{ 958{
959#ifndef QT_NO_SOUND 959#ifndef QT_NO_SOUND
960 static Sound snd ( "alarm" ); 960 static Sound snd ( "alarm" );
961 int fd; 961 int fd;
962 int vol; 962 int vol;
963 bool vol_reset = false; 963 bool vol_reset = false;
964 964
965 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 965 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
966 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 966 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
967 Config cfg ( "qpe" ); 967 Config cfg ( "qpe" );
968 cfg. setGroup ( "Volume" ); 968 cfg. setGroup ( "Volume" );
969 969
970 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 970 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
971 if ( volalarm < 0 ) 971 if ( volalarm < 0 )
972 volalarm = 0; 972 volalarm = 0;
973 else if ( volalarm > 100 ) 973 else if ( volalarm > 100 )
974 volalarm = 100; 974 volalarm = 100;
975 volalarm |= ( volalarm << 8 ); 975 volalarm |= ( volalarm << 8 );
976 976
977 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 977 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
978 vol_reset = true; 978 vol_reset = true;
979 } 979 }
980 } 980 }
981 981
982 snd. play ( ); 982 snd. play ( );
983 while ( !snd. isFinished ( )) 983 while ( !snd. isFinished ( ))
984 qApp-> processEvents ( ); 984 qApp-> processEvents ( );
985 985
986 if ( fd >= 0 ) { 986 if ( fd >= 0 ) {
987 if ( vol_reset ) 987 if ( vol_reset )
988 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 988 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
989 ::close ( fd ); 989 ::close ( fd );
990 } 990 }
991#endif 991#endif
992} 992}
993 993
994 994
995bool iPAQ::setSoftSuspend ( bool soft ) 995bool iPAQ::setSoftSuspend ( bool soft )
996{ 996{
997 bool res = false; 997 bool res = false;
998 int fd; 998 int fd;
999 999
1000 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1000 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1001 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1001 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1002 res = true; 1002 res = true;
1003 else 1003 else
1004 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1004 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1005 1005
1006 ::close ( fd ); 1006 ::close ( fd );
1007 } 1007 }
1008 else 1008 else
1009 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1009 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1010 1010
1011 return res; 1011 return res;
1012} 1012}
1013 1013
1014 1014
1015bool iPAQ::setDisplayBrightness ( int bright ) 1015bool iPAQ::setDisplayBrightness ( int bright )
1016{ 1016{
1017 bool res = false; 1017 bool res = false;
1018 int fd; 1018 int fd;
1019 1019
1020 if ( bright > 255 ) 1020 if ( bright > 255 )
1021 bright = 255; 1021 bright = 255;
1022 if ( bright < 0 ) 1022 if ( bright < 0 )
1023 bright = 0; 1023 bright = 0;
1024 1024
1025 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1025 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1026 FLITE_IN bl; 1026 FLITE_IN bl;
1027 bl. mode = 1; 1027 bl. mode = 1;
1028 bl. pwr = bright ? 1 : 0; 1028 bl. pwr = bright ? 1 : 0;
1029 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1029 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1030 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1030 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1031 ::close ( fd ); 1031 ::close ( fd );
1032 } 1032 }
1033 return res; 1033 return res;
1034} 1034}
1035 1035
1036int iPAQ::displayBrightnessResolution ( ) const 1036int iPAQ::displayBrightnessResolution ( ) const
1037{ 1037{
1038 switch ( model ( )) { 1038 switch ( model ( )) {
1039 case Model_iPAQ_H31xx: 1039 case Model_iPAQ_H31xx:
1040 case Model_iPAQ_H36xx: 1040 case Model_iPAQ_H36xx:
1041 case Model_iPAQ_H37xx: 1041 case Model_iPAQ_H37xx:
1042 return 128; // really 256, but >128 could damage the LCD 1042 return 128; // really 256, but >128 could damage the LCD
1043 1043
1044 case Model_iPAQ_H38xx: 1044 case Model_iPAQ_H38xx:
1045 case Model_iPAQ_H39xx: 1045 case Model_iPAQ_H39xx:
1046 return 64; 1046 return 64;
1047 1047
1048 default: 1048 default:
1049 return 2; 1049 return 2;
1050 } 1050 }
1051} 1051}
1052 1052
1053 1053
1054bool iPAQ::hasLightSensor ( ) const 1054bool iPAQ::hasLightSensor ( ) const
1055{ 1055{
1056 return true; 1056 return true;
1057} 1057}
1058 1058
1059int iPAQ::readLightSensor ( ) 1059int iPAQ::readLightSensor ( )
1060{ 1060{
1061 int fd; 1061 int fd;
1062 int val = -1; 1062 int val = -1;
1063 1063
1064 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1064 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1065 char buffer [8]; 1065 char buffer [8];
1066 1066
1067 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1067 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1068 char *endptr; 1068 char *endptr;
1069 1069
1070 buffer [4] = 0; 1070 buffer [4] = 0;
1071 val = ::strtol ( buffer + 2, &endptr, 16 ); 1071 val = ::strtol ( buffer + 2, &endptr, 16 );
1072 1072
1073 if ( *endptr != 0 ) 1073 if ( *endptr != 0 )
1074 val = -1; 1074 val = -1;
1075 } 1075 }
1076 ::close ( fd ); 1076 ::close ( fd );
1077 } 1077 }
1078 1078
1079 return val; 1079 return val;
1080} 1080}
1081 1081
1082int iPAQ::lightSensorResolution ( ) const 1082int iPAQ::lightSensorResolution ( ) const
1083{ 1083{
1084 return 256; 1084 return 256;
1085} 1085}
1086 1086
1087/************************************************** 1087/**************************************************
1088 * 1088 *
1089 * Zaurus 1089 * Zaurus
1090 * 1090 *
1091 **************************************************/ 1091 **************************************************/
1092 1092
1093 1093
1094 1094
1095void Zaurus::init ( ) 1095void Zaurus::init ( )
1096{ 1096{
1097 d-> m_vendorstr = "Sharp"; 1097 d-> m_vendorstr = "Sharp";
1098 d-> m_vendor = Vendor_Sharp; 1098 d-> m_vendor = Vendor_Sharp;
1099 1099
1100 QFile f ( "/proc/filesystems" ); 1100 QFile f ( "/proc/filesystems" );
1101 1101
1102 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1102 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1103 d-> m_vendorstr = "OpenZaurus Team"; 1103 d-> m_vendorstr = "OpenZaurus Team";
1104 d-> m_systemstr = "OpenZaurus"; 1104 d-> m_systemstr = "OpenZaurus";
1105 d-> m_system = System_OpenZaurus; 1105 d-> m_system = System_OpenZaurus;
1106 1106
1107 f. close ( ); 1107 f. close ( );
1108 1108
1109 f. setName ( "/etc/oz_version" ); 1109 f. setName ( "/etc/oz_version" );
1110 if ( f. open ( IO_ReadOnly )) { 1110 if ( f. open ( IO_ReadOnly )) {
1111 QTextStream ts ( &f ); 1111 QTextStream ts ( &f );
1112 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1112 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1113 f. close ( ); 1113 f. close ( );
1114 } 1114 }
1115 } 1115 }
1116 else { 1116 else {
1117 d-> m_systemstr = "Zaurus"; 1117 d-> m_systemstr = "Zaurus";
1118 d-> m_system = System_Zaurus; 1118 d-> m_system = System_Zaurus;
1119 } 1119 }
1120 1120
1121 f. setName ( "/proc/deviceinfo/product" ); 1121 f. setName ( "/proc/deviceinfo/product" );
1122 if ( f. open ( IO_ReadOnly ) ) { 1122 if ( f. open ( IO_ReadOnly ) ) {
1123 QTextStream ts ( &f ); 1123 QTextStream ts ( &f );
1124 QString model = ts. readLine ( ); 1124 QString model = ts. readLine ( );
1125 f. close ( ); 1125 f. close ( );
1126 1126
1127 d-> m_modelstr = QString("Zaurus ") + model; 1127 d-> m_modelstr = QString("Zaurus ") + model;
1128 if ( model == "SL-5500" ) 1128 if ( model == "SL-5500" )
1129 d-> m_model = Model_Zaurus_SL5500; 1129 d-> m_model = Model_Zaurus_SL5500;
1130 else if ( model == "SL-C700" ) 1130 else if ( model == "SL-C700" )
1131 d-> m_model = Model_Zaurus_SLC700; 1131 d-> m_model = Model_Zaurus_SLC700;
1132 else if ( model == "SL-A300" ) 1132 else if ( model == "SL-A300" )
1133 d-> m_model = Model_Zaurus_SLA300; 1133 d-> m_model = Model_Zaurus_SLA300;
1134 else if ( model == "SL-B600" || model == "SL-5600" ) 1134 else if ( model == "SL-B600" || model == "SL-5600" )
1135 d-> m_model = Model_Zaurus_SLB600; 1135 d-> m_model = Model_Zaurus_SLB600;
1136 else 1136 else
1137 d-> m_model = Model_Zaurus_SL5000; 1137 d-> m_model = Model_Zaurus_SL5000;
1138 } 1138 }
1139 else { 1139 else {
1140 d-> m_model = Model_Zaurus_SL5000; 1140 d-> m_model = Model_Zaurus_SL5000;
1141 d-> m_modelstr = "Zaurus (model unknown)"; 1141 d-> m_modelstr = "Zaurus (model unknown)";
1142 } 1142 }
1143 1143
1144 switch ( d-> m_model ) { 1144 switch ( d-> m_model ) {
1145 case Model_Zaurus_SLA300: 1145 case Model_Zaurus_SLA300:
1146 d-> m_rotation = Rot0; 1146 d-> m_rotation = Rot0;
1147 break; 1147 break;
1148 case Model_Zaurus_SLC700: 1148 case Model_Zaurus_SLC700:
1149 /* note for C700, we must check the display rotation 1149 bool flipstate = false;
1150 * sensor to set an appropriate value 1150 // Note: need to 1) set flipstate based on physical screen orientation
1151 */ 1151 // and 2) check to see if the user overrode the rotation direction
1152 // using appearance, and if so, remove that item from the Config to
1153 // ensure the rotate applet flips us back to the previous state.
1154 if ( flipstate ) {
1155 // 480x640
1156 d-> m_rotation = Rot0;
1157 d-> m_direction = CW;
1158 } else {
1159 // 640x480
1160 d-> m_rotation = Rot270;
1161 d-> m_direction = CCW;
1162 }
1163 break;
1152 case Model_Zaurus_SLB600: 1164 case Model_Zaurus_SLB600:
1153 case Model_Zaurus_SL5500: 1165 case Model_Zaurus_SL5500:
1154 case Model_Zaurus_SL5000: 1166 case Model_Zaurus_SL5000:
1155 default: 1167 default:
1156 d-> m_rotation = Rot270; 1168 d-> m_rotation = Rot270;
1157 break; 1169 break;
1158 } 1170 }
1159 m_leds [0] = Led_Off; 1171 m_leds [0] = Led_Off;
1160} 1172}
1161 1173
1162void Zaurus::initButtons ( ) 1174void Zaurus::initButtons ( )
1163{ 1175{
1164 if ( d-> m_buttons ) 1176 if ( d-> m_buttons )
1165 return; 1177 return;
1166 1178
1167 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 1179 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
1168 1180
1169 d-> m_buttons = new QValueList <ODeviceButton>; 1181 d-> m_buttons = new QValueList <ODeviceButton>;
1170 1182
1171 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { 1183 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
1172 z_button *zb = z_buttons + i; 1184 z_button *zb = z_buttons + i;
1173 ODeviceButton b; 1185 ODeviceButton b;
1174 1186
1175 b. setKeycode ( zb-> code ); 1187 b. setKeycode ( zb-> code );
1176 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1188 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1177 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1189 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1178 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1190 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1179 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1191 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1180 1192
1181 d-> m_buttons-> append ( b ); 1193 d-> m_buttons-> append ( b );
1182 } 1194 }
1183 1195
1184 reloadButtonMapping ( ); 1196 reloadButtonMapping ( );
1185 1197
1186 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1198 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1187 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1199 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1188} 1200}
1189 1201
1190#include <unistd.h> 1202#include <unistd.h>
1191#include <fcntl.h> 1203#include <fcntl.h>
1192#include <sys/ioctl.h> 1204#include <sys/ioctl.h>
1193 1205
1194//#include <asm/sharp_char.h> // including kernel headers is evil ... 1206//#include <asm/sharp_char.h> // including kernel headers is evil ...
1195 1207
1196#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1208#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1197 1209
1198 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1210 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1199#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1211#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1200 1212
1201#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1213#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1202#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1214#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1203#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1215#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1204 1216
1205/* --- for SHARP_BUZZER device --- */ 1217/* --- for SHARP_BUZZER device --- */
1206 1218
1207 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1219 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1208//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1220//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1209 1221
1210#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1222#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1211#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1223#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1212#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1224#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1213#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1225#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1214#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1226#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1215 1227
1216//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1228//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1217//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1229//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1218 1230
1219//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1231//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1220//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1232//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1221//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1233//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1222//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1234//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1223//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1235//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1224//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1236//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1225//#define SHARP_PDA_APPSTART 9 /* application start */ 1237//#define SHARP_PDA_APPSTART 9 /* application start */
1226//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1238//#define SHARP_PDA_APPQUIT 10 /* application ends */
1227 1239
1228//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1240//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1229//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1241//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1230//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1242//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1231//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1243//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1232// 1244//
1233 1245
1234 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1246 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1235#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1247#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1236 1248
1237typedef struct sharp_led_status { 1249typedef struct sharp_led_status {
1238 int which; /* select which LED status is wanted. */ 1250 int which; /* select which LED status is wanted. */
1239 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1251 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1240} sharp_led_status; 1252} sharp_led_status;
1241 1253
1242#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1254#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1243 1255
1244#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1256#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1245#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1257#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1246#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1258#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1247 1259
1248// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1260// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1249 1261
1250#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1262#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1251#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1263#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1252#define APM_EVT_POWER_BUTTON (1 << 0) 1264#define APM_EVT_POWER_BUTTON (1 << 0)
1253 1265
1254#define FL_IOCTL_STEP_CONTRAST 100 1266#define FL_IOCTL_STEP_CONTRAST 100
1255 1267
1256 1268
1257void Zaurus::buzzer ( int sound ) 1269void Zaurus::buzzer ( int sound )
1258{ 1270{
1259 static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1271 static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1260 1272
1261 if ( fd >= 0 ) { 1273 if ( fd >= 0 ) {
1262 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1274 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1263 ::close ( fd ); 1275 ::close ( fd );
1264 } 1276 }
1265} 1277}
1266 1278
1267 1279
1268void Zaurus::alarmSound ( ) 1280void Zaurus::alarmSound ( )
1269{ 1281{
1270 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1282 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1271} 1283}
1272 1284
1273void Zaurus::touchSound ( ) 1285void Zaurus::touchSound ( )
1274{ 1286{
1275 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1287 buzzer ( SHARP_BUZ_TOUCHSOUND );
1276} 1288}
1277 1289
1278void Zaurus::keySound ( ) 1290void Zaurus::keySound ( )
1279{ 1291{
1280 buzzer ( SHARP_BUZ_KEYSOUND ); 1292 buzzer ( SHARP_BUZ_KEYSOUND );
1281} 1293}
1282 1294
1283 1295
1284QValueList <OLed> Zaurus::ledList ( ) const 1296QValueList <OLed> Zaurus::ledList ( ) const
1285{ 1297{
1286 QValueList <OLed> vl; 1298 QValueList <OLed> vl;
1287 vl << Led_Mail; 1299 vl << Led_Mail;
1288 return vl; 1300 return vl;
1289} 1301}
1290 1302
1291QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1303QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1292{ 1304{
1293 QValueList <OLedState> vl; 1305 QValueList <OLedState> vl;
1294 1306
1295 if ( l == Led_Mail ) 1307 if ( l == Led_Mail )
1296 vl << Led_Off << Led_On << Led_BlinkSlow; 1308 vl << Led_Off << Led_On << Led_BlinkSlow;
1297 return vl; 1309 return vl;
1298} 1310}
1299 1311
1300OLedState Zaurus::ledState ( OLed which ) const 1312OLedState Zaurus::ledState ( OLed which ) const
1301{ 1313{
1302 if ( which == Led_Mail ) 1314 if ( which == Led_Mail )
1303 return m_leds [0]; 1315 return m_leds [0];
1304 else 1316 else
1305 return Led_Off; 1317 return Led_Off;
1306} 1318}
1307 1319
1308bool Zaurus::setLedState ( OLed which, OLedState st ) 1320bool Zaurus::setLedState ( OLed which, OLedState st )
1309{ 1321{
1310 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1322 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1311 1323
1312 if ( which == Led_Mail ) { 1324 if ( which == Led_Mail ) {
1313 if ( fd >= 0 ) { 1325 if ( fd >= 0 ) {
1314 struct sharp_led_status leds; 1326 struct sharp_led_status leds;
1315 ::memset ( &leds, 0, sizeof( leds )); 1327 ::memset ( &leds, 0, sizeof( leds ));
1316 leds. which = SHARP_LED_MAIL_EXISTS; 1328 leds. which = SHARP_LED_MAIL_EXISTS;
1317 bool ok = true; 1329 bool ok = true;
1318 1330
1319 switch ( st ) { 1331 switch ( st ) {
1320 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1332 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1321 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1333 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1322 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1334 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1323 default : ok = false; 1335 default : ok = false;
1324 } 1336 }
1325 1337
1326 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1338 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1327 m_leds [0] = st; 1339 m_leds [0] = st;
1328 return true; 1340 return true;
1329 } 1341 }
1330 } 1342 }
1331 } 1343 }
1332 return false; 1344 return false;
1333} 1345}
1334 1346
1335bool Zaurus::setSoftSuspend ( bool soft ) 1347bool Zaurus::setSoftSuspend ( bool soft )
1336{ 1348{
1337 bool res = false; 1349 bool res = false;
1338 int fd; 1350 int fd;
1339 1351
1340 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1352 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1341 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1353 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1342 1354
1343 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1355 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1344 1356
1345 if ( sources >= 0 ) { 1357 if ( sources >= 0 ) {
1346 if ( soft ) 1358 if ( soft )
1347 sources &= ~APM_EVT_POWER_BUTTON; 1359 sources &= ~APM_EVT_POWER_BUTTON;
1348 else 1360 else
1349 sources |= APM_EVT_POWER_BUTTON; 1361 sources |= APM_EVT_POWER_BUTTON;
1350 1362
1351 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1363 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1352 res = true; 1364 res = true;
1353 else 1365 else
1354 perror ( "APM_IOCGEVTSRC" ); 1366 perror ( "APM_IOCGEVTSRC" );
1355 } 1367 }
1356 else 1368 else
1357 perror ( "APM_IOCGEVTSRC" ); 1369 perror ( "APM_IOCGEVTSRC" );
1358 1370
1359 ::close ( fd ); 1371 ::close ( fd );
1360 } 1372 }
1361 else 1373 else
1362 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1374 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1363 1375
1364 return res; 1376 return res;
1365} 1377}
1366 1378
1367 1379
1368bool Zaurus::setDisplayBrightness ( int bright ) 1380bool Zaurus::setDisplayBrightness ( int bright )
1369{ 1381{
1370 bool res = false; 1382 bool res = false;
1371 int fd; 1383 int fd;
1372 1384
1373 if ( bright > 255 ) 1385 if ( bright > 255 )
1374 bright = 255; 1386 bright = 255;
1375 if ( bright < 0 ) 1387 if ( bright < 0 )
1376 bright = 0; 1388 bright = 0;
1377 1389
1378 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1390 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1379 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1391 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1380 if ( bright && !bl ) 1392 if ( bright && !bl )
1381 bl = 1; 1393 bl = 1;
1382 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1394 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1383 ::close ( fd ); 1395 ::close ( fd );
1384 } 1396 }
1385 return res; 1397 return res;
1386} 1398}
1387 1399
1388 1400
1389int Zaurus::displayBrightnessResolution ( ) const 1401int Zaurus::displayBrightnessResolution ( ) const
1390{ 1402{
1391 return 5; 1403 return 5;
1392} 1404}
1393 1405
1394 1406