author | eilers <eilers> | 2003-08-08 15:13:30 (UTC) |
---|---|---|
committer | eilers <eilers> | 2003-08-08 15:13:30 (UTC) |
commit | c6d96c514c58b288ac0bc8f844db35123bcaf2ad (patch) (unidiff) | |
tree | 67941875720aeb94ea306e94ed36610cea3022fb | |
parent | b87b33dc1f6e8e1276a7035ab7a3e53b8ed4bd16 (diff) | |
download | opie-c6d96c514c58b288ac0bc8f844db35123bcaf2ad.zip opie-c6d96c514c58b288ac0bc8f844db35123bcaf2ad.tar.gz opie-c6d96c514c58b288ac0bc8f844db35123bcaf2ad.tar.bz2 |
Added support for C 750 (Shepherd):
Device is detected and sounds for keypress, screentap and alarm is working (using the
sound device)
Attention: Please don't activate the screentab sound. It has some quirks..
-rw-r--r-- | libopie/odevice.cpp | 87 |
1 files changed, 78 insertions, 9 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 17ae389..a134810 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1298,103 +1298,113 @@ int iPAQ::readLightSensor ( ) | |||
1298 | char *endptr; | 1298 | char *endptr; |
1299 | 1299 | ||
1300 | buffer [4] = 0; | 1300 | buffer [4] = 0; |
1301 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1301 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1302 | 1302 | ||
1303 | if ( *endptr != 0 ) | 1303 | if ( *endptr != 0 ) |
1304 | val = -1; | 1304 | val = -1; |
1305 | } | 1305 | } |
1306 | ::close ( fd ); | 1306 | ::close ( fd ); |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | return val; | 1309 | return val; |
1310 | } | 1310 | } |
1311 | 1311 | ||
1312 | int iPAQ::lightSensorResolution ( ) const | 1312 | int iPAQ::lightSensorResolution ( ) const |
1313 | { | 1313 | { |
1314 | return 256; | 1314 | return 256; |
1315 | } | 1315 | } |
1316 | 1316 | ||
1317 | /************************************************** | 1317 | /************************************************** |
1318 | * | 1318 | * |
1319 | * Zaurus | 1319 | * Zaurus |
1320 | * | 1320 | * |
1321 | **************************************************/ | 1321 | **************************************************/ |
1322 | 1322 | ||
1323 | 1323 | ||
1324 | 1324 | ||
1325 | void Zaurus::init ( ) | 1325 | void Zaurus::init ( ) |
1326 | { | 1326 | { |
1327 | d-> m_vendorstr = "Sharp"; | 1327 | d-> m_vendorstr = "Sharp"; |
1328 | d-> m_vendor = Vendor_Sharp; | 1328 | d-> m_vendor = Vendor_Sharp; |
1329 | 1329 | ||
1330 | QFile f ( "/proc/filesystems" ); | 1330 | // QFile f ( "/proc/filesystems" ); |
1331 | QString model; | 1331 | QString model; |
1332 | 1332 | ||
1333 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1333 | // It isn't a good idea to check the system configuration to |
1334 | // detect the distribution ! | ||
1335 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | ||
1336 | // because it uses a jffs2 filesystem.. | ||
1337 | // (eilers) | ||
1338 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | ||
1339 | QFile f ("/etc/oz_version"); | ||
1340 | if ( f.exists() ){ | ||
1334 | d-> m_vendorstr = "OpenZaurus Team"; | 1341 | d-> m_vendorstr = "OpenZaurus Team"; |
1335 | d-> m_systemstr = "OpenZaurus"; | 1342 | d-> m_systemstr = "OpenZaurus"; |
1336 | d-> m_system = System_OpenZaurus; | 1343 | d-> m_system = System_OpenZaurus; |
1337 | 1344 | ||
1338 | f. close ( ); | 1345 | // f. close ( ); |
1339 | 1346 | ||
1340 | f. setName ( "/etc/oz_version" ); | 1347 | // f. setName ( "/etc/oz_version" ); |
1341 | if ( f. open ( IO_ReadOnly )) { | 1348 | if ( f. open ( IO_ReadOnly )) { |
1342 | QTextStream ts ( &f ); | 1349 | QTextStream ts ( &f ); |
1343 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1350 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1344 | f. close ( ); | 1351 | f. close ( ); |
1345 | } | 1352 | } |
1346 | } | 1353 | } |
1347 | else { | 1354 | else { |
1348 | d-> m_systemstr = "Zaurus"; | 1355 | d-> m_systemstr = "Zaurus"; |
1349 | d-> m_system = System_Zaurus; | 1356 | d-> m_system = System_Zaurus; |
1350 | } | 1357 | } |
1351 | 1358 | ||
1352 | f. setName ( "/proc/cpuinfo" ); | 1359 | f. setName ( "/proc/cpuinfo" ); |
1353 | if ( f. open ( IO_ReadOnly ) ) { | 1360 | if ( f. open ( IO_ReadOnly ) ) { |
1354 | QTextStream ts ( &f ); | 1361 | QTextStream ts ( &f ); |
1355 | QString line; | 1362 | QString line; |
1356 | while( line = ts. readLine ( ) ) { | 1363 | while( line = ts. readLine ( ) ) { |
1357 | if ( line. left ( 8 ) == "Hardware" ) | 1364 | if ( line. left ( 8 ) == "Hardware" ) |
1358 | break; | 1365 | break; |
1359 | } | 1366 | } |
1360 | int loc = line. find ( ":" ); | 1367 | int loc = line. find ( ":" ); |
1361 | if ( loc != -1 ) | 1368 | if ( loc != -1 ) |
1362 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1369 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1363 | } | 1370 | } |
1364 | 1371 | ||
1365 | if ( model == "SHARP Corgi" ) { | 1372 | if ( model == "SHARP Corgi" ) { |
1366 | d-> m_model = Model_Zaurus_SLC700; | 1373 | d-> m_model = Model_Zaurus_SLC700; |
1367 | d-> m_modelstr = "Zaurus SL-C700"; | 1374 | d-> m_modelstr = "Zaurus SL-C700"; |
1368 | } else if ( model == "SHARP Poodle" ) { | 1375 | } else if ( model == "SHARP Shepherd" ) { |
1376 | d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers) | ||
1377 | d-> m_modelstr = "Zaurus SL-C750"; | ||
1378 | }else if ( model == "SHARP Poodle" ) { | ||
1369 | d-> m_model = Model_Zaurus_SLB600; | 1379 | d-> m_model = Model_Zaurus_SLB600; |
1370 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1380 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1371 | } else if ( model = "Sharp-Collie" ) { | 1381 | } else if ( model = "Sharp-Collie" ) { |
1372 | d-> m_model = Model_Zaurus_SL5500; | 1382 | d-> m_model = Model_Zaurus_SL5500; |
1373 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1383 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1374 | } else { | 1384 | } else { |
1375 | d-> m_model = Model_Zaurus_SL5500; | 1385 | d-> m_model = Model_Zaurus_SL5500; |
1376 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1386 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1377 | } | 1387 | } |
1378 | 1388 | ||
1379 | bool flipstate = false; | 1389 | bool flipstate = false; |
1380 | switch ( d-> m_model ) { | 1390 | switch ( d-> m_model ) { |
1381 | case Model_Zaurus_SLA300: | 1391 | case Model_Zaurus_SLA300: |
1382 | d-> m_rotation = Rot0; | 1392 | d-> m_rotation = Rot0; |
1383 | break; | 1393 | break; |
1384 | case Model_Zaurus_SLC700: | 1394 | case Model_Zaurus_SLC700: |
1385 | // Note: need to 1) set flipstate based on physical screen orientation | 1395 | // Note: need to 1) set flipstate based on physical screen orientation |
1386 | // and 2) check to see if the user overrode the rotation direction | 1396 | // and 2) check to see if the user overrode the rotation direction |
1387 | // using appearance, and if so, remove that item from the Config to | 1397 | // using appearance, and if so, remove that item from the Config to |
1388 | // ensure the rotate applet flips us back to the previous state. | 1398 | // ensure the rotate applet flips us back to the previous state. |
1389 | if ( flipstate ) { | 1399 | if ( flipstate ) { |
1390 | // 480x640 | 1400 | // 480x640 |
1391 | d-> m_rotation = Rot0; | 1401 | d-> m_rotation = Rot0; |
1392 | d-> m_direction = CW; | 1402 | d-> m_direction = CW; |
1393 | } else { | 1403 | } else { |
1394 | // 640x480 | 1404 | // 640x480 |
1395 | d-> m_rotation = Rot270; | 1405 | d-> m_rotation = Rot270; |
1396 | d-> m_direction = CCW; | 1406 | d-> m_direction = CCW; |
1397 | } | 1407 | } |
1398 | break; | 1408 | break; |
1399 | case Model_Zaurus_SLB600: | 1409 | case Model_Zaurus_SLB600: |
1400 | case Model_Zaurus_SL5500: | 1410 | case Model_Zaurus_SL5500: |
@@ -1485,70 +1495,129 @@ void Zaurus::initButtons ( ) | |||
1485 | 1495 | ||
1486 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1496 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1487 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1497 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1488 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1498 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1489 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1499 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1490 | // | 1500 | // |
1491 | 1501 | ||
1492 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1502 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1493 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1503 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1494 | 1504 | ||
1495 | typedef struct sharp_led_status { | 1505 | typedef struct sharp_led_status { |
1496 | int which; /* select which LED status is wanted. */ | 1506 | int which; /* select which LED status is wanted. */ |
1497 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1507 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1498 | } sharp_led_status; | 1508 | } sharp_led_status; |
1499 | 1509 | ||
1500 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1510 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1501 | 1511 | ||
1502 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1512 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1503 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1513 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1504 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1514 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1505 | 1515 | ||
1506 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1516 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1507 | 1517 | ||
1508 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1518 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1509 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1519 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1510 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1520 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1511 | 1521 | ||
1512 | #define FL_IOCTL_STEP_CONTRAST 100 | 1522 | #define FL_IOCTL_STEP_CONTRAST 100 |
1513 | 1523 | ||
1514 | 1524 | ||
1515 | void Zaurus::buzzer ( int sound ) | 1525 | void Zaurus::buzzer ( int sound ) |
1516 | { | 1526 | { |
1517 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1527 | // Not all devices have real sound. |
1528 | #ifndef QT_NO_SOUND | ||
1529 | switch ( d-> m_model ) { | ||
1530 | case Model_Zaurus_SLC700:{ | ||
1531 | int fd; | ||
1532 | int vol; | ||
1533 | bool vol_reset = false; | ||
1534 | |||
1535 | QString soundname; | ||
1536 | |||
1537 | switch ( sound ){ | ||
1538 | case SHARP_BUZ_SCHEDULE_ALARM: | ||
1539 | soundname = "alarm"; | ||
1540 | break; | ||
1541 | case SHARP_BUZ_TOUCHSOUND: | ||
1542 | soundname = "touchsound"; | ||
1543 | break; | ||
1544 | case SHARP_BUZ_KEYSOUND: | ||
1545 | soundname = "keysound"; | ||
1546 | break; | ||
1547 | default: | ||
1548 | soundname = "alarm"; | ||
1549 | |||
1550 | } | ||
1518 | 1551 | ||
1519 | if ( fd >= 0 ) { | 1552 | Sound snd ( soundname ); |
1520 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1553 | |
1521 | ::close ( fd ); | 1554 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1555 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | ||
1556 | Config cfg ( "qpe" ); | ||
1557 | cfg. setGroup ( "Volume" ); | ||
1558 | |||
1559 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | ||
1560 | if ( volalarm < 0 ) | ||
1561 | volalarm = 0; | ||
1562 | else if ( volalarm > 100 ) | ||
1563 | volalarm = 100; | ||
1564 | volalarm |= ( volalarm << 8 ); | ||
1565 | |||
1566 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | ||
1567 | vol_reset = true; | ||
1568 | } | ||
1569 | } | ||
1570 | |||
1571 | snd. play ( ); | ||
1572 | while ( !snd. isFinished ( )) | ||
1573 | qApp-> processEvents ( ); | ||
1574 | |||
1575 | if ( fd >= 0 ) { | ||
1576 | if ( vol_reset ) | ||
1577 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | ||
1578 | ::close ( fd ); | ||
1579 | } | ||
1580 | break; | ||
1522 | } | 1581 | } |
1582 | default:{ // Devices with buzzer | ||
1583 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | ||
1584 | |||
1585 | if ( fd >= 0 ) { | ||
1586 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | ||
1587 | ::close ( fd ); | ||
1588 | } | ||
1589 | } | ||
1590 | } | ||
1591 | #endif | ||
1523 | } | 1592 | } |
1524 | 1593 | ||
1525 | 1594 | ||
1526 | void Zaurus::alarmSound ( ) | 1595 | void Zaurus::alarmSound ( ) |
1527 | { | 1596 | { |
1528 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1597 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1529 | } | 1598 | } |
1530 | 1599 | ||
1531 | void Zaurus::touchSound ( ) | 1600 | void Zaurus::touchSound ( ) |
1532 | { | 1601 | { |
1533 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1602 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1534 | } | 1603 | } |
1535 | 1604 | ||
1536 | void Zaurus::keySound ( ) | 1605 | void Zaurus::keySound ( ) |
1537 | { | 1606 | { |
1538 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1607 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1539 | } | 1608 | } |
1540 | 1609 | ||
1541 | 1610 | ||
1542 | QValueList <OLed> Zaurus::ledList ( ) const | 1611 | QValueList <OLed> Zaurus::ledList ( ) const |
1543 | { | 1612 | { |
1544 | QValueList <OLed> vl; | 1613 | QValueList <OLed> vl; |
1545 | vl << Led_Mail; | 1614 | vl << Led_Mail; |
1546 | return vl; | 1615 | return vl; |
1547 | } | 1616 | } |
1548 | 1617 | ||
1549 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1618 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1550 | { | 1619 | { |
1551 | QValueList <OLedState> vl; | 1620 | QValueList <OLedState> vl; |
1552 | 1621 | ||
1553 | if ( l == Led_Mail ) | 1622 | if ( l == Led_Mail ) |
1554 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1623 | vl << Led_Off << Led_On << Led_BlinkSlow; |