summaryrefslogtreecommitdiff
authoreilers <eilers>2003-08-08 15:13:30 (UTC)
committer eilers <eilers>2003-08-08 15:13:30 (UTC)
commitc6d96c514c58b288ac0bc8f844db35123bcaf2ad (patch) (unidiff)
tree67941875720aeb94ea306e94ed36610cea3022fb
parentb87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (diff)
downloadopie-c6d96c514c58b288ac0bc8f844db35123bcaf2ad.zip
opie-c6d96c514c58b288ac0bc8f844db35123bcaf2ad.tar.gz
opie-c6d96c514c58b288ac0bc8f844db35123bcaf2ad.tar.bz2
Added support for C 750 (Shepherd):
Device is detected and sounds for keypress, screentap and alarm is working (using the sound device) Attention: Please don't activate the screentab sound. It has some quirks..
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp87
1 files changed, 78 insertions, 9 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 17ae389..a134810 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1138,577 +1138,646 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b
1138 1138
1139 // Rotate cursor keys 180° 1139 // Rotate cursor keys 180°
1140 case Key_Left : 1140 case Key_Left :
1141 case Key_Right: 1141 case Key_Right:
1142 case Key_Up : 1142 case Key_Up :
1143 case Key_Down : { 1143 case Key_Down : {
1144 if (( d-> m_model == Model_iPAQ_H31xx ) || 1144 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1145 ( d-> m_model == Model_iPAQ_H38xx )) { 1145 ( d-> m_model == Model_iPAQ_H38xx )) {
1146 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1146 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1147 } 1147 }
1148 break; 1148 break;
1149 } 1149 }
1150 1150
1151 // map Power Button short/long press to F34/F35 1151 // map Power Button short/long press to F34/F35
1152 case Key_SysReq: { 1152 case Key_SysReq: {
1153 if ( isPress ) { 1153 if ( isPress ) {
1154 if ( m_power_timer ) 1154 if ( m_power_timer )
1155 killTimer ( m_power_timer ); 1155 killTimer ( m_power_timer );
1156 m_power_timer = startTimer ( 500 ); 1156 m_power_timer = startTimer ( 500 );
1157 } 1157 }
1158 else if ( m_power_timer ) { 1158 else if ( m_power_timer ) {
1159 killTimer ( m_power_timer ); 1159 killTimer ( m_power_timer );
1160 m_power_timer = 0; 1160 m_power_timer = 0;
1161 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1161 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1162 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1162 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1163 } 1163 }
1164 newkeycode = Key_unknown; 1164 newkeycode = Key_unknown;
1165 break; 1165 break;
1166 } 1166 }
1167 } 1167 }
1168 1168
1169 if ( newkeycode != keycode ) { 1169 if ( newkeycode != keycode ) {
1170 if ( newkeycode != Key_unknown ) 1170 if ( newkeycode != Key_unknown )
1171 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1171 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1172 return true; 1172 return true;
1173 } 1173 }
1174 else 1174 else
1175 return false; 1175 return false;
1176} 1176}
1177 1177
1178void iPAQ::timerEvent ( QTimerEvent * ) 1178void iPAQ::timerEvent ( QTimerEvent * )
1179{ 1179{
1180 killTimer ( m_power_timer ); 1180 killTimer ( m_power_timer );
1181 m_power_timer = 0; 1181 m_power_timer = 0;
1182 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1182 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1183 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1183 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1184} 1184}
1185 1185
1186 1186
1187void iPAQ::alarmSound ( ) 1187void iPAQ::alarmSound ( )
1188{ 1188{
1189#ifndef QT_NO_SOUND 1189#ifndef QT_NO_SOUND
1190 static Sound snd ( "alarm" ); 1190 static Sound snd ( "alarm" );
1191 int fd; 1191 int fd;
1192 int vol; 1192 int vol;
1193 bool vol_reset = false; 1193 bool vol_reset = false;
1194 1194
1195 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1195 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1196 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1196 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1197 Config cfg ( "qpe" ); 1197 Config cfg ( "qpe" );
1198 cfg. setGroup ( "Volume" ); 1198 cfg. setGroup ( "Volume" );
1199 1199
1200 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1200 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1201 if ( volalarm < 0 ) 1201 if ( volalarm < 0 )
1202 volalarm = 0; 1202 volalarm = 0;
1203 else if ( volalarm > 100 ) 1203 else if ( volalarm > 100 )
1204 volalarm = 100; 1204 volalarm = 100;
1205 volalarm |= ( volalarm << 8 ); 1205 volalarm |= ( volalarm << 8 );
1206 1206
1207 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1207 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1208 vol_reset = true; 1208 vol_reset = true;
1209 } 1209 }
1210 } 1210 }
1211 1211
1212 snd. play ( ); 1212 snd. play ( );
1213 while ( !snd. isFinished ( )) 1213 while ( !snd. isFinished ( ))
1214 qApp-> processEvents ( ); 1214 qApp-> processEvents ( );
1215 1215
1216 if ( fd >= 0 ) { 1216 if ( fd >= 0 ) {
1217 if ( vol_reset ) 1217 if ( vol_reset )
1218 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1218 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1219 ::close ( fd ); 1219 ::close ( fd );
1220 } 1220 }
1221#endif 1221#endif
1222} 1222}
1223 1223
1224 1224
1225bool iPAQ::setSoftSuspend ( bool soft ) 1225bool iPAQ::setSoftSuspend ( bool soft )
1226{ 1226{
1227 bool res = false; 1227 bool res = false;
1228 int fd; 1228 int fd;
1229 1229
1230 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1230 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1231 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1231 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1232 res = true; 1232 res = true;
1233 else 1233 else
1234 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1234 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1235 1235
1236 ::close ( fd ); 1236 ::close ( fd );
1237 } 1237 }
1238 else 1238 else
1239 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1239 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1240 1240
1241 return res; 1241 return res;
1242} 1242}
1243 1243
1244 1244
1245bool iPAQ::setDisplayBrightness ( int bright ) 1245bool iPAQ::setDisplayBrightness ( int bright )
1246{ 1246{
1247 bool res = false; 1247 bool res = false;
1248 int fd; 1248 int fd;
1249 1249
1250 if ( bright > 255 ) 1250 if ( bright > 255 )
1251 bright = 255; 1251 bright = 255;
1252 if ( bright < 0 ) 1252 if ( bright < 0 )
1253 bright = 0; 1253 bright = 0;
1254 1254
1255 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1255 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1256 FLITE_IN bl; 1256 FLITE_IN bl;
1257 bl. mode = 1; 1257 bl. mode = 1;
1258 bl. pwr = bright ? 1 : 0; 1258 bl. pwr = bright ? 1 : 0;
1259 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1259 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1260 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1260 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1261 ::close ( fd ); 1261 ::close ( fd );
1262 } 1262 }
1263 return res; 1263 return res;
1264} 1264}
1265 1265
1266int iPAQ::displayBrightnessResolution ( ) const 1266int iPAQ::displayBrightnessResolution ( ) const
1267{ 1267{
1268 switch ( model ( )) { 1268 switch ( model ( )) {
1269 case Model_iPAQ_H31xx: 1269 case Model_iPAQ_H31xx:
1270 case Model_iPAQ_H36xx: 1270 case Model_iPAQ_H36xx:
1271 case Model_iPAQ_H37xx: 1271 case Model_iPAQ_H37xx:
1272 return 128; // really 256, but >128 could damage the LCD 1272 return 128; // really 256, but >128 could damage the LCD
1273 1273
1274 case Model_iPAQ_H38xx: 1274 case Model_iPAQ_H38xx:
1275 case Model_iPAQ_H39xx: 1275 case Model_iPAQ_H39xx:
1276 return 64; 1276 return 64;
1277 1277
1278 default: 1278 default:
1279 return 2; 1279 return 2;
1280 } 1280 }
1281} 1281}
1282 1282
1283 1283
1284bool iPAQ::hasLightSensor ( ) const 1284bool iPAQ::hasLightSensor ( ) const
1285{ 1285{
1286 return true; 1286 return true;
1287} 1287}
1288 1288
1289int iPAQ::readLightSensor ( ) 1289int iPAQ::readLightSensor ( )
1290{ 1290{
1291 int fd; 1291 int fd;
1292 int val = -1; 1292 int val = -1;
1293 1293
1294 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1294 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1295 char buffer [8]; 1295 char buffer [8];
1296 1296
1297 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1297 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1298 char *endptr; 1298 char *endptr;
1299 1299
1300 buffer [4] = 0; 1300 buffer [4] = 0;
1301 val = ::strtol ( buffer + 2, &endptr, 16 ); 1301 val = ::strtol ( buffer + 2, &endptr, 16 );
1302 1302
1303 if ( *endptr != 0 ) 1303 if ( *endptr != 0 )
1304 val = -1; 1304 val = -1;
1305 } 1305 }
1306 ::close ( fd ); 1306 ::close ( fd );
1307 } 1307 }
1308 1308
1309 return val; 1309 return val;
1310} 1310}
1311 1311
1312int iPAQ::lightSensorResolution ( ) const 1312int iPAQ::lightSensorResolution ( ) const
1313{ 1313{
1314 return 256; 1314 return 256;
1315} 1315}
1316 1316
1317/************************************************** 1317/**************************************************
1318 * 1318 *
1319 * Zaurus 1319 * Zaurus
1320 * 1320 *
1321 **************************************************/ 1321 **************************************************/
1322 1322
1323 1323
1324 1324
1325void Zaurus::init ( ) 1325void Zaurus::init ( )
1326{ 1326{
1327 d-> m_vendorstr = "Sharp"; 1327 d-> m_vendorstr = "Sharp";
1328 d-> m_vendor = Vendor_Sharp; 1328 d-> m_vendor = Vendor_Sharp;
1329 1329
1330 QFile f ( "/proc/filesystems" ); 1330 // QFile f ( "/proc/filesystems" );
1331 QString model; 1331 QString model;
1332 1332
1333 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1333 // It isn't a good idea to check the system configuration to
1334 // detect the distribution !
1335 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1336 // because it uses a jffs2 filesystem..
1337 // (eilers)
1338 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1339 QFile f ("/etc/oz_version");
1340 if ( f.exists() ){
1334 d-> m_vendorstr = "OpenZaurus Team"; 1341 d-> m_vendorstr = "OpenZaurus Team";
1335 d-> m_systemstr = "OpenZaurus"; 1342 d-> m_systemstr = "OpenZaurus";
1336 d-> m_system = System_OpenZaurus; 1343 d-> m_system = System_OpenZaurus;
1337 1344
1338 f. close ( ); 1345 // f. close ( );
1339 1346
1340 f. setName ( "/etc/oz_version" ); 1347 // f. setName ( "/etc/oz_version" );
1341 if ( f. open ( IO_ReadOnly )) { 1348 if ( f. open ( IO_ReadOnly )) {
1342 QTextStream ts ( &f ); 1349 QTextStream ts ( &f );
1343 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1350 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1344 f. close ( ); 1351 f. close ( );
1345 } 1352 }
1346 } 1353 }
1347 else { 1354 else {
1348 d-> m_systemstr = "Zaurus"; 1355 d-> m_systemstr = "Zaurus";
1349 d-> m_system = System_Zaurus; 1356 d-> m_system = System_Zaurus;
1350 } 1357 }
1351 1358
1352 f. setName ( "/proc/cpuinfo" ); 1359 f. setName ( "/proc/cpuinfo" );
1353 if ( f. open ( IO_ReadOnly ) ) { 1360 if ( f. open ( IO_ReadOnly ) ) {
1354 QTextStream ts ( &f ); 1361 QTextStream ts ( &f );
1355 QString line; 1362 QString line;
1356 while( line = ts. readLine ( ) ) { 1363 while( line = ts. readLine ( ) ) {
1357 if ( line. left ( 8 ) == "Hardware" ) 1364 if ( line. left ( 8 ) == "Hardware" )
1358 break; 1365 break;
1359 } 1366 }
1360 int loc = line. find ( ":" ); 1367 int loc = line. find ( ":" );
1361 if ( loc != -1 ) 1368 if ( loc != -1 )
1362 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1369 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1363 } 1370 }
1364 1371
1365 if ( model == "SHARP Corgi" ) { 1372 if ( model == "SHARP Corgi" ) {
1366 d-> m_model = Model_Zaurus_SLC700; 1373 d-> m_model = Model_Zaurus_SLC700;
1367 d-> m_modelstr = "Zaurus SL-C700"; 1374 d-> m_modelstr = "Zaurus SL-C700";
1368 } else if ( model == "SHARP Poodle" ) { 1375 } else if ( model == "SHARP Shepherd" ) {
1376 d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers)
1377 d-> m_modelstr = "Zaurus SL-C750";
1378 }else if ( model == "SHARP Poodle" ) {
1369 d-> m_model = Model_Zaurus_SLB600; 1379 d-> m_model = Model_Zaurus_SLB600;
1370 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1380 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1371 } else if ( model = "Sharp-Collie" ) { 1381 } else if ( model = "Sharp-Collie" ) {
1372 d-> m_model = Model_Zaurus_SL5500; 1382 d-> m_model = Model_Zaurus_SL5500;
1373 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1383 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1374 } else { 1384 } else {
1375 d-> m_model = Model_Zaurus_SL5500; 1385 d-> m_model = Model_Zaurus_SL5500;
1376 d-> m_modelstr = "Zaurus (Model unknown)"; 1386 d-> m_modelstr = "Zaurus (Model unknown)";
1377 } 1387 }
1378 1388
1379 bool flipstate = false; 1389 bool flipstate = false;
1380 switch ( d-> m_model ) { 1390 switch ( d-> m_model ) {
1381 case Model_Zaurus_SLA300: 1391 case Model_Zaurus_SLA300:
1382 d-> m_rotation = Rot0; 1392 d-> m_rotation = Rot0;
1383 break; 1393 break;
1384 case Model_Zaurus_SLC700: 1394 case Model_Zaurus_SLC700:
1385 // Note: need to 1) set flipstate based on physical screen orientation 1395 // Note: need to 1) set flipstate based on physical screen orientation
1386 // and 2) check to see if the user overrode the rotation direction 1396 // and 2) check to see if the user overrode the rotation direction
1387 // using appearance, and if so, remove that item from the Config to 1397 // using appearance, and if so, remove that item from the Config to
1388 // ensure the rotate applet flips us back to the previous state. 1398 // ensure the rotate applet flips us back to the previous state.
1389 if ( flipstate ) { 1399 if ( flipstate ) {
1390 // 480x640 1400 // 480x640
1391 d-> m_rotation = Rot0; 1401 d-> m_rotation = Rot0;
1392 d-> m_direction = CW; 1402 d-> m_direction = CW;
1393 } else { 1403 } else {
1394 // 640x480 1404 // 640x480
1395 d-> m_rotation = Rot270; 1405 d-> m_rotation = Rot270;
1396 d-> m_direction = CCW; 1406 d-> m_direction = CCW;
1397 } 1407 }
1398 break; 1408 break;
1399 case Model_Zaurus_SLB600: 1409 case Model_Zaurus_SLB600:
1400 case Model_Zaurus_SL5500: 1410 case Model_Zaurus_SL5500:
1401 case Model_Zaurus_SL5000: 1411 case Model_Zaurus_SL5000:
1402 default: 1412 default:
1403 d-> m_rotation = Rot270; 1413 d-> m_rotation = Rot270;
1404 break; 1414 break;
1405 } 1415 }
1406 m_leds [0] = Led_Off; 1416 m_leds [0] = Led_Off;
1407} 1417}
1408 1418
1409void Zaurus::initButtons ( ) 1419void Zaurus::initButtons ( )
1410{ 1420{
1411 if ( d-> m_buttons ) 1421 if ( d-> m_buttons )
1412 return; 1422 return;
1413 1423
1414 d-> m_buttons = new QValueList <ODeviceButton>; 1424 d-> m_buttons = new QValueList <ODeviceButton>;
1415 1425
1416 struct z_button * pz_buttons; 1426 struct z_button * pz_buttons;
1417 int buttoncount; 1427 int buttoncount;
1418 switch ( d-> m_model ) { 1428 switch ( d-> m_model ) {
1419 case Model_Zaurus_SLC700: 1429 case Model_Zaurus_SLC700:
1420 pz_buttons = z_buttons_c700; 1430 pz_buttons = z_buttons_c700;
1421 buttoncount = ARRAY_SIZE(z_buttons_c700); 1431 buttoncount = ARRAY_SIZE(z_buttons_c700);
1422 break; 1432 break;
1423 default: 1433 default:
1424 pz_buttons = z_buttons; 1434 pz_buttons = z_buttons;
1425 buttoncount = ARRAY_SIZE(z_buttons); 1435 buttoncount = ARRAY_SIZE(z_buttons);
1426 break; 1436 break;
1427 } 1437 }
1428 1438
1429 for ( int i = 0; i < buttoncount; i++ ) { 1439 for ( int i = 0; i < buttoncount; i++ ) {
1430 struct z_button *zb = pz_buttons + i; 1440 struct z_button *zb = pz_buttons + i;
1431 ODeviceButton b; 1441 ODeviceButton b;
1432 1442
1433 b. setKeycode ( zb-> code ); 1443 b. setKeycode ( zb-> code );
1434 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1444 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1435 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1445 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1436 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1446 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1437 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1447 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1438 1448
1439 d-> m_buttons-> append ( b ); 1449 d-> m_buttons-> append ( b );
1440 } 1450 }
1441 1451
1442 reloadButtonMapping ( ); 1452 reloadButtonMapping ( );
1443 1453
1444 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1454 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1445 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1455 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1446} 1456}
1447 1457
1448#include <unistd.h> 1458#include <unistd.h>
1449#include <fcntl.h> 1459#include <fcntl.h>
1450#include <sys/ioctl.h> 1460#include <sys/ioctl.h>
1451 1461
1452//#include <asm/sharp_char.h> // including kernel headers is evil ... 1462//#include <asm/sharp_char.h> // including kernel headers is evil ...
1453 1463
1454#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1464#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1455 1465
1456 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1466 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1457#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1467#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1458 1468
1459#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1469#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1460#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1470#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1461#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1471#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1462 1472
1463/* --- for SHARP_BUZZER device --- */ 1473/* --- for SHARP_BUZZER device --- */
1464 1474
1465 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1475 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1466//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1476//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1467 1477
1468#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1478#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1469#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1479#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1470#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1480#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1471#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1481#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1472#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1482#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1473 1483
1474//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1484//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1475//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1485//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1476 1486
1477//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1487//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1478//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1488//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1479//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1489//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1480//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1490//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1481//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1491//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1482//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1492//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1483//#define SHARP_PDA_APPSTART 9 /* application start */ 1493//#define SHARP_PDA_APPSTART 9 /* application start */
1484//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1494//#define SHARP_PDA_APPQUIT 10 /* application ends */
1485 1495
1486//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1496//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1487//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1497//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1488//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1498//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1489//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1499//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1490// 1500//
1491 1501
1492 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1502 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1493#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1503#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1494 1504
1495typedef struct sharp_led_status { 1505typedef struct sharp_led_status {
1496 int which; /* select which LED status is wanted. */ 1506 int which; /* select which LED status is wanted. */
1497 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1507 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1498} sharp_led_status; 1508} sharp_led_status;
1499 1509
1500#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1510#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1501 1511
1502#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1512#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1503#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1513#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1504#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1514#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1505 1515
1506// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1516// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1507 1517
1508#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1518#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1509#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1519#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1510#define APM_EVT_POWER_BUTTON (1 << 0) 1520#define APM_EVT_POWER_BUTTON (1 << 0)
1511 1521
1512#define FL_IOCTL_STEP_CONTRAST 100 1522#define FL_IOCTL_STEP_CONTRAST 100
1513 1523
1514 1524
1515void Zaurus::buzzer ( int sound ) 1525void Zaurus::buzzer ( int sound )
1516{ 1526{
1517 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1527 // Not all devices have real sound.
1528#ifndef QT_NO_SOUND
1529 switch ( d-> m_model ) {
1530 case Model_Zaurus_SLC700:{
1531 int fd;
1532 int vol;
1533 bool vol_reset = false;
1534
1535 QString soundname;
1536
1537 switch ( sound ){
1538 case SHARP_BUZ_SCHEDULE_ALARM:
1539 soundname = "alarm";
1540 break;
1541 case SHARP_BUZ_TOUCHSOUND:
1542 soundname = "touchsound";
1543 break;
1544 case SHARP_BUZ_KEYSOUND:
1545 soundname = "keysound";
1546 break;
1547 default:
1548 soundname = "alarm";
1549
1550 }
1518 1551
1519 if ( fd >= 0 ) { 1552 Sound snd ( soundname );
1520 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1553
1521 ::close ( fd ); 1554 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1555 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1556 Config cfg ( "qpe" );
1557 cfg. setGroup ( "Volume" );
1558
1559 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1560 if ( volalarm < 0 )
1561 volalarm = 0;
1562 else if ( volalarm > 100 )
1563 volalarm = 100;
1564 volalarm |= ( volalarm << 8 );
1565
1566 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1567 vol_reset = true;
1568 }
1569 }
1570
1571 snd. play ( );
1572 while ( !snd. isFinished ( ))
1573 qApp-> processEvents ( );
1574
1575 if ( fd >= 0 ) {
1576 if ( vol_reset )
1577 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1578 ::close ( fd );
1579 }
1580 break;
1522 } 1581 }
1582 default:{ // Devices with buzzer
1583 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1584
1585 if ( fd >= 0 ) {
1586 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1587 ::close ( fd );
1588 }
1589 }
1590 }
1591#endif
1523} 1592}
1524 1593
1525 1594
1526void Zaurus::alarmSound ( ) 1595void Zaurus::alarmSound ( )
1527{ 1596{
1528 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1597 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1529} 1598}
1530 1599
1531void Zaurus::touchSound ( ) 1600void Zaurus::touchSound ( )
1532{ 1601{
1533 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1602 buzzer ( SHARP_BUZ_TOUCHSOUND );
1534} 1603}
1535 1604
1536void Zaurus::keySound ( ) 1605void Zaurus::keySound ( )
1537{ 1606{
1538 buzzer ( SHARP_BUZ_KEYSOUND ); 1607 buzzer ( SHARP_BUZ_KEYSOUND );
1539} 1608}
1540 1609
1541 1610
1542QValueList <OLed> Zaurus::ledList ( ) const 1611QValueList <OLed> Zaurus::ledList ( ) const
1543{ 1612{
1544 QValueList <OLed> vl; 1613 QValueList <OLed> vl;
1545 vl << Led_Mail; 1614 vl << Led_Mail;
1546 return vl; 1615 return vl;
1547} 1616}
1548 1617
1549QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1618QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1550{ 1619{
1551 QValueList <OLedState> vl; 1620 QValueList <OLedState> vl;
1552 1621
1553 if ( l == Led_Mail ) 1622 if ( l == Led_Mail )
1554 vl << Led_Off << Led_On << Led_BlinkSlow; 1623 vl << Led_Off << Led_On << Led_BlinkSlow;
1555 return vl; 1624 return vl;
1556} 1625}
1557 1626
1558OLedState Zaurus::ledState ( OLed which ) const 1627OLedState Zaurus::ledState ( OLed which ) const
1559{ 1628{
1560 if ( which == Led_Mail ) 1629 if ( which == Led_Mail )
1561 return m_leds [0]; 1630 return m_leds [0];
1562 else 1631 else
1563 return Led_Off; 1632 return Led_Off;
1564} 1633}
1565 1634
1566bool Zaurus::setLedState ( OLed which, OLedState st ) 1635bool Zaurus::setLedState ( OLed which, OLedState st )
1567{ 1636{
1568 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1637 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1569 1638
1570 if ( which == Led_Mail ) { 1639 if ( which == Led_Mail ) {
1571 if ( fd >= 0 ) { 1640 if ( fd >= 0 ) {
1572 struct sharp_led_status leds; 1641 struct sharp_led_status leds;
1573 ::memset ( &leds, 0, sizeof( leds )); 1642 ::memset ( &leds, 0, sizeof( leds ));
1574 leds. which = SHARP_LED_MAIL_EXISTS; 1643 leds. which = SHARP_LED_MAIL_EXISTS;
1575 bool ok = true; 1644 bool ok = true;
1576 1645
1577 switch ( st ) { 1646 switch ( st ) {
1578 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1647 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1579 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1648 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1580 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1649 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1581 default : ok = false; 1650 default : ok = false;
1582 } 1651 }
1583 1652
1584 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1653 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1585 m_leds [0] = st; 1654 m_leds [0] = st;
1586 return true; 1655 return true;
1587 } 1656 }
1588 } 1657 }
1589 } 1658 }
1590 return false; 1659 return false;
1591} 1660}
1592 1661
1593bool Zaurus::setSoftSuspend ( bool soft ) 1662bool Zaurus::setSoftSuspend ( bool soft )
1594{ 1663{
1595 bool res = false; 1664 bool res = false;
1596 int fd; 1665 int fd;
1597 1666
1598 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1667 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1599 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1668 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1600 1669
1601 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1670 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1602 1671
1603 if ( sources >= 0 ) { 1672 if ( sources >= 0 ) {
1604 if ( soft ) 1673 if ( soft )
1605 sources &= ~APM_EVT_POWER_BUTTON; 1674 sources &= ~APM_EVT_POWER_BUTTON;
1606 else 1675 else
1607 sources |= APM_EVT_POWER_BUTTON; 1676 sources |= APM_EVT_POWER_BUTTON;
1608 1677
1609 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1678 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1610 res = true; 1679 res = true;
1611 else 1680 else
1612 perror ( "APM_IOCGEVTSRC" ); 1681 perror ( "APM_IOCGEVTSRC" );
1613 } 1682 }
1614 else 1683 else
1615 perror ( "APM_IOCGEVTSRC" ); 1684 perror ( "APM_IOCGEVTSRC" );
1616 1685
1617 ::close ( fd ); 1686 ::close ( fd );
1618 } 1687 }
1619 else 1688 else
1620 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1689 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1621 1690
1622 return res; 1691 return res;
1623} 1692}
1624 1693
1625 1694
1626bool Zaurus::setDisplayBrightness ( int bright ) 1695bool Zaurus::setDisplayBrightness ( int bright )
1627{ 1696{
1628 bool res = false; 1697 bool res = false;
1629 int fd; 1698 int fd;
1630 1699
1631 if ( bright > 255 ) 1700 if ( bright > 255 )
1632 bright = 255; 1701 bright = 255;
1633 if ( bright < 0 ) 1702 if ( bright < 0 )
1634 bright = 0; 1703 bright = 0;
1635 1704
1636 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1705 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1637 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1706 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1638 if ( bright && !bl ) 1707 if ( bright && !bl )
1639 bl = 1; 1708 bl = 1;
1640 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1709 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1641 ::close ( fd ); 1710 ::close ( fd );
1642 } 1711 }
1643 return res; 1712 return res;
1644} 1713}
1645 1714
1646 1715
1647int Zaurus::displayBrightnessResolution ( ) const 1716int Zaurus::displayBrightnessResolution ( ) const
1648{ 1717{
1649 return 5; 1718 return 5;
1650} 1719}
1651 1720
1652/************************************************** 1721/**************************************************
1653 * 1722 *
1654 * SIMpad 1723 * SIMpad
1655 * 1724 *
1656 **************************************************/ 1725 **************************************************/
1657 1726
1658void SIMpad::init ( ) 1727void SIMpad::init ( )
1659{ 1728{
1660 d-> m_vendorstr = "SIEMENS"; 1729 d-> m_vendorstr = "SIEMENS";
1661 d-> m_vendor = Vendor_SIEMENS; 1730 d-> m_vendor = Vendor_SIEMENS;
1662 1731
1663 QFile f ( "/proc/hal/model" ); 1732 QFile f ( "/proc/hal/model" );
1664 1733
1665 //TODO Implement model checking 1734 //TODO Implement model checking
1666 //FIXME For now we assume an SL4 1735 //FIXME For now we assume an SL4
1667 1736
1668 d-> m_modelstr = "SL4"; 1737 d-> m_modelstr = "SL4";
1669 d-> m_model = Model_SIMpad_SL4; 1738 d-> m_model = Model_SIMpad_SL4;
1670 1739
1671 switch ( d-> m_model ) { 1740 switch ( d-> m_model ) {
1672 default: 1741 default:
1673 d-> m_rotation = Rot0; 1742 d-> m_rotation = Rot0;
1674 d-> m_direction = CCW; 1743 d-> m_direction = CCW;
1675 d-> m_holdtime = 1000; // 1000ms 1744 d-> m_holdtime = 1000; // 1000ms
1676 1745
1677 break; 1746 break;
1678 } 1747 }
1679 1748
1680 f. setName ( "/etc/familiar-version" ); 1749 f. setName ( "/etc/familiar-version" );
1681 if ( f. open ( IO_ReadOnly )) { 1750 if ( f. open ( IO_ReadOnly )) {
1682 d-> m_systemstr = "Familiar"; 1751 d-> m_systemstr = "Familiar";
1683 d-> m_system = System_Familiar; 1752 d-> m_system = System_Familiar;
1684 1753
1685 QTextStream ts ( &f ); 1754 QTextStream ts ( &f );
1686 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1755 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1687 1756
1688 f. close ( ); 1757 f. close ( );
1689 } else { 1758 } else {
1690 f. setName ( "/etc/oz_version" ); 1759 f. setName ( "/etc/oz_version" );
1691 1760
1692 if ( f. open ( IO_ReadOnly )) { 1761 if ( f. open ( IO_ReadOnly )) {
1693 d-> m_systemstr = "OpenEmbedded/SIMpad"; 1762 d-> m_systemstr = "OpenEmbedded/SIMpad";
1694 d-> m_system = System_OpenZaurus; 1763 d-> m_system = System_OpenZaurus;
1695 1764
1696 QTextStream ts ( &f ); 1765 QTextStream ts ( &f );
1697 ts.setDevice ( &f ); 1766 ts.setDevice ( &f );
1698 d-> m_sysverstr = ts. readLine ( ); 1767 d-> m_sysverstr = ts. readLine ( );
1699 f. close ( ); 1768 f. close ( );
1700 } 1769 }
1701 } 1770 }
1702 1771
1703 m_leds [0] = m_leds [1] = Led_Off; 1772 m_leds [0] = m_leds [1] = Led_Off;
1704 1773
1705 m_power_timer = 0; 1774 m_power_timer = 0;
1706 1775
1707} 1776}
1708 1777
1709void SIMpad::initButtons ( ) 1778void SIMpad::initButtons ( )
1710{ 1779{
1711 if ( d-> m_buttons ) 1780 if ( d-> m_buttons )
1712 return; 1781 return;
1713 1782
1714 if ( isQWS( ) ) 1783 if ( isQWS( ) )