author | mickeyl <mickeyl> | 2003-12-30 02:17:25 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-12-30 02:17:25 (UTC) |
commit | b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a (patch) (unidiff) | |
tree | 98db0a0053c53e98ba758773f80ad8e14c9564c9 | |
parent | b636d3d91e8456b22bc450b3d7f3a862b7f615a9 (diff) | |
download | opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.zip opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.gz opie-b53d9bc11a1e35e52f2fda4586ba8a53f8e0b48a.tar.bz2 |
fix a problem in the c7x0 backlight handling...
Bah! Got confused by the input interval for ODevice::setDisplayBrightness()
(once) again - it has been ridiculous to scale that down from [0-255] to the actual
interval since the day we invented ODevice::displayBrightnessResolution().
I'm going to remove that antique cruft soon.
-rw-r--r-- | libopie/odevice.cpp | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index bc09e92..82a0099 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1302,937 +1302,939 @@ bool iPAQ::setLedState ( OLed l, OLedState st ) | |||
1302 | case Led_Off : leds. OffOnBlink = 0; break; | 1302 | case Led_Off : leds. OffOnBlink = 0; break; |
1303 | case Led_On : leds. OffOnBlink = 1; break; | 1303 | case Led_On : leds. OffOnBlink = 1; break; |
1304 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1304 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1305 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1305 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1306 | } | 1306 | } |
1307 | 1307 | ||
1308 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1308 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1309 | m_leds [0] = st; | 1309 | m_leds [0] = st; |
1310 | return true; | 1310 | return true; |
1311 | } | 1311 | } |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | return false; | 1314 | return false; |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | 1317 | ||
1318 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1318 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1319 | { | 1319 | { |
1320 | int newkeycode = keycode; | 1320 | int newkeycode = keycode; |
1321 | 1321 | ||
1322 | switch ( keycode ) { | 1322 | switch ( keycode ) { |
1323 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1323 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1324 | case HardKey_Menu: { | 1324 | case HardKey_Menu: { |
1325 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1325 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1326 | ( d-> m_model == Model_iPAQ_H39xx ) || | 1326 | ( d-> m_model == Model_iPAQ_H39xx ) || |
1327 | ( d-> m_model == Model_iPAQ_H5xxx)) { | 1327 | ( d-> m_model == Model_iPAQ_H5xxx)) { |
1328 | newkeycode = HardKey_Mail; | 1328 | newkeycode = HardKey_Mail; |
1329 | } | 1329 | } |
1330 | break; | 1330 | break; |
1331 | } | 1331 | } |
1332 | 1332 | ||
1333 | // Rotate cursor keys 180° | 1333 | // Rotate cursor keys 180° |
1334 | case Key_Left : | 1334 | case Key_Left : |
1335 | case Key_Right: | 1335 | case Key_Right: |
1336 | case Key_Up : | 1336 | case Key_Up : |
1337 | case Key_Down : { | 1337 | case Key_Down : { |
1338 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1338 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1339 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1339 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1340 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1340 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1341 | } | 1341 | } |
1342 | break; | 1342 | break; |
1343 | } | 1343 | } |
1344 | 1344 | ||
1345 | // map Power Button short/long press to F34/F35 | 1345 | // map Power Button short/long press to F34/F35 |
1346 | case Key_SysReq: { | 1346 | case Key_SysReq: { |
1347 | if ( isPress ) { | 1347 | if ( isPress ) { |
1348 | if ( m_power_timer ) | 1348 | if ( m_power_timer ) |
1349 | killTimer ( m_power_timer ); | 1349 | killTimer ( m_power_timer ); |
1350 | m_power_timer = startTimer ( 500 ); | 1350 | m_power_timer = startTimer ( 500 ); |
1351 | } | 1351 | } |
1352 | else if ( m_power_timer ) { | 1352 | else if ( m_power_timer ) { |
1353 | killTimer ( m_power_timer ); | 1353 | killTimer ( m_power_timer ); |
1354 | m_power_timer = 0; | 1354 | m_power_timer = 0; |
1355 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 1355 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
1356 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 1356 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
1357 | } | 1357 | } |
1358 | newkeycode = Key_unknown; | 1358 | newkeycode = Key_unknown; |
1359 | break; | 1359 | break; |
1360 | } | 1360 | } |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | if ( newkeycode != keycode ) { | 1363 | if ( newkeycode != keycode ) { |
1364 | if ( newkeycode != Key_unknown ) | 1364 | if ( newkeycode != Key_unknown ) |
1365 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 1365 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
1366 | return true; | 1366 | return true; |
1367 | } | 1367 | } |
1368 | else | 1368 | else |
1369 | return false; | 1369 | return false; |
1370 | } | 1370 | } |
1371 | 1371 | ||
1372 | void iPAQ::timerEvent ( QTimerEvent * ) | 1372 | void iPAQ::timerEvent ( QTimerEvent * ) |
1373 | { | 1373 | { |
1374 | killTimer ( m_power_timer ); | 1374 | killTimer ( m_power_timer ); |
1375 | m_power_timer = 0; | 1375 | m_power_timer = 0; |
1376 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1376 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1377 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1377 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1378 | } | 1378 | } |
1379 | 1379 | ||
1380 | 1380 | ||
1381 | void iPAQ::alarmSound ( ) | 1381 | void iPAQ::alarmSound ( ) |
1382 | { | 1382 | { |
1383 | #ifndef QT_NO_SOUND | 1383 | #ifndef QT_NO_SOUND |
1384 | static Sound snd ( "alarm" ); | 1384 | static Sound snd ( "alarm" ); |
1385 | int fd; | 1385 | int fd; |
1386 | int vol; | 1386 | int vol; |
1387 | bool vol_reset = false; | 1387 | bool vol_reset = false; |
1388 | 1388 | ||
1389 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1389 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1390 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1390 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1391 | Config cfg ( "qpe" ); | 1391 | Config cfg ( "qpe" ); |
1392 | cfg. setGroup ( "Volume" ); | 1392 | cfg. setGroup ( "Volume" ); |
1393 | 1393 | ||
1394 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1394 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1395 | if ( volalarm < 0 ) | 1395 | if ( volalarm < 0 ) |
1396 | volalarm = 0; | 1396 | volalarm = 0; |
1397 | else if ( volalarm > 100 ) | 1397 | else if ( volalarm > 100 ) |
1398 | volalarm = 100; | 1398 | volalarm = 100; |
1399 | volalarm |= ( volalarm << 8 ); | 1399 | volalarm |= ( volalarm << 8 ); |
1400 | 1400 | ||
1401 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1401 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1402 | vol_reset = true; | 1402 | vol_reset = true; |
1403 | } | 1403 | } |
1404 | } | 1404 | } |
1405 | 1405 | ||
1406 | snd. play ( ); | 1406 | snd. play ( ); |
1407 | while ( !snd. isFinished ( )) | 1407 | while ( !snd. isFinished ( )) |
1408 | qApp-> processEvents ( ); | 1408 | qApp-> processEvents ( ); |
1409 | 1409 | ||
1410 | if ( fd >= 0 ) { | 1410 | if ( fd >= 0 ) { |
1411 | if ( vol_reset ) | 1411 | if ( vol_reset ) |
1412 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1412 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1413 | ::close ( fd ); | 1413 | ::close ( fd ); |
1414 | } | 1414 | } |
1415 | #endif | 1415 | #endif |
1416 | } | 1416 | } |
1417 | 1417 | ||
1418 | 1418 | ||
1419 | bool iPAQ::setSoftSuspend ( bool soft ) | 1419 | bool iPAQ::setSoftSuspend ( bool soft ) |
1420 | { | 1420 | { |
1421 | bool res = false; | 1421 | bool res = false; |
1422 | int fd; | 1422 | int fd; |
1423 | 1423 | ||
1424 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1424 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1425 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1425 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1426 | res = true; | 1426 | res = true; |
1427 | else | 1427 | else |
1428 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1428 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1429 | 1429 | ||
1430 | ::close ( fd ); | 1430 | ::close ( fd ); |
1431 | } | 1431 | } |
1432 | else | 1432 | else |
1433 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1433 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1434 | 1434 | ||
1435 | return res; | 1435 | return res; |
1436 | } | 1436 | } |
1437 | 1437 | ||
1438 | 1438 | ||
1439 | bool iPAQ::setDisplayBrightness ( int bright ) | 1439 | bool iPAQ::setDisplayBrightness ( int bright ) |
1440 | { | 1440 | { |
1441 | bool res = false; | 1441 | bool res = false; |
1442 | int fd; | 1442 | int fd; |
1443 | 1443 | ||
1444 | if ( bright > 255 ) | 1444 | if ( bright > 255 ) |
1445 | bright = 255; | 1445 | bright = 255; |
1446 | if ( bright < 0 ) | 1446 | if ( bright < 0 ) |
1447 | bright = 0; | 1447 | bright = 0; |
1448 | 1448 | ||
1449 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1449 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1450 | FLITE_IN bl; | 1450 | FLITE_IN bl; |
1451 | bl. mode = 1; | 1451 | bl. mode = 1; |
1452 | bl. pwr = bright ? 1 : 0; | 1452 | bl. pwr = bright ? 1 : 0; |
1453 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1453 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1454 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1454 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1455 | ::close ( fd ); | 1455 | ::close ( fd ); |
1456 | } | 1456 | } |
1457 | return res; | 1457 | return res; |
1458 | } | 1458 | } |
1459 | 1459 | ||
1460 | int iPAQ::displayBrightnessResolution ( ) const | 1460 | int iPAQ::displayBrightnessResolution ( ) const |
1461 | { | 1461 | { |
1462 | switch ( model ( )) { | 1462 | switch ( model ( )) { |
1463 | case Model_iPAQ_H31xx: | 1463 | case Model_iPAQ_H31xx: |
1464 | case Model_iPAQ_H36xx: | 1464 | case Model_iPAQ_H36xx: |
1465 | case Model_iPAQ_H37xx: | 1465 | case Model_iPAQ_H37xx: |
1466 | return 128; // really 256, but >128 could damage the LCD | 1466 | return 128; // really 256, but >128 could damage the LCD |
1467 | 1467 | ||
1468 | case Model_iPAQ_H38xx: | 1468 | case Model_iPAQ_H38xx: |
1469 | case Model_iPAQ_H39xx: | 1469 | case Model_iPAQ_H39xx: |
1470 | return 64; | 1470 | return 64; |
1471 | case Model_iPAQ_H5xxx: | 1471 | case Model_iPAQ_H5xxx: |
1472 | return 255; | 1472 | return 255; |
1473 | 1473 | ||
1474 | default: | 1474 | default: |
1475 | return 2; | 1475 | return 2; |
1476 | } | 1476 | } |
1477 | } | 1477 | } |
1478 | 1478 | ||
1479 | 1479 | ||
1480 | bool iPAQ::hasLightSensor ( ) const | 1480 | bool iPAQ::hasLightSensor ( ) const |
1481 | { | 1481 | { |
1482 | return true; | 1482 | return true; |
1483 | } | 1483 | } |
1484 | 1484 | ||
1485 | int iPAQ::readLightSensor ( ) | 1485 | int iPAQ::readLightSensor ( ) |
1486 | { | 1486 | { |
1487 | int fd; | 1487 | int fd; |
1488 | int val = -1; | 1488 | int val = -1; |
1489 | 1489 | ||
1490 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1490 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1491 | char buffer [8]; | 1491 | char buffer [8]; |
1492 | 1492 | ||
1493 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1493 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1494 | char *endptr; | 1494 | char *endptr; |
1495 | 1495 | ||
1496 | buffer [4] = 0; | 1496 | buffer [4] = 0; |
1497 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1497 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1498 | 1498 | ||
1499 | if ( *endptr != 0 ) | 1499 | if ( *endptr != 0 ) |
1500 | val = -1; | 1500 | val = -1; |
1501 | } | 1501 | } |
1502 | ::close ( fd ); | 1502 | ::close ( fd ); |
1503 | } | 1503 | } |
1504 | 1504 | ||
1505 | return val; | 1505 | return val; |
1506 | } | 1506 | } |
1507 | 1507 | ||
1508 | int iPAQ::lightSensorResolution ( ) const | 1508 | int iPAQ::lightSensorResolution ( ) const |
1509 | { | 1509 | { |
1510 | return 256; | 1510 | return 256; |
1511 | } | 1511 | } |
1512 | 1512 | ||
1513 | /************************************************** | 1513 | /************************************************** |
1514 | * | 1514 | * |
1515 | * Zaurus | 1515 | * Zaurus |
1516 | * | 1516 | * |
1517 | **************************************************/ | 1517 | **************************************************/ |
1518 | 1518 | ||
1519 | // Check whether this device is the sharp zaurus.. | 1519 | // Check whether this device is the sharp zaurus.. |
1520 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 1520 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
1521 | // class up into individual classes. We need three classes | 1521 | // class up into individual classes. We need three classes |
1522 | // | 1522 | // |
1523 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 1523 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
1524 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 1524 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
1525 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 1525 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
1526 | // | 1526 | // |
1527 | // Only question right now is: Do we really need to do it? Because as soon | 1527 | // Only question right now is: Do we really need to do it? Because as soon |
1528 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 1528 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
1529 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 1529 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
1530 | // | 1530 | // |
1531 | // Comments? - mickeyl. | 1531 | // Comments? - mickeyl. |
1532 | 1532 | ||
1533 | bool Zaurus::isZaurus() | 1533 | bool Zaurus::isZaurus() |
1534 | { | 1534 | { |
1535 | 1535 | ||
1536 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1536 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
1537 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | 1537 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ |
1538 | return true; | 1538 | return true; |
1539 | } | 1539 | } |
1540 | 1540 | ||
1541 | // On non-embedix kernels, we have to look closer. | 1541 | // On non-embedix kernels, we have to look closer. |
1542 | bool is_zaurus = false; | 1542 | bool is_zaurus = false; |
1543 | QFile f ( "/proc/cpuinfo" ); | 1543 | QFile f ( "/proc/cpuinfo" ); |
1544 | if ( f. open ( IO_ReadOnly ) ) { | 1544 | if ( f. open ( IO_ReadOnly ) ) { |
1545 | QString model; | 1545 | QString model; |
1546 | QFile f ( "/proc/cpuinfo" ); | 1546 | QFile f ( "/proc/cpuinfo" ); |
1547 | 1547 | ||
1548 | QTextStream ts ( &f ); | 1548 | QTextStream ts ( &f ); |
1549 | QString line; | 1549 | QString line; |
1550 | while( line = ts. readLine ( ) ) { | 1550 | while( line = ts. readLine ( ) ) { |
1551 | if ( line. left ( 8 ) == "Hardware" ) | 1551 | if ( line. left ( 8 ) == "Hardware" ) |
1552 | break; | 1552 | break; |
1553 | } | 1553 | } |
1554 | int loc = line. find ( ":" ); | 1554 | int loc = line. find ( ":" ); |
1555 | if ( loc != -1 ) | 1555 | if ( loc != -1 ) |
1556 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1556 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1557 | 1557 | ||
1558 | if ( model == "Sharp-Collie" | 1558 | if ( model == "Sharp-Collie" |
1559 | || model == "Collie" | 1559 | || model == "Collie" |
1560 | || model == "SHARP Corgi" | 1560 | || model == "SHARP Corgi" |
1561 | || model == "SHARP Shepherd" | 1561 | || model == "SHARP Shepherd" |
1562 | || model == "SHARP Poodle" | 1562 | || model == "SHARP Poodle" |
1563 | || model == "SHARP Husky" | 1563 | || model == "SHARP Husky" |
1564 | ) | 1564 | ) |
1565 | is_zaurus = true; | 1565 | is_zaurus = true; |
1566 | 1566 | ||
1567 | } | 1567 | } |
1568 | return is_zaurus; | 1568 | return is_zaurus; |
1569 | } | 1569 | } |
1570 | 1570 | ||
1571 | 1571 | ||
1572 | void Zaurus::init ( ) | 1572 | void Zaurus::init ( ) |
1573 | { | 1573 | { |
1574 | d-> m_vendorstr = "Sharp"; | 1574 | d-> m_vendorstr = "Sharp"; |
1575 | d-> m_vendor = Vendor_Sharp; | 1575 | d-> m_vendor = Vendor_Sharp; |
1576 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 1576 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
1577 | 1577 | ||
1578 | // QFile f ( "/proc/filesystems" ); | 1578 | // QFile f ( "/proc/filesystems" ); |
1579 | QString model; | 1579 | QString model; |
1580 | 1580 | ||
1581 | // It isn't a good idea to check the system configuration to | 1581 | // It isn't a good idea to check the system configuration to |
1582 | // detect the distribution ! | 1582 | // detect the distribution ! |
1583 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1583 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1584 | // because it uses a jffs2 filesystem.. | 1584 | // because it uses a jffs2 filesystem.. |
1585 | // (eilers) | 1585 | // (eilers) |
1586 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1586 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1587 | QFile f ("/etc/oz_version"); | 1587 | QFile f ("/etc/oz_version"); |
1588 | if ( f.exists() ){ | 1588 | if ( f.exists() ){ |
1589 | d-> m_vendorstr = "OpenZaurus Team"; | 1589 | d-> m_vendorstr = "OpenZaurus Team"; |
1590 | d-> m_systemstr = "OpenZaurus"; | 1590 | d-> m_systemstr = "OpenZaurus"; |
1591 | d-> m_system = System_OpenZaurus; | 1591 | d-> m_system = System_OpenZaurus; |
1592 | 1592 | ||
1593 | if ( f. open ( IO_ReadOnly )) { | 1593 | if ( f. open ( IO_ReadOnly )) { |
1594 | QTextStream ts ( &f ); | 1594 | QTextStream ts ( &f ); |
1595 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1595 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1596 | f. close ( ); | 1596 | f. close ( ); |
1597 | } | 1597 | } |
1598 | 1598 | ||
1599 | // Openzaurus sometimes uses the embedix kernel! | 1599 | // Openzaurus sometimes uses the embedix kernel! |
1600 | // => Check whether this is an embedix kernel | 1600 | // => Check whether this is an embedix kernel |
1601 | FILE *uname = popen("uname -r", "r"); | 1601 | FILE *uname = popen("uname -r", "r"); |
1602 | QString line; | 1602 | QString line; |
1603 | if ( f.open(IO_ReadOnly, uname) ) { | 1603 | if ( f.open(IO_ReadOnly, uname) ) { |
1604 | QTextStream ts ( &f ); | 1604 | QTextStream ts ( &f ); |
1605 | line = ts. readLine ( ); | 1605 | line = ts. readLine ( ); |
1606 | int loc = line. find ( "embedix" ); | 1606 | int loc = line. find ( "embedix" ); |
1607 | if ( loc != -1 ) | 1607 | if ( loc != -1 ) |
1608 | m_embedix = true; | 1608 | m_embedix = true; |
1609 | else | 1609 | else |
1610 | m_embedix = false; | 1610 | m_embedix = false; |
1611 | f. close ( ); | 1611 | f. close ( ); |
1612 | } | 1612 | } |
1613 | pclose(uname); | 1613 | pclose(uname); |
1614 | } | 1614 | } |
1615 | else { | 1615 | else { |
1616 | d-> m_systemstr = "Zaurus"; | 1616 | d-> m_systemstr = "Zaurus"; |
1617 | d-> m_system = System_Zaurus; | 1617 | d-> m_system = System_Zaurus; |
1618 | } | 1618 | } |
1619 | 1619 | ||
1620 | f. setName ( "/proc/cpuinfo" ); | 1620 | f. setName ( "/proc/cpuinfo" ); |
1621 | if ( f. open ( IO_ReadOnly ) ) { | 1621 | if ( f. open ( IO_ReadOnly ) ) { |
1622 | QTextStream ts ( &f ); | 1622 | QTextStream ts ( &f ); |
1623 | QString line; | 1623 | QString line; |
1624 | while( line = ts. readLine ( ) ) { | 1624 | while( line = ts. readLine ( ) ) { |
1625 | if ( line. left ( 8 ) == "Hardware" ) | 1625 | if ( line. left ( 8 ) == "Hardware" ) |
1626 | break; | 1626 | break; |
1627 | } | 1627 | } |
1628 | int loc = line. find ( ":" ); | 1628 | int loc = line. find ( ":" ); |
1629 | if ( loc != -1 ) | 1629 | if ( loc != -1 ) |
1630 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1630 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1631 | } | 1631 | } |
1632 | 1632 | ||
1633 | if ( model == "SHARP Corgi" ) { | 1633 | if ( model == "SHARP Corgi" ) { |
1634 | d-> m_model = Model_Zaurus_SLC7x0; | 1634 | d-> m_model = Model_Zaurus_SLC7x0; |
1635 | d-> m_modelstr = "Zaurus SL-C700"; | 1635 | d-> m_modelstr = "Zaurus SL-C700"; |
1636 | } else if ( model == "SHARP Shepherd" ) { | 1636 | } else if ( model == "SHARP Shepherd" ) { |
1637 | d-> m_model = Model_Zaurus_SLC7x0; | 1637 | d-> m_model = Model_Zaurus_SLC7x0; |
1638 | d-> m_modelstr = "Zaurus SL-C750"; | 1638 | d-> m_modelstr = "Zaurus SL-C750"; |
1639 | } else if ( model == "SHARP Husky" ) { | 1639 | } else if ( model == "SHARP Husky" ) { |
1640 | d-> m_model = Model_Zaurus_SLC7x0; | 1640 | d-> m_model = Model_Zaurus_SLC7x0; |
1641 | d-> m_modelstr = "Zaurus SL-C760"; | 1641 | d-> m_modelstr = "Zaurus SL-C760"; |
1642 | } else if ( model == "SHARP Poodle" ) { | 1642 | } else if ( model == "SHARP Poodle" ) { |
1643 | d-> m_model = Model_Zaurus_SLB600; | 1643 | d-> m_model = Model_Zaurus_SLB600; |
1644 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1644 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1645 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1645 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1646 | d-> m_model = Model_Zaurus_SL5500; | 1646 | d-> m_model = Model_Zaurus_SL5500; |
1647 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1647 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1648 | } else { | 1648 | } else { |
1649 | d-> m_model = Model_Zaurus_SL5500; | 1649 | d-> m_model = Model_Zaurus_SL5500; |
1650 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1650 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1651 | } | 1651 | } |
1652 | 1652 | ||
1653 | bool flipstate = false; | 1653 | bool flipstate = false; |
1654 | switch ( d-> m_model ) { | 1654 | switch ( d-> m_model ) { |
1655 | case Model_Zaurus_SLA300: | 1655 | case Model_Zaurus_SLA300: |
1656 | d-> m_rotation = Rot0; | 1656 | d-> m_rotation = Rot0; |
1657 | break; | 1657 | break; |
1658 | case Model_Zaurus_SLC7x0: | 1658 | case Model_Zaurus_SLC7x0: |
1659 | d-> m_rotation = rotation(); | 1659 | d-> m_rotation = rotation(); |
1660 | d-> m_direction = direction(); | 1660 | d-> m_direction = direction(); |
1661 | break; | 1661 | break; |
1662 | case Model_Zaurus_SLB600: | 1662 | case Model_Zaurus_SLB600: |
1663 | case Model_Zaurus_SL5500: | 1663 | case Model_Zaurus_SL5500: |
1664 | case Model_Zaurus_SL5000: | 1664 | case Model_Zaurus_SL5000: |
1665 | default: | 1665 | default: |
1666 | d-> m_rotation = Rot270; | 1666 | d-> m_rotation = Rot270; |
1667 | break; | 1667 | break; |
1668 | } | 1668 | } |
1669 | m_leds [0] = Led_Off; | 1669 | m_leds [0] = Led_Off; |
1670 | } | 1670 | } |
1671 | 1671 | ||
1672 | void Zaurus::initButtons ( ) | 1672 | void Zaurus::initButtons ( ) |
1673 | { | 1673 | { |
1674 | if ( d-> m_buttons ) | 1674 | if ( d-> m_buttons ) |
1675 | return; | 1675 | return; |
1676 | 1676 | ||
1677 | d-> m_buttons = new QValueList <ODeviceButton>; | 1677 | d-> m_buttons = new QValueList <ODeviceButton>; |
1678 | 1678 | ||
1679 | struct z_button * pz_buttons; | 1679 | struct z_button * pz_buttons; |
1680 | int buttoncount; | 1680 | int buttoncount; |
1681 | switch ( d-> m_model ) { | 1681 | switch ( d-> m_model ) { |
1682 | case Model_Zaurus_SLC7x0: | 1682 | case Model_Zaurus_SLC7x0: |
1683 | pz_buttons = z_buttons_c700; | 1683 | pz_buttons = z_buttons_c700; |
1684 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1684 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1685 | break; | 1685 | break; |
1686 | default: | 1686 | default: |
1687 | pz_buttons = z_buttons; | 1687 | pz_buttons = z_buttons; |
1688 | buttoncount = ARRAY_SIZE(z_buttons); | 1688 | buttoncount = ARRAY_SIZE(z_buttons); |
1689 | break; | 1689 | break; |
1690 | } | 1690 | } |
1691 | 1691 | ||
1692 | for ( int i = 0; i < buttoncount; i++ ) { | 1692 | for ( int i = 0; i < buttoncount; i++ ) { |
1693 | struct z_button *zb = pz_buttons + i; | 1693 | struct z_button *zb = pz_buttons + i; |
1694 | ODeviceButton b; | 1694 | ODeviceButton b; |
1695 | 1695 | ||
1696 | b. setKeycode ( zb-> code ); | 1696 | b. setKeycode ( zb-> code ); |
1697 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1697 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1698 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1698 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1699 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), | 1699 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1700 | zb-> fpressedaction )); | 1700 | zb-> fpressedaction )); |
1701 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | 1701 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), |
1702 | zb-> fheldaction )); | 1702 | zb-> fheldaction )); |
1703 | 1703 | ||
1704 | d-> m_buttons-> append ( b ); | 1704 | d-> m_buttons-> append ( b ); |
1705 | } | 1705 | } |
1706 | 1706 | ||
1707 | reloadButtonMapping ( ); | 1707 | reloadButtonMapping ( ); |
1708 | 1708 | ||
1709 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1709 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1710 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), | 1710 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), |
1711 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1711 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1712 | } | 1712 | } |
1713 | 1713 | ||
1714 | #include <unistd.h> | 1714 | #include <unistd.h> |
1715 | #include <fcntl.h> | 1715 | #include <fcntl.h> |
1716 | #include <sys/ioctl.h> | 1716 | #include <sys/ioctl.h> |
1717 | 1717 | ||
1718 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1718 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1719 | 1719 | ||
1720 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1720 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1721 | 1721 | ||
1722 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1722 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1723 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1723 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1724 | 1724 | ||
1725 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1725 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1726 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1726 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1727 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1727 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1728 | 1728 | ||
1729 | /* --- for SHARP_BUZZER device --- */ | 1729 | /* --- for SHARP_BUZZER device --- */ |
1730 | 1730 | ||
1731 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1731 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1732 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1732 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1733 | 1733 | ||
1734 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1734 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1735 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1735 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1736 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1736 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1737 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1737 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1738 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1738 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1739 | 1739 | ||
1740 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1740 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1741 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1741 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1742 | 1742 | ||
1743 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1743 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1744 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1744 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1745 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1745 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1746 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1746 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1747 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1747 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1748 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1748 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1749 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1749 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1750 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1750 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1751 | 1751 | ||
1752 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1752 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1753 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1753 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1754 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1754 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1755 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1755 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1756 | // | 1756 | // |
1757 | 1757 | ||
1758 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1758 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1759 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1759 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1760 | 1760 | ||
1761 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 1761 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
1762 | 1762 | ||
1763 | typedef struct sharp_led_status { | 1763 | typedef struct sharp_led_status { |
1764 | int which; /* select which LED status is wanted. */ | 1764 | int which; /* select which LED status is wanted. */ |
1765 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1765 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1766 | } sharp_led_status; | 1766 | } sharp_led_status; |
1767 | 1767 | ||
1768 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1768 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1769 | 1769 | ||
1770 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1770 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1771 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1771 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1772 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1772 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1773 | 1773 | ||
1774 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1774 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1775 | 1775 | ||
1776 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1776 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1777 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1777 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1778 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1778 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1779 | 1779 | ||
1780 | #define FL_IOCTL_STEP_CONTRAST 100 | 1780 | #define FL_IOCTL_STEP_CONTRAST 100 |
1781 | 1781 | ||
1782 | 1782 | ||
1783 | void Zaurus::buzzer ( int sound ) | 1783 | void Zaurus::buzzer ( int sound ) |
1784 | { | 1784 | { |
1785 | #ifndef QT_NO_SOUND | 1785 | #ifndef QT_NO_SOUND |
1786 | QString soundname; | 1786 | QString soundname; |
1787 | 1787 | ||
1788 | // Not all devices have real sound | 1788 | // Not all devices have real sound |
1789 | if ( d->m_model == Model_Zaurus_SLC7x0 | 1789 | if ( d->m_model == Model_Zaurus_SLC7x0 |
1790 | || d->m_model == Model_Zaurus_SLB600 ){ | 1790 | || d->m_model == Model_Zaurus_SLB600 ){ |
1791 | 1791 | ||
1792 | switch ( sound ){ | 1792 | switch ( sound ){ |
1793 | case SHARP_BUZ_SCHEDULE_ALARM: | 1793 | case SHARP_BUZ_SCHEDULE_ALARM: |
1794 | soundname = "alarm"; | 1794 | soundname = "alarm"; |
1795 | break; | 1795 | break; |
1796 | case SHARP_BUZ_TOUCHSOUND: | 1796 | case SHARP_BUZ_TOUCHSOUND: |
1797 | soundname = "touchsound"; | 1797 | soundname = "touchsound"; |
1798 | break; | 1798 | break; |
1799 | case SHARP_BUZ_KEYSOUND: | 1799 | case SHARP_BUZ_KEYSOUND: |
1800 | soundname = "keysound"; | 1800 | soundname = "keysound"; |
1801 | break; | 1801 | break; |
1802 | default: | 1802 | default: |
1803 | soundname = "alarm"; | 1803 | soundname = "alarm"; |
1804 | 1804 | ||
1805 | } | 1805 | } |
1806 | } | 1806 | } |
1807 | 1807 | ||
1808 | // If a soundname is defined, we expect that this device has | 1808 | // If a soundname is defined, we expect that this device has |
1809 | // sound capabilities.. Otherwise we expect to have the buzzer | 1809 | // sound capabilities.. Otherwise we expect to have the buzzer |
1810 | // device.. | 1810 | // device.. |
1811 | if ( !soundname.isEmpty() ){ | 1811 | if ( !soundname.isEmpty() ){ |
1812 | int fd; | 1812 | int fd; |
1813 | int vol; | 1813 | int vol; |
1814 | bool vol_reset = false; | 1814 | bool vol_reset = false; |
1815 | 1815 | ||
1816 | Sound snd ( soundname ); | 1816 | Sound snd ( soundname ); |
1817 | 1817 | ||
1818 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1818 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1819 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1819 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1820 | Config cfg ( "qpe" ); | 1820 | Config cfg ( "qpe" ); |
1821 | cfg. setGroup ( "Volume" ); | 1821 | cfg. setGroup ( "Volume" ); |
1822 | 1822 | ||
1823 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1823 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1824 | if ( volalarm < 0 ) | 1824 | if ( volalarm < 0 ) |
1825 | volalarm = 0; | 1825 | volalarm = 0; |
1826 | else if ( volalarm > 100 ) | 1826 | else if ( volalarm > 100 ) |
1827 | volalarm = 100; | 1827 | volalarm = 100; |
1828 | volalarm |= ( volalarm << 8 ); | 1828 | volalarm |= ( volalarm << 8 ); |
1829 | 1829 | ||
1830 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1830 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1831 | vol_reset = true; | 1831 | vol_reset = true; |
1832 | } | 1832 | } |
1833 | } | 1833 | } |
1834 | 1834 | ||
1835 | snd. play ( ); | 1835 | snd. play ( ); |
1836 | while ( !snd. isFinished ( )) | 1836 | while ( !snd. isFinished ( )) |
1837 | qApp-> processEvents ( ); | 1837 | qApp-> processEvents ( ); |
1838 | 1838 | ||
1839 | if ( fd >= 0 ) { | 1839 | if ( fd >= 0 ) { |
1840 | if ( vol_reset ) | 1840 | if ( vol_reset ) |
1841 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1841 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1842 | ::close ( fd ); | 1842 | ::close ( fd ); |
1843 | } | 1843 | } |
1844 | } else { | 1844 | } else { |
1845 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1845 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1846 | 1846 | ||
1847 | if ( fd >= 0 ) { | 1847 | if ( fd >= 0 ) { |
1848 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1848 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1849 | ::close ( fd ); | 1849 | ::close ( fd ); |
1850 | } | 1850 | } |
1851 | 1851 | ||
1852 | } | 1852 | } |
1853 | #endif | 1853 | #endif |
1854 | } | 1854 | } |
1855 | 1855 | ||
1856 | 1856 | ||
1857 | void Zaurus::alarmSound ( ) | 1857 | void Zaurus::alarmSound ( ) |
1858 | { | 1858 | { |
1859 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1859 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1860 | } | 1860 | } |
1861 | 1861 | ||
1862 | void Zaurus::touchSound ( ) | 1862 | void Zaurus::touchSound ( ) |
1863 | { | 1863 | { |
1864 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1864 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1865 | } | 1865 | } |
1866 | 1866 | ||
1867 | void Zaurus::keySound ( ) | 1867 | void Zaurus::keySound ( ) |
1868 | { | 1868 | { |
1869 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1869 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1870 | } | 1870 | } |
1871 | 1871 | ||
1872 | 1872 | ||
1873 | QValueList <OLed> Zaurus::ledList ( ) const | 1873 | QValueList <OLed> Zaurus::ledList ( ) const |
1874 | { | 1874 | { |
1875 | QValueList <OLed> vl; | 1875 | QValueList <OLed> vl; |
1876 | vl << Led_Mail; | 1876 | vl << Led_Mail; |
1877 | return vl; | 1877 | return vl; |
1878 | } | 1878 | } |
1879 | 1879 | ||
1880 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1880 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1881 | { | 1881 | { |
1882 | QValueList <OLedState> vl; | 1882 | QValueList <OLedState> vl; |
1883 | 1883 | ||
1884 | if ( l == Led_Mail ) | 1884 | if ( l == Led_Mail ) |
1885 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1885 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1886 | return vl; | 1886 | return vl; |
1887 | } | 1887 | } |
1888 | 1888 | ||
1889 | OLedState Zaurus::ledState ( OLed which ) const | 1889 | OLedState Zaurus::ledState ( OLed which ) const |
1890 | { | 1890 | { |
1891 | if ( which == Led_Mail ) | 1891 | if ( which == Led_Mail ) |
1892 | return m_leds [0]; | 1892 | return m_leds [0]; |
1893 | else | 1893 | else |
1894 | return Led_Off; | 1894 | return Led_Off; |
1895 | } | 1895 | } |
1896 | 1896 | ||
1897 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1897 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1898 | { | 1898 | { |
1899 | if (!m_embedix) // Currently not supported on non_embedix kernels | 1899 | if (!m_embedix) // Currently not supported on non_embedix kernels |
1900 | return false; | 1900 | return false; |
1901 | 1901 | ||
1902 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1902 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1903 | 1903 | ||
1904 | if ( which == Led_Mail ) { | 1904 | if ( which == Led_Mail ) { |
1905 | if ( fd >= 0 ) { | 1905 | if ( fd >= 0 ) { |
1906 | struct sharp_led_status leds; | 1906 | struct sharp_led_status leds; |
1907 | ::memset ( &leds, 0, sizeof( leds )); | 1907 | ::memset ( &leds, 0, sizeof( leds )); |
1908 | leds. which = SHARP_LED_MAIL_EXISTS; | 1908 | leds. which = SHARP_LED_MAIL_EXISTS; |
1909 | bool ok = true; | 1909 | bool ok = true; |
1910 | 1910 | ||
1911 | switch ( st ) { | 1911 | switch ( st ) { |
1912 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1912 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1913 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1913 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1914 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1914 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1915 | default : ok = false; | 1915 | default : ok = false; |
1916 | } | 1916 | } |
1917 | 1917 | ||
1918 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1918 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1919 | m_leds [0] = st; | 1919 | m_leds [0] = st; |
1920 | return true; | 1920 | return true; |
1921 | } | 1921 | } |
1922 | } | 1922 | } |
1923 | } | 1923 | } |
1924 | return false; | 1924 | return false; |
1925 | } | 1925 | } |
1926 | 1926 | ||
1927 | bool Zaurus::setSoftSuspend ( bool soft ) | 1927 | bool Zaurus::setSoftSuspend ( bool soft ) |
1928 | { | 1928 | { |
1929 | if (!m_embedix) { | 1929 | if (!m_embedix) { |
1930 | /* non-Embedix kernels dont have kernel autosuspend */ | 1930 | /* non-Embedix kernels dont have kernel autosuspend */ |
1931 | return ODevice::setSoftSuspend( soft ); | 1931 | return ODevice::setSoftSuspend( soft ); |
1932 | } | 1932 | } |
1933 | 1933 | ||
1934 | bool res = false; | 1934 | bool res = false; |
1935 | int fd; | 1935 | int fd; |
1936 | 1936 | ||
1937 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1937 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1938 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1938 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1939 | 1939 | ||
1940 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1940 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1941 | 1941 | ||
1942 | if ( sources >= 0 ) { | 1942 | if ( sources >= 0 ) { |
1943 | if ( soft ) | 1943 | if ( soft ) |
1944 | sources &= ~APM_EVT_POWER_BUTTON; | 1944 | sources &= ~APM_EVT_POWER_BUTTON; |
1945 | else | 1945 | else |
1946 | sources |= APM_EVT_POWER_BUTTON; | 1946 | sources |= APM_EVT_POWER_BUTTON; |
1947 | 1947 | ||
1948 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1948 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1949 | res = true; | 1949 | res = true; |
1950 | else | 1950 | else |
1951 | perror ( "APM_IOCGEVTSRC" ); | 1951 | perror ( "APM_IOCGEVTSRC" ); |
1952 | } | 1952 | } |
1953 | else | 1953 | else |
1954 | perror ( "APM_IOCGEVTSRC" ); | 1954 | perror ( "APM_IOCGEVTSRC" ); |
1955 | 1955 | ||
1956 | ::close ( fd ); | 1956 | ::close ( fd ); |
1957 | } | 1957 | } |
1958 | else | 1958 | else |
1959 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1959 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1960 | 1960 | ||
1961 | return res; | 1961 | return res; |
1962 | } | 1962 | } |
1963 | 1963 | ||
1964 | 1964 | ||
1965 | bool Zaurus::setDisplayBrightness ( int bright ) | 1965 | bool Zaurus::setDisplayBrightness ( int bright ) |
1966 | { | 1966 | { |
1967 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | ||
1967 | bool res = false; | 1968 | bool res = false; |
1968 | int fd; | 1969 | int fd; |
1969 | 1970 | ||
1970 | if ( bright > 255 ) bright = 255; | 1971 | if ( bright > 255 ) bright = 255; |
1971 | if ( bright < 0 ) bright = 0; | 1972 | if ( bright < 0 ) bright = 0; |
1972 | 1973 | ||
1973 | if ( m_embedix ) | 1974 | if ( m_embedix ) |
1974 | { | 1975 | { |
1975 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 1976 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
1976 | { | 1977 | { |
1978 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | ||
1977 | // special treatment for devices with the corgi backlight interface | 1979 | // special treatment for devices with the corgi backlight interface |
1978 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 1980 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
1979 | { | 1981 | { |
1980 | if ( bright > 0x11 ) bright = 0x11; | 1982 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); |
1981 | char writeCommand[100]; | 1983 | char writeCommand[100]; |
1982 | const int count = sprintf( writeCommand, "0x%x\n", bright ); | 1984 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
1983 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 1985 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
1984 | ::close ( fd ); | 1986 | ::close ( fd ); |
1985 | } | 1987 | } |
1986 | return res; | 1988 | return res; |
1987 | } | 1989 | } |
1988 | else | 1990 | else |
1989 | { | 1991 | { |
1990 | // standard treatment for devices with the dumb embedix frontlight interface | 1992 | // standard treatment for devices with the dumb embedix frontlight interface |
1991 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1993 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1992 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1994 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1993 | if ( bright && !bl ) | 1995 | if ( bright && !bl ) |
1994 | bl = 1; | 1996 | bl = 1; |
1995 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1997 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1996 | ::close ( fd ); | 1998 | ::close ( fd ); |
1997 | } | 1999 | } |
1998 | } | 2000 | } |
1999 | } | 2001 | } |
2000 | else | 2002 | else |
2001 | { | 2003 | { |
2002 | // special treatment for the OpenZaurus unified interface | 2004 | // special treatment for the OpenZaurus unified interface |
2003 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 2005 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
2004 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 2006 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
2005 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 2007 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
2006 | ::close ( fd ); | 2008 | ::close ( fd ); |
2007 | } | 2009 | } |
2008 | } | 2010 | } |
2009 | return res; | 2011 | return res; |
2010 | } | 2012 | } |
2011 | 2013 | ||
2012 | bool Zaurus::suspend ( ) | 2014 | bool Zaurus::suspend ( ) |
2013 | { | 2015 | { |
2014 | qDebug("ODevice::suspend"); | 2016 | qDebug("ODevice::suspend"); |
2015 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2017 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2016 | return false; | 2018 | return false; |
2017 | 2019 | ||
2018 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 2020 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
2019 | return false; | 2021 | return false; |
2020 | 2022 | ||
2021 | bool res = false; | 2023 | bool res = false; |
2022 | 2024 | ||
2023 | struct timeval tvs, tvn; | 2025 | struct timeval tvs, tvn; |
2024 | ::gettimeofday ( &tvs, 0 ); | 2026 | ::gettimeofday ( &tvs, 0 ); |
2025 | 2027 | ||
2026 | ::sync ( ); // flush fs caches | 2028 | ::sync ( ); // flush fs caches |
2027 | res = ( ::system ( "apm --suspend" ) == 0 ); | 2029 | res = ( ::system ( "apm --suspend" ) == 0 ); |
2028 | 2030 | ||
2029 | // This is needed because the iPAQ apm implementation is asynchronous and we | 2031 | // This is needed because the iPAQ apm implementation is asynchronous and we |
2030 | // can not be sure when exactly the device is really suspended | 2032 | // can not be sure when exactly the device is really suspended |
2031 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 2033 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
2032 | 2034 | ||
2033 | if ( res ) { | 2035 | if ( res ) { |
2034 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 2036 | do { // Yes, wait 15 seconds. This APM bug sucks big time. |
2035 | ::usleep ( 200 * 1000 ); | 2037 | ::usleep ( 200 * 1000 ); |
2036 | ::gettimeofday ( &tvn, 0 ); | 2038 | ::gettimeofday ( &tvn, 0 ); |
2037 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 2039 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
2038 | } | 2040 | } |
2039 | 2041 | ||
2040 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 2042 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
2041 | return res; | 2043 | return res; |
2042 | } | 2044 | } |
2043 | 2045 | ||
2044 | 2046 | ||
2045 | Transformation Zaurus::rotation ( ) const | 2047 | Transformation Zaurus::rotation ( ) const |
2046 | { | 2048 | { |
2047 | Transformation rot; | 2049 | Transformation rot; |
2048 | int handle = 0; | 2050 | int handle = 0; |
2049 | int retval = 0; | 2051 | int retval = 0; |
2050 | 2052 | ||
2051 | switch ( d-> m_model ) { | 2053 | switch ( d-> m_model ) { |
2052 | case Model_Zaurus_SLC7x0: | 2054 | case Model_Zaurus_SLC7x0: |
2053 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2055 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2054 | if (handle == -1) { | 2056 | if (handle == -1) { |
2055 | return Rot270; | 2057 | return Rot270; |
2056 | } else { | 2058 | } else { |
2057 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2059 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2058 | ::close (handle); | 2060 | ::close (handle); |
2059 | 2061 | ||
2060 | if (retval == 2 ) | 2062 | if (retval == 2 ) |
2061 | rot = Rot0; | 2063 | rot = Rot0; |
2062 | else | 2064 | else |
2063 | rot = Rot270; | 2065 | rot = Rot270; |
2064 | } | 2066 | } |
2065 | break; | 2067 | break; |
2066 | case Model_Zaurus_SLA300: | 2068 | case Model_Zaurus_SLA300: |
2067 | case Model_Zaurus_SLB600: | 2069 | case Model_Zaurus_SLB600: |
2068 | case Model_Zaurus_SL5500: | 2070 | case Model_Zaurus_SL5500: |
2069 | case Model_Zaurus_SL5000: | 2071 | case Model_Zaurus_SL5000: |
2070 | default: | 2072 | default: |
2071 | rot = d-> m_rotation; | 2073 | rot = d-> m_rotation; |
2072 | break; | 2074 | break; |
2073 | } | 2075 | } |
2074 | 2076 | ||
2075 | return rot; | 2077 | return rot; |
2076 | } | 2078 | } |
2077 | ODirection Zaurus::direction ( ) const | 2079 | ODirection Zaurus::direction ( ) const |
2078 | { | 2080 | { |
2079 | ODirection dir; | 2081 | ODirection dir; |
2080 | int handle = 0; | 2082 | int handle = 0; |
2081 | int retval = 0; | 2083 | int retval = 0; |
2082 | switch ( d-> m_model ) { | 2084 | switch ( d-> m_model ) { |
2083 | case Model_Zaurus_SLC7x0: | 2085 | case Model_Zaurus_SLC7x0: |
2084 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2086 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2085 | if (handle == -1) { | 2087 | if (handle == -1) { |
2086 | dir = CW; | 2088 | dir = CW; |
2087 | } else { | 2089 | } else { |
2088 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2090 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2089 | ::close (handle); | 2091 | ::close (handle); |
2090 | if (retval == 2 ) | 2092 | if (retval == 2 ) |
2091 | dir = CCW; | 2093 | dir = CCW; |
2092 | else | 2094 | else |
2093 | dir = CW; | 2095 | dir = CW; |
2094 | } | 2096 | } |
2095 | break; | 2097 | break; |
2096 | case Model_Zaurus_SLA300: | 2098 | case Model_Zaurus_SLA300: |
2097 | case Model_Zaurus_SLB600: | 2099 | case Model_Zaurus_SLB600: |
2098 | case Model_Zaurus_SL5500: | 2100 | case Model_Zaurus_SL5500: |
2099 | case Model_Zaurus_SL5000: | 2101 | case Model_Zaurus_SL5000: |
2100 | default: | 2102 | default: |
2101 | dir = d-> m_direction; | 2103 | dir = d-> m_direction; |
2102 | break; | 2104 | break; |
2103 | } | 2105 | } |
2104 | return dir; | 2106 | return dir; |
2105 | 2107 | ||
2106 | } | 2108 | } |
2107 | 2109 | ||
2108 | int Zaurus::displayBrightnessResolution ( ) const | 2110 | int Zaurus::displayBrightnessResolution ( ) const |
2109 | { | 2111 | { |
2110 | if (m_embedix) | 2112 | if (m_embedix) |
2111 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; | 2113 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; |
2112 | else | 2114 | else |
2113 | return 256; | 2115 | return 256; |
2114 | } | 2116 | } |
2115 | 2117 | ||
2116 | bool Zaurus::hasHingeSensor() const | 2118 | bool Zaurus::hasHingeSensor() const |
2117 | { | 2119 | { |
2118 | return d->m_model == Model_Zaurus_SLC7x0; | 2120 | return d->m_model == Model_Zaurus_SLC7x0; |
2119 | } | 2121 | } |
2120 | 2122 | ||
2121 | OHingeStatus Zaurus::readHingeSensor() | 2123 | OHingeStatus Zaurus::readHingeSensor() |
2122 | { | 2124 | { |
2123 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2125 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2124 | if (handle == -1) | 2126 | if (handle == -1) |
2125 | { | 2127 | { |
2126 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 2128 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
2127 | return CASE_UNKNOWN; | 2129 | return CASE_UNKNOWN; |
2128 | } | 2130 | } |
2129 | else | 2131 | else |
2130 | { | 2132 | { |
2131 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2133 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2132 | ::close (handle); | 2134 | ::close (handle); |
2133 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 2135 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
2134 | { | 2136 | { |
2135 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 2137 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
2136 | return static_cast<OHingeStatus>( retval ); | 2138 | return static_cast<OHingeStatus>( retval ); |
2137 | } | 2139 | } |
2138 | else | 2140 | else |
2139 | { | 2141 | { |
2140 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 2142 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
2141 | return CASE_UNKNOWN; | 2143 | return CASE_UNKNOWN; |
2142 | } | 2144 | } |
2143 | } | 2145 | } |
2144 | } | 2146 | } |
2145 | 2147 | ||
2146 | 2148 | ||
2147 | /************************************************** | 2149 | /************************************************** |
2148 | * | 2150 | * |
2149 | * SIMpad | 2151 | * SIMpad |
2150 | * | 2152 | * |
2151 | **************************************************/ | 2153 | **************************************************/ |
2152 | 2154 | ||
2153 | void SIMpad::init ( ) | 2155 | void SIMpad::init ( ) |
2154 | { | 2156 | { |
2155 | d-> m_vendorstr = "SIEMENS"; | 2157 | d-> m_vendorstr = "SIEMENS"; |
2156 | d-> m_vendor = Vendor_SIEMENS; | 2158 | d-> m_vendor = Vendor_SIEMENS; |
2157 | 2159 | ||
2158 | QFile f ( "/proc/hal/model" ); | 2160 | QFile f ( "/proc/hal/model" ); |
2159 | 2161 | ||
2160 | //TODO Implement model checking | 2162 | //TODO Implement model checking |
2161 | //FIXME For now we assume an SL4 | 2163 | //FIXME For now we assume an SL4 |
2162 | 2164 | ||
2163 | d-> m_modelstr = "SL4"; | 2165 | d-> m_modelstr = "SL4"; |
2164 | d-> m_model = Model_SIMpad_SL4; | 2166 | d-> m_model = Model_SIMpad_SL4; |
2165 | 2167 | ||
2166 | switch ( d-> m_model ) { | 2168 | switch ( d-> m_model ) { |
2167 | default: | 2169 | default: |
2168 | d-> m_rotation = Rot0; | 2170 | d-> m_rotation = Rot0; |
2169 | d-> m_direction = CCW; | 2171 | d-> m_direction = CCW; |
2170 | d-> m_holdtime = 1000; // 1000ms | 2172 | d-> m_holdtime = 1000; // 1000ms |
2171 | 2173 | ||
2172 | break; | 2174 | break; |
2173 | } | 2175 | } |
2174 | 2176 | ||
2175 | f. setName ( "/etc/familiar-version" ); | 2177 | f. setName ( "/etc/familiar-version" ); |
2176 | if ( f. open ( IO_ReadOnly )) { | 2178 | if ( f. open ( IO_ReadOnly )) { |
2177 | d-> m_systemstr = "Familiar"; | 2179 | d-> m_systemstr = "Familiar"; |
2178 | d-> m_system = System_Familiar; | 2180 | d-> m_system = System_Familiar; |
2179 | 2181 | ||
2180 | QTextStream ts ( &f ); | 2182 | QTextStream ts ( &f ); |
2181 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2183 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2182 | 2184 | ||
2183 | f. close ( ); | 2185 | f. close ( ); |
2184 | } else { | 2186 | } else { |
2185 | f. setName ( "/etc/oz_version" ); | 2187 | f. setName ( "/etc/oz_version" ); |
2186 | 2188 | ||
2187 | if ( f. open ( IO_ReadOnly )) { | 2189 | if ( f. open ( IO_ReadOnly )) { |
2188 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 2190 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
2189 | d-> m_system = System_OpenZaurus; | 2191 | d-> m_system = System_OpenZaurus; |
2190 | 2192 | ||
2191 | QTextStream ts ( &f ); | 2193 | QTextStream ts ( &f ); |
2192 | ts.setDevice ( &f ); | 2194 | ts.setDevice ( &f ); |
2193 | d-> m_sysverstr = ts. readLine ( ); | 2195 | d-> m_sysverstr = ts. readLine ( ); |
2194 | f. close ( ); | 2196 | f. close ( ); |
2195 | } | 2197 | } |
2196 | } | 2198 | } |
2197 | 2199 | ||
2198 | m_leds [0] = m_leds [1] = Led_Off; | 2200 | m_leds [0] = m_leds [1] = Led_Off; |
2199 | 2201 | ||
2200 | m_power_timer = 0; | 2202 | m_power_timer = 0; |
2201 | 2203 | ||
2202 | } | 2204 | } |
2203 | 2205 | ||
2204 | void SIMpad::initButtons ( ) | 2206 | void SIMpad::initButtons ( ) |
2205 | { | 2207 | { |
2206 | if ( d-> m_buttons ) | 2208 | if ( d-> m_buttons ) |
2207 | return; | 2209 | return; |
2208 | 2210 | ||
2209 | if ( isQWS( ) ) | 2211 | if ( isQWS( ) ) |
2210 | QWSServer::setKeyboardFilter ( this ); | 2212 | QWSServer::setKeyboardFilter ( this ); |
2211 | 2213 | ||
2212 | d-> m_buttons = new QValueList <ODeviceButton>; | 2214 | d-> m_buttons = new QValueList <ODeviceButton>; |
2213 | 2215 | ||
2214 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 2216 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
2215 | s_button *sb = simpad_buttons + i; | 2217 | s_button *sb = simpad_buttons + i; |
2216 | ODeviceButton b; | 2218 | ODeviceButton b; |
2217 | 2219 | ||
2218 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 2220 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
2219 | b. setKeycode ( sb-> code ); | 2221 | b. setKeycode ( sb-> code ); |
2220 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 2222 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
2221 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 2223 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
2222 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 2224 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
2223 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 2225 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
2224 | 2226 | ||
2225 | d-> m_buttons-> append ( b ); | 2227 | d-> m_buttons-> append ( b ); |
2226 | } | 2228 | } |
2227 | } | 2229 | } |
2228 | reloadButtonMapping ( ); | 2230 | reloadButtonMapping ( ); |
2229 | 2231 | ||
2230 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2232 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2231 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2233 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
2232 | } | 2234 | } |
2233 | 2235 | ||
2234 | // SIMpad boardcontrol register CS3 | 2236 | // SIMpad boardcontrol register CS3 |
2235 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 2237 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
2236 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 2238 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
2237 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 2239 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
2238 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 2240 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |