author | alwin <alwin> | 2004-03-02 12:14:15 (UTC) |
---|---|---|
committer | alwin <alwin> | 2004-03-02 12:14:15 (UTC) |
commit | 0d59c780513da78033f4d9040475dee9db0256d4 (patch) (unidiff) | |
tree | 503d320b4aa3daae9982082e7b34e3e2c48bdfb7 /libopie/odevice.cpp | |
parent | a0981652d61776d70f25980f035748b21339e946 (diff) | |
download | opie-0d59c780513da78033f4d9040475dee9db0256d4.zip opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.gz opie-0d59c780513da78033f4d9040475dee9db0256d4.tar.bz2 |
run the optimize_connect script
the whole cvs is tagged with "before_optimize_connect" if there are problems you
can check the diff (but it had compiled and run here)
-rw-r--r-- | libopie/odevice.cpp | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index c0b6efa..4258d60 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -407,257 +407,257 @@ public: | |||
407 | 407 | ||
408 | struct yopy_button { | 408 | struct yopy_button { |
409 | Qt::Key code; | 409 | Qt::Key code; |
410 | char *utext; | 410 | char *utext; |
411 | char *pix; | 411 | char *pix; |
412 | char *fpressedservice; | 412 | char *fpressedservice; |
413 | char *fpressedaction; | 413 | char *fpressedaction; |
414 | char *fheldservice; | 414 | char *fheldservice; |
415 | char *fheldaction; | 415 | char *fheldaction; |
416 | } yopy_buttons [] = { | 416 | } yopy_buttons [] = { |
417 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | 417 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), |
418 | "devicebuttons/yopy_action", | 418 | "devicebuttons/yopy_action", |
419 | "datebook", "nextView()", | 419 | "datebook", "nextView()", |
420 | "today", "raise()" }, | 420 | "today", "raise()" }, |
421 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | 421 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), |
422 | "devicebuttons/yopy_ok", | 422 | "devicebuttons/yopy_ok", |
423 | "addressbook", "raise()", | 423 | "addressbook", "raise()", |
424 | "addressbook", "beamBusinessCard()" }, | 424 | "addressbook", "beamBusinessCard()" }, |
425 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | 425 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), |
426 | "devicebuttons/yopy_end", | 426 | "devicebuttons/yopy_end", |
427 | "QPE/Launcher", "home()", | 427 | "QPE/Launcher", "home()", |
428 | "buttonsettings", "raise()" }, | 428 | "buttonsettings", "raise()" }, |
429 | }; | 429 | }; |
430 | 430 | ||
431 | static QCString makeChannel ( const char *str ) | 431 | static QCString makeChannel ( const char *str ) |
432 | { | 432 | { |
433 | if ( str && !::strchr ( str, '/' )) | 433 | if ( str && !::strchr ( str, '/' )) |
434 | return QCString ( "QPE/Application/" ) + str; | 434 | return QCString ( "QPE/Application/" ) + str; |
435 | else | 435 | else |
436 | return str; | 436 | return str; |
437 | } | 437 | } |
438 | 438 | ||
439 | static inline bool isQWS() | 439 | static inline bool isQWS() |
440 | { | 440 | { |
441 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 441 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
442 | } | 442 | } |
443 | 443 | ||
444 | ODevice *ODevice::inst ( ) | 444 | ODevice *ODevice::inst ( ) |
445 | { | 445 | { |
446 | static ODevice *dev = 0; | 446 | static ODevice *dev = 0; |
447 | 447 | ||
448 | if ( !dev ) { | 448 | if ( !dev ) { |
449 | if ( QFile::exists ( "/proc/hal/model" )) | 449 | if ( QFile::exists ( "/proc/hal/model" )) |
450 | dev = new iPAQ ( ); | 450 | dev = new iPAQ ( ); |
451 | else if ( Zaurus::isZaurus() ) | 451 | else if ( Zaurus::isZaurus() ) |
452 | dev = new Zaurus ( ); | 452 | dev = new Zaurus ( ); |
453 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 453 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
454 | dev = new SIMpad ( ); | 454 | dev = new SIMpad ( ); |
455 | else if ( QFile::exists ( "/proc/sys/board/name" )) | 455 | else if ( QFile::exists ( "/proc/sys/board/name" )) |
456 | dev = new Ramses ( ); | 456 | dev = new Ramses ( ); |
457 | else if ( Yopy::isYopy() ) | 457 | else if ( Yopy::isYopy() ) |
458 | dev = new Yopy ( ); | 458 | dev = new Yopy ( ); |
459 | else if ( Jornada::isJornada() ) | 459 | else if ( Jornada::isJornada() ) |
460 | dev = new Jornada ( ); | 460 | dev = new Jornada ( ); |
461 | else | 461 | else |
462 | dev = new ODevice ( ); | 462 | dev = new ODevice ( ); |
463 | dev-> init ( ); | 463 | dev-> init ( ); |
464 | } | 464 | } |
465 | return dev; | 465 | return dev; |
466 | } | 466 | } |
467 | 467 | ||
468 | 468 | ||
469 | /************************************************** | 469 | /************************************************** |
470 | * | 470 | * |
471 | * common | 471 | * common |
472 | * | 472 | * |
473 | **************************************************/ | 473 | **************************************************/ |
474 | 474 | ||
475 | 475 | ||
476 | ODevice::ODevice ( ) | 476 | ODevice::ODevice ( ) |
477 | { | 477 | { |
478 | d = new ODeviceData; | 478 | d = new ODeviceData; |
479 | 479 | ||
480 | d-> m_modelstr = "Unknown"; | 480 | d-> m_modelstr = "Unknown"; |
481 | d-> m_model = Model_Unknown; | 481 | d-> m_model = Model_Unknown; |
482 | d-> m_vendorstr = "Unknown"; | 482 | d-> m_vendorstr = "Unknown"; |
483 | d-> m_vendor = Vendor_Unknown; | 483 | d-> m_vendor = Vendor_Unknown; |
484 | d-> m_systemstr = "Unknown"; | 484 | d-> m_systemstr = "Unknown"; |
485 | d-> m_system = System_Unknown; | 485 | d-> m_system = System_Unknown; |
486 | d-> m_sysverstr = "0.0"; | 486 | d-> m_sysverstr = "0.0"; |
487 | d-> m_rotation = Rot0; | 487 | d-> m_rotation = Rot0; |
488 | d-> m_direction = CW; | 488 | d-> m_direction = CW; |
489 | 489 | ||
490 | d-> m_holdtime = 1000; // 1000ms | 490 | d-> m_holdtime = 1000; // 1000ms |
491 | d-> m_buttons = 0; | 491 | d-> m_buttons = 0; |
492 | d-> m_cpu_frequencies = new QStrList; | 492 | d-> m_cpu_frequencies = new QStrList; |
493 | } | 493 | } |
494 | 494 | ||
495 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 495 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
496 | { | 496 | { |
497 | if ( msg == "deviceButtonMappingChanged()" ) { | 497 | if ( msg == "deviceButtonMappingChanged()" ) { |
498 | reloadButtonMapping ( ); | 498 | reloadButtonMapping ( ); |
499 | } | 499 | } |
500 | } | 500 | } |
501 | 501 | ||
502 | void ODevice::init ( ) | 502 | void ODevice::init ( ) |
503 | { | 503 | { |
504 | } | 504 | } |
505 | 505 | ||
506 | /** | 506 | /** |
507 | * This method initialises the button mapping | 507 | * This method initialises the button mapping |
508 | */ | 508 | */ |
509 | void ODevice::initButtons ( ) | 509 | void ODevice::initButtons ( ) |
510 | { | 510 | { |
511 | if ( d-> m_buttons ) | 511 | if ( d-> m_buttons ) |
512 | return; | 512 | return; |
513 | 513 | ||
514 | // Simulation uses iPAQ 3660 device buttons | 514 | // Simulation uses iPAQ 3660 device buttons |
515 | 515 | ||
516 | qDebug ( "init Buttons" ); | 516 | qDebug ( "init Buttons" ); |
517 | d-> m_buttons = new QValueList <ODeviceButton>; | 517 | d-> m_buttons = new QValueList <ODeviceButton>; |
518 | 518 | ||
519 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 519 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
520 | i_button *ib = ipaq_buttons + i; | 520 | i_button *ib = ipaq_buttons + i; |
521 | ODeviceButton b; | 521 | ODeviceButton b; |
522 | 522 | ||
523 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 523 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
524 | b. setKeycode ( ib-> code ); | 524 | b. setKeycode ( ib-> code ); |
525 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 525 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
526 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 526 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
527 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 527 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
528 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 528 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
529 | d-> m_buttons-> append ( b ); | 529 | d-> m_buttons-> append ( b ); |
530 | } | 530 | } |
531 | } | 531 | } |
532 | reloadButtonMapping ( ); | 532 | reloadButtonMapping ( ); |
533 | 533 | ||
534 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 534 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
535 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 535 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
536 | } | 536 | } |
537 | 537 | ||
538 | ODevice::~ODevice ( ) | 538 | ODevice::~ODevice ( ) |
539 | { | 539 | { |
540 | // we leak m_devicebuttons and m_cpu_frequency | 540 | // we leak m_devicebuttons and m_cpu_frequency |
541 | // but it's a singleton and it is not so importantant | 541 | // but it's a singleton and it is not so importantant |
542 | // -zecke | 542 | // -zecke |
543 | delete d; | 543 | delete d; |
544 | } | 544 | } |
545 | 545 | ||
546 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 546 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
547 | { | 547 | { |
548 | return false; | 548 | return false; |
549 | } | 549 | } |
550 | 550 | ||
551 | //#include <linux/apm_bios.h> | 551 | //#include <linux/apm_bios.h> |
552 | 552 | ||
553 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 553 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
554 | 554 | ||
555 | /** | 555 | /** |
556 | * This method will try to suspend the device | 556 | * This method will try to suspend the device |
557 | * It only works if the user is the QWS Server and the apm application | 557 | * It only works if the user is the QWS Server and the apm application |
558 | * is installed. | 558 | * is installed. |
559 | * It tries to suspend and then waits some time cause some distributions | 559 | * It tries to suspend and then waits some time cause some distributions |
560 | * do have asynchronus apm implementations. | 560 | * do have asynchronus apm implementations. |
561 | * This method will either fail and return false or it'll suspend the | 561 | * This method will either fail and return false or it'll suspend the |
562 | * device and return once the device got woken up | 562 | * device and return once the device got woken up |
563 | * | 563 | * |
564 | * @return if the device got suspended | 564 | * @return if the device got suspended |
565 | */ | 565 | */ |
566 | bool ODevice::suspend ( ) | 566 | bool ODevice::suspend ( ) |
567 | { | 567 | { |
568 | qDebug("ODevice::suspend"); | 568 | qDebug("ODevice::suspend"); |
569 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 569 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
570 | return false; | 570 | return false; |
571 | 571 | ||
572 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 572 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
573 | return false; | 573 | return false; |
574 | 574 | ||
575 | bool res = false; | 575 | bool res = false; |
576 | 576 | ||
577 | struct timeval tvs, tvn; | 577 | struct timeval tvs, tvn; |
578 | ::gettimeofday ( &tvs, 0 ); | 578 | ::gettimeofday ( &tvs, 0 ); |
579 | 579 | ||
580 | ::sync ( ); // flush fs caches | 580 | ::sync ( ); // flush fs caches |
581 | res = ( ::system ( "apm --suspend" ) == 0 ); | 581 | res = ( ::system ( "apm --suspend" ) == 0 ); |
582 | 582 | ||
583 | // This is needed because the iPAQ apm implementation is asynchronous and we | 583 | // This is needed because the iPAQ apm implementation is asynchronous and we |
584 | // can not be sure when exactly the device is really suspended | 584 | // can not be sure when exactly the device is really suspended |
585 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 585 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
586 | 586 | ||
587 | if ( res ) { | 587 | if ( res ) { |
588 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 588 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
589 | ::usleep ( 200 * 1000 ); | 589 | ::usleep ( 200 * 1000 ); |
590 | ::gettimeofday ( &tvn, 0 ); | 590 | ::gettimeofday ( &tvn, 0 ); |
591 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 591 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
592 | } | 592 | } |
593 | 593 | ||
594 | return res; | 594 | return res; |
595 | } | 595 | } |
596 | 596 | ||
597 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 597 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
598 | 598 | ||
599 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 599 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
600 | 600 | ||
601 | /* VESA Blanking Levels */ | 601 | /* VESA Blanking Levels */ |
602 | #define VESA_NO_BLANKING 0 | 602 | #define VESA_NO_BLANKING 0 |
603 | #define VESA_VSYNC_SUSPEND 1 | 603 | #define VESA_VSYNC_SUSPEND 1 |
604 | #define VESA_HSYNC_SUSPEND 2 | 604 | #define VESA_HSYNC_SUSPEND 2 |
605 | #define VESA_POWERDOWN 3 | 605 | #define VESA_POWERDOWN 3 |
606 | 606 | ||
607 | /** | 607 | /** |
608 | * This sets the display on or off | 608 | * This sets the display on or off |
609 | */ | 609 | */ |
610 | bool ODevice::setDisplayStatus ( bool on ) | 610 | bool ODevice::setDisplayStatus ( bool on ) |
611 | { | 611 | { |
612 | qDebug("ODevice::setDisplayStatus(%d)", on); | 612 | qDebug("ODevice::setDisplayStatus(%d)", on); |
613 | 613 | ||
614 | if ( d-> m_model == Model_Unknown ) | 614 | if ( d-> m_model == Model_Unknown ) |
615 | return false; | 615 | return false; |
616 | 616 | ||
617 | bool res = false; | 617 | bool res = false; |
618 | int fd; | 618 | int fd; |
619 | 619 | ||
620 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 620 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
621 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 621 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
622 | ::close ( fd ); | 622 | ::close ( fd ); |
623 | } | 623 | } |
624 | return res; | 624 | return res; |
625 | } | 625 | } |
626 | 626 | ||
627 | /** | 627 | /** |
628 | * This sets the display brightness | 628 | * This sets the display brightness |
629 | * | 629 | * |
630 | * @param p The brightness to be set on a scale from 0 to 255 | 630 | * @param p The brightness to be set on a scale from 0 to 255 |
631 | * @return success or failure | 631 | * @return success or failure |
632 | */ | 632 | */ |
633 | bool ODevice::setDisplayBrightness ( int p) | 633 | bool ODevice::setDisplayBrightness ( int p) |
634 | { | 634 | { |
635 | Q_UNUSED( p ) | 635 | Q_UNUSED( p ) |
636 | return false; | 636 | return false; |
637 | } | 637 | } |
638 | 638 | ||
639 | /** | 639 | /** |
640 | * @return returns the number of steppings on the brightness slider | 640 | * @return returns the number of steppings on the brightness slider |
641 | * in the Light-'n-Power settings. | 641 | * in the Light-'n-Power settings. |
642 | */ | 642 | */ |
643 | int ODevice::displayBrightnessResolution ( ) const | 643 | int ODevice::displayBrightnessResolution ( ) const |
644 | { | 644 | { |
645 | return 16; | 645 | return 16; |
646 | } | 646 | } |
647 | 647 | ||
648 | /** | 648 | /** |
649 | * This sets the display contrast | 649 | * This sets the display contrast |
650 | * @param p The contrast to be set on a scale from 0 to 255 | 650 | * @param p The contrast to be set on a scale from 0 to 255 |
651 | * @return success or failure | 651 | * @return success or failure |
652 | */ | 652 | */ |
653 | bool ODevice::setDisplayContrast ( int p) | 653 | bool ODevice::setDisplayContrast ( int p) |
654 | { | 654 | { |
655 | Q_UNUSED( p ) | 655 | Q_UNUSED( p ) |
656 | return false; | 656 | return false; |
657 | } | 657 | } |
658 | 658 | ||
659 | /** | 659 | /** |
660 | * @return return the max value for the brightness settings slider | 660 | * @return return the max value for the brightness settings slider |
661 | * or 0 if the device doesn't support setting of a contrast | 661 | * or 0 if the device doesn't support setting of a contrast |
662 | */ | 662 | */ |
663 | int ODevice::displayContrastResolution ( ) const | 663 | int ODevice::displayContrastResolution ( ) const |
@@ -987,406 +987,406 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | |||
987 | mb_chan=b. pressedAction ( ). channel ( ); | 987 | mb_chan=b. pressedAction ( ). channel ( ); |
988 | 988 | ||
989 | Config buttonFile ( "ButtonSettings" ); | 989 | Config buttonFile ( "ButtonSettings" ); |
990 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 990 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
991 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 991 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
992 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 992 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
993 | 993 | ||
994 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 994 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
995 | 995 | ||
996 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 996 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
997 | } | 997 | } |
998 | 998 | ||
999 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 999 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
1000 | { | 1000 | { |
1001 | initButtons ( ); | 1001 | initButtons ( ); |
1002 | 1002 | ||
1003 | if ( button >= (int) d-> m_buttons-> count ( )) | 1003 | if ( button >= (int) d-> m_buttons-> count ( )) |
1004 | return; | 1004 | return; |
1005 | 1005 | ||
1006 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 1006 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
1007 | b. setHeldAction ( action ); | 1007 | b. setHeldAction ( action ); |
1008 | 1008 | ||
1009 | Config buttonFile ( "ButtonSettings" ); | 1009 | Config buttonFile ( "ButtonSettings" ); |
1010 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 1010 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
1011 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 1011 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
1012 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 1012 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
1013 | 1013 | ||
1014 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 1014 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
1015 | 1015 | ||
1016 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 1016 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
1017 | } | 1017 | } |
1018 | void ODevice::virtual_hook(int id, void* data){ | 1018 | void ODevice::virtual_hook(int id, void* data){ |
1019 | switch( id ) { | 1019 | switch( id ) { |
1020 | case VIRTUAL_ROTATION:{ | 1020 | case VIRTUAL_ROTATION:{ |
1021 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); | 1021 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); |
1022 | rot->trans = d->m_rotation; | 1022 | rot->trans = d->m_rotation; |
1023 | break; | 1023 | break; |
1024 | } | 1024 | } |
1025 | case VIRTUAL_DIRECTION:{ | 1025 | case VIRTUAL_DIRECTION:{ |
1026 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); | 1026 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); |
1027 | dir->direct = d->m_direction; | 1027 | dir->direct = d->m_direction; |
1028 | break; | 1028 | break; |
1029 | } | 1029 | } |
1030 | case VIRTUAL_HAS_HINGE:{ | 1030 | case VIRTUAL_HAS_HINGE:{ |
1031 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); | 1031 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); |
1032 | hin->hasHinge = false; | 1032 | hin->hasHinge = false; |
1033 | break; | 1033 | break; |
1034 | } | 1034 | } |
1035 | case VIRTUAL_HINGE:{ | 1035 | case VIRTUAL_HINGE:{ |
1036 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); | 1036 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); |
1037 | hin->hingeStat = CASE_UNKNOWN; | 1037 | hin->hingeStat = CASE_UNKNOWN; |
1038 | break; | 1038 | break; |
1039 | } | 1039 | } |
1040 | } | 1040 | } |
1041 | } | 1041 | } |
1042 | 1042 | ||
1043 | /************************************************** | 1043 | /************************************************** |
1044 | * | 1044 | * |
1045 | * Yopy 3500/3700 | 1045 | * Yopy 3500/3700 |
1046 | * | 1046 | * |
1047 | **************************************************/ | 1047 | **************************************************/ |
1048 | 1048 | ||
1049 | bool Yopy::isYopy ( ) | 1049 | bool Yopy::isYopy ( ) |
1050 | { | 1050 | { |
1051 | QFile f( "/proc/cpuinfo" ); | 1051 | QFile f( "/proc/cpuinfo" ); |
1052 | if ( f. open ( IO_ReadOnly ) ) { | 1052 | if ( f. open ( IO_ReadOnly ) ) { |
1053 | QTextStream ts ( &f ); | 1053 | QTextStream ts ( &f ); |
1054 | QString line; | 1054 | QString line; |
1055 | while( line = ts. readLine ( ) ) { | 1055 | while( line = ts. readLine ( ) ) { |
1056 | if ( line. left ( 8 ) == "Hardware" ) { | 1056 | if ( line. left ( 8 ) == "Hardware" ) { |
1057 | int loc = line. find ( ":" ); | 1057 | int loc = line. find ( ":" ); |
1058 | if ( loc != -1 ) { | 1058 | if ( loc != -1 ) { |
1059 | QString model = | 1059 | QString model = |
1060 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1060 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1061 | return ( model == "Yopy" ); | 1061 | return ( model == "Yopy" ); |
1062 | } | 1062 | } |
1063 | } | 1063 | } |
1064 | } | 1064 | } |
1065 | } | 1065 | } |
1066 | return false; | 1066 | return false; |
1067 | } | 1067 | } |
1068 | 1068 | ||
1069 | void Yopy::init ( ) | 1069 | void Yopy::init ( ) |
1070 | { | 1070 | { |
1071 | d-> m_vendorstr = "G.Mate"; | 1071 | d-> m_vendorstr = "G.Mate"; |
1072 | d-> m_vendor = Vendor_GMate; | 1072 | d-> m_vendor = Vendor_GMate; |
1073 | d-> m_modelstr = "Yopy3700"; | 1073 | d-> m_modelstr = "Yopy3700"; |
1074 | d-> m_model = Model_Yopy_3700; | 1074 | d-> m_model = Model_Yopy_3700; |
1075 | d-> m_rotation = Rot0; | 1075 | d-> m_rotation = Rot0; |
1076 | 1076 | ||
1077 | d-> m_systemstr = "Linupy"; | 1077 | d-> m_systemstr = "Linupy"; |
1078 | d-> m_system = System_Linupy; | 1078 | d-> m_system = System_Linupy; |
1079 | 1079 | ||
1080 | QFile f ( "/etc/issue" ); | 1080 | QFile f ( "/etc/issue" ); |
1081 | if ( f. open ( IO_ReadOnly )) { | 1081 | if ( f. open ( IO_ReadOnly )) { |
1082 | QTextStream ts ( &f ); | 1082 | QTextStream ts ( &f ); |
1083 | ts.readLine(); | 1083 | ts.readLine(); |
1084 | d-> m_sysverstr = ts. readLine ( ); | 1084 | d-> m_sysverstr = ts. readLine ( ); |
1085 | f. close ( ); | 1085 | f. close ( ); |
1086 | } | 1086 | } |
1087 | } | 1087 | } |
1088 | 1088 | ||
1089 | void Yopy::initButtons ( ) | 1089 | void Yopy::initButtons ( ) |
1090 | { | 1090 | { |
1091 | if ( d-> m_buttons ) | 1091 | if ( d-> m_buttons ) |
1092 | return; | 1092 | return; |
1093 | 1093 | ||
1094 | d-> m_buttons = new QValueList <ODeviceButton>; | 1094 | d-> m_buttons = new QValueList <ODeviceButton>; |
1095 | 1095 | ||
1096 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 1096 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { |
1097 | 1097 | ||
1098 | yopy_button *ib = yopy_buttons + i; | 1098 | yopy_button *ib = yopy_buttons + i; |
1099 | 1099 | ||
1100 | ODeviceButton b; | 1100 | ODeviceButton b; |
1101 | 1101 | ||
1102 | b. setKeycode ( ib-> code ); | 1102 | b. setKeycode ( ib-> code ); |
1103 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1103 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1104 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1104 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1105 | b. setFactoryPresetPressedAction | 1105 | b. setFactoryPresetPressedAction |
1106 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 1106 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); |
1107 | b. setFactoryPresetHeldAction | 1107 | b. setFactoryPresetHeldAction |
1108 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 1108 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); |
1109 | 1109 | ||
1110 | d-> m_buttons-> append ( b ); | 1110 | d-> m_buttons-> append ( b ); |
1111 | } | 1111 | } |
1112 | reloadButtonMapping ( ); | 1112 | reloadButtonMapping ( ); |
1113 | 1113 | ||
1114 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | 1114 | QCopChannel *sysch = new QCopChannel("QPE/System", this); |
1115 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), | 1115 | connect(sysch, SIGNAL(received(const QCString&,const QByteArray&)), |
1116 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); | 1116 | this, SLOT(systemMessage(const QCString&,const QByteArray&))); |
1117 | } | 1117 | } |
1118 | 1118 | ||
1119 | bool Yopy::suspend() | 1119 | bool Yopy::suspend() |
1120 | { | 1120 | { |
1121 | /* Opie for Yopy does not implement its own power management at the | 1121 | /* Opie for Yopy does not implement its own power management at the |
1122 | moment. The public version runs parallel to X, and relies on the | 1122 | moment. The public version runs parallel to X, and relies on the |
1123 | existing power management features. */ | 1123 | existing power management features. */ |
1124 | return false; | 1124 | return false; |
1125 | } | 1125 | } |
1126 | 1126 | ||
1127 | bool Yopy::setDisplayBrightness(int bright) | 1127 | bool Yopy::setDisplayBrightness(int bright) |
1128 | { | 1128 | { |
1129 | /* The code here works, but is disabled as the current version runs | 1129 | /* The code here works, but is disabled as the current version runs |
1130 | parallel to X, and relies on the existing backlight demon. */ | 1130 | parallel to X, and relies on the existing backlight demon. */ |
1131 | #if 0 | 1131 | #if 0 |
1132 | if ( QFile::exists("/proc/sys/pm/light") ) { | 1132 | if ( QFile::exists("/proc/sys/pm/light") ) { |
1133 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 1133 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
1134 | if (fd >= 0 ) { | 1134 | if (fd >= 0 ) { |
1135 | if (bright) | 1135 | if (bright) |
1136 | ::write(fd, "1\n", 2); | 1136 | ::write(fd, "1\n", 2); |
1137 | else | 1137 | else |
1138 | ::write(fd, "0\n", 2); | 1138 | ::write(fd, "0\n", 2); |
1139 | ::close(fd); | 1139 | ::close(fd); |
1140 | return true; | 1140 | return true; |
1141 | } | 1141 | } |
1142 | } | 1142 | } |
1143 | #endif | 1143 | #endif |
1144 | return false; | 1144 | return false; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | int Yopy::displayBrightnessResolution() const | 1147 | int Yopy::displayBrightnessResolution() const |
1148 | { | 1148 | { |
1149 | return 2; | 1149 | return 2; |
1150 | } | 1150 | } |
1151 | 1151 | ||
1152 | /************************************************** | 1152 | /************************************************** |
1153 | * | 1153 | * |
1154 | * iPAQ | 1154 | * iPAQ |
1155 | * | 1155 | * |
1156 | **************************************************/ | 1156 | **************************************************/ |
1157 | 1157 | ||
1158 | void iPAQ::init ( ) | 1158 | void iPAQ::init ( ) |
1159 | { | 1159 | { |
1160 | d-> m_vendorstr = "HP"; | 1160 | d-> m_vendorstr = "HP"; |
1161 | d-> m_vendor = Vendor_HP; | 1161 | d-> m_vendor = Vendor_HP; |
1162 | 1162 | ||
1163 | QFile f ( "/proc/hal/model" ); | 1163 | QFile f ( "/proc/hal/model" ); |
1164 | 1164 | ||
1165 | if ( f. open ( IO_ReadOnly )) { | 1165 | if ( f. open ( IO_ReadOnly )) { |
1166 | QTextStream ts ( &f ); | 1166 | QTextStream ts ( &f ); |
1167 | 1167 | ||
1168 | d-> m_modelstr = "H" + ts. readLine ( ); | 1168 | d-> m_modelstr = "H" + ts. readLine ( ); |
1169 | 1169 | ||
1170 | if ( d-> m_modelstr == "H3100" ) | 1170 | if ( d-> m_modelstr == "H3100" ) |
1171 | d-> m_model = Model_iPAQ_H31xx; | 1171 | d-> m_model = Model_iPAQ_H31xx; |
1172 | else if ( d-> m_modelstr == "H3600" ) | 1172 | else if ( d-> m_modelstr == "H3600" ) |
1173 | d-> m_model = Model_iPAQ_H36xx; | 1173 | d-> m_model = Model_iPAQ_H36xx; |
1174 | else if ( d-> m_modelstr == "H3700" ) | 1174 | else if ( d-> m_modelstr == "H3700" ) |
1175 | d-> m_model = Model_iPAQ_H37xx; | 1175 | d-> m_model = Model_iPAQ_H37xx; |
1176 | else if ( d-> m_modelstr == "H3800" ) | 1176 | else if ( d-> m_modelstr == "H3800" ) |
1177 | d-> m_model = Model_iPAQ_H38xx; | 1177 | d-> m_model = Model_iPAQ_H38xx; |
1178 | else if ( d-> m_modelstr == "H3900" ) | 1178 | else if ( d-> m_modelstr == "H3900" ) |
1179 | d-> m_model = Model_iPAQ_H39xx; | 1179 | d-> m_model = Model_iPAQ_H39xx; |
1180 | else if ( d-> m_modelstr == "H5400" ) | 1180 | else if ( d-> m_modelstr == "H5400" ) |
1181 | d-> m_model = Model_iPAQ_H5xxx; | 1181 | d-> m_model = Model_iPAQ_H5xxx; |
1182 | else | 1182 | else |
1183 | d-> m_model = Model_Unknown; | 1183 | d-> m_model = Model_Unknown; |
1184 | 1184 | ||
1185 | f. close ( ); | 1185 | f. close ( ); |
1186 | } | 1186 | } |
1187 | 1187 | ||
1188 | switch ( d-> m_model ) { | 1188 | switch ( d-> m_model ) { |
1189 | case Model_iPAQ_H31xx: | 1189 | case Model_iPAQ_H31xx: |
1190 | case Model_iPAQ_H38xx: | 1190 | case Model_iPAQ_H38xx: |
1191 | d-> m_rotation = Rot90; | 1191 | d-> m_rotation = Rot90; |
1192 | break; | 1192 | break; |
1193 | case Model_iPAQ_H36xx: | 1193 | case Model_iPAQ_H36xx: |
1194 | case Model_iPAQ_H37xx: | 1194 | case Model_iPAQ_H37xx: |
1195 | case Model_iPAQ_H39xx: | 1195 | case Model_iPAQ_H39xx: |
1196 | 1196 | ||
1197 | default: | 1197 | default: |
1198 | d-> m_rotation = Rot270; | 1198 | d-> m_rotation = Rot270; |
1199 | break; | 1199 | break; |
1200 | case Model_iPAQ_H5xxx: | 1200 | case Model_iPAQ_H5xxx: |
1201 | d-> m_rotation = Rot0; | 1201 | d-> m_rotation = Rot0; |
1202 | } | 1202 | } |
1203 | 1203 | ||
1204 | f. setName ( "/etc/familiar-version" ); | 1204 | f. setName ( "/etc/familiar-version" ); |
1205 | if ( f. open ( IO_ReadOnly )) { | 1205 | if ( f. open ( IO_ReadOnly )) { |
1206 | d-> m_systemstr = "Familiar"; | 1206 | d-> m_systemstr = "Familiar"; |
1207 | d-> m_system = System_Familiar; | 1207 | d-> m_system = System_Familiar; |
1208 | 1208 | ||
1209 | QTextStream ts ( &f ); | 1209 | QTextStream ts ( &f ); |
1210 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1210 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1211 | 1211 | ||
1212 | f. close ( ); | 1212 | f. close ( ); |
1213 | } else { | 1213 | } else { |
1214 | f. setName ( "/etc/oz_version" ); | 1214 | f. setName ( "/etc/oz_version" ); |
1215 | 1215 | ||
1216 | if ( f. open ( IO_ReadOnly )) { | 1216 | if ( f. open ( IO_ReadOnly )) { |
1217 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 1217 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
1218 | d-> m_system = System_Familiar; | 1218 | d-> m_system = System_Familiar; |
1219 | 1219 | ||
1220 | QTextStream ts ( &f ); | 1220 | QTextStream ts ( &f ); |
1221 | ts.setDevice ( &f ); | 1221 | ts.setDevice ( &f ); |
1222 | d-> m_sysverstr = ts. readLine ( ); | 1222 | d-> m_sysverstr = ts. readLine ( ); |
1223 | f. close ( ); | 1223 | f. close ( ); |
1224 | } | 1224 | } |
1225 | } | 1225 | } |
1226 | 1226 | ||
1227 | 1227 | ||
1228 | 1228 | ||
1229 | 1229 | ||
1230 | 1230 | ||
1231 | m_leds [0] = m_leds [1] = Led_Off; | 1231 | m_leds [0] = m_leds [1] = Led_Off; |
1232 | 1232 | ||
1233 | m_power_timer = 0; | 1233 | m_power_timer = 0; |
1234 | 1234 | ||
1235 | } | 1235 | } |
1236 | 1236 | ||
1237 | void iPAQ::initButtons ( ) | 1237 | void iPAQ::initButtons ( ) |
1238 | { | 1238 | { |
1239 | if ( d-> m_buttons ) | 1239 | if ( d-> m_buttons ) |
1240 | return; | 1240 | return; |
1241 | 1241 | ||
1242 | if ( isQWS( ) ) | 1242 | if ( isQWS( ) ) |
1243 | QWSServer::setKeyboardFilter ( this ); | 1243 | QWSServer::setKeyboardFilter ( this ); |
1244 | 1244 | ||
1245 | d-> m_buttons = new QValueList <ODeviceButton>; | 1245 | d-> m_buttons = new QValueList <ODeviceButton>; |
1246 | 1246 | ||
1247 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1247 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1248 | i_button *ib = ipaq_buttons + i; | 1248 | i_button *ib = ipaq_buttons + i; |
1249 | ODeviceButton b; | 1249 | ODeviceButton b; |
1250 | 1250 | ||
1251 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1251 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1252 | b. setKeycode ( ib-> code ); | 1252 | b. setKeycode ( ib-> code ); |
1253 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1253 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1254 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1254 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1255 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1255 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1256 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1256 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1257 | 1257 | ||
1258 | d-> m_buttons-> append ( b ); | 1258 | d-> m_buttons-> append ( b ); |
1259 | } | 1259 | } |
1260 | } | 1260 | } |
1261 | reloadButtonMapping ( ); | 1261 | reloadButtonMapping ( ); |
1262 | 1262 | ||
1263 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1263 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1264 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1264 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
1265 | } | 1265 | } |
1266 | 1266 | ||
1267 | 1267 | ||
1268 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1268 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1269 | 1269 | ||
1270 | typedef struct { | 1270 | typedef struct { |
1271 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1271 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1272 | unsigned char TotalTime; /* Units of 5 seconds */ | 1272 | unsigned char TotalTime; /* Units of 5 seconds */ |
1273 | unsigned char OnTime; /* units of 100m/s */ | 1273 | unsigned char OnTime; /* units of 100m/s */ |
1274 | unsigned char OffTime; /* units of 100m/s */ | 1274 | unsigned char OffTime; /* units of 100m/s */ |
1275 | } LED_IN; | 1275 | } LED_IN; |
1276 | 1276 | ||
1277 | typedef struct { | 1277 | typedef struct { |
1278 | unsigned char mode; | 1278 | unsigned char mode; |
1279 | unsigned char pwr; | 1279 | unsigned char pwr; |
1280 | unsigned char brightness; | 1280 | unsigned char brightness; |
1281 | } FLITE_IN; | 1281 | } FLITE_IN; |
1282 | 1282 | ||
1283 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1283 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1284 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1284 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1285 | 1285 | ||
1286 | 1286 | ||
1287 | QValueList <OLed> iPAQ::ledList ( ) const | 1287 | QValueList <OLed> iPAQ::ledList ( ) const |
1288 | { | 1288 | { |
1289 | QValueList <OLed> vl; | 1289 | QValueList <OLed> vl; |
1290 | vl << Led_Power; | 1290 | vl << Led_Power; |
1291 | 1291 | ||
1292 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1292 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1293 | vl << Led_BlueTooth; | 1293 | vl << Led_BlueTooth; |
1294 | return vl; | 1294 | return vl; |
1295 | } | 1295 | } |
1296 | 1296 | ||
1297 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1297 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1298 | { | 1298 | { |
1299 | QValueList <OLedState> vl; | 1299 | QValueList <OLedState> vl; |
1300 | 1300 | ||
1301 | if ( l == Led_Power ) | 1301 | if ( l == Led_Power ) |
1302 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1302 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1303 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1303 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1304 | vl << Led_Off; // << Led_On << ??? | 1304 | vl << Led_Off; // << Led_On << ??? |
1305 | 1305 | ||
1306 | return vl; | 1306 | return vl; |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | OLedState iPAQ::ledState ( OLed l ) const | 1309 | OLedState iPAQ::ledState ( OLed l ) const |
1310 | { | 1310 | { |
1311 | switch ( l ) { | 1311 | switch ( l ) { |
1312 | case Led_Power: | 1312 | case Led_Power: |
1313 | return m_leds [0]; | 1313 | return m_leds [0]; |
1314 | case Led_BlueTooth: | 1314 | case Led_BlueTooth: |
1315 | return m_leds [1]; | 1315 | return m_leds [1]; |
1316 | default: | 1316 | default: |
1317 | return Led_Off; | 1317 | return Led_Off; |
1318 | } | 1318 | } |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1321 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1322 | { | 1322 | { |
1323 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1323 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1324 | 1324 | ||
1325 | if ( l == Led_Power ) { | 1325 | if ( l == Led_Power ) { |
1326 | if ( fd >= 0 ) { | 1326 | if ( fd >= 0 ) { |
1327 | LED_IN leds; | 1327 | LED_IN leds; |
1328 | ::memset ( &leds, 0, sizeof( leds )); | 1328 | ::memset ( &leds, 0, sizeof( leds )); |
1329 | leds. TotalTime = 0; | 1329 | leds. TotalTime = 0; |
1330 | leds. OnTime = 0; | 1330 | leds. OnTime = 0; |
1331 | leds. OffTime = 1; | 1331 | leds. OffTime = 1; |
1332 | leds. OffOnBlink = 2; | 1332 | leds. OffOnBlink = 2; |
1333 | 1333 | ||
1334 | switch ( st ) { | 1334 | switch ( st ) { |
1335 | case Led_Off : leds. OffOnBlink = 0; break; | 1335 | case Led_Off : leds. OffOnBlink = 0; break; |
1336 | case Led_On : leds. OffOnBlink = 1; break; | 1336 | case Led_On : leds. OffOnBlink = 1; break; |
1337 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1337 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1338 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1338 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1339 | } | 1339 | } |
1340 | 1340 | ||
1341 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1341 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1342 | m_leds [0] = st; | 1342 | m_leds [0] = st; |
1343 | return true; | 1343 | return true; |
1344 | } | 1344 | } |
1345 | } | 1345 | } |
1346 | } | 1346 | } |
1347 | return false; | 1347 | return false; |
1348 | } | 1348 | } |
1349 | 1349 | ||
1350 | 1350 | ||
1351 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1351 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1352 | { | 1352 | { |
1353 | int newkeycode = keycode; | 1353 | int newkeycode = keycode; |
1354 | 1354 | ||
1355 | switch ( keycode ) { | 1355 | switch ( keycode ) { |
1356 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1356 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1357 | case HardKey_Menu: { | 1357 | case HardKey_Menu: { |
1358 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1358 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1359 | ( d-> m_model == Model_iPAQ_H39xx ) || | 1359 | ( d-> m_model == Model_iPAQ_H39xx ) || |
1360 | ( d-> m_model == Model_iPAQ_H5xxx)) { | 1360 | ( d-> m_model == Model_iPAQ_H5xxx)) { |
1361 | newkeycode = HardKey_Mail; | 1361 | newkeycode = HardKey_Mail; |
1362 | } | 1362 | } |
1363 | break; | 1363 | break; |
1364 | } | 1364 | } |
1365 | 1365 | ||
1366 | // Rotate cursor keys 180° or 270° | 1366 | // Rotate cursor keys 180° or 270° |
1367 | case Key_Left : | 1367 | case Key_Left : |
1368 | case Key_Right: | 1368 | case Key_Right: |
1369 | case Key_Up : | 1369 | case Key_Up : |
1370 | case Key_Down : { | 1370 | case Key_Down : { |
1371 | 1371 | ||
1372 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1372 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1373 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1373 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1374 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1374 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1375 | } | 1375 | } |
1376 | // Rotate the cursor keys by 270° | 1376 | // Rotate the cursor keys by 270° |
1377 | // keycode - Key_Left = position of the button starting from left clockwise | 1377 | // keycode - Key_Left = position of the button starting from left clockwise |
1378 | // add the rotation to it and modolo. No we've the original offset | 1378 | // add the rotation to it and modolo. No we've the original offset |
1379 | // add the offset to the Key_Left key | 1379 | // add the offset to the Key_Left key |
1380 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 1380 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
1381 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 1381 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
1382 | break; | 1382 | break; |
1383 | } | 1383 | } |
1384 | 1384 | ||
1385 | // map Power Button short/long press to F34/F35 | 1385 | // map Power Button short/long press to F34/F35 |
1386 | case Key_SysReq: { | 1386 | case Key_SysReq: { |
1387 | if ( isPress ) { | 1387 | if ( isPress ) { |
1388 | if ( m_power_timer ) | 1388 | if ( m_power_timer ) |
1389 | killTimer ( m_power_timer ); | 1389 | killTimer ( m_power_timer ); |
1390 | m_power_timer = startTimer ( 500 ); | 1390 | m_power_timer = startTimer ( 500 ); |
1391 | } | 1391 | } |
1392 | else if ( m_power_timer ) { | 1392 | else if ( m_power_timer ) { |
@@ -1622,258 +1622,258 @@ void Zaurus::init ( ) | |||
1622 | // detect the distribution ! | 1622 | // detect the distribution ! |
1623 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1623 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1624 | // because it uses a jffs2 filesystem.. | 1624 | // because it uses a jffs2 filesystem.. |
1625 | // (eilers) | 1625 | // (eilers) |
1626 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1626 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1627 | QFile f ("/etc/oz_version"); | 1627 | QFile f ("/etc/oz_version"); |
1628 | if ( f.exists() ){ | 1628 | if ( f.exists() ){ |
1629 | d-> m_vendorstr = "OpenZaurus Team"; | 1629 | d-> m_vendorstr = "OpenZaurus Team"; |
1630 | d-> m_systemstr = "OpenZaurus"; | 1630 | d-> m_systemstr = "OpenZaurus"; |
1631 | d-> m_system = System_OpenZaurus; | 1631 | d-> m_system = System_OpenZaurus; |
1632 | 1632 | ||
1633 | if ( f. open ( IO_ReadOnly )) { | 1633 | if ( f. open ( IO_ReadOnly )) { |
1634 | QTextStream ts ( &f ); | 1634 | QTextStream ts ( &f ); |
1635 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1635 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1636 | f. close ( ); | 1636 | f. close ( ); |
1637 | } | 1637 | } |
1638 | 1638 | ||
1639 | // Openzaurus sometimes uses the embedix kernel! | 1639 | // Openzaurus sometimes uses the embedix kernel! |
1640 | // => Check whether this is an embedix kernel | 1640 | // => Check whether this is an embedix kernel |
1641 | FILE *uname = popen("uname -r", "r"); | 1641 | FILE *uname = popen("uname -r", "r"); |
1642 | QString line; | 1642 | QString line; |
1643 | if ( f.open(IO_ReadOnly, uname) ) { | 1643 | if ( f.open(IO_ReadOnly, uname) ) { |
1644 | QTextStream ts ( &f ); | 1644 | QTextStream ts ( &f ); |
1645 | line = ts. readLine ( ); | 1645 | line = ts. readLine ( ); |
1646 | int loc = line. find ( "embedix" ); | 1646 | int loc = line. find ( "embedix" ); |
1647 | if ( loc != -1 ) | 1647 | if ( loc != -1 ) |
1648 | m_embedix = true; | 1648 | m_embedix = true; |
1649 | else | 1649 | else |
1650 | m_embedix = false; | 1650 | m_embedix = false; |
1651 | f. close ( ); | 1651 | f. close ( ); |
1652 | } | 1652 | } |
1653 | pclose(uname); | 1653 | pclose(uname); |
1654 | } | 1654 | } |
1655 | else { | 1655 | else { |
1656 | d-> m_systemstr = "Zaurus"; | 1656 | d-> m_systemstr = "Zaurus"; |
1657 | d-> m_system = System_Zaurus; | 1657 | d-> m_system = System_Zaurus; |
1658 | } | 1658 | } |
1659 | 1659 | ||
1660 | f. setName ( "/proc/cpuinfo" ); | 1660 | f. setName ( "/proc/cpuinfo" ); |
1661 | if ( f. open ( IO_ReadOnly ) ) { | 1661 | if ( f. open ( IO_ReadOnly ) ) { |
1662 | QTextStream ts ( &f ); | 1662 | QTextStream ts ( &f ); |
1663 | QString line; | 1663 | QString line; |
1664 | while( line = ts. readLine ( ) ) { | 1664 | while( line = ts. readLine ( ) ) { |
1665 | if ( line. left ( 8 ) == "Hardware" ) | 1665 | if ( line. left ( 8 ) == "Hardware" ) |
1666 | break; | 1666 | break; |
1667 | } | 1667 | } |
1668 | int loc = line. find ( ":" ); | 1668 | int loc = line. find ( ":" ); |
1669 | if ( loc != -1 ) | 1669 | if ( loc != -1 ) |
1670 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1670 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1671 | } | 1671 | } |
1672 | 1672 | ||
1673 | if ( model == "SHARP Corgi" ) { | 1673 | if ( model == "SHARP Corgi" ) { |
1674 | d-> m_model = Model_Zaurus_SLC7x0; | 1674 | d-> m_model = Model_Zaurus_SLC7x0; |
1675 | d-> m_modelstr = "Zaurus SL-C700"; | 1675 | d-> m_modelstr = "Zaurus SL-C700"; |
1676 | } else if ( model == "SHARP Shepherd" ) { | 1676 | } else if ( model == "SHARP Shepherd" ) { |
1677 | d-> m_model = Model_Zaurus_SLC7x0; | 1677 | d-> m_model = Model_Zaurus_SLC7x0; |
1678 | d-> m_modelstr = "Zaurus SL-C750"; | 1678 | d-> m_modelstr = "Zaurus SL-C750"; |
1679 | } else if ( model == "SHARP Husky" ) { | 1679 | } else if ( model == "SHARP Husky" ) { |
1680 | d-> m_model = Model_Zaurus_SLC7x0; | 1680 | d-> m_model = Model_Zaurus_SLC7x0; |
1681 | d-> m_modelstr = "Zaurus SL-C760"; | 1681 | d-> m_modelstr = "Zaurus SL-C760"; |
1682 | } else if ( model == "SHARP Poodle" ) { | 1682 | } else if ( model == "SHARP Poodle" ) { |
1683 | d-> m_model = Model_Zaurus_SLB600; | 1683 | d-> m_model = Model_Zaurus_SLB600; |
1684 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1684 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1685 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1685 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1686 | d-> m_model = Model_Zaurus_SL5500; | 1686 | d-> m_model = Model_Zaurus_SL5500; |
1687 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1687 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1688 | } else { | 1688 | } else { |
1689 | d-> m_model = Model_Zaurus_SL5500; | 1689 | d-> m_model = Model_Zaurus_SL5500; |
1690 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1690 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1691 | } | 1691 | } |
1692 | 1692 | ||
1693 | bool flipstate = false; | 1693 | bool flipstate = false; |
1694 | switch ( d-> m_model ) { | 1694 | switch ( d-> m_model ) { |
1695 | case Model_Zaurus_SLA300: | 1695 | case Model_Zaurus_SLA300: |
1696 | d-> m_rotation = Rot0; | 1696 | d-> m_rotation = Rot0; |
1697 | break; | 1697 | break; |
1698 | case Model_Zaurus_SLC7x0: | 1698 | case Model_Zaurus_SLC7x0: |
1699 | d-> m_rotation = rotation(); | 1699 | d-> m_rotation = rotation(); |
1700 | d-> m_direction = direction(); | 1700 | d-> m_direction = direction(); |
1701 | break; | 1701 | break; |
1702 | case Model_Zaurus_SLB600: | 1702 | case Model_Zaurus_SLB600: |
1703 | case Model_Zaurus_SL5500: | 1703 | case Model_Zaurus_SL5500: |
1704 | case Model_Zaurus_SL5000: | 1704 | case Model_Zaurus_SL5000: |
1705 | default: | 1705 | default: |
1706 | d-> m_rotation = Rot270; | 1706 | d-> m_rotation = Rot270; |
1707 | break; | 1707 | break; |
1708 | } | 1708 | } |
1709 | m_leds [0] = Led_Off; | 1709 | m_leds [0] = Led_Off; |
1710 | } | 1710 | } |
1711 | 1711 | ||
1712 | void Zaurus::initButtons ( ) | 1712 | void Zaurus::initButtons ( ) |
1713 | { | 1713 | { |
1714 | if ( d-> m_buttons ) | 1714 | if ( d-> m_buttons ) |
1715 | return; | 1715 | return; |
1716 | 1716 | ||
1717 | d-> m_buttons = new QValueList <ODeviceButton>; | 1717 | d-> m_buttons = new QValueList <ODeviceButton>; |
1718 | 1718 | ||
1719 | struct z_button * pz_buttons; | 1719 | struct z_button * pz_buttons; |
1720 | int buttoncount; | 1720 | int buttoncount; |
1721 | switch ( d-> m_model ) { | 1721 | switch ( d-> m_model ) { |
1722 | case Model_Zaurus_SLC7x0: | 1722 | case Model_Zaurus_SLC7x0: |
1723 | pz_buttons = z_buttons_c700; | 1723 | pz_buttons = z_buttons_c700; |
1724 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1724 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1725 | break; | 1725 | break; |
1726 | default: | 1726 | default: |
1727 | pz_buttons = z_buttons; | 1727 | pz_buttons = z_buttons; |
1728 | buttoncount = ARRAY_SIZE(z_buttons); | 1728 | buttoncount = ARRAY_SIZE(z_buttons); |
1729 | break; | 1729 | break; |
1730 | } | 1730 | } |
1731 | 1731 | ||
1732 | for ( int i = 0; i < buttoncount; i++ ) { | 1732 | for ( int i = 0; i < buttoncount; i++ ) { |
1733 | struct z_button *zb = pz_buttons + i; | 1733 | struct z_button *zb = pz_buttons + i; |
1734 | ODeviceButton b; | 1734 | ODeviceButton b; |
1735 | 1735 | ||
1736 | b. setKeycode ( zb-> code ); | 1736 | b. setKeycode ( zb-> code ); |
1737 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1737 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1738 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1738 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1739 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), | 1739 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1740 | zb-> fpressedaction )); | 1740 | zb-> fpressedaction )); |
1741 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | 1741 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), |
1742 | zb-> fheldaction )); | 1742 | zb-> fheldaction )); |
1743 | 1743 | ||
1744 | d-> m_buttons-> append ( b ); | 1744 | d-> m_buttons-> append ( b ); |
1745 | } | 1745 | } |
1746 | 1746 | ||
1747 | reloadButtonMapping ( ); | 1747 | reloadButtonMapping ( ); |
1748 | 1748 | ||
1749 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1749 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1750 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), | 1750 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), |
1751 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1751 | this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
1752 | } | 1752 | } |
1753 | 1753 | ||
1754 | #include <unistd.h> | 1754 | #include <unistd.h> |
1755 | #include <fcntl.h> | 1755 | #include <fcntl.h> |
1756 | #include <sys/ioctl.h> | 1756 | #include <sys/ioctl.h> |
1757 | 1757 | ||
1758 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1758 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1759 | 1759 | ||
1760 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1760 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1761 | 1761 | ||
1762 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1762 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1763 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1763 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1764 | 1764 | ||
1765 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1765 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1766 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1766 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1767 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1767 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1768 | 1768 | ||
1769 | /* --- for SHARP_BUZZER device --- */ | 1769 | /* --- for SHARP_BUZZER device --- */ |
1770 | 1770 | ||
1771 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1771 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1772 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1772 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1773 | 1773 | ||
1774 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1774 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1775 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1775 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1776 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1776 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1777 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1777 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1778 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1778 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1779 | 1779 | ||
1780 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1780 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1781 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1781 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1782 | 1782 | ||
1783 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1783 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1784 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1784 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1785 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1785 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1786 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1786 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1787 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1787 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1788 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1788 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1789 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1789 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1790 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1790 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1791 | 1791 | ||
1792 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1792 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1793 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1793 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1794 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1794 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1795 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1795 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1796 | // | 1796 | // |
1797 | 1797 | ||
1798 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1798 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1799 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1799 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1800 | 1800 | ||
1801 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 1801 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
1802 | 1802 | ||
1803 | typedef struct sharp_led_status { | 1803 | typedef struct sharp_led_status { |
1804 | int which; /* select which LED status is wanted. */ | 1804 | int which; /* select which LED status is wanted. */ |
1805 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1805 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1806 | } sharp_led_status; | 1806 | } sharp_led_status; |
1807 | 1807 | ||
1808 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1808 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1809 | 1809 | ||
1810 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1810 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1811 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1811 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1812 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1812 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1813 | 1813 | ||
1814 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1814 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1815 | 1815 | ||
1816 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1816 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1817 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1817 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1818 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1818 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1819 | 1819 | ||
1820 | #define FL_IOCTL_STEP_CONTRAST 100 | 1820 | #define FL_IOCTL_STEP_CONTRAST 100 |
1821 | 1821 | ||
1822 | 1822 | ||
1823 | void Zaurus::buzzer ( int sound ) | 1823 | void Zaurus::buzzer ( int sound ) |
1824 | { | 1824 | { |
1825 | #ifndef QT_NO_SOUND | 1825 | #ifndef QT_NO_SOUND |
1826 | QString soundname; | 1826 | QString soundname; |
1827 | 1827 | ||
1828 | // Not all devices have real sound | 1828 | // Not all devices have real sound |
1829 | if ( d->m_model == Model_Zaurus_SLC7x0 | 1829 | if ( d->m_model == Model_Zaurus_SLC7x0 |
1830 | || d->m_model == Model_Zaurus_SLB600 ){ | 1830 | || d->m_model == Model_Zaurus_SLB600 ){ |
1831 | 1831 | ||
1832 | switch ( sound ){ | 1832 | switch ( sound ){ |
1833 | case SHARP_BUZ_SCHEDULE_ALARM: | 1833 | case SHARP_BUZ_SCHEDULE_ALARM: |
1834 | soundname = "alarm"; | 1834 | soundname = "alarm"; |
1835 | break; | 1835 | break; |
1836 | case SHARP_BUZ_TOUCHSOUND: | 1836 | case SHARP_BUZ_TOUCHSOUND: |
1837 | soundname = "touchsound"; | 1837 | soundname = "touchsound"; |
1838 | break; | 1838 | break; |
1839 | case SHARP_BUZ_KEYSOUND: | 1839 | case SHARP_BUZ_KEYSOUND: |
1840 | soundname = "keysound"; | 1840 | soundname = "keysound"; |
1841 | break; | 1841 | break; |
1842 | default: | 1842 | default: |
1843 | soundname = "alarm"; | 1843 | soundname = "alarm"; |
1844 | 1844 | ||
1845 | } | 1845 | } |
1846 | } | 1846 | } |
1847 | 1847 | ||
1848 | // If a soundname is defined, we expect that this device has | 1848 | // If a soundname is defined, we expect that this device has |
1849 | // sound capabilities.. Otherwise we expect to have the buzzer | 1849 | // sound capabilities.. Otherwise we expect to have the buzzer |
1850 | // device.. | 1850 | // device.. |
1851 | if ( !soundname.isEmpty() ){ | 1851 | if ( !soundname.isEmpty() ){ |
1852 | int fd; | 1852 | int fd; |
1853 | int vol; | 1853 | int vol; |
1854 | bool vol_reset = false; | 1854 | bool vol_reset = false; |
1855 | 1855 | ||
1856 | Sound snd ( soundname ); | 1856 | Sound snd ( soundname ); |
1857 | 1857 | ||
1858 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1858 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1859 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1859 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1860 | Config cfg ( "qpe" ); | 1860 | Config cfg ( "qpe" ); |
1861 | cfg. setGroup ( "Volume" ); | 1861 | cfg. setGroup ( "Volume" ); |
1862 | 1862 | ||
1863 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1863 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1864 | if ( volalarm < 0 ) | 1864 | if ( volalarm < 0 ) |
1865 | volalarm = 0; | 1865 | volalarm = 0; |
1866 | else if ( volalarm > 100 ) | 1866 | else if ( volalarm > 100 ) |
1867 | volalarm = 100; | 1867 | volalarm = 100; |
1868 | volalarm |= ( volalarm << 8 ); | 1868 | volalarm |= ( volalarm << 8 ); |
1869 | 1869 | ||
1870 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1870 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1871 | vol_reset = true; | 1871 | vol_reset = true; |
1872 | } | 1872 | } |
1873 | } | 1873 | } |
1874 | 1874 | ||
1875 | snd. play ( ); | 1875 | snd. play ( ); |
1876 | while ( !snd. isFinished ( )) | 1876 | while ( !snd. isFinished ( )) |
1877 | qApp-> processEvents ( ); | 1877 | qApp-> processEvents ( ); |
1878 | 1878 | ||
1879 | if ( fd >= 0 ) { | 1879 | if ( fd >= 0 ) { |
@@ -2173,257 +2173,257 @@ OHingeStatus Zaurus::readHingeSensor() | |||
2173 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2173 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2174 | ::close (handle); | 2174 | ::close (handle); |
2175 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 2175 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
2176 | { | 2176 | { |
2177 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 2177 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
2178 | return static_cast<OHingeStatus>( retval ); | 2178 | return static_cast<OHingeStatus>( retval ); |
2179 | } | 2179 | } |
2180 | else | 2180 | else |
2181 | { | 2181 | { |
2182 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 2182 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
2183 | return CASE_UNKNOWN; | 2183 | return CASE_UNKNOWN; |
2184 | } | 2184 | } |
2185 | } | 2185 | } |
2186 | } | 2186 | } |
2187 | 2187 | ||
2188 | 2188 | ||
2189 | void Zaurus::virtual_hook( int id, void *data ) { | 2189 | void Zaurus::virtual_hook( int id, void *data ) { |
2190 | switch( id ) { | 2190 | switch( id ) { |
2191 | case VIRTUAL_ROTATION:{ | 2191 | case VIRTUAL_ROTATION:{ |
2192 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); | 2192 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); |
2193 | rot->trans = rotation(); | 2193 | rot->trans = rotation(); |
2194 | break; | 2194 | break; |
2195 | } | 2195 | } |
2196 | case VIRTUAL_DIRECTION:{ | 2196 | case VIRTUAL_DIRECTION:{ |
2197 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); | 2197 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); |
2198 | dir->direct = direction(); | 2198 | dir->direct = direction(); |
2199 | break; | 2199 | break; |
2200 | } | 2200 | } |
2201 | case VIRTUAL_HAS_HINGE:{ | 2201 | case VIRTUAL_HAS_HINGE:{ |
2202 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); | 2202 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); |
2203 | hin->hasHinge = hasHingeSensor(); | 2203 | hin->hasHinge = hasHingeSensor(); |
2204 | break; | 2204 | break; |
2205 | } | 2205 | } |
2206 | case VIRTUAL_HINGE:{ | 2206 | case VIRTUAL_HINGE:{ |
2207 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); | 2207 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); |
2208 | hin->hingeStat = readHingeSensor(); | 2208 | hin->hingeStat = readHingeSensor(); |
2209 | break; | 2209 | break; |
2210 | } | 2210 | } |
2211 | default: | 2211 | default: |
2212 | ODevice::virtual_hook( id, data ); | 2212 | ODevice::virtual_hook( id, data ); |
2213 | break; | 2213 | break; |
2214 | } | 2214 | } |
2215 | } | 2215 | } |
2216 | 2216 | ||
2217 | /************************************************** | 2217 | /************************************************** |
2218 | * | 2218 | * |
2219 | * SIMpad | 2219 | * SIMpad |
2220 | * | 2220 | * |
2221 | **************************************************/ | 2221 | **************************************************/ |
2222 | 2222 | ||
2223 | void SIMpad::init ( ) | 2223 | void SIMpad::init ( ) |
2224 | { | 2224 | { |
2225 | d-> m_vendorstr = "SIEMENS"; | 2225 | d-> m_vendorstr = "SIEMENS"; |
2226 | d-> m_vendor = Vendor_SIEMENS; | 2226 | d-> m_vendor = Vendor_SIEMENS; |
2227 | 2227 | ||
2228 | QFile f ( "/proc/hal/model" ); | 2228 | QFile f ( "/proc/hal/model" ); |
2229 | 2229 | ||
2230 | //TODO Implement model checking | 2230 | //TODO Implement model checking |
2231 | //FIXME For now we assume an SL4 | 2231 | //FIXME For now we assume an SL4 |
2232 | 2232 | ||
2233 | d-> m_modelstr = "SL4"; | 2233 | d-> m_modelstr = "SL4"; |
2234 | d-> m_model = Model_SIMpad_SL4; | 2234 | d-> m_model = Model_SIMpad_SL4; |
2235 | 2235 | ||
2236 | switch ( d-> m_model ) { | 2236 | switch ( d-> m_model ) { |
2237 | default: | 2237 | default: |
2238 | d-> m_rotation = Rot0; | 2238 | d-> m_rotation = Rot0; |
2239 | d-> m_direction = CCW; | 2239 | d-> m_direction = CCW; |
2240 | d-> m_holdtime = 1000; // 1000ms | 2240 | d-> m_holdtime = 1000; // 1000ms |
2241 | 2241 | ||
2242 | break; | 2242 | break; |
2243 | } | 2243 | } |
2244 | 2244 | ||
2245 | f. setName ( "/etc/familiar-version" ); | 2245 | f. setName ( "/etc/familiar-version" ); |
2246 | if ( f. open ( IO_ReadOnly )) { | 2246 | if ( f. open ( IO_ReadOnly )) { |
2247 | d-> m_systemstr = "Familiar"; | 2247 | d-> m_systemstr = "Familiar"; |
2248 | d-> m_system = System_Familiar; | 2248 | d-> m_system = System_Familiar; |
2249 | 2249 | ||
2250 | QTextStream ts ( &f ); | 2250 | QTextStream ts ( &f ); |
2251 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2251 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2252 | 2252 | ||
2253 | f. close ( ); | 2253 | f. close ( ); |
2254 | } else { | 2254 | } else { |
2255 | f. setName ( "/etc/oz_version" ); | 2255 | f. setName ( "/etc/oz_version" ); |
2256 | 2256 | ||
2257 | if ( f. open ( IO_ReadOnly )) { | 2257 | if ( f. open ( IO_ReadOnly )) { |
2258 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 2258 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
2259 | d-> m_system = System_OpenZaurus; | 2259 | d-> m_system = System_OpenZaurus; |
2260 | 2260 | ||
2261 | QTextStream ts ( &f ); | 2261 | QTextStream ts ( &f ); |
2262 | ts.setDevice ( &f ); | 2262 | ts.setDevice ( &f ); |
2263 | d-> m_sysverstr = ts. readLine ( ); | 2263 | d-> m_sysverstr = ts. readLine ( ); |
2264 | f. close ( ); | 2264 | f. close ( ); |
2265 | } | 2265 | } |
2266 | } | 2266 | } |
2267 | 2267 | ||
2268 | m_leds [0] = m_leds [1] = Led_Off; | 2268 | m_leds [0] = m_leds [1] = Led_Off; |
2269 | 2269 | ||
2270 | m_power_timer = 0; | 2270 | m_power_timer = 0; |
2271 | 2271 | ||
2272 | } | 2272 | } |
2273 | 2273 | ||
2274 | void SIMpad::initButtons ( ) | 2274 | void SIMpad::initButtons ( ) |
2275 | { | 2275 | { |
2276 | if ( d-> m_buttons ) | 2276 | if ( d-> m_buttons ) |
2277 | return; | 2277 | return; |
2278 | 2278 | ||
2279 | if ( isQWS( ) ) | 2279 | if ( isQWS( ) ) |
2280 | QWSServer::setKeyboardFilter ( this ); | 2280 | QWSServer::setKeyboardFilter ( this ); |
2281 | 2281 | ||
2282 | d-> m_buttons = new QValueList <ODeviceButton>; | 2282 | d-> m_buttons = new QValueList <ODeviceButton>; |
2283 | 2283 | ||
2284 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 2284 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
2285 | s_button *sb = simpad_buttons + i; | 2285 | s_button *sb = simpad_buttons + i; |
2286 | ODeviceButton b; | 2286 | ODeviceButton b; |
2287 | 2287 | ||
2288 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 2288 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
2289 | b. setKeycode ( sb-> code ); | 2289 | b. setKeycode ( sb-> code ); |
2290 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 2290 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
2291 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 2291 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
2292 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 2292 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
2293 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 2293 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
2294 | 2294 | ||
2295 | d-> m_buttons-> append ( b ); | 2295 | d-> m_buttons-> append ( b ); |
2296 | } | 2296 | } |
2297 | } | 2297 | } |
2298 | reloadButtonMapping ( ); | 2298 | reloadButtonMapping ( ); |
2299 | 2299 | ||
2300 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2300 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2301 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2301 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
2302 | } | 2302 | } |
2303 | 2303 | ||
2304 | // SIMpad boardcontrol register CS3 | 2304 | // SIMpad boardcontrol register CS3 |
2305 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 2305 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
2306 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 2306 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
2307 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 2307 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
2308 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 2308 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
2309 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 2309 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
2310 | #define SIMPAD_DISPLAY_ON 0x0010 | 2310 | #define SIMPAD_DISPLAY_ON 0x0010 |
2311 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 2311 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
2312 | #define SIMPAD_MQ_RESET 0x0040 | 2312 | #define SIMPAD_MQ_RESET 0x0040 |
2313 | #define SIMPAD_PCMCIA_RESET 0x0080 | 2313 | #define SIMPAD_PCMCIA_RESET 0x0080 |
2314 | #define SIMPAD_DECT_POWER_ON 0x0100 | 2314 | #define SIMPAD_DECT_POWER_ON 0x0100 |
2315 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 2315 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
2316 | #define SIMPAD_RS232_ON 0x0400 | 2316 | #define SIMPAD_RS232_ON 0x0400 |
2317 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 2317 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
2318 | #define SIMPAD_LED2_ON 0x1000 | 2318 | #define SIMPAD_LED2_ON 0x1000 |
2319 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 2319 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
2320 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 2320 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
2321 | #define SIMPAD_RESET_SIMCARD 0x8000 | 2321 | #define SIMPAD_RESET_SIMCARD 0x8000 |
2322 | 2322 | ||
2323 | //SIMpad touchscreen backlight strength control | 2323 | //SIMpad touchscreen backlight strength control |
2324 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 2324 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
2325 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 2325 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
2326 | 2326 | ||
2327 | QValueList <OLed> SIMpad::ledList ( ) const | 2327 | QValueList <OLed> SIMpad::ledList ( ) const |
2328 | { | 2328 | { |
2329 | QValueList <OLed> vl; | 2329 | QValueList <OLed> vl; |
2330 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 2330 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
2331 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 2331 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
2332 | return vl; | 2332 | return vl; |
2333 | } | 2333 | } |
2334 | 2334 | ||
2335 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 2335 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
2336 | { | 2336 | { |
2337 | QValueList <OLedState> vl; | 2337 | QValueList <OLedState> vl; |
2338 | 2338 | ||
2339 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 2339 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
2340 | vl << Led_Off << Led_On; | 2340 | vl << Led_Off << Led_On; |
2341 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 2341 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
2342 | //vl << Led_Off; | 2342 | //vl << Led_Off; |
2343 | return vl; | 2343 | return vl; |
2344 | } | 2344 | } |
2345 | 2345 | ||
2346 | OLedState SIMpad::ledState ( OLed l ) const | 2346 | OLedState SIMpad::ledState ( OLed l ) const |
2347 | { | 2347 | { |
2348 | switch ( l ) { | 2348 | switch ( l ) { |
2349 | case Led_Power: | 2349 | case Led_Power: |
2350 | return m_leds [0]; | 2350 | return m_leds [0]; |
2351 | //case Led_Mail: | 2351 | //case Led_Mail: |
2352 | //return m_leds [1]; | 2352 | //return m_leds [1]; |
2353 | default: | 2353 | default: |
2354 | return Led_Off; | 2354 | return Led_Off; |
2355 | } | 2355 | } |
2356 | } | 2356 | } |
2357 | 2357 | ||
2358 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 2358 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
2359 | { | 2359 | { |
2360 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 2360 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
2361 | 2361 | ||
2362 | if ( l == Led_Power ) { | 2362 | if ( l == Led_Power ) { |
2363 | if ( fd >= 0 ) { | 2363 | if ( fd >= 0 ) { |
2364 | LED_IN leds; | 2364 | LED_IN leds; |
2365 | ::memset ( &leds, 0, sizeof( leds )); | 2365 | ::memset ( &leds, 0, sizeof( leds )); |
2366 | leds. TotalTime = 0; | 2366 | leds. TotalTime = 0; |
2367 | leds. OnTime = 0; | 2367 | leds. OnTime = 0; |
2368 | leds. OffTime = 1; | 2368 | leds. OffTime = 1; |
2369 | leds. OffOnBlink = 2; | 2369 | leds. OffOnBlink = 2; |
2370 | 2370 | ||
2371 | switch ( st ) { | 2371 | switch ( st ) { |
2372 | case Led_Off : leds. OffOnBlink = 0; break; | 2372 | case Led_Off : leds. OffOnBlink = 0; break; |
2373 | case Led_On : leds. OffOnBlink = 1; break; | 2373 | case Led_On : leds. OffOnBlink = 1; break; |
2374 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 2374 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
2375 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 2375 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
2376 | } | 2376 | } |
2377 | 2377 | ||
2378 | { | 2378 | { |
2379 | /*TODO Implement this like that: | 2379 | /*TODO Implement this like that: |
2380 | read from cs3 | 2380 | read from cs3 |
2381 | && with SIMPAD_LED2_ON | 2381 | && with SIMPAD_LED2_ON |
2382 | write to cs3 */ | 2382 | write to cs3 */ |
2383 | m_leds [0] = st; | 2383 | m_leds [0] = st; |
2384 | return true; | 2384 | return true; |
2385 | } | 2385 | } |
2386 | } | 2386 | } |
2387 | } | 2387 | } |
2388 | return false; | 2388 | return false; |
2389 | } | 2389 | } |
2390 | 2390 | ||
2391 | 2391 | ||
2392 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 2392 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
2393 | { | 2393 | { |
2394 | //TODO | 2394 | //TODO |
2395 | return false; | 2395 | return false; |
2396 | } | 2396 | } |
2397 | 2397 | ||
2398 | void SIMpad::timerEvent ( QTimerEvent * ) | 2398 | void SIMpad::timerEvent ( QTimerEvent * ) |
2399 | { | 2399 | { |
2400 | killTimer ( m_power_timer ); | 2400 | killTimer ( m_power_timer ); |
2401 | m_power_timer = 0; | 2401 | m_power_timer = 0; |
2402 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 2402 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
2403 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 2403 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
2404 | } | 2404 | } |
2405 | 2405 | ||
2406 | 2406 | ||
2407 | void SIMpad::alarmSound ( ) | 2407 | void SIMpad::alarmSound ( ) |
2408 | { | 2408 | { |
2409 | #ifndef QT_NO_SOUND | 2409 | #ifndef QT_NO_SOUND |
2410 | static Sound snd ( "alarm" ); | 2410 | static Sound snd ( "alarm" ); |
2411 | int fd; | 2411 | int fd; |
2412 | int vol; | 2412 | int vol; |
2413 | bool vol_reset = false; | 2413 | bool vol_reset = false; |
2414 | 2414 | ||
2415 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 2415 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
2416 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 2416 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
2417 | Config cfg ( "qpe" ); | 2417 | Config cfg ( "qpe" ); |
2418 | cfg. setGroup ( "Volume" ); | 2418 | cfg. setGroup ( "Volume" ); |
2419 | 2419 | ||
2420 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 2420 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
2421 | if ( volalarm < 0 ) | 2421 | if ( volalarm < 0 ) |
2422 | volalarm = 0; | 2422 | volalarm = 0; |
2423 | else if ( volalarm > 100 ) | 2423 | else if ( volalarm > 100 ) |
2424 | volalarm = 100; | 2424 | volalarm = 100; |
2425 | volalarm |= ( volalarm << 8 ); | 2425 | volalarm |= ( volalarm << 8 ); |
2426 | 2426 | ||
2427 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 2427 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
2428 | vol_reset = true; | 2428 | vol_reset = true; |
2429 | } | 2429 | } |
@@ -2673,174 +2673,174 @@ bool Ramses::setDisplayBrightness(int bright) | |||
2673 | ::close(fd); | 2673 | ::close(fd); |
2674 | } | 2674 | } |
2675 | 2675 | ||
2676 | // scale backlight brightness to hardware | 2676 | // scale backlight brightness to hardware |
2677 | bright = 500-(bright * 500 / 255); | 2677 | bright = 500-(bright * 500 / 255); |
2678 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2678 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2679 | qDebug(" %d -> pwm1", bright); | 2679 | qDebug(" %d -> pwm1", bright); |
2680 | char writeCommand[100]; | 2680 | char writeCommand[100]; |
2681 | const int count = sprintf(writeCommand, "%d\n", bright); | 2681 | const int count = sprintf(writeCommand, "%d\n", bright); |
2682 | res = (::write(fd, writeCommand, count) != -1); | 2682 | res = (::write(fd, writeCommand, count) != -1); |
2683 | ::close(fd); | 2683 | ::close(fd); |
2684 | } | 2684 | } |
2685 | return res; | 2685 | return res; |
2686 | } | 2686 | } |
2687 | 2687 | ||
2688 | 2688 | ||
2689 | int Ramses::displayBrightnessResolution() const | 2689 | int Ramses::displayBrightnessResolution() const |
2690 | { | 2690 | { |
2691 | return 32; | 2691 | return 32; |
2692 | } | 2692 | } |
2693 | 2693 | ||
2694 | bool Ramses::setDisplayContrast(int contr) | 2694 | bool Ramses::setDisplayContrast(int contr) |
2695 | { | 2695 | { |
2696 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2696 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2697 | bool res = false; | 2697 | bool res = false; |
2698 | int fd; | 2698 | int fd; |
2699 | 2699 | ||
2700 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2700 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2701 | 2701 | ||
2702 | if (contr > 255 ) | 2702 | if (contr > 255 ) |
2703 | contr = 255; | 2703 | contr = 255; |
2704 | if (contr < 0) | 2704 | if (contr < 0) |
2705 | contr = 0; | 2705 | contr = 0; |
2706 | contr = 90 - (contr * 20 / 255); | 2706 | contr = 90 - (contr * 20 / 255); |
2707 | 2707 | ||
2708 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2708 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2709 | qDebug(" %d -> pwm0", contr); | 2709 | qDebug(" %d -> pwm0", contr); |
2710 | char writeCommand[100]; | 2710 | char writeCommand[100]; |
2711 | const int count = sprintf(writeCommand, "%d\n", contr); | 2711 | const int count = sprintf(writeCommand, "%d\n", contr); |
2712 | res = (::write(fd, writeCommand, count) != -1); | 2712 | res = (::write(fd, writeCommand, count) != -1); |
2713 | res = true; | 2713 | res = true; |
2714 | ::close(fd); | 2714 | ::close(fd); |
2715 | } | 2715 | } |
2716 | return res; | 2716 | return res; |
2717 | } | 2717 | } |
2718 | 2718 | ||
2719 | 2719 | ||
2720 | int Ramses::displayContrastResolution() const | 2720 | int Ramses::displayContrastResolution() const |
2721 | { | 2721 | { |
2722 | return 20; | 2722 | return 20; |
2723 | } | 2723 | } |
2724 | 2724 | ||
2725 | 2725 | ||
2726 | /************************************************** | 2726 | /************************************************** |
2727 | * * | 2727 | * * |
2728 | * Jornada * | 2728 | * Jornada * |
2729 | * * | 2729 | * * |
2730 | **************************************************/ | 2730 | **************************************************/ |
2731 | 2731 | ||
2732 | 2732 | ||
2733 | bool Jornada::isJornada ( ) | 2733 | bool Jornada::isJornada ( ) |
2734 | { | 2734 | { |
2735 | QFile f( "/proc/cpuinfo" ); | 2735 | QFile f( "/proc/cpuinfo" ); |
2736 | if ( f. open ( IO_ReadOnly ) ) { | 2736 | if ( f. open ( IO_ReadOnly ) ) { |
2737 | QTextStream ts ( &f ); | 2737 | QTextStream ts ( &f ); |
2738 | QString line; | 2738 | QString line; |
2739 | while( line = ts. readLine ( ) ) { | 2739 | while( line = ts. readLine ( ) ) { |
2740 | if ( line. left ( 8 ) == "Hardware" ) { | 2740 | if ( line. left ( 8 ) == "Hardware" ) { |
2741 | int loc = line. find ( ":" ); | 2741 | int loc = line. find ( ":" ); |
2742 | if ( loc != -1 ) { | 2742 | if ( loc != -1 ) { |
2743 | QString model = | 2743 | QString model = |
2744 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 2744 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
2745 | return ( model == "HP Jornada 56x" ); | 2745 | return ( model == "HP Jornada 56x" ); |
2746 | } | 2746 | } |
2747 | } | 2747 | } |
2748 | } | 2748 | } |
2749 | } | 2749 | } |
2750 | return false; | 2750 | return false; |
2751 | } | 2751 | } |
2752 | 2752 | ||
2753 | void Jornada::init ( ) | 2753 | void Jornada::init ( ) |
2754 | { | 2754 | { |
2755 | d-> m_vendorstr = "HP"; | 2755 | d-> m_vendorstr = "HP"; |
2756 | d-> m_vendor = Vendor_HP; | 2756 | d-> m_vendor = Vendor_HP; |
2757 | d-> m_modelstr = "Jornada 56x"; | 2757 | d-> m_modelstr = "Jornada 56x"; |
2758 | d-> m_model = Model_Jornada_56x; | 2758 | d-> m_model = Model_Jornada_56x; |
2759 | d-> m_systemstr = "Familiar"; | 2759 | d-> m_systemstr = "Familiar"; |
2760 | d-> m_system = System_Familiar; | 2760 | d-> m_system = System_Familiar; |
2761 | d-> m_rotation = Rot0; | 2761 | d-> m_rotation = Rot0; |
2762 | 2762 | ||
2763 | QFile f ( "/etc/familiar-version" ); | 2763 | QFile f ( "/etc/familiar-version" ); |
2764 | f. setName ( "/etc/familiar-version" ); | 2764 | f. setName ( "/etc/familiar-version" ); |
2765 | if ( f. open ( IO_ReadOnly )) { | 2765 | if ( f. open ( IO_ReadOnly )) { |
2766 | 2766 | ||
2767 | QTextStream ts ( &f ); | 2767 | QTextStream ts ( &f ); |
2768 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2768 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2769 | 2769 | ||
2770 | f. close ( ); | 2770 | f. close ( ); |
2771 | } | 2771 | } |
2772 | } | 2772 | } |
2773 | 2773 | ||
2774 | #if 0 | 2774 | #if 0 |
2775 | void Jornada::initButtons ( ) | 2775 | void Jornada::initButtons ( ) |
2776 | { | 2776 | { |
2777 | if ( d-> m_buttons ) | 2777 | if ( d-> m_buttons ) |
2778 | return; | 2778 | return; |
2779 | 2779 | ||
2780 | // Simulation uses iPAQ 3660 device buttons | 2780 | // Simulation uses iPAQ 3660 device buttons |
2781 | 2781 | ||
2782 | qDebug ( "init Buttons" ); | 2782 | qDebug ( "init Buttons" ); |
2783 | d-> m_buttons = new QValueList <ODeviceButton>; | 2783 | d-> m_buttons = new QValueList <ODeviceButton>; |
2784 | 2784 | ||
2785 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 2785 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
2786 | i_button *ib = ipaq_buttons + i; | 2786 | i_button *ib = ipaq_buttons + i; |
2787 | ODeviceButton b; | 2787 | ODeviceButton b; |
2788 | 2788 | ||
2789 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 2789 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
2790 | b. setKeycode ( ib-> code ); | 2790 | b. setKeycode ( ib-> code ); |
2791 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 2791 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
2792 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 2792 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
2793 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 2793 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
2794 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 2794 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
2795 | d-> m_buttons-> append ( b ); | 2795 | d-> m_buttons-> append ( b ); |
2796 | } | 2796 | } |
2797 | } | 2797 | } |
2798 | reloadButtonMapping ( ); | 2798 | reloadButtonMapping ( ); |
2799 | 2799 | ||
2800 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2800 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2801 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2801 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
2802 | } | 2802 | } |
2803 | #endif | 2803 | #endif |
2804 | int Jornada::displayBrightnessResolution ( ) const | 2804 | int Jornada::displayBrightnessResolution ( ) const |
2805 | { | 2805 | { |
2806 | } | 2806 | } |
2807 | 2807 | ||
2808 | bool Jornada::setDisplayBrightness ( int bright ) | 2808 | bool Jornada::setDisplayBrightness ( int bright ) |
2809 | { | 2809 | { |
2810 | bool res = false; | 2810 | bool res = false; |
2811 | int fd; | 2811 | int fd; |
2812 | 2812 | ||
2813 | if ( bright > 255 ) | 2813 | if ( bright > 255 ) |
2814 | bright = 255; | 2814 | bright = 255; |
2815 | if ( bright < 0 ) | 2815 | if ( bright < 0 ) |
2816 | bright = 0; | 2816 | bright = 0; |
2817 | 2817 | ||
2818 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 2818 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
2819 | FLITE_IN bl; | 2819 | FLITE_IN bl; |
2820 | bl. mode = 1; | 2820 | bl. mode = 1; |
2821 | bl. pwr = bright ? 1 : 0; | 2821 | bl. pwr = bright ? 1 : 0; |
2822 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 2822 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
2823 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 2823 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
2824 | ::close ( fd ); | 2824 | ::close ( fd ); |
2825 | } | 2825 | } |
2826 | return res; | 2826 | return res; |
2827 | } | 2827 | } |
2828 | 2828 | ||
2829 | bool Jornada::setSoftSuspend ( bool soft ) | 2829 | bool Jornada::setSoftSuspend ( bool soft ) |
2830 | { | 2830 | { |
2831 | bool res = false; | 2831 | bool res = false; |
2832 | int fd; | 2832 | int fd; |
2833 | 2833 | ||
2834 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 2834 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
2835 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 2835 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
2836 | res = true; | 2836 | res = true; |
2837 | else | 2837 | else |
2838 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 2838 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
2839 | 2839 | ||
2840 | ::close ( fd ); | 2840 | ::close ( fd ); |
2841 | } | 2841 | } |
2842 | else | 2842 | else |
2843 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 2843 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
2844 | 2844 | ||
2845 | return res; | 2845 | return res; |
2846 | } | 2846 | } |