-rw-r--r-- | libopie/odevice.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 71ed9e4..9373ef9 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1368,386 +1368,400 @@ void iPAQ::alarmSound ( ) | |||
1368 | cfg. setGroup ( "Volume" ); | 1368 | cfg. setGroup ( "Volume" ); |
1369 | 1369 | ||
1370 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1370 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1371 | if ( volalarm < 0 ) | 1371 | if ( volalarm < 0 ) |
1372 | volalarm = 0; | 1372 | volalarm = 0; |
1373 | else if ( volalarm > 100 ) | 1373 | else if ( volalarm > 100 ) |
1374 | volalarm = 100; | 1374 | volalarm = 100; |
1375 | volalarm |= ( volalarm << 8 ); | 1375 | volalarm |= ( volalarm << 8 ); |
1376 | 1376 | ||
1377 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1377 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1378 | vol_reset = true; | 1378 | vol_reset = true; |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | snd. play ( ); | 1382 | snd. play ( ); |
1383 | while ( !snd. isFinished ( )) | 1383 | while ( !snd. isFinished ( )) |
1384 | qApp-> processEvents ( ); | 1384 | qApp-> processEvents ( ); |
1385 | 1385 | ||
1386 | if ( fd >= 0 ) { | 1386 | if ( fd >= 0 ) { |
1387 | if ( vol_reset ) | 1387 | if ( vol_reset ) |
1388 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1388 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1389 | ::close ( fd ); | 1389 | ::close ( fd ); |
1390 | } | 1390 | } |
1391 | #endif | 1391 | #endif |
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | 1394 | ||
1395 | bool iPAQ::setSoftSuspend ( bool soft ) | 1395 | bool iPAQ::setSoftSuspend ( bool soft ) |
1396 | { | 1396 | { |
1397 | bool res = false; | 1397 | bool res = false; |
1398 | int fd; | 1398 | int fd; |
1399 | 1399 | ||
1400 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1400 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1401 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1401 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1402 | res = true; | 1402 | res = true; |
1403 | else | 1403 | else |
1404 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1404 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1405 | 1405 | ||
1406 | ::close ( fd ); | 1406 | ::close ( fd ); |
1407 | } | 1407 | } |
1408 | else | 1408 | else |
1409 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1409 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1410 | 1410 | ||
1411 | return res; | 1411 | return res; |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | 1414 | ||
1415 | bool iPAQ::setDisplayBrightness ( int bright ) | 1415 | bool iPAQ::setDisplayBrightness ( int bright ) |
1416 | { | 1416 | { |
1417 | bool res = false; | 1417 | bool res = false; |
1418 | int fd; | 1418 | int fd; |
1419 | 1419 | ||
1420 | if ( bright > 255 ) | 1420 | if ( bright > 255 ) |
1421 | bright = 255; | 1421 | bright = 255; |
1422 | if ( bright < 0 ) | 1422 | if ( bright < 0 ) |
1423 | bright = 0; | 1423 | bright = 0; |
1424 | 1424 | ||
1425 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1425 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1426 | FLITE_IN bl; | 1426 | FLITE_IN bl; |
1427 | bl. mode = 1; | 1427 | bl. mode = 1; |
1428 | bl. pwr = bright ? 1 : 0; | 1428 | bl. pwr = bright ? 1 : 0; |
1429 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1429 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1430 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1430 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1431 | ::close ( fd ); | 1431 | ::close ( fd ); |
1432 | } | 1432 | } |
1433 | return res; | 1433 | return res; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | int iPAQ::displayBrightnessResolution ( ) const | 1436 | int iPAQ::displayBrightnessResolution ( ) const |
1437 | { | 1437 | { |
1438 | switch ( model ( )) { | 1438 | switch ( model ( )) { |
1439 | case Model_iPAQ_H31xx: | 1439 | case Model_iPAQ_H31xx: |
1440 | case Model_iPAQ_H36xx: | 1440 | case Model_iPAQ_H36xx: |
1441 | case Model_iPAQ_H37xx: | 1441 | case Model_iPAQ_H37xx: |
1442 | return 128; // really 256, but >128 could damage the LCD | 1442 | return 128; // really 256, but >128 could damage the LCD |
1443 | 1443 | ||
1444 | case Model_iPAQ_H38xx: | 1444 | case Model_iPAQ_H38xx: |
1445 | case Model_iPAQ_H39xx: | 1445 | case Model_iPAQ_H39xx: |
1446 | return 64; | 1446 | return 64; |
1447 | case Model_iPAQ_H5xxx: | 1447 | case Model_iPAQ_H5xxx: |
1448 | return 255; | 1448 | return 255; |
1449 | 1449 | ||
1450 | default: | 1450 | default: |
1451 | return 2; | 1451 | return 2; |
1452 | } | 1452 | } |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | 1455 | ||
1456 | bool iPAQ::hasLightSensor ( ) const | 1456 | bool iPAQ::hasLightSensor ( ) const |
1457 | { | 1457 | { |
1458 | return true; | 1458 | return true; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | int iPAQ::readLightSensor ( ) | 1461 | int iPAQ::readLightSensor ( ) |
1462 | { | 1462 | { |
1463 | int fd; | 1463 | int fd; |
1464 | int val = -1; | 1464 | int val = -1; |
1465 | 1465 | ||
1466 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1466 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1467 | char buffer [8]; | 1467 | char buffer [8]; |
1468 | 1468 | ||
1469 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1469 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1470 | char *endptr; | 1470 | char *endptr; |
1471 | 1471 | ||
1472 | buffer [4] = 0; | 1472 | buffer [4] = 0; |
1473 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1473 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1474 | 1474 | ||
1475 | if ( *endptr != 0 ) | 1475 | if ( *endptr != 0 ) |
1476 | val = -1; | 1476 | val = -1; |
1477 | } | 1477 | } |
1478 | ::close ( fd ); | 1478 | ::close ( fd ); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | return val; | 1481 | return val; |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | int iPAQ::lightSensorResolution ( ) const | 1484 | int iPAQ::lightSensorResolution ( ) const |
1485 | { | 1485 | { |
1486 | return 256; | 1486 | return 256; |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | /************************************************** | 1489 | /************************************************** |
1490 | * | 1490 | * |
1491 | * Zaurus | 1491 | * Zaurus |
1492 | * | 1492 | * |
1493 | **************************************************/ | 1493 | **************************************************/ |
1494 | 1494 | ||
1495 | // Check whether this device is the sharp zaurus.. | 1495 | // Check whether this device is the sharp zaurus.. |
1496 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | ||
1497 | // class up into individual classes. We need three classes | ||
1498 | // | ||
1499 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | ||
1500 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | ||
1501 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | ||
1502 | // | ||
1503 | // Only question right now is: Do we really need to do it? Because as soon | ||
1504 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | ||
1505 | // Zaurus models (concerning apm, backlight, buttons, etc.) | ||
1506 | // | ||
1507 | // Comments? - mickeyl. | ||
1508 | |||
1496 | bool Zaurus::isZaurus() | 1509 | bool Zaurus::isZaurus() |
1497 | { | 1510 | { |
1498 | 1511 | ||
1499 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1512 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
1500 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | 1513 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ |
1501 | return true; | 1514 | return true; |
1502 | } | 1515 | } |
1503 | 1516 | ||
1504 | // On non-embedix kernels, we have to look closer. | 1517 | // On non-embedix kernels, we have to look closer. |
1505 | bool is_zaurus = false; | 1518 | bool is_zaurus = false; |
1506 | QFile f ( "/proc/cpuinfo" ); | 1519 | QFile f ( "/proc/cpuinfo" ); |
1507 | if ( f. open ( IO_ReadOnly ) ) { | 1520 | if ( f. open ( IO_ReadOnly ) ) { |
1508 | QString model; | 1521 | QString model; |
1509 | QFile f ( "/proc/cpuinfo" ); | 1522 | QFile f ( "/proc/cpuinfo" ); |
1510 | 1523 | ||
1511 | QTextStream ts ( &f ); | 1524 | QTextStream ts ( &f ); |
1512 | QString line; | 1525 | QString line; |
1513 | while( line = ts. readLine ( ) ) { | 1526 | while( line = ts. readLine ( ) ) { |
1514 | if ( line. left ( 8 ) == "Hardware" ) | 1527 | if ( line. left ( 8 ) == "Hardware" ) |
1515 | break; | 1528 | break; |
1516 | } | 1529 | } |
1517 | int loc = line. find ( ":" ); | 1530 | int loc = line. find ( ":" ); |
1518 | if ( loc != -1 ) | 1531 | if ( loc != -1 ) |
1519 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1532 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1520 | 1533 | ||
1521 | if ( model == "Sharp-Collie" | 1534 | if ( model == "Sharp-Collie" |
1522 | || model == "Collie" | 1535 | || model == "Collie" |
1523 | || model == "SHARP Corgi" | 1536 | || model == "SHARP Corgi" |
1524 | || model == "SHARP Shepherd" | 1537 | || model == "SHARP Shepherd" |
1525 | || model == "SHARP Poodle" | 1538 | || model == "SHARP Poodle" |
1526 | || model == "SHARP Husky" | 1539 | || model == "SHARP Husky" |
1527 | ) | 1540 | ) |
1528 | is_zaurus = true; | 1541 | is_zaurus = true; |
1529 | 1542 | ||
1530 | } | 1543 | } |
1531 | return is_zaurus; | 1544 | return is_zaurus; |
1532 | } | 1545 | } |
1533 | 1546 | ||
1534 | 1547 | ||
1535 | void Zaurus::init ( ) | 1548 | void Zaurus::init ( ) |
1536 | { | 1549 | { |
1537 | d-> m_vendorstr = "Sharp"; | 1550 | d-> m_vendorstr = "Sharp"; |
1538 | d-> m_vendor = Vendor_Sharp; | 1551 | d-> m_vendor = Vendor_Sharp; |
1539 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 1552 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
1540 | 1553 | ||
1541 | // QFile f ( "/proc/filesystems" ); | 1554 | // QFile f ( "/proc/filesystems" ); |
1542 | QString model; | 1555 | QString model; |
1543 | 1556 | ||
1544 | // It isn't a good idea to check the system configuration to | 1557 | // It isn't a good idea to check the system configuration to |
1545 | // detect the distribution ! | 1558 | // detect the distribution ! |
1546 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1559 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1547 | // because it uses a jffs2 filesystem.. | 1560 | // because it uses a jffs2 filesystem.. |
1548 | // (eilers) | 1561 | // (eilers) |
1549 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1562 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1550 | QFile f ("/etc/oz_version"); | 1563 | QFile f ("/etc/oz_version"); |
1551 | if ( f.exists() ){ | 1564 | if ( f.exists() ){ |
1552 | d-> m_vendorstr = "OpenZaurus Team"; | 1565 | d-> m_vendorstr = "OpenZaurus Team"; |
1553 | d-> m_systemstr = "OpenZaurus"; | 1566 | d-> m_systemstr = "OpenZaurus"; |
1554 | d-> m_system = System_OpenZaurus; | 1567 | d-> m_system = System_OpenZaurus; |
1555 | 1568 | ||
1556 | if ( f. open ( IO_ReadOnly )) { | 1569 | if ( f. open ( IO_ReadOnly )) { |
1557 | QTextStream ts ( &f ); | 1570 | QTextStream ts ( &f ); |
1558 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1571 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1559 | f. close ( ); | 1572 | f. close ( ); |
1560 | } | 1573 | } |
1561 | 1574 | ||
1562 | // Openzaurus sometimes uses the embedix kernel! | 1575 | // Openzaurus sometimes uses the embedix kernel! |
1563 | // => Check whether this is an embedix kernel | 1576 | // => Check whether this is an embedix kernel |
1564 | FILE *uname = popen("uname -r", "r"); | 1577 | FILE *uname = popen("uname -r", "r"); |
1565 | QString line; | 1578 | QString line; |
1566 | if ( f.open(IO_ReadOnly, uname) ) { | 1579 | if ( f.open(IO_ReadOnly, uname) ) { |
1567 | QTextStream ts ( &f ); | 1580 | QTextStream ts ( &f ); |
1568 | line = ts. readLine ( ); | 1581 | line = ts. readLine ( ); |
1569 | int loc = line. find ( "embedix" ); | 1582 | int loc = line. find ( "embedix" ); |
1570 | if ( loc != -1 ) | 1583 | if ( loc != -1 ) |
1571 | m_embedix = true; | 1584 | m_embedix = true; |
1572 | else | 1585 | else |
1573 | m_embedix = false; | 1586 | m_embedix = false; |
1574 | f. close ( ); | 1587 | f. close ( ); |
1575 | } | 1588 | } |
1576 | pclose(uname); | 1589 | pclose(uname); |
1577 | } | 1590 | } |
1578 | else { | 1591 | else { |
1579 | d-> m_systemstr = "Zaurus"; | 1592 | d-> m_systemstr = "Zaurus"; |
1580 | d-> m_system = System_Zaurus; | 1593 | d-> m_system = System_Zaurus; |
1581 | } | 1594 | } |
1582 | 1595 | ||
1583 | f. setName ( "/proc/cpuinfo" ); | 1596 | f. setName ( "/proc/cpuinfo" ); |
1584 | if ( f. open ( IO_ReadOnly ) ) { | 1597 | if ( f. open ( IO_ReadOnly ) ) { |
1585 | QTextStream ts ( &f ); | 1598 | QTextStream ts ( &f ); |
1586 | QString line; | 1599 | QString line; |
1587 | while( line = ts. readLine ( ) ) { | 1600 | while( line = ts. readLine ( ) ) { |
1588 | if ( line. left ( 8 ) == "Hardware" ) | 1601 | if ( line. left ( 8 ) == "Hardware" ) |
1589 | break; | 1602 | break; |
1590 | } | 1603 | } |
1591 | int loc = line. find ( ":" ); | 1604 | int loc = line. find ( ":" ); |
1592 | if ( loc != -1 ) | 1605 | if ( loc != -1 ) |
1593 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1606 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1594 | } | 1607 | } |
1595 | 1608 | ||
1596 | if ( model == "SHARP Corgi" ) { | 1609 | if ( model == "SHARP Corgi" ) { |
1597 | d-> m_model = Model_Zaurus_SLC7x0; | 1610 | d-> m_model = Model_Zaurus_SLC7x0; |
1598 | d-> m_modelstr = "Zaurus SL-C700"; | 1611 | d-> m_modelstr = "Zaurus SL-C700"; |
1599 | } else if ( model == "SHARP Shepherd" ) { | 1612 | } else if ( model == "SHARP Shepherd" ) { |
1600 | d-> m_model = Model_Zaurus_SLC7x0; | 1613 | d-> m_model = Model_Zaurus_SLC7x0; |
1601 | d-> m_modelstr = "Zaurus SL-C750"; | 1614 | d-> m_modelstr = "Zaurus SL-C750"; |
1602 | } else if ( model == "SHARP Husky" ) { | 1615 | } else if ( model == "SHARP Husky" ) { |
1603 | d-> m_model = Model_Zaurus_SLC7x0; | 1616 | d-> m_model = Model_Zaurus_SLC7x0; |
1604 | d-> m_modelstr = "Zaurus SL-C760"; | 1617 | d-> m_modelstr = "Zaurus SL-C760"; |
1605 | } else if ( model == "SHARP Poodle" ) { | 1618 | } else if ( model == "SHARP Poodle" ) { |
1606 | d-> m_model = Model_Zaurus_SLB600; | 1619 | d-> m_model = Model_Zaurus_SLB600; |
1607 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1620 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1608 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1621 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1609 | d-> m_model = Model_Zaurus_SL5500; | 1622 | d-> m_model = Model_Zaurus_SL5500; |
1610 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1623 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1611 | } else { | 1624 | } else { |
1612 | d-> m_model = Model_Zaurus_SL5500; | 1625 | d-> m_model = Model_Zaurus_SL5500; |
1613 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1626 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1614 | } | 1627 | } |
1615 | 1628 | ||
1616 | bool flipstate = false; | 1629 | bool flipstate = false; |
1617 | switch ( d-> m_model ) { | 1630 | switch ( d-> m_model ) { |
1618 | case Model_Zaurus_SLA300: | 1631 | case Model_Zaurus_SLA300: |
1619 | d-> m_rotation = Rot0; | 1632 | d-> m_rotation = Rot0; |
1620 | break; | 1633 | break; |
1621 | case Model_Zaurus_SLC7x0: | 1634 | case Model_Zaurus_SLC7x0: |
1622 | // Note: need to 1) set flipstate based on physical screen orientation | 1635 | // Note: need to 1) set flipstate based on physical screen orientation |
1623 | // and 2) check to see if the user overrode the rotation direction | 1636 | // and 2) check to see if the user overrode the rotation direction |
1624 | // using appearance, and if so, remove that item from the Config to | 1637 | // using appearance, and if so, remove that item from the Config to |
1625 | // ensure the rotate applet flips us back to the previous state. | 1638 | // ensure the rotate applet flips us back to the previous state. |
1639 | // treke said he has patches for detecting the phys. so where are they, treke? -mickeyl. | ||
1626 | if ( flipstate ) { | 1640 | if ( flipstate ) { |
1627 | // 480x640 | 1641 | // 480x640 |
1628 | d-> m_rotation = Rot0; | 1642 | d-> m_rotation = Rot0; |
1629 | d-> m_direction = CW; | 1643 | d-> m_direction = CW; |
1630 | } else { | 1644 | } else { |
1631 | // 640x480 | 1645 | // 640x480 |
1632 | d-> m_rotation = Rot270; | 1646 | d-> m_rotation = Rot270; |
1633 | d-> m_direction = CCW; | 1647 | d-> m_direction = CCW; |
1634 | } | 1648 | } |
1635 | break; | 1649 | break; |
1636 | case Model_Zaurus_SLB600: | 1650 | case Model_Zaurus_SLB600: |
1637 | case Model_Zaurus_SL5500: | 1651 | case Model_Zaurus_SL5500: |
1638 | case Model_Zaurus_SL5000: | 1652 | case Model_Zaurus_SL5000: |
1639 | default: | 1653 | default: |
1640 | d-> m_rotation = Rot270; | 1654 | d-> m_rotation = Rot270; |
1641 | break; | 1655 | break; |
1642 | } | 1656 | } |
1643 | m_leds [0] = Led_Off; | 1657 | m_leds [0] = Led_Off; |
1644 | } | 1658 | } |
1645 | 1659 | ||
1646 | void Zaurus::initButtons ( ) | 1660 | void Zaurus::initButtons ( ) |
1647 | { | 1661 | { |
1648 | if ( d-> m_buttons ) | 1662 | if ( d-> m_buttons ) |
1649 | return; | 1663 | return; |
1650 | 1664 | ||
1651 | d-> m_buttons = new QValueList <ODeviceButton>; | 1665 | d-> m_buttons = new QValueList <ODeviceButton>; |
1652 | 1666 | ||
1653 | struct z_button * pz_buttons; | 1667 | struct z_button * pz_buttons; |
1654 | int buttoncount; | 1668 | int buttoncount; |
1655 | switch ( d-> m_model ) { | 1669 | switch ( d-> m_model ) { |
1656 | case Model_Zaurus_SLC7x0: | 1670 | case Model_Zaurus_SLC7x0: |
1657 | pz_buttons = z_buttons_c700; | 1671 | pz_buttons = z_buttons_c700; |
1658 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1672 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1659 | break; | 1673 | break; |
1660 | default: | 1674 | default: |
1661 | pz_buttons = z_buttons; | 1675 | pz_buttons = z_buttons; |
1662 | buttoncount = ARRAY_SIZE(z_buttons); | 1676 | buttoncount = ARRAY_SIZE(z_buttons); |
1663 | break; | 1677 | break; |
1664 | } | 1678 | } |
1665 | 1679 | ||
1666 | for ( int i = 0; i < buttoncount; i++ ) { | 1680 | for ( int i = 0; i < buttoncount; i++ ) { |
1667 | struct z_button *zb = pz_buttons + i; | 1681 | struct z_button *zb = pz_buttons + i; |
1668 | ODeviceButton b; | 1682 | ODeviceButton b; |
1669 | 1683 | ||
1670 | b. setKeycode ( zb-> code ); | 1684 | b. setKeycode ( zb-> code ); |
1671 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1685 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1672 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1686 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1673 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), | 1687 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1674 | zb-> fpressedaction )); | 1688 | zb-> fpressedaction )); |
1675 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | 1689 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), |
1676 | zb-> fheldaction )); | 1690 | zb-> fheldaction )); |
1677 | 1691 | ||
1678 | d-> m_buttons-> append ( b ); | 1692 | d-> m_buttons-> append ( b ); |
1679 | } | 1693 | } |
1680 | 1694 | ||
1681 | reloadButtonMapping ( ); | 1695 | reloadButtonMapping ( ); |
1682 | 1696 | ||
1683 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1697 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1684 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), | 1698 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), |
1685 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1699 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1686 | } | 1700 | } |
1687 | 1701 | ||
1688 | #include <unistd.h> | 1702 | #include <unistd.h> |
1689 | #include <fcntl.h> | 1703 | #include <fcntl.h> |
1690 | #include <sys/ioctl.h> | 1704 | #include <sys/ioctl.h> |
1691 | 1705 | ||
1692 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1706 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1693 | 1707 | ||
1694 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1708 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1695 | 1709 | ||
1696 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1710 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1697 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1711 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1698 | 1712 | ||
1699 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1713 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1700 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1714 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1701 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1715 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1702 | 1716 | ||
1703 | /* --- for SHARP_BUZZER device --- */ | 1717 | /* --- for SHARP_BUZZER device --- */ |
1704 | 1718 | ||
1705 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1719 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1706 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1720 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1707 | 1721 | ||
1708 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1722 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1709 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1723 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1710 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1724 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1711 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1725 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1712 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1726 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1713 | 1727 | ||
1714 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1728 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1715 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1729 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1716 | 1730 | ||
1717 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1731 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1718 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1732 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1719 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1733 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1720 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1734 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1721 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1735 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1722 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1736 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1723 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1737 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1724 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1738 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1725 | 1739 | ||
1726 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1740 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1727 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1741 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1728 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1742 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1729 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1743 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1730 | // | 1744 | // |
1731 | 1745 | ||
1732 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1746 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1733 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1747 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1734 | 1748 | ||
1735 | typedef struct sharp_led_status { | 1749 | typedef struct sharp_led_status { |
1736 | int which; /* select which LED status is wanted. */ | 1750 | int which; /* select which LED status is wanted. */ |
1737 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1751 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1738 | } sharp_led_status; | 1752 | } sharp_led_status; |
1739 | 1753 | ||
1740 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1754 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1741 | 1755 | ||
1742 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1756 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1743 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1757 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1744 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1758 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1745 | 1759 | ||
1746 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1760 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1747 | 1761 | ||
1748 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1762 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1749 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1763 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1750 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1764 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1751 | 1765 | ||
1752 | #define FL_IOCTL_STEP_CONTRAST 100 | 1766 | #define FL_IOCTL_STEP_CONTRAST 100 |
1753 | 1767 | ||
@@ -1811,256 +1825,259 @@ void Zaurus::buzzer ( int sound ) | |||
1811 | if ( fd >= 0 ) { | 1825 | if ( fd >= 0 ) { |
1812 | if ( vol_reset ) | 1826 | if ( vol_reset ) |
1813 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1827 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1814 | ::close ( fd ); | 1828 | ::close ( fd ); |
1815 | } | 1829 | } |
1816 | } else { | 1830 | } else { |
1817 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1831 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1818 | 1832 | ||
1819 | if ( fd >= 0 ) { | 1833 | if ( fd >= 0 ) { |
1820 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1834 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1821 | ::close ( fd ); | 1835 | ::close ( fd ); |
1822 | } | 1836 | } |
1823 | 1837 | ||
1824 | } | 1838 | } |
1825 | #endif | 1839 | #endif |
1826 | } | 1840 | } |
1827 | 1841 | ||
1828 | 1842 | ||
1829 | void Zaurus::alarmSound ( ) | 1843 | void Zaurus::alarmSound ( ) |
1830 | { | 1844 | { |
1831 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1845 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1832 | } | 1846 | } |
1833 | 1847 | ||
1834 | void Zaurus::touchSound ( ) | 1848 | void Zaurus::touchSound ( ) |
1835 | { | 1849 | { |
1836 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1850 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1837 | } | 1851 | } |
1838 | 1852 | ||
1839 | void Zaurus::keySound ( ) | 1853 | void Zaurus::keySound ( ) |
1840 | { | 1854 | { |
1841 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1855 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1842 | } | 1856 | } |
1843 | 1857 | ||
1844 | 1858 | ||
1845 | QValueList <OLed> Zaurus::ledList ( ) const | 1859 | QValueList <OLed> Zaurus::ledList ( ) const |
1846 | { | 1860 | { |
1847 | QValueList <OLed> vl; | 1861 | QValueList <OLed> vl; |
1848 | vl << Led_Mail; | 1862 | vl << Led_Mail; |
1849 | return vl; | 1863 | return vl; |
1850 | } | 1864 | } |
1851 | 1865 | ||
1852 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1866 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1853 | { | 1867 | { |
1854 | QValueList <OLedState> vl; | 1868 | QValueList <OLedState> vl; |
1855 | 1869 | ||
1856 | if ( l == Led_Mail ) | 1870 | if ( l == Led_Mail ) |
1857 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1871 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1858 | return vl; | 1872 | return vl; |
1859 | } | 1873 | } |
1860 | 1874 | ||
1861 | OLedState Zaurus::ledState ( OLed which ) const | 1875 | OLedState Zaurus::ledState ( OLed which ) const |
1862 | { | 1876 | { |
1863 | if ( which == Led_Mail ) | 1877 | if ( which == Led_Mail ) |
1864 | return m_leds [0]; | 1878 | return m_leds [0]; |
1865 | else | 1879 | else |
1866 | return Led_Off; | 1880 | return Led_Off; |
1867 | } | 1881 | } |
1868 | 1882 | ||
1869 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1883 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1870 | { | 1884 | { |
1871 | if (!m_embedix) // Currently not supported on non_embedix kernels | 1885 | if (!m_embedix) // Currently not supported on non_embedix kernels |
1872 | return false; | 1886 | return false; |
1873 | 1887 | ||
1874 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1888 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1875 | 1889 | ||
1876 | if ( which == Led_Mail ) { | 1890 | if ( which == Led_Mail ) { |
1877 | if ( fd >= 0 ) { | 1891 | if ( fd >= 0 ) { |
1878 | struct sharp_led_status leds; | 1892 | struct sharp_led_status leds; |
1879 | ::memset ( &leds, 0, sizeof( leds )); | 1893 | ::memset ( &leds, 0, sizeof( leds )); |
1880 | leds. which = SHARP_LED_MAIL_EXISTS; | 1894 | leds. which = SHARP_LED_MAIL_EXISTS; |
1881 | bool ok = true; | 1895 | bool ok = true; |
1882 | 1896 | ||
1883 | switch ( st ) { | 1897 | switch ( st ) { |
1884 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1898 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1885 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1899 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1886 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1900 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1887 | default : ok = false; | 1901 | default : ok = false; |
1888 | } | 1902 | } |
1889 | 1903 | ||
1890 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1904 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1891 | m_leds [0] = st; | 1905 | m_leds [0] = st; |
1892 | return true; | 1906 | return true; |
1893 | } | 1907 | } |
1894 | } | 1908 | } |
1895 | } | 1909 | } |
1896 | return false; | 1910 | return false; |
1897 | } | 1911 | } |
1898 | 1912 | ||
1899 | bool Zaurus::setSoftSuspend ( bool soft ) | 1913 | bool Zaurus::setSoftSuspend ( bool soft ) |
1900 | { | 1914 | { |
1901 | if (!m_embedix) { | 1915 | if (!m_embedix) { |
1902 | /* non-Embedix kernels dont have kernel autosuspend */ | 1916 | /* non-Embedix kernels dont have kernel autosuspend */ |
1903 | return ODevice::setSoftSuspend( soft ); | 1917 | return ODevice::setSoftSuspend( soft ); |
1904 | } | 1918 | } |
1905 | 1919 | ||
1906 | bool res = false; | 1920 | bool res = false; |
1907 | int fd; | 1921 | int fd; |
1908 | 1922 | ||
1909 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1923 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1910 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1924 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1911 | 1925 | ||
1912 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1926 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1913 | 1927 | ||
1914 | if ( sources >= 0 ) { | 1928 | if ( sources >= 0 ) { |
1915 | if ( soft ) | 1929 | if ( soft ) |
1916 | sources &= ~APM_EVT_POWER_BUTTON; | 1930 | sources &= ~APM_EVT_POWER_BUTTON; |
1917 | else | 1931 | else |
1918 | sources |= APM_EVT_POWER_BUTTON; | 1932 | sources |= APM_EVT_POWER_BUTTON; |
1919 | 1933 | ||
1920 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1934 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1921 | res = true; | 1935 | res = true; |
1922 | else | 1936 | else |
1923 | perror ( "APM_IOCGEVTSRC" ); | 1937 | perror ( "APM_IOCGEVTSRC" ); |
1924 | } | 1938 | } |
1925 | else | 1939 | else |
1926 | perror ( "APM_IOCGEVTSRC" ); | 1940 | perror ( "APM_IOCGEVTSRC" ); |
1927 | 1941 | ||
1928 | ::close ( fd ); | 1942 | ::close ( fd ); |
1929 | } | 1943 | } |
1930 | else | 1944 | else |
1931 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1945 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1932 | 1946 | ||
1933 | return res; | 1947 | return res; |
1934 | } | 1948 | } |
1935 | 1949 | ||
1936 | 1950 | ||
1937 | bool Zaurus::setDisplayBrightness ( int bright ) | 1951 | bool Zaurus::setDisplayBrightness ( int bright ) |
1938 | { | 1952 | { |
1953 | // FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which | ||
1954 | // is nice to use. Currently it exposes 16+1 levels. Implement this! | ||
1955 | // (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) | ||
1939 | bool res = false; | 1956 | bool res = false; |
1940 | int fd; | 1957 | int fd; |
1941 | 1958 | ||
1942 | if ( bright > 255 ) | 1959 | if ( bright > 255 ) |
1943 | bright = 255; | 1960 | bright = 255; |
1944 | if ( bright < 0 ) | 1961 | if ( bright < 0 ) |
1945 | bright = 0; | 1962 | bright = 0; |
1946 | 1963 | ||
1947 | if (m_embedix) { | 1964 | if (m_embedix) { |
1948 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1965 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1949 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1966 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1950 | if ( bright && !bl ) | 1967 | if ( bright && !bl ) |
1951 | bl = 1; | 1968 | bl = 1; |
1952 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1969 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1953 | ::close ( fd ); | 1970 | ::close ( fd ); |
1954 | } | 1971 | } |
1955 | } else { | 1972 | } else { |
1956 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 1973 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
1957 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 1974 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
1958 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 1975 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
1959 | ::close ( fd ); | 1976 | ::close ( fd ); |
1960 | } | 1977 | } |
1961 | } | 1978 | } |
1962 | return res; | 1979 | return res; |
1963 | } | 1980 | } |
1964 | 1981 | ||
1965 | 1982 | ||
1966 | int Zaurus::displayBrightnessResolution ( ) const | 1983 | int Zaurus::displayBrightnessResolution ( ) const |
1967 | { | 1984 | { |
1968 | if (m_embedix) | 1985 | if (m_embedix) |
1969 | return 5; | 1986 | return 5; |
1970 | else | 1987 | else |
1971 | return 256; | 1988 | return 256; |
1972 | } | 1989 | } |
1973 | 1990 | ||
1974 | /************************************************** | 1991 | /************************************************** |
1975 | * | 1992 | * |
1976 | * SIMpad | 1993 | * SIMpad |
1977 | * | 1994 | * |
1978 | **************************************************/ | 1995 | **************************************************/ |
1979 | 1996 | ||
1980 | void SIMpad::init ( ) | 1997 | void SIMpad::init ( ) |
1981 | { | 1998 | { |
1982 | d-> m_vendorstr = "SIEMENS"; | 1999 | d-> m_vendorstr = "SIEMENS"; |
1983 | d-> m_vendor = Vendor_SIEMENS; | 2000 | d-> m_vendor = Vendor_SIEMENS; |
1984 | 2001 | ||
1985 | QFile f ( "/proc/hal/model" ); | 2002 | QFile f ( "/proc/hal/model" ); |
1986 | 2003 | ||
1987 | //TODO Implement model checking | 2004 | //TODO Implement model checking |
1988 | //FIXME For now we assume an SL4 | 2005 | //FIXME For now we assume an SL4 |
1989 | 2006 | ||
1990 | d-> m_modelstr = "SL4"; | 2007 | d-> m_modelstr = "SL4"; |
1991 | d-> m_model = Model_SIMpad_SL4; | 2008 | d-> m_model = Model_SIMpad_SL4; |
1992 | 2009 | ||
1993 | switch ( d-> m_model ) { | 2010 | switch ( d-> m_model ) { |
1994 | default: | 2011 | default: |
1995 | d-> m_rotation = Rot0; | 2012 | d-> m_rotation = Rot0; |
1996 | d-> m_direction = CCW; | 2013 | d-> m_direction = CCW; |
1997 | d-> m_holdtime = 1000; // 1000ms | 2014 | d-> m_holdtime = 1000; // 1000ms |
1998 | 2015 | ||
1999 | break; | 2016 | break; |
2000 | } | 2017 | } |
2001 | 2018 | ||
2002 | f. setName ( "/etc/familiar-version" ); | 2019 | f. setName ( "/etc/familiar-version" ); |
2003 | if ( f. open ( IO_ReadOnly )) { | 2020 | if ( f. open ( IO_ReadOnly )) { |
2004 | d-> m_systemstr = "Familiar"; | 2021 | d-> m_systemstr = "Familiar"; |
2005 | d-> m_system = System_Familiar; | 2022 | d-> m_system = System_Familiar; |
2006 | 2023 | ||
2007 | QTextStream ts ( &f ); | 2024 | QTextStream ts ( &f ); |
2008 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2025 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2009 | 2026 | ||
2010 | f. close ( ); | 2027 | f. close ( ); |
2011 | } else { | 2028 | } else { |
2012 | f. setName ( "/etc/oz_version" ); | 2029 | f. setName ( "/etc/oz_version" ); |
2013 | 2030 | ||
2014 | if ( f. open ( IO_ReadOnly )) { | 2031 | if ( f. open ( IO_ReadOnly )) { |
2015 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 2032 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
2016 | d-> m_system = System_OpenZaurus; | 2033 | d-> m_system = System_OpenZaurus; |
2017 | 2034 | ||
2018 | QTextStream ts ( &f ); | 2035 | QTextStream ts ( &f ); |
2019 | ts.setDevice ( &f ); | 2036 | ts.setDevice ( &f ); |
2020 | d-> m_sysverstr = ts. readLine ( ); | 2037 | d-> m_sysverstr = ts. readLine ( ); |
2021 | f. close ( ); | 2038 | f. close ( ); |
2022 | } | 2039 | } |
2023 | } | 2040 | } |
2024 | 2041 | ||
2025 | m_leds [0] = m_leds [1] = Led_Off; | 2042 | m_leds [0] = m_leds [1] = Led_Off; |
2026 | 2043 | ||
2027 | m_power_timer = 0; | 2044 | m_power_timer = 0; |
2028 | 2045 | ||
2029 | } | 2046 | } |
2030 | 2047 | ||
2031 | void SIMpad::initButtons ( ) | 2048 | void SIMpad::initButtons ( ) |
2032 | { | 2049 | { |
2033 | if ( d-> m_buttons ) | 2050 | if ( d-> m_buttons ) |
2034 | return; | 2051 | return; |
2035 | 2052 | ||
2036 | if ( isQWS( ) ) | 2053 | if ( isQWS( ) ) |
2037 | QWSServer::setKeyboardFilter ( this ); | 2054 | QWSServer::setKeyboardFilter ( this ); |
2038 | 2055 | ||
2039 | d-> m_buttons = new QValueList <ODeviceButton>; | 2056 | d-> m_buttons = new QValueList <ODeviceButton>; |
2040 | 2057 | ||
2041 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 2058 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
2042 | s_button *sb = simpad_buttons + i; | 2059 | s_button *sb = simpad_buttons + i; |
2043 | ODeviceButton b; | 2060 | ODeviceButton b; |
2044 | 2061 | ||
2045 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 2062 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
2046 | b. setKeycode ( sb-> code ); | 2063 | b. setKeycode ( sb-> code ); |
2047 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 2064 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
2048 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 2065 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
2049 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 2066 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
2050 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 2067 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
2051 | 2068 | ||
2052 | d-> m_buttons-> append ( b ); | 2069 | d-> m_buttons-> append ( b ); |
2053 | } | 2070 | } |
2054 | } | 2071 | } |
2055 | reloadButtonMapping ( ); | 2072 | reloadButtonMapping ( ); |
2056 | 2073 | ||
2057 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2074 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2058 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2075 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
2059 | } | 2076 | } |
2060 | 2077 | ||
2061 | // SIMpad boardcontrol register CS3 | 2078 | // SIMpad boardcontrol register CS3 |
2062 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 2079 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
2063 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 2080 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
2064 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 2081 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
2065 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 2082 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
2066 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 2083 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |