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