summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp5
1 files changed, 4 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 02f13b5..2873407 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1004,797 +1004,800 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b
1004 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1004 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1005 } 1005 }
1006 newkeycode = Key_unknown; 1006 newkeycode = Key_unknown;
1007 break; 1007 break;
1008 } 1008 }
1009 } 1009 }
1010 1010
1011 if ( newkeycode != keycode ) { 1011 if ( newkeycode != keycode ) {
1012 if ( newkeycode != Key_unknown ) 1012 if ( newkeycode != Key_unknown )
1013 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1013 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1014 return true; 1014 return true;
1015 } 1015 }
1016 else 1016 else
1017 return false; 1017 return false;
1018} 1018}
1019 1019
1020void iPAQ::timerEvent ( QTimerEvent * ) 1020void iPAQ::timerEvent ( QTimerEvent * )
1021{ 1021{
1022 killTimer ( m_power_timer ); 1022 killTimer ( m_power_timer );
1023 m_power_timer = 0; 1023 m_power_timer = 0;
1024 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1024 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1025 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1025 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1026} 1026}
1027 1027
1028 1028
1029void iPAQ::alarmSound ( ) 1029void iPAQ::alarmSound ( )
1030{ 1030{
1031#ifndef QT_NO_SOUND 1031#ifndef QT_NO_SOUND
1032 static Sound snd ( "alarm" ); 1032 static Sound snd ( "alarm" );
1033 int fd; 1033 int fd;
1034 int vol; 1034 int vol;
1035 bool vol_reset = false; 1035 bool vol_reset = false;
1036 1036
1037 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1037 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1038 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1038 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1039 Config cfg ( "qpe" ); 1039 Config cfg ( "qpe" );
1040 cfg. setGroup ( "Volume" ); 1040 cfg. setGroup ( "Volume" );
1041 1041
1042 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1042 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1043 if ( volalarm < 0 ) 1043 if ( volalarm < 0 )
1044 volalarm = 0; 1044 volalarm = 0;
1045 else if ( volalarm > 100 ) 1045 else if ( volalarm > 100 )
1046 volalarm = 100; 1046 volalarm = 100;
1047 volalarm |= ( volalarm << 8 ); 1047 volalarm |= ( volalarm << 8 );
1048 1048
1049 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1049 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1050 vol_reset = true; 1050 vol_reset = true;
1051 } 1051 }
1052 } 1052 }
1053 1053
1054 snd. play ( ); 1054 snd. play ( );
1055 while ( !snd. isFinished ( )) 1055 while ( !snd. isFinished ( ))
1056 qApp-> processEvents ( ); 1056 qApp-> processEvents ( );
1057 1057
1058 if ( fd >= 0 ) { 1058 if ( fd >= 0 ) {
1059 if ( vol_reset ) 1059 if ( vol_reset )
1060 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1060 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1061 ::close ( fd ); 1061 ::close ( fd );
1062 } 1062 }
1063#endif 1063#endif
1064} 1064}
1065 1065
1066 1066
1067bool iPAQ::setSoftSuspend ( bool soft ) 1067bool iPAQ::setSoftSuspend ( bool soft )
1068{ 1068{
1069 bool res = false; 1069 bool res = false;
1070 int fd; 1070 int fd;
1071 1071
1072 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1072 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1073 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1073 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1074 res = true; 1074 res = true;
1075 else 1075 else
1076 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1076 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1077 1077
1078 ::close ( fd ); 1078 ::close ( fd );
1079 } 1079 }
1080 else 1080 else
1081 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1081 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1082 1082
1083 return res; 1083 return res;
1084} 1084}
1085 1085
1086 1086
1087bool iPAQ::setDisplayBrightness ( int bright ) 1087bool iPAQ::setDisplayBrightness ( int bright )
1088{ 1088{
1089 bool res = false; 1089 bool res = false;
1090 int fd; 1090 int fd;
1091 1091
1092 if ( bright > 255 ) 1092 if ( bright > 255 )
1093 bright = 255; 1093 bright = 255;
1094 if ( bright < 0 ) 1094 if ( bright < 0 )
1095 bright = 0; 1095 bright = 0;
1096 1096
1097 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1097 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1098 FLITE_IN bl; 1098 FLITE_IN bl;
1099 bl. mode = 1; 1099 bl. mode = 1;
1100 bl. pwr = bright ? 1 : 0; 1100 bl. pwr = bright ? 1 : 0;
1101 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1101 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1102 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1102 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1103 ::close ( fd ); 1103 ::close ( fd );
1104 } 1104 }
1105 return res; 1105 return res;
1106} 1106}
1107 1107
1108int iPAQ::displayBrightnessResolution ( ) const 1108int iPAQ::displayBrightnessResolution ( ) const
1109{ 1109{
1110 switch ( model ( )) { 1110 switch ( model ( )) {
1111 case Model_iPAQ_H31xx: 1111 case Model_iPAQ_H31xx:
1112 case Model_iPAQ_H36xx: 1112 case Model_iPAQ_H36xx:
1113 case Model_iPAQ_H37xx: 1113 case Model_iPAQ_H37xx:
1114 return 128; // really 256, but >128 could damage the LCD 1114 return 128; // really 256, but >128 could damage the LCD
1115 1115
1116 case Model_iPAQ_H38xx: 1116 case Model_iPAQ_H38xx:
1117 case Model_iPAQ_H39xx: 1117 case Model_iPAQ_H39xx:
1118 return 64; 1118 return 64;
1119 1119
1120 default: 1120 default:
1121 return 2; 1121 return 2;
1122 } 1122 }
1123} 1123}
1124 1124
1125 1125
1126bool iPAQ::hasLightSensor ( ) const 1126bool iPAQ::hasLightSensor ( ) const
1127{ 1127{
1128 return true; 1128 return true;
1129} 1129}
1130 1130
1131int iPAQ::readLightSensor ( ) 1131int iPAQ::readLightSensor ( )
1132{ 1132{
1133 int fd; 1133 int fd;
1134 int val = -1; 1134 int val = -1;
1135 1135
1136 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1136 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1137 char buffer [8]; 1137 char buffer [8];
1138 1138
1139 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1139 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1140 char *endptr; 1140 char *endptr;
1141 1141
1142 buffer [4] = 0; 1142 buffer [4] = 0;
1143 val = ::strtol ( buffer + 2, &endptr, 16 ); 1143 val = ::strtol ( buffer + 2, &endptr, 16 );
1144 1144
1145 if ( *endptr != 0 ) 1145 if ( *endptr != 0 )
1146 val = -1; 1146 val = -1;
1147 } 1147 }
1148 ::close ( fd ); 1148 ::close ( fd );
1149 } 1149 }
1150 1150
1151 return val; 1151 return val;
1152} 1152}
1153 1153
1154int iPAQ::lightSensorResolution ( ) const 1154int iPAQ::lightSensorResolution ( ) const
1155{ 1155{
1156 return 256; 1156 return 256;
1157} 1157}
1158 1158
1159/************************************************** 1159/**************************************************
1160 * 1160 *
1161 * Zaurus 1161 * Zaurus
1162 * 1162 *
1163 **************************************************/ 1163 **************************************************/
1164 1164
1165 1165
1166 1166
1167void Zaurus::init ( ) 1167void Zaurus::init ( )
1168{ 1168{
1169 d-> m_vendorstr = "Sharp"; 1169 d-> m_vendorstr = "Sharp";
1170 d-> m_vendor = Vendor_Sharp; 1170 d-> m_vendor = Vendor_Sharp;
1171 1171
1172 QFile f ( "/proc/filesystems" ); 1172 QFile f ( "/proc/filesystems" );
1173 QString model; 1173 QString model;
1174 1174
1175 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1175 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1176 d-> m_vendorstr = "OpenZaurus Team"; 1176 d-> m_vendorstr = "OpenZaurus Team";
1177 d-> m_systemstr = "OpenZaurus"; 1177 d-> m_systemstr = "OpenZaurus";
1178 d-> m_system = System_OpenZaurus; 1178 d-> m_system = System_OpenZaurus;
1179 1179
1180 f. close ( ); 1180 f. close ( );
1181 1181
1182 f. setName ( "/etc/oz_version" ); 1182 f. setName ( "/etc/oz_version" );
1183 if ( f. open ( IO_ReadOnly )) { 1183 if ( f. open ( IO_ReadOnly )) {
1184 QTextStream ts ( &f ); 1184 QTextStream ts ( &f );
1185 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1185 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1186 f. close ( ); 1186 f. close ( );
1187 } 1187 }
1188 } 1188 }
1189 else { 1189 else {
1190 d-> m_systemstr = "Zaurus"; 1190 d-> m_systemstr = "Zaurus";
1191 d-> m_system = System_Zaurus; 1191 d-> m_system = System_Zaurus;
1192 } 1192 }
1193 1193
1194 f. setName ( "/proc/cpuinfo" ); 1194 f. setName ( "/proc/cpuinfo" );
1195 if ( f. open ( IO_ReadOnly ) ) { 1195 if ( f. open ( IO_ReadOnly ) ) {
1196 QTextStream ts ( &f ); 1196 QTextStream ts ( &f );
1197 QString line; 1197 QString line;
1198 while( line = ts. readLine ( ) ) { 1198 while( line = ts. readLine ( ) ) {
1199 if ( line. left ( 8 ) == "Hardware" ) 1199 if ( line. left ( 8 ) == "Hardware" )
1200 break; 1200 break;
1201 } 1201 }
1202 int loc = line. find ( ":" ); 1202 int loc = line. find ( ":" );
1203 if ( loc != -1 ) 1203 if ( loc != -1 )
1204 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1204 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1205 } 1205 }
1206 1206
1207 if ( model == "SHARP Corgi" ) { 1207 if ( model == "SHARP Corgi" ) {
1208 d-> m_model = Model_Zaurus_SLC700; 1208 d-> m_model = Model_Zaurus_SLC700;
1209 d-> m_modelstr = "Zaurus SL-C700"; 1209 d-> m_modelstr = "Zaurus SL-C700";
1210 } else if ( model == "SHARP Poodle" ) { 1210 } else if ( model == "SHARP Poodle" ) {
1211 d-> m_model = Model_Zaurus_SLB600; 1211 d-> m_model = Model_Zaurus_SLB600;
1212 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1212 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1213 } else if ( model = "Sharp-Collie" ) { 1213 } else if ( model = "Sharp-Collie" ) {
1214 d-> m_model = Model_Zaurus_SL5500; 1214 d-> m_model = Model_Zaurus_SL5500;
1215 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1215 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1216 } else { 1216 } else {
1217 d-> m_model = Model_Zaurus_SL5500; 1217 d-> m_model = Model_Zaurus_SL5500;
1218 d-> m_modelstr = "Zaurus (Model unknown)"; 1218 d-> m_modelstr = "Zaurus (Model unknown)";
1219 } 1219 }
1220 1220
1221 bool flipstate = false; 1221 bool flipstate = false;
1222 switch ( d-> m_model ) { 1222 switch ( d-> m_model ) {
1223 case Model_Zaurus_SLA300: 1223 case Model_Zaurus_SLA300:
1224 d-> m_rotation = Rot0; 1224 d-> m_rotation = Rot0;
1225 break; 1225 break;
1226 case Model_Zaurus_SLC700: 1226 case Model_Zaurus_SLC700:
1227 // Note: need to 1) set flipstate based on physical screen orientation 1227 // Note: need to 1) set flipstate based on physical screen orientation
1228 // and 2) check to see if the user overrode the rotation direction 1228 // and 2) check to see if the user overrode the rotation direction
1229 // using appearance, and if so, remove that item from the Config to 1229 // using appearance, and if so, remove that item from the Config to
1230 // ensure the rotate applet flips us back to the previous state. 1230 // ensure the rotate applet flips us back to the previous state.
1231 if ( flipstate ) { 1231 if ( flipstate ) {
1232 // 480x640 1232 // 480x640
1233 d-> m_rotation = Rot0; 1233 d-> m_rotation = Rot0;
1234 d-> m_direction = CW; 1234 d-> m_direction = CW;
1235 } else { 1235 } else {
1236 // 640x480 1236 // 640x480
1237 d-> m_rotation = Rot270; 1237 d-> m_rotation = Rot270;
1238 d-> m_direction = CCW; 1238 d-> m_direction = CCW;
1239 } 1239 }
1240 break; 1240 break;
1241 case Model_Zaurus_SLB600: 1241 case Model_Zaurus_SLB600:
1242 case Model_Zaurus_SL5500: 1242 case Model_Zaurus_SL5500:
1243 case Model_Zaurus_SL5000: 1243 case Model_Zaurus_SL5000:
1244 default: 1244 default:
1245 d-> m_rotation = Rot270; 1245 d-> m_rotation = Rot270;
1246 break; 1246 break;
1247 } 1247 }
1248 m_leds [0] = Led_Off; 1248 m_leds [0] = Led_Off;
1249} 1249}
1250 1250
1251void Zaurus::initButtons ( ) 1251void Zaurus::initButtons ( )
1252{ 1252{
1253 if ( d-> m_buttons ) 1253 if ( d-> m_buttons )
1254 return; 1254 return;
1255 1255
1256 d-> m_buttons = new QValueList <ODeviceButton>; 1256 d-> m_buttons = new QValueList <ODeviceButton>;
1257 1257
1258 struct z_button * pz_buttons; 1258 struct z_button * pz_buttons;
1259 int buttoncount; 1259 int buttoncount;
1260 switch ( d-> m_model ) { 1260 switch ( d-> m_model ) {
1261 case Model_Zaurus_SLC700: 1261 case Model_Zaurus_SLC700:
1262 pz_buttons = z_buttons_c700; 1262 pz_buttons = z_buttons_c700;
1263 buttoncount = ARRAY_SIZE(z_buttons_c700); 1263 buttoncount = ARRAY_SIZE(z_buttons_c700);
1264 break; 1264 break;
1265 default: 1265 default:
1266 pz_buttons = z_buttons; 1266 pz_buttons = z_buttons;
1267 buttoncount = ARRAY_SIZE(z_buttons); 1267 buttoncount = ARRAY_SIZE(z_buttons);
1268 break; 1268 break;
1269 } 1269 }
1270 1270
1271 for ( int i = 0; i < buttoncount; i++ ) { 1271 for ( int i = 0; i < buttoncount; i++ ) {
1272 struct z_button *zb = pz_buttons + i; 1272 struct z_button *zb = pz_buttons + i;
1273 ODeviceButton b; 1273 ODeviceButton b;
1274 1274
1275 b. setKeycode ( zb-> code ); 1275 b. setKeycode ( zb-> code );
1276 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1276 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1277 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1277 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1278 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1278 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1279 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1279 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1280 1280
1281 d-> m_buttons-> append ( b ); 1281 d-> m_buttons-> append ( b );
1282 } 1282 }
1283 1283
1284 reloadButtonMapping ( ); 1284 reloadButtonMapping ( );
1285 1285
1286 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1286 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1287 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1287 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1288} 1288}
1289 1289
1290#include <unistd.h> 1290#include <unistd.h>
1291#include <fcntl.h> 1291#include <fcntl.h>
1292#include <sys/ioctl.h> 1292#include <sys/ioctl.h>
1293 1293
1294//#include <asm/sharp_char.h> // including kernel headers is evil ... 1294//#include <asm/sharp_char.h> // including kernel headers is evil ...
1295 1295
1296#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1296#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1297 1297
1298 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1298 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1299#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1299#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1300 1300
1301#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1301#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1302#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1302#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1303#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1303#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1304 1304
1305/* --- for SHARP_BUZZER device --- */ 1305/* --- for SHARP_BUZZER device --- */
1306 1306
1307 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1307 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1308//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1308//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1309 1309
1310#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1310#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1311#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1311#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1312#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1312#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1313#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1313#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1314#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1314#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1315 1315
1316//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1316//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1317//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1317//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1318 1318
1319//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1319//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1320//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1320//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1321//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1321//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1322//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1322//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1323//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1323//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1324//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1324//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1325//#define SHARP_PDA_APPSTART 9 /* application start */ 1325//#define SHARP_PDA_APPSTART 9 /* application start */
1326//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1326//#define SHARP_PDA_APPQUIT 10 /* application ends */
1327 1327
1328//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1328//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1329//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1329//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1330//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1330//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1331//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1331//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1332// 1332//
1333 1333
1334 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1334 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1335#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1335#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1336 1336
1337typedef struct sharp_led_status { 1337typedef struct sharp_led_status {
1338 int which; /* select which LED status is wanted. */ 1338 int which; /* select which LED status is wanted. */
1339 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1339 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1340} sharp_led_status; 1340} sharp_led_status;
1341 1341
1342#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1342#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1343 1343
1344#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1344#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1345#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1345#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1346#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1346#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1347 1347
1348// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1348// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1349 1349
1350#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1350#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1351#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1351#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1352#define APM_EVT_POWER_BUTTON (1 << 0) 1352#define APM_EVT_POWER_BUTTON (1 << 0)
1353 1353
1354#define FL_IOCTL_STEP_CONTRAST 100 1354#define FL_IOCTL_STEP_CONTRAST 100
1355 1355
1356 1356
1357void Zaurus::buzzer ( int sound ) 1357void Zaurus::buzzer ( int sound )
1358{ 1358{
1359 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1359 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1360 1360
1361 if ( fd >= 0 ) { 1361 if ( fd >= 0 ) {
1362 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1362 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1363 ::close ( fd ); 1363 ::close ( fd );
1364 } 1364 }
1365} 1365}
1366 1366
1367 1367
1368void Zaurus::alarmSound ( ) 1368void Zaurus::alarmSound ( )
1369{ 1369{
1370 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1370 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1371} 1371}
1372 1372
1373void Zaurus::touchSound ( ) 1373void Zaurus::touchSound ( )
1374{ 1374{
1375 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1375 buzzer ( SHARP_BUZ_TOUCHSOUND );
1376} 1376}
1377 1377
1378void Zaurus::keySound ( ) 1378void Zaurus::keySound ( )
1379{ 1379{
1380 buzzer ( SHARP_BUZ_KEYSOUND ); 1380 buzzer ( SHARP_BUZ_KEYSOUND );
1381} 1381}
1382 1382
1383 1383
1384QValueList <OLed> Zaurus::ledList ( ) const 1384QValueList <OLed> Zaurus::ledList ( ) const
1385{ 1385{
1386 QValueList <OLed> vl; 1386 QValueList <OLed> vl;
1387 vl << Led_Mail; 1387 vl << Led_Mail;
1388 return vl; 1388 return vl;
1389} 1389}
1390 1390
1391QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1391QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1392{ 1392{
1393 QValueList <OLedState> vl; 1393 QValueList <OLedState> vl;
1394 1394
1395 if ( l == Led_Mail ) 1395 if ( l == Led_Mail )
1396 vl << Led_Off << Led_On << Led_BlinkSlow; 1396 vl << Led_Off << Led_On << Led_BlinkSlow;
1397 return vl; 1397 return vl;
1398} 1398}
1399 1399
1400OLedState Zaurus::ledState ( OLed which ) const 1400OLedState Zaurus::ledState ( OLed which ) const
1401{ 1401{
1402 if ( which == Led_Mail ) 1402 if ( which == Led_Mail )
1403 return m_leds [0]; 1403 return m_leds [0];
1404 else 1404 else
1405 return Led_Off; 1405 return Led_Off;
1406} 1406}
1407 1407
1408bool Zaurus::setLedState ( OLed which, OLedState st ) 1408bool Zaurus::setLedState ( OLed which, OLedState st )
1409{ 1409{
1410 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1410 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1411 1411
1412 if ( which == Led_Mail ) { 1412 if ( which == Led_Mail ) {
1413 if ( fd >= 0 ) { 1413 if ( fd >= 0 ) {
1414 struct sharp_led_status leds; 1414 struct sharp_led_status leds;
1415 ::memset ( &leds, 0, sizeof( leds )); 1415 ::memset ( &leds, 0, sizeof( leds ));
1416 leds. which = SHARP_LED_MAIL_EXISTS; 1416 leds. which = SHARP_LED_MAIL_EXISTS;
1417 bool ok = true; 1417 bool ok = true;
1418 1418
1419 switch ( st ) { 1419 switch ( st ) {
1420 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1420 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1421 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1421 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1422 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1422 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1423 default : ok = false; 1423 default : ok = false;
1424 } 1424 }
1425 1425
1426 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1426 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1427 m_leds [0] = st; 1427 m_leds [0] = st;
1428 return true; 1428 return true;
1429 } 1429 }
1430 } 1430 }
1431 } 1431 }
1432 return false; 1432 return false;
1433} 1433}
1434 1434
1435bool Zaurus::setSoftSuspend ( bool soft ) 1435bool Zaurus::setSoftSuspend ( bool soft )
1436{ 1436{
1437 bool res = false; 1437 bool res = false;
1438 int fd; 1438 int fd;
1439 1439
1440 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1440 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1441 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1441 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1442 1442
1443 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1443 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1444 1444
1445 if ( sources >= 0 ) { 1445 if ( sources >= 0 ) {
1446 if ( soft ) 1446 if ( soft )
1447 sources &= ~APM_EVT_POWER_BUTTON; 1447 sources &= ~APM_EVT_POWER_BUTTON;
1448 else 1448 else
1449 sources |= APM_EVT_POWER_BUTTON; 1449 sources |= APM_EVT_POWER_BUTTON;
1450 1450
1451 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1451 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1452 res = true; 1452 res = true;
1453 else 1453 else
1454 perror ( "APM_IOCGEVTSRC" ); 1454 perror ( "APM_IOCGEVTSRC" );
1455 } 1455 }
1456 else 1456 else
1457 perror ( "APM_IOCGEVTSRC" ); 1457 perror ( "APM_IOCGEVTSRC" );
1458 1458
1459 ::close ( fd ); 1459 ::close ( fd );
1460 } 1460 }
1461 else 1461 else
1462 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1462 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1463 1463
1464 return res; 1464 return res;
1465} 1465}
1466 1466
1467 1467
1468bool Zaurus::setDisplayBrightness ( int bright ) 1468bool Zaurus::setDisplayBrightness ( int bright )
1469{ 1469{
1470 bool res = false; 1470 bool res = false;
1471 int fd; 1471 int fd;
1472 1472
1473 if ( bright > 255 ) 1473 if ( bright > 255 )
1474 bright = 255; 1474 bright = 255;
1475 if ( bright < 0 ) 1475 if ( bright < 0 )
1476 bright = 0; 1476 bright = 0;
1477 1477
1478 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1478 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1479 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1479 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1480 if ( bright && !bl ) 1480 if ( bright && !bl )
1481 bl = 1; 1481 bl = 1;
1482 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1482 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1483 ::close ( fd ); 1483 ::close ( fd );
1484 } 1484 }
1485 return res; 1485 return res;
1486} 1486}
1487 1487
1488 1488
1489int Zaurus::displayBrightnessResolution ( ) const 1489int Zaurus::displayBrightnessResolution ( ) const
1490{ 1490{
1491 return 5; 1491 return 5;
1492} 1492}
1493 1493
1494 1494
1495/************************************************** 1495/**************************************************
1496 * 1496 *
1497 * SIMpad 1497 * SIMpad
1498 * 1498 *
1499 **************************************************/ 1499 **************************************************/
1500 1500
1501void SIMpad::init ( ) 1501void SIMpad::init ( )
1502{ 1502{
1503 d-> m_vendorstr = "SIEMENS"; 1503 d-> m_vendorstr = "SIEMENS";
1504 d-> m_vendor = Vendor_SIEMENS; 1504 d-> m_vendor = Vendor_SIEMENS;
1505 1505
1506 QFile f ( "/proc/hal/model" ); 1506 QFile f ( "/proc/hal/model" );
1507 1507
1508 //TODO Implement model checking 1508 //TODO Implement model checking
1509 //FIXME For now we assume an SL4 1509 //FIXME For now we assume an SL4
1510 1510
1511 d-> m_modelstr = "SL4"; 1511 d-> m_modelstr = "SL4";
1512 d-> m_model = Model_SIMpad_SL4; 1512 d-> m_model = Model_SIMpad_SL4;
1513 1513
1514 switch ( d-> m_model ) { 1514 switch ( d-> m_model ) {
1515 default: 1515 default:
1516 d-> m_rotation = Rot270; 1516 d-> m_rotation = Rot0;
1517 d-> m_direction = CCW;
1518 d-> m_holdtime = 1000; // 1000ms
1519
1517 break; 1520 break;
1518 } 1521 }
1519 1522
1520 f. setName ( "/etc/familiar-version" ); 1523 f. setName ( "/etc/familiar-version" );
1521 if ( f. open ( IO_ReadOnly )) { 1524 if ( f. open ( IO_ReadOnly )) {
1522 d-> m_systemstr = "Familiar"; 1525 d-> m_systemstr = "Familiar";
1523 d-> m_system = System_Familiar; 1526 d-> m_system = System_Familiar;
1524 1527
1525 QTextStream ts ( &f ); 1528 QTextStream ts ( &f );
1526 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1529 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1527 1530
1528 f. close ( ); 1531 f. close ( );
1529 } else { 1532 } else {
1530 f. setName ( "/etc/oz_version" ); 1533 f. setName ( "/etc/oz_version" );
1531 1534
1532 if ( f. open ( IO_ReadOnly )) { 1535 if ( f. open ( IO_ReadOnly )) {
1533 d-> m_systemstr = "OpenEmbedded/SIMpad"; 1536 d-> m_systemstr = "OpenEmbedded/SIMpad";
1534 d-> m_system = System_OpenZaurus; 1537 d-> m_system = System_OpenZaurus;
1535 1538
1536 QTextStream ts ( &f ); 1539 QTextStream ts ( &f );
1537 ts.setDevice ( &f ); 1540 ts.setDevice ( &f );
1538 d-> m_sysverstr = ts. readLine ( ); 1541 d-> m_sysverstr = ts. readLine ( );
1539 f. close ( ); 1542 f. close ( );
1540 } 1543 }
1541 } 1544 }
1542 1545
1543 m_leds [0] = m_leds [1] = Led_Off; 1546 m_leds [0] = m_leds [1] = Led_Off;
1544 1547
1545 m_power_timer = 0; 1548 m_power_timer = 0;
1546 1549
1547} 1550}
1548 1551
1549void SIMpad::initButtons ( ) 1552void SIMpad::initButtons ( )
1550{ 1553{
1551 if ( d-> m_buttons ) 1554 if ( d-> m_buttons )
1552 return; 1555 return;
1553 1556
1554 if ( isQWS( ) ) 1557 if ( isQWS( ) )
1555 QWSServer::setKeyboardFilter ( this ); 1558 QWSServer::setKeyboardFilter ( this );
1556 1559
1557 d-> m_buttons = new QValueList <ODeviceButton>; 1560 d-> m_buttons = new QValueList <ODeviceButton>;
1558 1561
1559 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 1562 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
1560 s_button *sb = simpad_buttons + i; 1563 s_button *sb = simpad_buttons + i;
1561 ODeviceButton b; 1564 ODeviceButton b;
1562 1565
1563 if (( sb-> model & d-> m_model ) == d-> m_model ) { 1566 if (( sb-> model & d-> m_model ) == d-> m_model ) {
1564 b. setKeycode ( sb-> code ); 1567 b. setKeycode ( sb-> code );
1565 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 1568 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
1566 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 1569 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
1567 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 1570 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
1568 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 1571 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
1569 1572
1570 d-> m_buttons-> append ( b ); 1573 d-> m_buttons-> append ( b );
1571 } 1574 }
1572 } 1575 }
1573 reloadButtonMapping ( ); 1576 reloadButtonMapping ( );
1574 1577
1575 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1578 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1576 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1579 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1577} 1580}
1578 1581
1579// SIMpad boardcontrol register CS3 1582// SIMpad boardcontrol register CS3
1580#define SIMPAD_BOARDCONTROL "/proc/cs3" 1583#define SIMPAD_BOARDCONTROL "/proc/cs3"
1581#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 1584#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
1582#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 1585#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
1583#define SIMPAD_EN1 0x0004 // This is only for EPROM's 1586#define SIMPAD_EN1 0x0004 // This is only for EPROM's
1584#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 1587#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
1585#define SIMPAD_DISPLAY_ON 0x0010 1588#define SIMPAD_DISPLAY_ON 0x0010
1586#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 1589#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
1587#define SIMPAD_MQ_RESET 0x0040 1590#define SIMPAD_MQ_RESET 0x0040
1588#define SIMPAD_PCMCIA_RESET 0x0080 1591#define SIMPAD_PCMCIA_RESET 0x0080
1589#define SIMPAD_DECT_POWER_ON 0x0100 1592#define SIMPAD_DECT_POWER_ON 0x0100
1590#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 1593#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
1591#define SIMPAD_RS232_ON 0x0400 1594#define SIMPAD_RS232_ON 0x0400
1592#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 1595#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
1593#define SIMPAD_LED2_ON 0x1000 1596#define SIMPAD_LED2_ON 0x1000
1594#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 1597#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
1595#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 1598#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
1596#define SIMPAD_RESET_SIMCARD 0x8000 1599#define SIMPAD_RESET_SIMCARD 0x8000
1597 1600
1598//SIMpad touchscreen backlight strength control 1601//SIMpad touchscreen backlight strength control
1599#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 1602#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
1600#define SIMPAD_BACKLIGHT_MASK 0x00a10044 1603#define SIMPAD_BACKLIGHT_MASK 0x00a10044
1601 1604
1602QValueList <OLed> SIMpad::ledList ( ) const 1605QValueList <OLed> SIMpad::ledList ( ) const
1603{ 1606{
1604 QValueList <OLed> vl; 1607 QValueList <OLed> vl;
1605 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 1608 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
1606 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 1609 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
1607 return vl; 1610 return vl;
1608} 1611}
1609 1612
1610QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 1613QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
1611{ 1614{
1612 QValueList <OLedState> vl; 1615 QValueList <OLedState> vl;
1613 1616
1614 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 1617 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
1615 vl << Led_Off << Led_On; 1618 vl << Led_Off << Led_On;
1616 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 1619 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
1617 //vl << Led_Off; 1620 //vl << Led_Off;
1618 return vl; 1621 return vl;
1619} 1622}
1620 1623
1621OLedState SIMpad::ledState ( OLed l ) const 1624OLedState SIMpad::ledState ( OLed l ) const
1622{ 1625{
1623 switch ( l ) { 1626 switch ( l ) {
1624 case Led_Power: 1627 case Led_Power:
1625 return m_leds [0]; 1628 return m_leds [0];
1626 //case Led_Mail: 1629 //case Led_Mail:
1627 //return m_leds [1]; 1630 //return m_leds [1];
1628 default: 1631 default:
1629 return Led_Off; 1632 return Led_Off;
1630 } 1633 }
1631} 1634}
1632 1635
1633bool SIMpad::setLedState ( OLed l, OLedState st ) 1636bool SIMpad::setLedState ( OLed l, OLedState st )
1634{ 1637{
1635 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 1638 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
1636 1639
1637 if ( l == Led_Power ) { 1640 if ( l == Led_Power ) {
1638 if ( fd >= 0 ) { 1641 if ( fd >= 0 ) {
1639 LED_IN leds; 1642 LED_IN leds;
1640 ::memset ( &leds, 0, sizeof( leds )); 1643 ::memset ( &leds, 0, sizeof( leds ));
1641 leds. TotalTime = 0; 1644 leds. TotalTime = 0;
1642 leds. OnTime = 0; 1645 leds. OnTime = 0;
1643 leds. OffTime = 1; 1646 leds. OffTime = 1;
1644 leds. OffOnBlink = 2; 1647 leds. OffOnBlink = 2;
1645 1648
1646 switch ( st ) { 1649 switch ( st ) {
1647 case Led_Off : leds. OffOnBlink = 0; break; 1650 case Led_Off : leds. OffOnBlink = 0; break;
1648 case Led_On : leds. OffOnBlink = 1; break; 1651 case Led_On : leds. OffOnBlink = 1; break;
1649 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1652 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1650 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1653 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1651 } 1654 }
1652 1655
1653 { 1656 {
1654 /*TODO Implement this like that: 1657 /*TODO Implement this like that:
1655 read from cs3 1658 read from cs3
1656 && with SIMPAD_LED2_ON 1659 && with SIMPAD_LED2_ON
1657 write to cs3 */ 1660 write to cs3 */
1658 m_leds [0] = st; 1661 m_leds [0] = st;
1659 return true; 1662 return true;
1660 } 1663 }
1661 } 1664 }
1662 } 1665 }
1663 return false; 1666 return false;
1664} 1667}
1665 1668
1666 1669
1667bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1670bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1668{ 1671{
1669 //TODO 1672 //TODO
1670 return false; 1673 return false;
1671} 1674}
1672 1675
1673void SIMpad::timerEvent ( QTimerEvent * ) 1676void SIMpad::timerEvent ( QTimerEvent * )
1674{ 1677{
1675 killTimer ( m_power_timer ); 1678 killTimer ( m_power_timer );
1676 m_power_timer = 0; 1679 m_power_timer = 0;
1677 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1680 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1678 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1681 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1679} 1682}
1680 1683
1681 1684
1682void SIMpad::alarmSound ( ) 1685void SIMpad::alarmSound ( )
1683{ 1686{
1684#ifndef QT_NO_SOUND 1687#ifndef QT_NO_SOUND
1685 static Sound snd ( "alarm" ); 1688 static Sound snd ( "alarm" );
1686 int fd; 1689 int fd;
1687 int vol; 1690 int vol;
1688 bool vol_reset = false; 1691 bool vol_reset = false;
1689 1692
1690 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1693 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1691 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1694 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1692 Config cfg ( "qpe" ); 1695 Config cfg ( "qpe" );
1693 cfg. setGroup ( "Volume" ); 1696 cfg. setGroup ( "Volume" );
1694 1697
1695 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1698 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1696 if ( volalarm < 0 ) 1699 if ( volalarm < 0 )
1697 volalarm = 0; 1700 volalarm = 0;
1698 else if ( volalarm > 100 ) 1701 else if ( volalarm > 100 )
1699 volalarm = 100; 1702 volalarm = 100;
1700 volalarm |= ( volalarm << 8 ); 1703 volalarm |= ( volalarm << 8 );
1701 1704
1702 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1705 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1703 vol_reset = true; 1706 vol_reset = true;
1704 } 1707 }
1705 } 1708 }
1706 1709
1707 snd. play ( ); 1710 snd. play ( );
1708 while ( !snd. isFinished ( )) 1711 while ( !snd. isFinished ( ))
1709 qApp-> processEvents ( ); 1712 qApp-> processEvents ( );
1710 1713
1711 if ( fd >= 0 ) { 1714 if ( fd >= 0 ) {
1712 if ( vol_reset ) 1715 if ( vol_reset )
1713 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1716 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1714 ::close ( fd ); 1717 ::close ( fd );
1715 } 1718 }
1716#endif 1719#endif
1717} 1720}
1718 1721
1719 1722
1720bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 1723bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
1721{ 1724{
1722 qDebug( "ODevice for SIMpad: suspend()" ); 1725 qDebug( "ODevice for SIMpad: suspend()" );
1723 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 1726 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1724 return false; 1727 return false;
1725 1728
1726 bool res = false; 1729 bool res = false;
1727 1730
1728 struct timeval tvs, tvn; 1731 struct timeval tvs, tvn;
1729 ::gettimeofday ( &tvs, 0 ); 1732 ::gettimeofday ( &tvs, 0 );
1730 1733
1731 ::sync ( ); // flush fs caches 1734 ::sync ( ); // flush fs caches
1732 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) 1735 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :)
1733 1736
1734 return res; 1737 return res;
1735} 1738}
1736 1739
1737 1740
1738bool SIMpad::setSoftSuspend ( bool soft ) 1741bool SIMpad::setSoftSuspend ( bool soft )
1739{ 1742{
1740 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 1743 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
1741 return false; 1744 return false;
1742} 1745}
1743 1746
1744 1747
1745bool SIMpad::setDisplayStatus ( bool on ) 1748bool SIMpad::setDisplayStatus ( bool on )
1746{ 1749{
1747 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 1750 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
1748 1751
1749 bool res = false; 1752 bool res = false;
1750 int fd; 1753 int fd;
1751 1754
1752 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 1755 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
1753 1756
1754 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 1757 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
1755 res = ( ::system( (const char*) cmdline ) == 0 ); 1758 res = ( ::system( (const char*) cmdline ) == 0 );
1756 ::close ( fd ); 1759 ::close ( fd );
1757 } 1760 }
1758 return res; 1761 return res;
1759} 1762}
1760 1763
1761 1764
1762bool SIMpad::setDisplayBrightness ( int bright ) 1765bool SIMpad::setDisplayBrightness ( int bright )
1763{ 1766{
1764 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 1767 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
1765 bool res = false; 1768 bool res = false;
1766 int fd; 1769 int fd;
1767 1770
1768 if ( bright > 255 ) 1771 if ( bright > 255 )
1769 bright = 255; 1772 bright = 255;
1770 if ( bright < 0 ) 1773 if ( bright < 0 )
1771 bright = 0; 1774 bright = 0;
1772 1775
1773 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 1776 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
1774 int value = 255 - bright; 1777 int value = 255 - bright;
1775 const int mask = SIMPAD_BACKLIGHT_MASK; 1778 const int mask = SIMPAD_BACKLIGHT_MASK;
1776 value = value << 8; 1779 value = value << 8;
1777 value += mask; 1780 value += mask;
1778 char writeCommand[100]; 1781 char writeCommand[100];
1779 const int count = sprintf( writeCommand, "0x%x\n", value ); 1782 const int count = sprintf( writeCommand, "0x%x\n", value );
1780 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1783 res = ( ::write ( fd, writeCommand, count ) != -1 );
1781 ::close ( fd ); 1784 ::close ( fd );
1782 } 1785 }
1783 return res; 1786 return res;
1784} 1787}
1785 1788
1786 1789
1787int SIMpad::displayBrightnessResolution ( ) const 1790int SIMpad::displayBrightnessResolution ( ) const
1788{ 1791{
1789 switch ( model ( )) { 1792 switch ( model ( )) {
1790 case Model_SIMpad_CL4: 1793 case Model_SIMpad_CL4:
1791 case Model_SIMpad_SL4: 1794 case Model_SIMpad_SL4:
1792 case Model_SIMpad_SLC: 1795 case Model_SIMpad_SLC:
1793 case Model_SIMpad_TSinus: 1796 case Model_SIMpad_TSinus:
1794 return 255; //TODO find out if this is save 1797 return 255; //TODO find out if this is save
1795 1798
1796 default: 1799 default:
1797 return 2; 1800 return 2;
1798 } 1801 }
1799} 1802}
1800 1803