-rw-r--r-- | libopie/odevice.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 71ed9e4..9373ef9 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -472,2132 +472,2149 @@ ODevice::ODevice ( ) | |||
472 | d-> m_model = Model_Unknown; | 472 | d-> m_model = Model_Unknown; |
473 | d-> m_vendorstr = "Unknown"; | 473 | d-> m_vendorstr = "Unknown"; |
474 | d-> m_vendor = Vendor_Unknown; | 474 | d-> m_vendor = Vendor_Unknown; |
475 | d-> m_systemstr = "Unknown"; | 475 | d-> m_systemstr = "Unknown"; |
476 | d-> m_system = System_Unknown; | 476 | d-> m_system = System_Unknown; |
477 | d-> m_sysverstr = "0.0"; | 477 | d-> m_sysverstr = "0.0"; |
478 | d-> m_rotation = Rot0; | 478 | d-> m_rotation = Rot0; |
479 | d-> m_direction = CW; | 479 | d-> m_direction = CW; |
480 | 480 | ||
481 | d-> m_holdtime = 1000; // 1000ms | 481 | d-> m_holdtime = 1000; // 1000ms |
482 | d-> m_buttons = 0; | 482 | d-> m_buttons = 0; |
483 | d-> m_cpu_frequencies = new QStrList; | 483 | d-> m_cpu_frequencies = new QStrList; |
484 | } | 484 | } |
485 | 485 | ||
486 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 486 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
487 | { | 487 | { |
488 | if ( msg == "deviceButtonMappingChanged()" ) { | 488 | if ( msg == "deviceButtonMappingChanged()" ) { |
489 | reloadButtonMapping ( ); | 489 | reloadButtonMapping ( ); |
490 | } | 490 | } |
491 | } | 491 | } |
492 | 492 | ||
493 | void ODevice::init ( ) | 493 | void ODevice::init ( ) |
494 | { | 494 | { |
495 | } | 495 | } |
496 | 496 | ||
497 | /** | 497 | /** |
498 | * This method initialises the button mapping | 498 | * This method initialises the button mapping |
499 | */ | 499 | */ |
500 | void ODevice::initButtons ( ) | 500 | void ODevice::initButtons ( ) |
501 | { | 501 | { |
502 | if ( d-> m_buttons ) | 502 | if ( d-> m_buttons ) |
503 | return; | 503 | return; |
504 | 504 | ||
505 | // Simulation uses iPAQ 3660 device buttons | 505 | // Simulation uses iPAQ 3660 device buttons |
506 | 506 | ||
507 | qDebug ( "init Buttons" ); | 507 | qDebug ( "init Buttons" ); |
508 | d-> m_buttons = new QValueList <ODeviceButton>; | 508 | d-> m_buttons = new QValueList <ODeviceButton>; |
509 | 509 | ||
510 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 510 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
511 | i_button *ib = ipaq_buttons + i; | 511 | i_button *ib = ipaq_buttons + i; |
512 | ODeviceButton b; | 512 | ODeviceButton b; |
513 | 513 | ||
514 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 514 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
515 | b. setKeycode ( ib-> code ); | 515 | b. setKeycode ( ib-> code ); |
516 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 516 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
517 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 517 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
518 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 518 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
519 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 519 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
520 | d-> m_buttons-> append ( b ); | 520 | d-> m_buttons-> append ( b ); |
521 | } | 521 | } |
522 | } | 522 | } |
523 | reloadButtonMapping ( ); | 523 | reloadButtonMapping ( ); |
524 | 524 | ||
525 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 525 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
526 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 526 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
527 | } | 527 | } |
528 | 528 | ||
529 | ODevice::~ODevice ( ) | 529 | ODevice::~ODevice ( ) |
530 | { | 530 | { |
531 | // we leak m_devicebuttons and m_cpu_frequency | 531 | // we leak m_devicebuttons and m_cpu_frequency |
532 | // but it's a singleton and it is not so importantant | 532 | // but it's a singleton and it is not so importantant |
533 | // -zecke | 533 | // -zecke |
534 | delete d; | 534 | delete d; |
535 | } | 535 | } |
536 | 536 | ||
537 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 537 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
538 | { | 538 | { |
539 | return false; | 539 | return false; |
540 | } | 540 | } |
541 | 541 | ||
542 | //#include <linux/apm_bios.h> | 542 | //#include <linux/apm_bios.h> |
543 | 543 | ||
544 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 544 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
545 | 545 | ||
546 | /** | 546 | /** |
547 | * This method will try to suspend the device | 547 | * This method will try to suspend the device |
548 | * It only works if the user is the QWS Server and the apm application | 548 | * It only works if the user is the QWS Server and the apm application |
549 | * is installed. | 549 | * is installed. |
550 | * It tries to suspend and then waits some time cause some distributions | 550 | * It tries to suspend and then waits some time cause some distributions |
551 | * do have asynchronus apm implementations. | 551 | * do have asynchronus apm implementations. |
552 | * This method will either fail and return false or it'll suspend the | 552 | * This method will either fail and return false or it'll suspend the |
553 | * device and return once the device got woken up | 553 | * device and return once the device got woken up |
554 | * | 554 | * |
555 | * @return if the device got suspended | 555 | * @return if the device got suspended |
556 | */ | 556 | */ |
557 | bool ODevice::suspend ( ) | 557 | bool ODevice::suspend ( ) |
558 | { | 558 | { |
559 | qDebug("ODevice::suspend"); | 559 | qDebug("ODevice::suspend"); |
560 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 560 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
561 | return false; | 561 | return false; |
562 | 562 | ||
563 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 563 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
564 | return false; | 564 | return false; |
565 | 565 | ||
566 | bool res = false; | 566 | bool res = false; |
567 | 567 | ||
568 | struct timeval tvs, tvn; | 568 | struct timeval tvs, tvn; |
569 | ::gettimeofday ( &tvs, 0 ); | 569 | ::gettimeofday ( &tvs, 0 ); |
570 | 570 | ||
571 | ::sync ( ); // flush fs caches | 571 | ::sync ( ); // flush fs caches |
572 | res = ( ::system ( "apm --suspend" ) == 0 ); | 572 | res = ( ::system ( "apm --suspend" ) == 0 ); |
573 | 573 | ||
574 | // This is needed because the iPAQ apm implementation is asynchronous and we | 574 | // This is needed because the iPAQ apm implementation is asynchronous and we |
575 | // can not be sure when exactly the device is really suspended | 575 | // can not be sure when exactly the device is really suspended |
576 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 576 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
577 | 577 | ||
578 | if ( res ) { | 578 | if ( res ) { |
579 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 579 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
580 | ::usleep ( 200 * 1000 ); | 580 | ::usleep ( 200 * 1000 ); |
581 | ::gettimeofday ( &tvn, 0 ); | 581 | ::gettimeofday ( &tvn, 0 ); |
582 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 582 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
583 | } | 583 | } |
584 | 584 | ||
585 | return res; | 585 | return res; |
586 | } | 586 | } |
587 | 587 | ||
588 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 588 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
589 | 589 | ||
590 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 590 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
591 | 591 | ||
592 | /* VESA Blanking Levels */ | 592 | /* VESA Blanking Levels */ |
593 | #define VESA_NO_BLANKING 0 | 593 | #define VESA_NO_BLANKING 0 |
594 | #define VESA_VSYNC_SUSPEND 1 | 594 | #define VESA_VSYNC_SUSPEND 1 |
595 | #define VESA_HSYNC_SUSPEND 2 | 595 | #define VESA_HSYNC_SUSPEND 2 |
596 | #define VESA_POWERDOWN 3 | 596 | #define VESA_POWERDOWN 3 |
597 | 597 | ||
598 | /** | 598 | /** |
599 | * This sets the display on or off | 599 | * This sets the display on or off |
600 | */ | 600 | */ |
601 | bool ODevice::setDisplayStatus ( bool on ) | 601 | bool ODevice::setDisplayStatus ( bool on ) |
602 | { | 602 | { |
603 | qDebug("ODevice::setDisplayStatus(%d)", on); | 603 | qDebug("ODevice::setDisplayStatus(%d)", on); |
604 | 604 | ||
605 | if ( d-> m_model == Model_Unknown ) | 605 | if ( d-> m_model == Model_Unknown ) |
606 | return false; | 606 | return false; |
607 | 607 | ||
608 | bool res = false; | 608 | bool res = false; |
609 | int fd; | 609 | int fd; |
610 | 610 | ||
611 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 611 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
612 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 612 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
613 | ::close ( fd ); | 613 | ::close ( fd ); |
614 | } | 614 | } |
615 | return res; | 615 | return res; |
616 | } | 616 | } |
617 | 617 | ||
618 | /** | 618 | /** |
619 | * This sets the display brightness | 619 | * This sets the display brightness |
620 | * | 620 | * |
621 | * @param p The brightness to be set on a scale from 0 to 255 | 621 | * @param p The brightness to be set on a scale from 0 to 255 |
622 | * @return success or failure | 622 | * @return success or failure |
623 | */ | 623 | */ |
624 | bool ODevice::setDisplayBrightness ( int p) | 624 | bool ODevice::setDisplayBrightness ( int p) |
625 | { | 625 | { |
626 | Q_UNUSED( p ) | 626 | Q_UNUSED( p ) |
627 | return false; | 627 | return false; |
628 | } | 628 | } |
629 | 629 | ||
630 | /** | 630 | /** |
631 | * @return returns the number of steppings on the brightness slider | 631 | * @return returns the number of steppings on the brightness slider |
632 | * in the Light-'n-Power settings. | 632 | * in the Light-'n-Power settings. |
633 | */ | 633 | */ |
634 | int ODevice::displayBrightnessResolution ( ) const | 634 | int ODevice::displayBrightnessResolution ( ) const |
635 | { | 635 | { |
636 | return 16; | 636 | return 16; |
637 | } | 637 | } |
638 | 638 | ||
639 | /** | 639 | /** |
640 | * This sets the display contrast | 640 | * This sets the display contrast |
641 | * @param p The contrast to be set on a scale from 0 to 255 | 641 | * @param p The contrast to be set on a scale from 0 to 255 |
642 | * @return success or failure | 642 | * @return success or failure |
643 | */ | 643 | */ |
644 | bool ODevice::setDisplayContrast ( int p) | 644 | bool ODevice::setDisplayContrast ( int p) |
645 | { | 645 | { |
646 | Q_UNUSED( p ) | 646 | Q_UNUSED( p ) |
647 | return false; | 647 | return false; |
648 | } | 648 | } |
649 | 649 | ||
650 | /** | 650 | /** |
651 | * @return return the max value for the brightness settings slider | 651 | * @return return the max value for the brightness settings slider |
652 | * or 0 if the device doesn't support setting of a contrast | 652 | * or 0 if the device doesn't support setting of a contrast |
653 | */ | 653 | */ |
654 | int ODevice::displayContrastResolution ( ) const | 654 | int ODevice::displayContrastResolution ( ) const |
655 | { | 655 | { |
656 | return 0; | 656 | return 0; |
657 | } | 657 | } |
658 | 658 | ||
659 | /** | 659 | /** |
660 | * This returns the vendor as string | 660 | * This returns the vendor as string |
661 | * @return Vendor as QString | 661 | * @return Vendor as QString |
662 | */ | 662 | */ |
663 | QString ODevice::vendorString ( ) const | 663 | QString ODevice::vendorString ( ) const |
664 | { | 664 | { |
665 | return d-> m_vendorstr; | 665 | return d-> m_vendorstr; |
666 | } | 666 | } |
667 | 667 | ||
668 | /** | 668 | /** |
669 | * This returns the vendor as one of the values of OVendor | 669 | * This returns the vendor as one of the values of OVendor |
670 | * @return OVendor | 670 | * @return OVendor |
671 | */ | 671 | */ |
672 | OVendor ODevice::vendor ( ) const | 672 | OVendor ODevice::vendor ( ) const |
673 | { | 673 | { |
674 | return d-> m_vendor; | 674 | return d-> m_vendor; |
675 | } | 675 | } |
676 | 676 | ||
677 | /** | 677 | /** |
678 | * This returns the model as a string | 678 | * This returns the model as a string |
679 | * @return A string representing the model | 679 | * @return A string representing the model |
680 | */ | 680 | */ |
681 | QString ODevice::modelString ( ) const | 681 | QString ODevice::modelString ( ) const |
682 | { | 682 | { |
683 | return d-> m_modelstr; | 683 | return d-> m_modelstr; |
684 | } | 684 | } |
685 | 685 | ||
686 | /** | 686 | /** |
687 | * This does return the OModel used | 687 | * This does return the OModel used |
688 | */ | 688 | */ |
689 | OModel ODevice::model ( ) const | 689 | OModel ODevice::model ( ) const |
690 | { | 690 | { |
691 | return d-> m_model; | 691 | return d-> m_model; |
692 | } | 692 | } |
693 | 693 | ||
694 | /** | 694 | /** |
695 | * This does return the systen name | 695 | * This does return the systen name |
696 | */ | 696 | */ |
697 | QString ODevice::systemString ( ) const | 697 | QString ODevice::systemString ( ) const |
698 | { | 698 | { |
699 | return d-> m_systemstr; | 699 | return d-> m_systemstr; |
700 | } | 700 | } |
701 | 701 | ||
702 | /** | 702 | /** |
703 | * Return System as OSystem value | 703 | * Return System as OSystem value |
704 | */ | 704 | */ |
705 | OSystem ODevice::system ( ) const | 705 | OSystem ODevice::system ( ) const |
706 | { | 706 | { |
707 | return d-> m_system; | 707 | return d-> m_system; |
708 | } | 708 | } |
709 | 709 | ||
710 | /** | 710 | /** |
711 | * @return the version string of the base system | 711 | * @return the version string of the base system |
712 | */ | 712 | */ |
713 | QString ODevice::systemVersionString ( ) const | 713 | QString ODevice::systemVersionString ( ) const |
714 | { | 714 | { |
715 | return d-> m_sysverstr; | 715 | return d-> m_sysverstr; |
716 | } | 716 | } |
717 | 717 | ||
718 | /** | 718 | /** |
719 | * @return the current Transformation | 719 | * @return the current Transformation |
720 | */ | 720 | */ |
721 | Transformation ODevice::rotation ( ) const | 721 | Transformation ODevice::rotation ( ) const |
722 | { | 722 | { |
723 | return d-> m_rotation; | 723 | return d-> m_rotation; |
724 | } | 724 | } |
725 | 725 | ||
726 | /** | 726 | /** |
727 | * @return the current rotation direction | 727 | * @return the current rotation direction |
728 | */ | 728 | */ |
729 | ODirection ODevice::direction ( ) const | 729 | ODirection ODevice::direction ( ) const |
730 | { | 730 | { |
731 | return d-> m_direction; | 731 | return d-> m_direction; |
732 | } | 732 | } |
733 | 733 | ||
734 | /** | 734 | /** |
735 | * This plays an alarmSound | 735 | * This plays an alarmSound |
736 | */ | 736 | */ |
737 | void ODevice::alarmSound ( ) | 737 | void ODevice::alarmSound ( ) |
738 | { | 738 | { |
739 | #ifndef QT_NO_SOUND | 739 | #ifndef QT_NO_SOUND |
740 | static Sound snd ( "alarm" ); | 740 | static Sound snd ( "alarm" ); |
741 | 741 | ||
742 | if ( snd. isFinished ( )) | 742 | if ( snd. isFinished ( )) |
743 | snd. play ( ); | 743 | snd. play ( ); |
744 | #endif | 744 | #endif |
745 | } | 745 | } |
746 | 746 | ||
747 | /** | 747 | /** |
748 | * This plays a key sound | 748 | * This plays a key sound |
749 | */ | 749 | */ |
750 | void ODevice::keySound ( ) | 750 | void ODevice::keySound ( ) |
751 | { | 751 | { |
752 | #ifndef QT_NO_SOUND | 752 | #ifndef QT_NO_SOUND |
753 | static Sound snd ( "keysound" ); | 753 | static Sound snd ( "keysound" ); |
754 | 754 | ||
755 | if ( snd. isFinished ( )) | 755 | if ( snd. isFinished ( )) |
756 | snd. play ( ); | 756 | snd. play ( ); |
757 | #endif | 757 | #endif |
758 | } | 758 | } |
759 | 759 | ||
760 | /** | 760 | /** |
761 | * This plays a touch sound | 761 | * This plays a touch sound |
762 | */ | 762 | */ |
763 | void ODevice::touchSound ( ) | 763 | void ODevice::touchSound ( ) |
764 | { | 764 | { |
765 | #ifndef QT_NO_SOUND | 765 | #ifndef QT_NO_SOUND |
766 | static Sound snd ( "touchsound" ); | 766 | static Sound snd ( "touchsound" ); |
767 | 767 | ||
768 | if ( snd. isFinished ( )) | 768 | if ( snd. isFinished ( )) |
769 | snd. play ( ); | 769 | snd. play ( ); |
770 | #endif | 770 | #endif |
771 | } | 771 | } |
772 | 772 | ||
773 | /** | 773 | /** |
774 | * This method will return a list of leds | 774 | * This method will return a list of leds |
775 | * available on this device | 775 | * available on this device |
776 | * @return a list of LEDs. | 776 | * @return a list of LEDs. |
777 | */ | 777 | */ |
778 | QValueList <OLed> ODevice::ledList ( ) const | 778 | QValueList <OLed> ODevice::ledList ( ) const |
779 | { | 779 | { |
780 | return QValueList <OLed> ( ); | 780 | return QValueList <OLed> ( ); |
781 | } | 781 | } |
782 | 782 | ||
783 | /** | 783 | /** |
784 | * This does return the state of the LEDs | 784 | * This does return the state of the LEDs |
785 | */ | 785 | */ |
786 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 786 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
787 | { | 787 | { |
788 | return QValueList <OLedState> ( ); | 788 | return QValueList <OLedState> ( ); |
789 | } | 789 | } |
790 | 790 | ||
791 | /** | 791 | /** |
792 | * @return the state for a given OLed | 792 | * @return the state for a given OLed |
793 | */ | 793 | */ |
794 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 794 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
795 | { | 795 | { |
796 | return Led_Off; | 796 | return Led_Off; |
797 | } | 797 | } |
798 | 798 | ||
799 | /** | 799 | /** |
800 | * Set the state for a LED | 800 | * Set the state for a LED |
801 | * @param which Which OLed to use | 801 | * @param which Which OLed to use |
802 | * @param st The state to set | 802 | * @param st The state to set |
803 | * @return success or failure | 803 | * @return success or failure |
804 | */ | 804 | */ |
805 | bool ODevice::setLedState ( OLed which, OLedState st ) | 805 | bool ODevice::setLedState ( OLed which, OLedState st ) |
806 | { | 806 | { |
807 | Q_UNUSED( which ) | 807 | Q_UNUSED( which ) |
808 | Q_UNUSED( st ) | 808 | Q_UNUSED( st ) |
809 | return false; | 809 | return false; |
810 | } | 810 | } |
811 | 811 | ||
812 | /** | 812 | /** |
813 | * @return if the device has a light sensor | 813 | * @return if the device has a light sensor |
814 | */ | 814 | */ |
815 | bool ODevice::hasLightSensor ( ) const | 815 | bool ODevice::hasLightSensor ( ) const |
816 | { | 816 | { |
817 | return false; | 817 | return false; |
818 | } | 818 | } |
819 | 819 | ||
820 | /** | 820 | /** |
821 | * @return a value from the light senso | 821 | * @return a value from the light senso |
822 | */ | 822 | */ |
823 | int ODevice::readLightSensor ( ) | 823 | int ODevice::readLightSensor ( ) |
824 | { | 824 | { |
825 | return -1; | 825 | return -1; |
826 | } | 826 | } |
827 | 827 | ||
828 | /** | 828 | /** |
829 | * @return the light sensor resolution whatever that is ;) | 829 | * @return the light sensor resolution whatever that is ;) |
830 | */ | 830 | */ |
831 | int ODevice::lightSensorResolution ( ) const | 831 | int ODevice::lightSensorResolution ( ) const |
832 | { | 832 | { |
833 | return 0; | 833 | return 0; |
834 | } | 834 | } |
835 | 835 | ||
836 | /** | 836 | /** |
837 | * @return a list with CPU frequencies supported by the hardware | 837 | * @return a list with CPU frequencies supported by the hardware |
838 | */ | 838 | */ |
839 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 839 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
840 | { | 840 | { |
841 | return *d->m_cpu_frequencies; | 841 | return *d->m_cpu_frequencies; |
842 | } | 842 | } |
843 | 843 | ||
844 | 844 | ||
845 | /** | 845 | /** |
846 | * Set desired CPU frequency | 846 | * Set desired CPU frequency |
847 | * | 847 | * |
848 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 848 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
849 | */ | 849 | */ |
850 | bool ODevice::setCurrentCpuFrequency(uint index) | 850 | bool ODevice::setCurrentCpuFrequency(uint index) |
851 | { | 851 | { |
852 | if (index >= d->m_cpu_frequencies->count()) | 852 | if (index >= d->m_cpu_frequencies->count()) |
853 | return false; | 853 | return false; |
854 | 854 | ||
855 | char *freq = d->m_cpu_frequencies->at(index); | 855 | char *freq = d->m_cpu_frequencies->at(index); |
856 | qWarning("set freq to %s", freq); | 856 | qWarning("set freq to %s", freq); |
857 | 857 | ||
858 | int fd; | 858 | int fd; |
859 | 859 | ||
860 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 860 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
861 | char writeCommand[50]; | 861 | char writeCommand[50]; |
862 | const int count = sprintf(writeCommand, "%s\n", freq); | 862 | const int count = sprintf(writeCommand, "%s\n", freq); |
863 | int res = (::write(fd, writeCommand, count) != -1); | 863 | int res = (::write(fd, writeCommand, count) != -1); |
864 | ::close(fd); | 864 | ::close(fd); |
865 | return res; | 865 | return res; |
866 | } | 866 | } |
867 | 867 | ||
868 | return false; | 868 | return false; |
869 | } | 869 | } |
870 | 870 | ||
871 | 871 | ||
872 | /** | 872 | /** |
873 | * @return a list of hardware buttons | 873 | * @return a list of hardware buttons |
874 | */ | 874 | */ |
875 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 875 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
876 | { | 876 | { |
877 | initButtons ( ); | 877 | initButtons ( ); |
878 | 878 | ||
879 | return *d-> m_buttons; | 879 | return *d-> m_buttons; |
880 | } | 880 | } |
881 | 881 | ||
882 | /** | 882 | /** |
883 | * @return The amount of time that would count as a hold | 883 | * @return The amount of time that would count as a hold |
884 | */ | 884 | */ |
885 | uint ODevice::buttonHoldTime ( ) const | 885 | uint ODevice::buttonHoldTime ( ) const |
886 | { | 886 | { |
887 | return d-> m_holdtime; | 887 | return d-> m_holdtime; |
888 | } | 888 | } |
889 | 889 | ||
890 | /** | 890 | /** |
891 | * This method return a ODeviceButton for a key code | 891 | * This method return a ODeviceButton for a key code |
892 | * or 0 if no special hardware button is available for the device | 892 | * or 0 if no special hardware button is available for the device |
893 | * | 893 | * |
894 | * @return The devicebutton or 0l | 894 | * @return The devicebutton or 0l |
895 | * @see ODeviceButton | 895 | * @see ODeviceButton |
896 | */ | 896 | */ |
897 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 897 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
898 | { | 898 | { |
899 | initButtons ( ); | 899 | initButtons ( ); |
900 | 900 | ||
901 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 901 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
902 | if ( (*it). keycode ( ) == code ) | 902 | if ( (*it). keycode ( ) == code ) |
903 | return &(*it); | 903 | return &(*it); |
904 | } | 904 | } |
905 | return 0; | 905 | return 0; |
906 | } | 906 | } |
907 | 907 | ||
908 | void ODevice::reloadButtonMapping ( ) | 908 | void ODevice::reloadButtonMapping ( ) |
909 | { | 909 | { |
910 | initButtons ( ); | 910 | initButtons ( ); |
911 | 911 | ||
912 | Config cfg ( "ButtonSettings" ); | 912 | Config cfg ( "ButtonSettings" ); |
913 | 913 | ||
914 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 914 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
915 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 915 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
916 | QString group = "Button" + QString::number ( i ); | 916 | QString group = "Button" + QString::number ( i ); |
917 | 917 | ||
918 | QCString pch, hch; | 918 | QCString pch, hch; |
919 | QCString pm, hm; | 919 | QCString pm, hm; |
920 | QByteArray pdata, hdata; | 920 | QByteArray pdata, hdata; |
921 | 921 | ||
922 | if ( cfg. hasGroup ( group )) { | 922 | if ( cfg. hasGroup ( group )) { |
923 | cfg. setGroup ( group ); | 923 | cfg. setGroup ( group ); |
924 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 924 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
925 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 925 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
926 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 926 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
927 | 927 | ||
928 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 928 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
929 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 929 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
930 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 930 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
931 | } | 931 | } |
932 | 932 | ||
933 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 933 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
934 | 934 | ||
935 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 935 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
936 | } | 936 | } |
937 | } | 937 | } |
938 | 938 | ||
939 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 939 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
940 | { | 940 | { |
941 | initButtons ( ); | 941 | initButtons ( ); |
942 | 942 | ||
943 | QString mb_chan; | 943 | QString mb_chan; |
944 | 944 | ||
945 | if ( button >= (int) d-> m_buttons-> count ( )) | 945 | if ( button >= (int) d-> m_buttons-> count ( )) |
946 | return; | 946 | return; |
947 | 947 | ||
948 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 948 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
949 | b. setPressedAction ( action ); | 949 | b. setPressedAction ( action ); |
950 | 950 | ||
951 | mb_chan=b. pressedAction ( ). channel ( ); | 951 | mb_chan=b. pressedAction ( ). channel ( ); |
952 | 952 | ||
953 | Config buttonFile ( "ButtonSettings" ); | 953 | Config buttonFile ( "ButtonSettings" ); |
954 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 954 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
955 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 955 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
956 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 956 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
957 | 957 | ||
958 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 958 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
959 | 959 | ||
960 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 960 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
961 | } | 961 | } |
962 | 962 | ||
963 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 963 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
964 | { | 964 | { |
965 | initButtons ( ); | 965 | initButtons ( ); |
966 | 966 | ||
967 | if ( button >= (int) d-> m_buttons-> count ( )) | 967 | if ( button >= (int) d-> m_buttons-> count ( )) |
968 | return; | 968 | return; |
969 | 969 | ||
970 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 970 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
971 | b. setHeldAction ( action ); | 971 | b. setHeldAction ( action ); |
972 | 972 | ||
973 | Config buttonFile ( "ButtonSettings" ); | 973 | Config buttonFile ( "ButtonSettings" ); |
974 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 974 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
975 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 975 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
976 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 976 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
977 | 977 | ||
978 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 978 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
979 | 979 | ||
980 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 980 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
981 | } | 981 | } |
982 | void ODevice::virtual_hook(int, void* ){ | 982 | void ODevice::virtual_hook(int, void* ){ |
983 | 983 | ||
984 | } | 984 | } |
985 | 985 | ||
986 | /************************************************** | 986 | /************************************************** |
987 | * | 987 | * |
988 | * Yopy 3500/3700 | 988 | * Yopy 3500/3700 |
989 | * | 989 | * |
990 | **************************************************/ | 990 | **************************************************/ |
991 | 991 | ||
992 | bool Yopy::isYopy ( ) | 992 | bool Yopy::isYopy ( ) |
993 | { | 993 | { |
994 | QFile f( "/proc/cpuinfo" ); | 994 | QFile f( "/proc/cpuinfo" ); |
995 | if ( f. open ( IO_ReadOnly ) ) { | 995 | if ( f. open ( IO_ReadOnly ) ) { |
996 | QTextStream ts ( &f ); | 996 | QTextStream ts ( &f ); |
997 | QString line; | 997 | QString line; |
998 | while( line = ts. readLine ( ) ) { | 998 | while( line = ts. readLine ( ) ) { |
999 | if ( line. left ( 8 ) == "Hardware" ) { | 999 | if ( line. left ( 8 ) == "Hardware" ) { |
1000 | int loc = line. find ( ":" ); | 1000 | int loc = line. find ( ":" ); |
1001 | if ( loc != -1 ) { | 1001 | if ( loc != -1 ) { |
1002 | QString model = | 1002 | QString model = |
1003 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1003 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1004 | return ( model == "Yopy" ); | 1004 | return ( model == "Yopy" ); |
1005 | } | 1005 | } |
1006 | } | 1006 | } |
1007 | } | 1007 | } |
1008 | } | 1008 | } |
1009 | return false; | 1009 | return false; |
1010 | } | 1010 | } |
1011 | 1011 | ||
1012 | void Yopy::init ( ) | 1012 | void Yopy::init ( ) |
1013 | { | 1013 | { |
1014 | d-> m_vendorstr = "G.Mate"; | 1014 | d-> m_vendorstr = "G.Mate"; |
1015 | d-> m_vendor = Vendor_GMate; | 1015 | d-> m_vendor = Vendor_GMate; |
1016 | d-> m_modelstr = "Yopy3700"; | 1016 | d-> m_modelstr = "Yopy3700"; |
1017 | d-> m_model = Model_Yopy_3700; | 1017 | d-> m_model = Model_Yopy_3700; |
1018 | d-> m_rotation = Rot0; | 1018 | d-> m_rotation = Rot0; |
1019 | 1019 | ||
1020 | d-> m_systemstr = "Linupy"; | 1020 | d-> m_systemstr = "Linupy"; |
1021 | d-> m_system = System_Linupy; | 1021 | d-> m_system = System_Linupy; |
1022 | 1022 | ||
1023 | QFile f ( "/etc/issue" ); | 1023 | QFile f ( "/etc/issue" ); |
1024 | if ( f. open ( IO_ReadOnly )) { | 1024 | if ( f. open ( IO_ReadOnly )) { |
1025 | QTextStream ts ( &f ); | 1025 | QTextStream ts ( &f ); |
1026 | ts.readLine(); | 1026 | ts.readLine(); |
1027 | d-> m_sysverstr = ts. readLine ( ); | 1027 | d-> m_sysverstr = ts. readLine ( ); |
1028 | f. close ( ); | 1028 | f. close ( ); |
1029 | } | 1029 | } |
1030 | } | 1030 | } |
1031 | 1031 | ||
1032 | void Yopy::initButtons ( ) | 1032 | void Yopy::initButtons ( ) |
1033 | { | 1033 | { |
1034 | if ( d-> m_buttons ) | 1034 | if ( d-> m_buttons ) |
1035 | return; | 1035 | return; |
1036 | 1036 | ||
1037 | d-> m_buttons = new QValueList <ODeviceButton>; | 1037 | d-> m_buttons = new QValueList <ODeviceButton>; |
1038 | 1038 | ||
1039 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 1039 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { |
1040 | 1040 | ||
1041 | yopy_button *ib = yopy_buttons + i; | 1041 | yopy_button *ib = yopy_buttons + i; |
1042 | 1042 | ||
1043 | ODeviceButton b; | 1043 | ODeviceButton b; |
1044 | 1044 | ||
1045 | b. setKeycode ( ib-> code ); | 1045 | b. setKeycode ( ib-> code ); |
1046 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1046 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1047 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1047 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1048 | b. setFactoryPresetPressedAction | 1048 | b. setFactoryPresetPressedAction |
1049 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 1049 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); |
1050 | b. setFactoryPresetHeldAction | 1050 | b. setFactoryPresetHeldAction |
1051 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 1051 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); |
1052 | 1052 | ||
1053 | d-> m_buttons-> append ( b ); | 1053 | d-> m_buttons-> append ( b ); |
1054 | } | 1054 | } |
1055 | reloadButtonMapping ( ); | 1055 | reloadButtonMapping ( ); |
1056 | 1056 | ||
1057 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | 1057 | QCopChannel *sysch = new QCopChannel("QPE/System", this); |
1058 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), | 1058 | connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), |
1059 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); | 1059 | this, SLOT(systemMessage(const QCString &, const QByteArray & ))); |
1060 | } | 1060 | } |
1061 | 1061 | ||
1062 | bool Yopy::suspend() | 1062 | bool Yopy::suspend() |
1063 | { | 1063 | { |
1064 | /* Opie for Yopy does not implement its own power management at the | 1064 | /* Opie for Yopy does not implement its own power management at the |
1065 | moment. The public version runs parallel to X, and relies on the | 1065 | moment. The public version runs parallel to X, and relies on the |
1066 | existing power management features. */ | 1066 | existing power management features. */ |
1067 | return false; | 1067 | return false; |
1068 | } | 1068 | } |
1069 | 1069 | ||
1070 | bool Yopy::setDisplayBrightness(int bright) | 1070 | bool Yopy::setDisplayBrightness(int bright) |
1071 | { | 1071 | { |
1072 | /* The code here works, but is disabled as the current version runs | 1072 | /* The code here works, but is disabled as the current version runs |
1073 | parallel to X, and relies on the existing backlight demon. */ | 1073 | parallel to X, and relies on the existing backlight demon. */ |
1074 | #if 0 | 1074 | #if 0 |
1075 | if ( QFile::exists("/proc/sys/pm/light") ) { | 1075 | if ( QFile::exists("/proc/sys/pm/light") ) { |
1076 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 1076 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
1077 | if (fd >= 0 ) { | 1077 | if (fd >= 0 ) { |
1078 | if (bright) | 1078 | if (bright) |
1079 | ::write(fd, "1\n", 2); | 1079 | ::write(fd, "1\n", 2); |
1080 | else | 1080 | else |
1081 | ::write(fd, "0\n", 2); | 1081 | ::write(fd, "0\n", 2); |
1082 | ::close(fd); | 1082 | ::close(fd); |
1083 | return true; | 1083 | return true; |
1084 | } | 1084 | } |
1085 | } | 1085 | } |
1086 | #endif | 1086 | #endif |
1087 | return false; | 1087 | return false; |
1088 | } | 1088 | } |
1089 | 1089 | ||
1090 | int Yopy::displayBrightnessResolution() const | 1090 | int Yopy::displayBrightnessResolution() const |
1091 | { | 1091 | { |
1092 | return 2; | 1092 | return 2; |
1093 | } | 1093 | } |
1094 | 1094 | ||
1095 | /************************************************** | 1095 | /************************************************** |
1096 | * | 1096 | * |
1097 | * iPAQ | 1097 | * iPAQ |
1098 | * | 1098 | * |
1099 | **************************************************/ | 1099 | **************************************************/ |
1100 | 1100 | ||
1101 | void iPAQ::init ( ) | 1101 | void iPAQ::init ( ) |
1102 | { | 1102 | { |
1103 | d-> m_vendorstr = "HP"; | 1103 | d-> m_vendorstr = "HP"; |
1104 | d-> m_vendor = Vendor_HP; | 1104 | d-> m_vendor = Vendor_HP; |
1105 | 1105 | ||
1106 | QFile f ( "/proc/hal/model" ); | 1106 | QFile f ( "/proc/hal/model" ); |
1107 | 1107 | ||
1108 | if ( f. open ( IO_ReadOnly )) { | 1108 | if ( f. open ( IO_ReadOnly )) { |
1109 | QTextStream ts ( &f ); | 1109 | QTextStream ts ( &f ); |
1110 | 1110 | ||
1111 | d-> m_modelstr = "H" + ts. readLine ( ); | 1111 | d-> m_modelstr = "H" + ts. readLine ( ); |
1112 | 1112 | ||
1113 | if ( d-> m_modelstr == "H3100" ) | 1113 | if ( d-> m_modelstr == "H3100" ) |
1114 | d-> m_model = Model_iPAQ_H31xx; | 1114 | d-> m_model = Model_iPAQ_H31xx; |
1115 | else if ( d-> m_modelstr == "H3600" ) | 1115 | else if ( d-> m_modelstr == "H3600" ) |
1116 | d-> m_model = Model_iPAQ_H36xx; | 1116 | d-> m_model = Model_iPAQ_H36xx; |
1117 | else if ( d-> m_modelstr == "H3700" ) | 1117 | else if ( d-> m_modelstr == "H3700" ) |
1118 | d-> m_model = Model_iPAQ_H37xx; | 1118 | d-> m_model = Model_iPAQ_H37xx; |
1119 | else if ( d-> m_modelstr == "H3800" ) | 1119 | else if ( d-> m_modelstr == "H3800" ) |
1120 | d-> m_model = Model_iPAQ_H38xx; | 1120 | d-> m_model = Model_iPAQ_H38xx; |
1121 | else if ( d-> m_modelstr == "H3900" ) | 1121 | else if ( d-> m_modelstr == "H3900" ) |
1122 | d-> m_model = Model_iPAQ_H39xx; | 1122 | d-> m_model = Model_iPAQ_H39xx; |
1123 | else if ( d-> m_modelstr == "H5400" ) | 1123 | else if ( d-> m_modelstr == "H5400" ) |
1124 | d-> m_model = Model_iPAQ_H5xxx; | 1124 | d-> m_model = Model_iPAQ_H5xxx; |
1125 | else | 1125 | else |
1126 | d-> m_model = Model_Unknown; | 1126 | d-> m_model = Model_Unknown; |
1127 | 1127 | ||
1128 | f. close ( ); | 1128 | f. close ( ); |
1129 | } | 1129 | } |
1130 | 1130 | ||
1131 | switch ( d-> m_model ) { | 1131 | switch ( d-> m_model ) { |
1132 | case Model_iPAQ_H31xx: | 1132 | case Model_iPAQ_H31xx: |
1133 | case Model_iPAQ_H38xx: | 1133 | case Model_iPAQ_H38xx: |
1134 | d-> m_rotation = Rot90; | 1134 | d-> m_rotation = Rot90; |
1135 | break; | 1135 | break; |
1136 | case Model_iPAQ_H36xx: | 1136 | case Model_iPAQ_H36xx: |
1137 | case Model_iPAQ_H37xx: | 1137 | case Model_iPAQ_H37xx: |
1138 | case Model_iPAQ_H39xx: | 1138 | case Model_iPAQ_H39xx: |
1139 | 1139 | ||
1140 | default: | 1140 | default: |
1141 | d-> m_rotation = Rot270; | 1141 | d-> m_rotation = Rot270; |
1142 | break; | 1142 | break; |
1143 | case Model_iPAQ_H5xxx: | 1143 | case Model_iPAQ_H5xxx: |
1144 | d-> m_rotation = Rot0; | 1144 | d-> m_rotation = Rot0; |
1145 | } | 1145 | } |
1146 | 1146 | ||
1147 | f. setName ( "/etc/familiar-version" ); | 1147 | f. setName ( "/etc/familiar-version" ); |
1148 | if ( f. open ( IO_ReadOnly )) { | 1148 | if ( f. open ( IO_ReadOnly )) { |
1149 | d-> m_systemstr = "Familiar"; | 1149 | d-> m_systemstr = "Familiar"; |
1150 | d-> m_system = System_Familiar; | 1150 | d-> m_system = System_Familiar; |
1151 | 1151 | ||
1152 | QTextStream ts ( &f ); | 1152 | QTextStream ts ( &f ); |
1153 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1153 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1154 | 1154 | ||
1155 | f. close ( ); | 1155 | f. close ( ); |
1156 | } else { | 1156 | } else { |
1157 | f. setName ( "/etc/oz_version" ); | 1157 | f. setName ( "/etc/oz_version" ); |
1158 | 1158 | ||
1159 | if ( f. open ( IO_ReadOnly )) { | 1159 | if ( f. open ( IO_ReadOnly )) { |
1160 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 1160 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
1161 | d-> m_system = System_Familiar; | 1161 | d-> m_system = System_Familiar; |
1162 | 1162 | ||
1163 | QTextStream ts ( &f ); | 1163 | QTextStream ts ( &f ); |
1164 | ts.setDevice ( &f ); | 1164 | ts.setDevice ( &f ); |
1165 | d-> m_sysverstr = ts. readLine ( ); | 1165 | d-> m_sysverstr = ts. readLine ( ); |
1166 | f. close ( ); | 1166 | f. close ( ); |
1167 | } | 1167 | } |
1168 | } | 1168 | } |
1169 | 1169 | ||
1170 | 1170 | ||
1171 | 1171 | ||
1172 | 1172 | ||
1173 | 1173 | ||
1174 | m_leds [0] = m_leds [1] = Led_Off; | 1174 | m_leds [0] = m_leds [1] = Led_Off; |
1175 | 1175 | ||
1176 | m_power_timer = 0; | 1176 | m_power_timer = 0; |
1177 | 1177 | ||
1178 | } | 1178 | } |
1179 | 1179 | ||
1180 | void iPAQ::initButtons ( ) | 1180 | void iPAQ::initButtons ( ) |
1181 | { | 1181 | { |
1182 | if ( d-> m_buttons ) | 1182 | if ( d-> m_buttons ) |
1183 | return; | 1183 | return; |
1184 | 1184 | ||
1185 | if ( isQWS( ) ) | 1185 | if ( isQWS( ) ) |
1186 | QWSServer::setKeyboardFilter ( this ); | 1186 | QWSServer::setKeyboardFilter ( this ); |
1187 | 1187 | ||
1188 | d-> m_buttons = new QValueList <ODeviceButton>; | 1188 | d-> m_buttons = new QValueList <ODeviceButton>; |
1189 | 1189 | ||
1190 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1190 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1191 | i_button *ib = ipaq_buttons + i; | 1191 | i_button *ib = ipaq_buttons + i; |
1192 | ODeviceButton b; | 1192 | ODeviceButton b; |
1193 | 1193 | ||
1194 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1194 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1195 | b. setKeycode ( ib-> code ); | 1195 | b. setKeycode ( ib-> code ); |
1196 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1196 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1197 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1197 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1198 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1198 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1199 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1199 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1200 | 1200 | ||
1201 | d-> m_buttons-> append ( b ); | 1201 | d-> m_buttons-> append ( b ); |
1202 | } | 1202 | } |
1203 | } | 1203 | } |
1204 | reloadButtonMapping ( ); | 1204 | reloadButtonMapping ( ); |
1205 | 1205 | ||
1206 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1206 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1207 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1207 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1208 | } | 1208 | } |
1209 | 1209 | ||
1210 | 1210 | ||
1211 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1211 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1212 | 1212 | ||
1213 | typedef struct { | 1213 | typedef struct { |
1214 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1214 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1215 | unsigned char TotalTime; /* Units of 5 seconds */ | 1215 | unsigned char TotalTime; /* Units of 5 seconds */ |
1216 | unsigned char OnTime; /* units of 100m/s */ | 1216 | unsigned char OnTime; /* units of 100m/s */ |
1217 | unsigned char OffTime; /* units of 100m/s */ | 1217 | unsigned char OffTime; /* units of 100m/s */ |
1218 | } LED_IN; | 1218 | } LED_IN; |
1219 | 1219 | ||
1220 | typedef struct { | 1220 | typedef struct { |
1221 | unsigned char mode; | 1221 | unsigned char mode; |
1222 | unsigned char pwr; | 1222 | unsigned char pwr; |
1223 | unsigned char brightness; | 1223 | unsigned char brightness; |
1224 | } FLITE_IN; | 1224 | } FLITE_IN; |
1225 | 1225 | ||
1226 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1226 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1227 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1227 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1228 | 1228 | ||
1229 | 1229 | ||
1230 | QValueList <OLed> iPAQ::ledList ( ) const | 1230 | QValueList <OLed> iPAQ::ledList ( ) const |
1231 | { | 1231 | { |
1232 | QValueList <OLed> vl; | 1232 | QValueList <OLed> vl; |
1233 | vl << Led_Power; | 1233 | vl << Led_Power; |
1234 | 1234 | ||
1235 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1235 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1236 | vl << Led_BlueTooth; | 1236 | vl << Led_BlueTooth; |
1237 | return vl; | 1237 | return vl; |
1238 | } | 1238 | } |
1239 | 1239 | ||
1240 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1240 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1241 | { | 1241 | { |
1242 | QValueList <OLedState> vl; | 1242 | QValueList <OLedState> vl; |
1243 | 1243 | ||
1244 | if ( l == Led_Power ) | 1244 | if ( l == Led_Power ) |
1245 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1245 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1246 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1246 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1247 | vl << Led_Off; // << Led_On << ??? | 1247 | vl << Led_Off; // << Led_On << ??? |
1248 | 1248 | ||
1249 | return vl; | 1249 | return vl; |
1250 | } | 1250 | } |
1251 | 1251 | ||
1252 | OLedState iPAQ::ledState ( OLed l ) const | 1252 | OLedState iPAQ::ledState ( OLed l ) const |
1253 | { | 1253 | { |
1254 | switch ( l ) { | 1254 | switch ( l ) { |
1255 | case Led_Power: | 1255 | case Led_Power: |
1256 | return m_leds [0]; | 1256 | return m_leds [0]; |
1257 | case Led_BlueTooth: | 1257 | case Led_BlueTooth: |
1258 | return m_leds [1]; | 1258 | return m_leds [1]; |
1259 | default: | 1259 | default: |
1260 | return Led_Off; | 1260 | return Led_Off; |
1261 | } | 1261 | } |
1262 | } | 1262 | } |
1263 | 1263 | ||
1264 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1264 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1265 | { | 1265 | { |
1266 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1266 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1267 | 1267 | ||
1268 | if ( l == Led_Power ) { | 1268 | if ( l == Led_Power ) { |
1269 | if ( fd >= 0 ) { | 1269 | if ( fd >= 0 ) { |
1270 | LED_IN leds; | 1270 | LED_IN leds; |
1271 | ::memset ( &leds, 0, sizeof( leds )); | 1271 | ::memset ( &leds, 0, sizeof( leds )); |
1272 | leds. TotalTime = 0; | 1272 | leds. TotalTime = 0; |
1273 | leds. OnTime = 0; | 1273 | leds. OnTime = 0; |
1274 | leds. OffTime = 1; | 1274 | leds. OffTime = 1; |
1275 | leds. OffOnBlink = 2; | 1275 | leds. OffOnBlink = 2; |
1276 | 1276 | ||
1277 | switch ( st ) { | 1277 | switch ( st ) { |
1278 | case Led_Off : leds. OffOnBlink = 0; break; | 1278 | case Led_Off : leds. OffOnBlink = 0; break; |
1279 | case Led_On : leds. OffOnBlink = 1; break; | 1279 | case Led_On : leds. OffOnBlink = 1; break; |
1280 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1280 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1281 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1281 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1282 | } | 1282 | } |
1283 | 1283 | ||
1284 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1284 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1285 | m_leds [0] = st; | 1285 | m_leds [0] = st; |
1286 | return true; | 1286 | return true; |
1287 | } | 1287 | } |
1288 | } | 1288 | } |
1289 | } | 1289 | } |
1290 | return false; | 1290 | return false; |
1291 | } | 1291 | } |
1292 | 1292 | ||
1293 | 1293 | ||
1294 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1294 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1295 | { | 1295 | { |
1296 | int newkeycode = keycode; | 1296 | int newkeycode = keycode; |
1297 | 1297 | ||
1298 | switch ( keycode ) { | 1298 | switch ( keycode ) { |
1299 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1299 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1300 | case HardKey_Menu: { | 1300 | case HardKey_Menu: { |
1301 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1301 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1302 | ( d-> m_model == Model_iPAQ_H39xx ) || | 1302 | ( d-> m_model == Model_iPAQ_H39xx ) || |
1303 | ( d-> m_model == Model_iPAQ_H5xxx)) { | 1303 | ( d-> m_model == Model_iPAQ_H5xxx)) { |
1304 | newkeycode = HardKey_Mail; | 1304 | newkeycode = HardKey_Mail; |
1305 | } | 1305 | } |
1306 | break; | 1306 | break; |
1307 | } | 1307 | } |
1308 | 1308 | ||
1309 | // Rotate cursor keys 180° | 1309 | // Rotate cursor keys 180° |
1310 | case Key_Left : | 1310 | case Key_Left : |
1311 | case Key_Right: | 1311 | case Key_Right: |
1312 | case Key_Up : | 1312 | case Key_Up : |
1313 | case Key_Down : { | 1313 | case Key_Down : { |
1314 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1314 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1315 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1315 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1316 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1316 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1317 | } | 1317 | } |
1318 | break; | 1318 | break; |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | // map Power Button short/long press to F34/F35 | 1321 | // map Power Button short/long press to F34/F35 |
1322 | case Key_SysReq: { | 1322 | case Key_SysReq: { |
1323 | if ( isPress ) { | 1323 | if ( isPress ) { |
1324 | if ( m_power_timer ) | 1324 | if ( m_power_timer ) |
1325 | killTimer ( m_power_timer ); | 1325 | killTimer ( m_power_timer ); |
1326 | m_power_timer = startTimer ( 500 ); | 1326 | m_power_timer = startTimer ( 500 ); |
1327 | } | 1327 | } |
1328 | else if ( m_power_timer ) { | 1328 | else if ( m_power_timer ) { |
1329 | killTimer ( m_power_timer ); | 1329 | killTimer ( m_power_timer ); |
1330 | m_power_timer = 0; | 1330 | m_power_timer = 0; |
1331 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 1331 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
1332 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 1332 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
1333 | } | 1333 | } |
1334 | newkeycode = Key_unknown; | 1334 | newkeycode = Key_unknown; |
1335 | break; | 1335 | break; |
1336 | } | 1336 | } |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | if ( newkeycode != keycode ) { | 1339 | if ( newkeycode != keycode ) { |
1340 | if ( newkeycode != Key_unknown ) | 1340 | if ( newkeycode != Key_unknown ) |
1341 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 1341 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
1342 | return true; | 1342 | return true; |
1343 | } | 1343 | } |
1344 | else | 1344 | else |
1345 | return false; | 1345 | return false; |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | void iPAQ::timerEvent ( QTimerEvent * ) | 1348 | void iPAQ::timerEvent ( QTimerEvent * ) |
1349 | { | 1349 | { |
1350 | killTimer ( m_power_timer ); | 1350 | killTimer ( m_power_timer ); |
1351 | m_power_timer = 0; | 1351 | m_power_timer = 0; |
1352 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1352 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1353 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1353 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | 1356 | ||
1357 | void iPAQ::alarmSound ( ) | 1357 | void iPAQ::alarmSound ( ) |
1358 | { | 1358 | { |
1359 | #ifndef QT_NO_SOUND | 1359 | #ifndef QT_NO_SOUND |
1360 | static Sound snd ( "alarm" ); | 1360 | static Sound snd ( "alarm" ); |
1361 | int fd; | 1361 | int fd; |
1362 | int vol; | 1362 | int vol; |
1363 | bool vol_reset = false; | 1363 | bool vol_reset = false; |
1364 | 1364 | ||
1365 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1365 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1366 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1366 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1367 | Config cfg ( "qpe" ); | 1367 | Config cfg ( "qpe" ); |
1368 | cfg. setGroup ( "Volume" ); | 1368 | cfg. setGroup ( "Volume" ); |
1369 | 1369 | ||
1370 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1370 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1371 | if ( volalarm < 0 ) | 1371 | if ( volalarm < 0 ) |
1372 | volalarm = 0; | 1372 | volalarm = 0; |
1373 | else if ( volalarm > 100 ) | 1373 | else if ( volalarm > 100 ) |
1374 | volalarm = 100; | 1374 | volalarm = 100; |
1375 | volalarm |= ( volalarm << 8 ); | 1375 | volalarm |= ( volalarm << 8 ); |
1376 | 1376 | ||
1377 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1377 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1378 | vol_reset = true; | 1378 | vol_reset = true; |
1379 | } | 1379 | } |
1380 | } | 1380 | } |
1381 | 1381 | ||
1382 | snd. play ( ); | 1382 | snd. play ( ); |
1383 | while ( !snd. isFinished ( )) | 1383 | while ( !snd. isFinished ( )) |
1384 | qApp-> processEvents ( ); | 1384 | qApp-> processEvents ( ); |
1385 | 1385 | ||
1386 | if ( fd >= 0 ) { | 1386 | if ( fd >= 0 ) { |
1387 | if ( vol_reset ) | 1387 | if ( vol_reset ) |
1388 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1388 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1389 | ::close ( fd ); | 1389 | ::close ( fd ); |
1390 | } | 1390 | } |
1391 | #endif | 1391 | #endif |
1392 | } | 1392 | } |
1393 | 1393 | ||
1394 | 1394 | ||
1395 | bool iPAQ::setSoftSuspend ( bool soft ) | 1395 | bool iPAQ::setSoftSuspend ( bool soft ) |
1396 | { | 1396 | { |
1397 | bool res = false; | 1397 | bool res = false; |
1398 | int fd; | 1398 | int fd; |
1399 | 1399 | ||
1400 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1400 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1401 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1401 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1402 | res = true; | 1402 | res = true; |
1403 | else | 1403 | else |
1404 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1404 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1405 | 1405 | ||
1406 | ::close ( fd ); | 1406 | ::close ( fd ); |
1407 | } | 1407 | } |
1408 | else | 1408 | else |
1409 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1409 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1410 | 1410 | ||
1411 | return res; | 1411 | return res; |
1412 | } | 1412 | } |
1413 | 1413 | ||
1414 | 1414 | ||
1415 | bool iPAQ::setDisplayBrightness ( int bright ) | 1415 | bool iPAQ::setDisplayBrightness ( int bright ) |
1416 | { | 1416 | { |
1417 | bool res = false; | 1417 | bool res = false; |
1418 | int fd; | 1418 | int fd; |
1419 | 1419 | ||
1420 | if ( bright > 255 ) | 1420 | if ( bright > 255 ) |
1421 | bright = 255; | 1421 | bright = 255; |
1422 | if ( bright < 0 ) | 1422 | if ( bright < 0 ) |
1423 | bright = 0; | 1423 | bright = 0; |
1424 | 1424 | ||
1425 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1425 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1426 | FLITE_IN bl; | 1426 | FLITE_IN bl; |
1427 | bl. mode = 1; | 1427 | bl. mode = 1; |
1428 | bl. pwr = bright ? 1 : 0; | 1428 | bl. pwr = bright ? 1 : 0; |
1429 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1429 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1430 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1430 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1431 | ::close ( fd ); | 1431 | ::close ( fd ); |
1432 | } | 1432 | } |
1433 | return res; | 1433 | return res; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | int iPAQ::displayBrightnessResolution ( ) const | 1436 | int iPAQ::displayBrightnessResolution ( ) const |
1437 | { | 1437 | { |
1438 | switch ( model ( )) { | 1438 | switch ( model ( )) { |
1439 | case Model_iPAQ_H31xx: | 1439 | case Model_iPAQ_H31xx: |
1440 | case Model_iPAQ_H36xx: | 1440 | case Model_iPAQ_H36xx: |
1441 | case Model_iPAQ_H37xx: | 1441 | case Model_iPAQ_H37xx: |
1442 | return 128; // really 256, but >128 could damage the LCD | 1442 | return 128; // really 256, but >128 could damage the LCD |
1443 | 1443 | ||
1444 | case Model_iPAQ_H38xx: | 1444 | case Model_iPAQ_H38xx: |
1445 | case Model_iPAQ_H39xx: | 1445 | case Model_iPAQ_H39xx: |
1446 | return 64; | 1446 | return 64; |
1447 | case Model_iPAQ_H5xxx: | 1447 | case Model_iPAQ_H5xxx: |
1448 | return 255; | 1448 | return 255; |
1449 | 1449 | ||
1450 | default: | 1450 | default: |
1451 | return 2; | 1451 | return 2; |
1452 | } | 1452 | } |
1453 | } | 1453 | } |
1454 | 1454 | ||
1455 | 1455 | ||
1456 | bool iPAQ::hasLightSensor ( ) const | 1456 | bool iPAQ::hasLightSensor ( ) const |
1457 | { | 1457 | { |
1458 | return true; | 1458 | return true; |
1459 | } | 1459 | } |
1460 | 1460 | ||
1461 | int iPAQ::readLightSensor ( ) | 1461 | int iPAQ::readLightSensor ( ) |
1462 | { | 1462 | { |
1463 | int fd; | 1463 | int fd; |
1464 | int val = -1; | 1464 | int val = -1; |
1465 | 1465 | ||
1466 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1466 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1467 | char buffer [8]; | 1467 | char buffer [8]; |
1468 | 1468 | ||
1469 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1469 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1470 | char *endptr; | 1470 | char *endptr; |
1471 | 1471 | ||
1472 | buffer [4] = 0; | 1472 | buffer [4] = 0; |
1473 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1473 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1474 | 1474 | ||
1475 | if ( *endptr != 0 ) | 1475 | if ( *endptr != 0 ) |
1476 | val = -1; | 1476 | val = -1; |
1477 | } | 1477 | } |
1478 | ::close ( fd ); | 1478 | ::close ( fd ); |
1479 | } | 1479 | } |
1480 | 1480 | ||
1481 | return val; | 1481 | return val; |
1482 | } | 1482 | } |
1483 | 1483 | ||
1484 | int iPAQ::lightSensorResolution ( ) const | 1484 | int iPAQ::lightSensorResolution ( ) const |
1485 | { | 1485 | { |
1486 | return 256; | 1486 | return 256; |
1487 | } | 1487 | } |
1488 | 1488 | ||
1489 | /************************************************** | 1489 | /************************************************** |
1490 | * | 1490 | * |
1491 | * Zaurus | 1491 | * Zaurus |
1492 | * | 1492 | * |
1493 | **************************************************/ | 1493 | **************************************************/ |
1494 | 1494 | ||
1495 | // Check whether this device is the sharp zaurus.. | 1495 | // Check whether this device is the sharp zaurus.. |
1496 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | ||
1497 | // class up into individual classes. We need three classes | ||
1498 | // | ||
1499 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | ||
1500 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | ||
1501 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | ||
1502 | // | ||
1503 | // Only question right now is: Do we really need to do it? Because as soon | ||
1504 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | ||
1505 | // Zaurus models (concerning apm, backlight, buttons, etc.) | ||
1506 | // | ||
1507 | // Comments? - mickeyl. | ||
1508 | |||
1496 | bool Zaurus::isZaurus() | 1509 | bool Zaurus::isZaurus() |
1497 | { | 1510 | { |
1498 | 1511 | ||
1499 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1512 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
1500 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | 1513 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ |
1501 | return true; | 1514 | return true; |
1502 | } | 1515 | } |
1503 | 1516 | ||
1504 | // On non-embedix kernels, we have to look closer. | 1517 | // On non-embedix kernels, we have to look closer. |
1505 | bool is_zaurus = false; | 1518 | bool is_zaurus = false; |
1506 | QFile f ( "/proc/cpuinfo" ); | 1519 | QFile f ( "/proc/cpuinfo" ); |
1507 | if ( f. open ( IO_ReadOnly ) ) { | 1520 | if ( f. open ( IO_ReadOnly ) ) { |
1508 | QString model; | 1521 | QString model; |
1509 | QFile f ( "/proc/cpuinfo" ); | 1522 | QFile f ( "/proc/cpuinfo" ); |
1510 | 1523 | ||
1511 | QTextStream ts ( &f ); | 1524 | QTextStream ts ( &f ); |
1512 | QString line; | 1525 | QString line; |
1513 | while( line = ts. readLine ( ) ) { | 1526 | while( line = ts. readLine ( ) ) { |
1514 | if ( line. left ( 8 ) == "Hardware" ) | 1527 | if ( line. left ( 8 ) == "Hardware" ) |
1515 | break; | 1528 | break; |
1516 | } | 1529 | } |
1517 | int loc = line. find ( ":" ); | 1530 | int loc = line. find ( ":" ); |
1518 | if ( loc != -1 ) | 1531 | if ( loc != -1 ) |
1519 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1532 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1520 | 1533 | ||
1521 | if ( model == "Sharp-Collie" | 1534 | if ( model == "Sharp-Collie" |
1522 | || model == "Collie" | 1535 | || model == "Collie" |
1523 | || model == "SHARP Corgi" | 1536 | || model == "SHARP Corgi" |
1524 | || model == "SHARP Shepherd" | 1537 | || model == "SHARP Shepherd" |
1525 | || model == "SHARP Poodle" | 1538 | || model == "SHARP Poodle" |
1526 | || model == "SHARP Husky" | 1539 | || model == "SHARP Husky" |
1527 | ) | 1540 | ) |
1528 | is_zaurus = true; | 1541 | is_zaurus = true; |
1529 | 1542 | ||
1530 | } | 1543 | } |
1531 | return is_zaurus; | 1544 | return is_zaurus; |
1532 | } | 1545 | } |
1533 | 1546 | ||
1534 | 1547 | ||
1535 | void Zaurus::init ( ) | 1548 | void Zaurus::init ( ) |
1536 | { | 1549 | { |
1537 | d-> m_vendorstr = "Sharp"; | 1550 | d-> m_vendorstr = "Sharp"; |
1538 | d-> m_vendor = Vendor_Sharp; | 1551 | d-> m_vendor = Vendor_Sharp; |
1539 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 1552 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
1540 | 1553 | ||
1541 | // QFile f ( "/proc/filesystems" ); | 1554 | // QFile f ( "/proc/filesystems" ); |
1542 | QString model; | 1555 | QString model; |
1543 | 1556 | ||
1544 | // It isn't a good idea to check the system configuration to | 1557 | // It isn't a good idea to check the system configuration to |
1545 | // detect the distribution ! | 1558 | // detect the distribution ! |
1546 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1559 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1547 | // because it uses a jffs2 filesystem.. | 1560 | // because it uses a jffs2 filesystem.. |
1548 | // (eilers) | 1561 | // (eilers) |
1549 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1562 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1550 | QFile f ("/etc/oz_version"); | 1563 | QFile f ("/etc/oz_version"); |
1551 | if ( f.exists() ){ | 1564 | if ( f.exists() ){ |
1552 | d-> m_vendorstr = "OpenZaurus Team"; | 1565 | d-> m_vendorstr = "OpenZaurus Team"; |
1553 | d-> m_systemstr = "OpenZaurus"; | 1566 | d-> m_systemstr = "OpenZaurus"; |
1554 | d-> m_system = System_OpenZaurus; | 1567 | d-> m_system = System_OpenZaurus; |
1555 | 1568 | ||
1556 | if ( f. open ( IO_ReadOnly )) { | 1569 | if ( f. open ( IO_ReadOnly )) { |
1557 | QTextStream ts ( &f ); | 1570 | QTextStream ts ( &f ); |
1558 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1571 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1559 | f. close ( ); | 1572 | f. close ( ); |
1560 | } | 1573 | } |
1561 | 1574 | ||
1562 | // Openzaurus sometimes uses the embedix kernel! | 1575 | // Openzaurus sometimes uses the embedix kernel! |
1563 | // => Check whether this is an embedix kernel | 1576 | // => Check whether this is an embedix kernel |
1564 | FILE *uname = popen("uname -r", "r"); | 1577 | FILE *uname = popen("uname -r", "r"); |
1565 | QString line; | 1578 | QString line; |
1566 | if ( f.open(IO_ReadOnly, uname) ) { | 1579 | if ( f.open(IO_ReadOnly, uname) ) { |
1567 | QTextStream ts ( &f ); | 1580 | QTextStream ts ( &f ); |
1568 | line = ts. readLine ( ); | 1581 | line = ts. readLine ( ); |
1569 | int loc = line. find ( "embedix" ); | 1582 | int loc = line. find ( "embedix" ); |
1570 | if ( loc != -1 ) | 1583 | if ( loc != -1 ) |
1571 | m_embedix = true; | 1584 | m_embedix = true; |
1572 | else | 1585 | else |
1573 | m_embedix = false; | 1586 | m_embedix = false; |
1574 | f. close ( ); | 1587 | f. close ( ); |
1575 | } | 1588 | } |
1576 | pclose(uname); | 1589 | pclose(uname); |
1577 | } | 1590 | } |
1578 | else { | 1591 | else { |
1579 | d-> m_systemstr = "Zaurus"; | 1592 | d-> m_systemstr = "Zaurus"; |
1580 | d-> m_system = System_Zaurus; | 1593 | d-> m_system = System_Zaurus; |
1581 | } | 1594 | } |
1582 | 1595 | ||
1583 | f. setName ( "/proc/cpuinfo" ); | 1596 | f. setName ( "/proc/cpuinfo" ); |
1584 | if ( f. open ( IO_ReadOnly ) ) { | 1597 | if ( f. open ( IO_ReadOnly ) ) { |
1585 | QTextStream ts ( &f ); | 1598 | QTextStream ts ( &f ); |
1586 | QString line; | 1599 | QString line; |
1587 | while( line = ts. readLine ( ) ) { | 1600 | while( line = ts. readLine ( ) ) { |
1588 | if ( line. left ( 8 ) == "Hardware" ) | 1601 | if ( line. left ( 8 ) == "Hardware" ) |
1589 | break; | 1602 | break; |
1590 | } | 1603 | } |
1591 | int loc = line. find ( ":" ); | 1604 | int loc = line. find ( ":" ); |
1592 | if ( loc != -1 ) | 1605 | if ( loc != -1 ) |
1593 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1606 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1594 | } | 1607 | } |
1595 | 1608 | ||
1596 | if ( model == "SHARP Corgi" ) { | 1609 | if ( model == "SHARP Corgi" ) { |
1597 | d-> m_model = Model_Zaurus_SLC7x0; | 1610 | d-> m_model = Model_Zaurus_SLC7x0; |
1598 | d-> m_modelstr = "Zaurus SL-C700"; | 1611 | d-> m_modelstr = "Zaurus SL-C700"; |
1599 | } else if ( model == "SHARP Shepherd" ) { | 1612 | } else if ( model == "SHARP Shepherd" ) { |
1600 | d-> m_model = Model_Zaurus_SLC7x0; | 1613 | d-> m_model = Model_Zaurus_SLC7x0; |
1601 | d-> m_modelstr = "Zaurus SL-C750"; | 1614 | d-> m_modelstr = "Zaurus SL-C750"; |
1602 | } else if ( model == "SHARP Husky" ) { | 1615 | } else if ( model == "SHARP Husky" ) { |
1603 | d-> m_model = Model_Zaurus_SLC7x0; | 1616 | d-> m_model = Model_Zaurus_SLC7x0; |
1604 | d-> m_modelstr = "Zaurus SL-C760"; | 1617 | d-> m_modelstr = "Zaurus SL-C760"; |
1605 | } else if ( model == "SHARP Poodle" ) { | 1618 | } else if ( model == "SHARP Poodle" ) { |
1606 | d-> m_model = Model_Zaurus_SLB600; | 1619 | d-> m_model = Model_Zaurus_SLB600; |
1607 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1620 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1608 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1621 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1609 | d-> m_model = Model_Zaurus_SL5500; | 1622 | d-> m_model = Model_Zaurus_SL5500; |
1610 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1623 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1611 | } else { | 1624 | } else { |
1612 | d-> m_model = Model_Zaurus_SL5500; | 1625 | d-> m_model = Model_Zaurus_SL5500; |
1613 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1626 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1614 | } | 1627 | } |
1615 | 1628 | ||
1616 | bool flipstate = false; | 1629 | bool flipstate = false; |
1617 | switch ( d-> m_model ) { | 1630 | switch ( d-> m_model ) { |
1618 | case Model_Zaurus_SLA300: | 1631 | case Model_Zaurus_SLA300: |
1619 | d-> m_rotation = Rot0; | 1632 | d-> m_rotation = Rot0; |
1620 | break; | 1633 | break; |
1621 | case Model_Zaurus_SLC7x0: | 1634 | case Model_Zaurus_SLC7x0: |
1622 | // Note: need to 1) set flipstate based on physical screen orientation | 1635 | // Note: need to 1) set flipstate based on physical screen orientation |
1623 | // and 2) check to see if the user overrode the rotation direction | 1636 | // and 2) check to see if the user overrode the rotation direction |
1624 | // using appearance, and if so, remove that item from the Config to | 1637 | // using appearance, and if so, remove that item from the Config to |
1625 | // ensure the rotate applet flips us back to the previous state. | 1638 | // ensure the rotate applet flips us back to the previous state. |
1639 | // treke said he has patches for detecting the phys. so where are they, treke? -mickeyl. | ||
1626 | if ( flipstate ) { | 1640 | if ( flipstate ) { |
1627 | // 480x640 | 1641 | // 480x640 |
1628 | d-> m_rotation = Rot0; | 1642 | d-> m_rotation = Rot0; |
1629 | d-> m_direction = CW; | 1643 | d-> m_direction = CW; |
1630 | } else { | 1644 | } else { |
1631 | // 640x480 | 1645 | // 640x480 |
1632 | d-> m_rotation = Rot270; | 1646 | d-> m_rotation = Rot270; |
1633 | d-> m_direction = CCW; | 1647 | d-> m_direction = CCW; |
1634 | } | 1648 | } |
1635 | break; | 1649 | break; |
1636 | case Model_Zaurus_SLB600: | 1650 | case Model_Zaurus_SLB600: |
1637 | case Model_Zaurus_SL5500: | 1651 | case Model_Zaurus_SL5500: |
1638 | case Model_Zaurus_SL5000: | 1652 | case Model_Zaurus_SL5000: |
1639 | default: | 1653 | default: |
1640 | d-> m_rotation = Rot270; | 1654 | d-> m_rotation = Rot270; |
1641 | break; | 1655 | break; |
1642 | } | 1656 | } |
1643 | m_leds [0] = Led_Off; | 1657 | m_leds [0] = Led_Off; |
1644 | } | 1658 | } |
1645 | 1659 | ||
1646 | void Zaurus::initButtons ( ) | 1660 | void Zaurus::initButtons ( ) |
1647 | { | 1661 | { |
1648 | if ( d-> m_buttons ) | 1662 | if ( d-> m_buttons ) |
1649 | return; | 1663 | return; |
1650 | 1664 | ||
1651 | d-> m_buttons = new QValueList <ODeviceButton>; | 1665 | d-> m_buttons = new QValueList <ODeviceButton>; |
1652 | 1666 | ||
1653 | struct z_button * pz_buttons; | 1667 | struct z_button * pz_buttons; |
1654 | int buttoncount; | 1668 | int buttoncount; |
1655 | switch ( d-> m_model ) { | 1669 | switch ( d-> m_model ) { |
1656 | case Model_Zaurus_SLC7x0: | 1670 | case Model_Zaurus_SLC7x0: |
1657 | pz_buttons = z_buttons_c700; | 1671 | pz_buttons = z_buttons_c700; |
1658 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1672 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1659 | break; | 1673 | break; |
1660 | default: | 1674 | default: |
1661 | pz_buttons = z_buttons; | 1675 | pz_buttons = z_buttons; |
1662 | buttoncount = ARRAY_SIZE(z_buttons); | 1676 | buttoncount = ARRAY_SIZE(z_buttons); |
1663 | break; | 1677 | break; |
1664 | } | 1678 | } |
1665 | 1679 | ||
1666 | for ( int i = 0; i < buttoncount; i++ ) { | 1680 | for ( int i = 0; i < buttoncount; i++ ) { |
1667 | struct z_button *zb = pz_buttons + i; | 1681 | struct z_button *zb = pz_buttons + i; |
1668 | ODeviceButton b; | 1682 | ODeviceButton b; |
1669 | 1683 | ||
1670 | b. setKeycode ( zb-> code ); | 1684 | b. setKeycode ( zb-> code ); |
1671 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1685 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1672 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1686 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1673 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), | 1687 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1674 | zb-> fpressedaction )); | 1688 | zb-> fpressedaction )); |
1675 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | 1689 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), |
1676 | zb-> fheldaction )); | 1690 | zb-> fheldaction )); |
1677 | 1691 | ||
1678 | d-> m_buttons-> append ( b ); | 1692 | d-> m_buttons-> append ( b ); |
1679 | } | 1693 | } |
1680 | 1694 | ||
1681 | reloadButtonMapping ( ); | 1695 | reloadButtonMapping ( ); |
1682 | 1696 | ||
1683 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1697 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1684 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), | 1698 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), |
1685 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1699 | this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1686 | } | 1700 | } |
1687 | 1701 | ||
1688 | #include <unistd.h> | 1702 | #include <unistd.h> |
1689 | #include <fcntl.h> | 1703 | #include <fcntl.h> |
1690 | #include <sys/ioctl.h> | 1704 | #include <sys/ioctl.h> |
1691 | 1705 | ||
1692 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1706 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1693 | 1707 | ||
1694 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1708 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1695 | 1709 | ||
1696 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1710 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1697 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1711 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1698 | 1712 | ||
1699 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1713 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1700 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1714 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1701 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1715 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1702 | 1716 | ||
1703 | /* --- for SHARP_BUZZER device --- */ | 1717 | /* --- for SHARP_BUZZER device --- */ |
1704 | 1718 | ||
1705 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1719 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1706 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1720 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1707 | 1721 | ||
1708 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1722 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1709 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1723 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1710 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1724 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1711 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1725 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1712 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1726 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1713 | 1727 | ||
1714 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1728 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1715 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1729 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1716 | 1730 | ||
1717 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1731 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1718 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1732 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1719 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1733 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1720 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1734 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1721 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1735 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1722 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1736 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1723 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1737 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1724 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1738 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1725 | 1739 | ||
1726 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1740 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1727 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1741 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1728 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1742 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1729 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1743 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1730 | // | 1744 | // |
1731 | 1745 | ||
1732 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1746 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1733 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1747 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1734 | 1748 | ||
1735 | typedef struct sharp_led_status { | 1749 | typedef struct sharp_led_status { |
1736 | int which; /* select which LED status is wanted. */ | 1750 | int which; /* select which LED status is wanted. */ |
1737 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1751 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1738 | } sharp_led_status; | 1752 | } sharp_led_status; |
1739 | 1753 | ||
1740 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1754 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1741 | 1755 | ||
1742 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1756 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1743 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1757 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1744 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1758 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1745 | 1759 | ||
1746 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1760 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1747 | 1761 | ||
1748 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1762 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1749 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1763 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1750 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1764 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1751 | 1765 | ||
1752 | #define FL_IOCTL_STEP_CONTRAST 100 | 1766 | #define FL_IOCTL_STEP_CONTRAST 100 |
1753 | 1767 | ||
1754 | 1768 | ||
1755 | void Zaurus::buzzer ( int sound ) | 1769 | void Zaurus::buzzer ( int sound ) |
1756 | { | 1770 | { |
1757 | #ifndef QT_NO_SOUND | 1771 | #ifndef QT_NO_SOUND |
1758 | QString soundname; | 1772 | QString soundname; |
1759 | 1773 | ||
1760 | // Not all devices have real sound | 1774 | // Not all devices have real sound |
1761 | if ( d->m_model == Model_Zaurus_SLC7x0 | 1775 | if ( d->m_model == Model_Zaurus_SLC7x0 |
1762 | || d->m_model == Model_Zaurus_SLB600 ){ | 1776 | || d->m_model == Model_Zaurus_SLB600 ){ |
1763 | 1777 | ||
1764 | switch ( sound ){ | 1778 | switch ( sound ){ |
1765 | case SHARP_BUZ_SCHEDULE_ALARM: | 1779 | case SHARP_BUZ_SCHEDULE_ALARM: |
1766 | soundname = "alarm"; | 1780 | soundname = "alarm"; |
1767 | break; | 1781 | break; |
1768 | case SHARP_BUZ_TOUCHSOUND: | 1782 | case SHARP_BUZ_TOUCHSOUND: |
1769 | soundname = "touchsound"; | 1783 | soundname = "touchsound"; |
1770 | break; | 1784 | break; |
1771 | case SHARP_BUZ_KEYSOUND: | 1785 | case SHARP_BUZ_KEYSOUND: |
1772 | soundname = "keysound"; | 1786 | soundname = "keysound"; |
1773 | break; | 1787 | break; |
1774 | default: | 1788 | default: |
1775 | soundname = "alarm"; | 1789 | soundname = "alarm"; |
1776 | 1790 | ||
1777 | } | 1791 | } |
1778 | } | 1792 | } |
1779 | 1793 | ||
1780 | // If a soundname is defined, we expect that this device has | 1794 | // If a soundname is defined, we expect that this device has |
1781 | // sound capabilities.. Otherwise we expect to have the buzzer | 1795 | // sound capabilities.. Otherwise we expect to have the buzzer |
1782 | // device.. | 1796 | // device.. |
1783 | if ( !soundname.isEmpty() ){ | 1797 | if ( !soundname.isEmpty() ){ |
1784 | int fd; | 1798 | int fd; |
1785 | int vol; | 1799 | int vol; |
1786 | bool vol_reset = false; | 1800 | bool vol_reset = false; |
1787 | 1801 | ||
1788 | Sound snd ( soundname ); | 1802 | Sound snd ( soundname ); |
1789 | 1803 | ||
1790 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1804 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1791 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1805 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1792 | Config cfg ( "qpe" ); | 1806 | Config cfg ( "qpe" ); |
1793 | cfg. setGroup ( "Volume" ); | 1807 | cfg. setGroup ( "Volume" ); |
1794 | 1808 | ||
1795 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1809 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1796 | if ( volalarm < 0 ) | 1810 | if ( volalarm < 0 ) |
1797 | volalarm = 0; | 1811 | volalarm = 0; |
1798 | else if ( volalarm > 100 ) | 1812 | else if ( volalarm > 100 ) |
1799 | volalarm = 100; | 1813 | volalarm = 100; |
1800 | volalarm |= ( volalarm << 8 ); | 1814 | volalarm |= ( volalarm << 8 ); |
1801 | 1815 | ||
1802 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1816 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1803 | vol_reset = true; | 1817 | vol_reset = true; |
1804 | } | 1818 | } |
1805 | } | 1819 | } |
1806 | 1820 | ||
1807 | snd. play ( ); | 1821 | snd. play ( ); |
1808 | while ( !snd. isFinished ( )) | 1822 | while ( !snd. isFinished ( )) |
1809 | qApp-> processEvents ( ); | 1823 | qApp-> processEvents ( ); |
1810 | 1824 | ||
1811 | if ( fd >= 0 ) { | 1825 | if ( fd >= 0 ) { |
1812 | if ( vol_reset ) | 1826 | if ( vol_reset ) |
1813 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1827 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1814 | ::close ( fd ); | 1828 | ::close ( fd ); |
1815 | } | 1829 | } |
1816 | } else { | 1830 | } else { |
1817 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1831 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1818 | 1832 | ||
1819 | if ( fd >= 0 ) { | 1833 | if ( fd >= 0 ) { |
1820 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1834 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1821 | ::close ( fd ); | 1835 | ::close ( fd ); |
1822 | } | 1836 | } |
1823 | 1837 | ||
1824 | } | 1838 | } |
1825 | #endif | 1839 | #endif |
1826 | } | 1840 | } |
1827 | 1841 | ||
1828 | 1842 | ||
1829 | void Zaurus::alarmSound ( ) | 1843 | void Zaurus::alarmSound ( ) |
1830 | { | 1844 | { |
1831 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1845 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1832 | } | 1846 | } |
1833 | 1847 | ||
1834 | void Zaurus::touchSound ( ) | 1848 | void Zaurus::touchSound ( ) |
1835 | { | 1849 | { |
1836 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1850 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1837 | } | 1851 | } |
1838 | 1852 | ||
1839 | void Zaurus::keySound ( ) | 1853 | void Zaurus::keySound ( ) |
1840 | { | 1854 | { |
1841 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1855 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1842 | } | 1856 | } |
1843 | 1857 | ||
1844 | 1858 | ||
1845 | QValueList <OLed> Zaurus::ledList ( ) const | 1859 | QValueList <OLed> Zaurus::ledList ( ) const |
1846 | { | 1860 | { |
1847 | QValueList <OLed> vl; | 1861 | QValueList <OLed> vl; |
1848 | vl << Led_Mail; | 1862 | vl << Led_Mail; |
1849 | return vl; | 1863 | return vl; |
1850 | } | 1864 | } |
1851 | 1865 | ||
1852 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1866 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1853 | { | 1867 | { |
1854 | QValueList <OLedState> vl; | 1868 | QValueList <OLedState> vl; |
1855 | 1869 | ||
1856 | if ( l == Led_Mail ) | 1870 | if ( l == Led_Mail ) |
1857 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1871 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1858 | return vl; | 1872 | return vl; |
1859 | } | 1873 | } |
1860 | 1874 | ||
1861 | OLedState Zaurus::ledState ( OLed which ) const | 1875 | OLedState Zaurus::ledState ( OLed which ) const |
1862 | { | 1876 | { |
1863 | if ( which == Led_Mail ) | 1877 | if ( which == Led_Mail ) |
1864 | return m_leds [0]; | 1878 | return m_leds [0]; |
1865 | else | 1879 | else |
1866 | return Led_Off; | 1880 | return Led_Off; |
1867 | } | 1881 | } |
1868 | 1882 | ||
1869 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1883 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1870 | { | 1884 | { |
1871 | if (!m_embedix) // Currently not supported on non_embedix kernels | 1885 | if (!m_embedix) // Currently not supported on non_embedix kernels |
1872 | return false; | 1886 | return false; |
1873 | 1887 | ||
1874 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1888 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1875 | 1889 | ||
1876 | if ( which == Led_Mail ) { | 1890 | if ( which == Led_Mail ) { |
1877 | if ( fd >= 0 ) { | 1891 | if ( fd >= 0 ) { |
1878 | struct sharp_led_status leds; | 1892 | struct sharp_led_status leds; |
1879 | ::memset ( &leds, 0, sizeof( leds )); | 1893 | ::memset ( &leds, 0, sizeof( leds )); |
1880 | leds. which = SHARP_LED_MAIL_EXISTS; | 1894 | leds. which = SHARP_LED_MAIL_EXISTS; |
1881 | bool ok = true; | 1895 | bool ok = true; |
1882 | 1896 | ||
1883 | switch ( st ) { | 1897 | switch ( st ) { |
1884 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1898 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1885 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1899 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1886 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1900 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1887 | default : ok = false; | 1901 | default : ok = false; |
1888 | } | 1902 | } |
1889 | 1903 | ||
1890 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1904 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1891 | m_leds [0] = st; | 1905 | m_leds [0] = st; |
1892 | return true; | 1906 | return true; |
1893 | } | 1907 | } |
1894 | } | 1908 | } |
1895 | } | 1909 | } |
1896 | return false; | 1910 | return false; |
1897 | } | 1911 | } |
1898 | 1912 | ||
1899 | bool Zaurus::setSoftSuspend ( bool soft ) | 1913 | bool Zaurus::setSoftSuspend ( bool soft ) |
1900 | { | 1914 | { |
1901 | if (!m_embedix) { | 1915 | if (!m_embedix) { |
1902 | /* non-Embedix kernels dont have kernel autosuspend */ | 1916 | /* non-Embedix kernels dont have kernel autosuspend */ |
1903 | return ODevice::setSoftSuspend( soft ); | 1917 | return ODevice::setSoftSuspend( soft ); |
1904 | } | 1918 | } |
1905 | 1919 | ||
1906 | bool res = false; | 1920 | bool res = false; |
1907 | int fd; | 1921 | int fd; |
1908 | 1922 | ||
1909 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1923 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1910 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1924 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1911 | 1925 | ||
1912 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1926 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1913 | 1927 | ||
1914 | if ( sources >= 0 ) { | 1928 | if ( sources >= 0 ) { |
1915 | if ( soft ) | 1929 | if ( soft ) |
1916 | sources &= ~APM_EVT_POWER_BUTTON; | 1930 | sources &= ~APM_EVT_POWER_BUTTON; |
1917 | else | 1931 | else |
1918 | sources |= APM_EVT_POWER_BUTTON; | 1932 | sources |= APM_EVT_POWER_BUTTON; |
1919 | 1933 | ||
1920 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1934 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1921 | res = true; | 1935 | res = true; |
1922 | else | 1936 | else |
1923 | perror ( "APM_IOCGEVTSRC" ); | 1937 | perror ( "APM_IOCGEVTSRC" ); |
1924 | } | 1938 | } |
1925 | else | 1939 | else |
1926 | perror ( "APM_IOCGEVTSRC" ); | 1940 | perror ( "APM_IOCGEVTSRC" ); |
1927 | 1941 | ||
1928 | ::close ( fd ); | 1942 | ::close ( fd ); |
1929 | } | 1943 | } |
1930 | else | 1944 | else |
1931 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1945 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1932 | 1946 | ||
1933 | return res; | 1947 | return res; |
1934 | } | 1948 | } |
1935 | 1949 | ||
1936 | 1950 | ||
1937 | bool Zaurus::setDisplayBrightness ( int bright ) | 1951 | bool Zaurus::setDisplayBrightness ( int bright ) |
1938 | { | 1952 | { |
1953 | // FIXME The C7x0 have a proc-interface (/proc/drivers/corgi-bl) which | ||
1954 | // is nice to use. Currently it exposes 16+1 levels. Implement this! | ||
1955 | // (or wait for kergoth unifying the interfaces in the OpenZaurus kernel.) | ||
1939 | bool res = false; | 1956 | bool res = false; |
1940 | int fd; | 1957 | int fd; |
1941 | 1958 | ||
1942 | if ( bright > 255 ) | 1959 | if ( bright > 255 ) |
1943 | bright = 255; | 1960 | bright = 255; |
1944 | if ( bright < 0 ) | 1961 | if ( bright < 0 ) |
1945 | bright = 0; | 1962 | bright = 0; |
1946 | 1963 | ||
1947 | if (m_embedix) { | 1964 | if (m_embedix) { |
1948 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1965 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1949 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1966 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1950 | if ( bright && !bl ) | 1967 | if ( bright && !bl ) |
1951 | bl = 1; | 1968 | bl = 1; |
1952 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1969 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1953 | ::close ( fd ); | 1970 | ::close ( fd ); |
1954 | } | 1971 | } |
1955 | } else { | 1972 | } else { |
1956 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 1973 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
1957 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 1974 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
1958 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 1975 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
1959 | ::close ( fd ); | 1976 | ::close ( fd ); |
1960 | } | 1977 | } |
1961 | } | 1978 | } |
1962 | return res; | 1979 | return res; |
1963 | } | 1980 | } |
1964 | 1981 | ||
1965 | 1982 | ||
1966 | int Zaurus::displayBrightnessResolution ( ) const | 1983 | int Zaurus::displayBrightnessResolution ( ) const |
1967 | { | 1984 | { |
1968 | if (m_embedix) | 1985 | if (m_embedix) |
1969 | return 5; | 1986 | return 5; |
1970 | else | 1987 | else |
1971 | return 256; | 1988 | return 256; |
1972 | } | 1989 | } |
1973 | 1990 | ||
1974 | /************************************************** | 1991 | /************************************************** |
1975 | * | 1992 | * |
1976 | * SIMpad | 1993 | * SIMpad |
1977 | * | 1994 | * |
1978 | **************************************************/ | 1995 | **************************************************/ |
1979 | 1996 | ||
1980 | void SIMpad::init ( ) | 1997 | void SIMpad::init ( ) |
1981 | { | 1998 | { |
1982 | d-> m_vendorstr = "SIEMENS"; | 1999 | d-> m_vendorstr = "SIEMENS"; |
1983 | d-> m_vendor = Vendor_SIEMENS; | 2000 | d-> m_vendor = Vendor_SIEMENS; |
1984 | 2001 | ||
1985 | QFile f ( "/proc/hal/model" ); | 2002 | QFile f ( "/proc/hal/model" ); |
1986 | 2003 | ||
1987 | //TODO Implement model checking | 2004 | //TODO Implement model checking |
1988 | //FIXME For now we assume an SL4 | 2005 | //FIXME For now we assume an SL4 |
1989 | 2006 | ||
1990 | d-> m_modelstr = "SL4"; | 2007 | d-> m_modelstr = "SL4"; |
1991 | d-> m_model = Model_SIMpad_SL4; | 2008 | d-> m_model = Model_SIMpad_SL4; |
1992 | 2009 | ||
1993 | switch ( d-> m_model ) { | 2010 | switch ( d-> m_model ) { |
1994 | default: | 2011 | default: |
1995 | d-> m_rotation = Rot0; | 2012 | d-> m_rotation = Rot0; |
1996 | d-> m_direction = CCW; | 2013 | d-> m_direction = CCW; |
1997 | d-> m_holdtime = 1000; // 1000ms | 2014 | d-> m_holdtime = 1000; // 1000ms |
1998 | 2015 | ||
1999 | break; | 2016 | break; |
2000 | } | 2017 | } |
2001 | 2018 | ||
2002 | f. setName ( "/etc/familiar-version" ); | 2019 | f. setName ( "/etc/familiar-version" ); |
2003 | if ( f. open ( IO_ReadOnly )) { | 2020 | if ( f. open ( IO_ReadOnly )) { |
2004 | d-> m_systemstr = "Familiar"; | 2021 | d-> m_systemstr = "Familiar"; |
2005 | d-> m_system = System_Familiar; | 2022 | d-> m_system = System_Familiar; |
2006 | 2023 | ||
2007 | QTextStream ts ( &f ); | 2024 | QTextStream ts ( &f ); |
2008 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2025 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2009 | 2026 | ||
2010 | f. close ( ); | 2027 | f. close ( ); |
2011 | } else { | 2028 | } else { |
2012 | f. setName ( "/etc/oz_version" ); | 2029 | f. setName ( "/etc/oz_version" ); |
2013 | 2030 | ||
2014 | if ( f. open ( IO_ReadOnly )) { | 2031 | if ( f. open ( IO_ReadOnly )) { |
2015 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 2032 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
2016 | d-> m_system = System_OpenZaurus; | 2033 | d-> m_system = System_OpenZaurus; |
2017 | 2034 | ||
2018 | QTextStream ts ( &f ); | 2035 | QTextStream ts ( &f ); |
2019 | ts.setDevice ( &f ); | 2036 | ts.setDevice ( &f ); |
2020 | d-> m_sysverstr = ts. readLine ( ); | 2037 | d-> m_sysverstr = ts. readLine ( ); |
2021 | f. close ( ); | 2038 | f. close ( ); |
2022 | } | 2039 | } |
2023 | } | 2040 | } |
2024 | 2041 | ||
2025 | m_leds [0] = m_leds [1] = Led_Off; | 2042 | m_leds [0] = m_leds [1] = Led_Off; |
2026 | 2043 | ||
2027 | m_power_timer = 0; | 2044 | m_power_timer = 0; |
2028 | 2045 | ||
2029 | } | 2046 | } |
2030 | 2047 | ||
2031 | void SIMpad::initButtons ( ) | 2048 | void SIMpad::initButtons ( ) |
2032 | { | 2049 | { |
2033 | if ( d-> m_buttons ) | 2050 | if ( d-> m_buttons ) |
2034 | return; | 2051 | return; |
2035 | 2052 | ||
2036 | if ( isQWS( ) ) | 2053 | if ( isQWS( ) ) |
2037 | QWSServer::setKeyboardFilter ( this ); | 2054 | QWSServer::setKeyboardFilter ( this ); |
2038 | 2055 | ||
2039 | d-> m_buttons = new QValueList <ODeviceButton>; | 2056 | d-> m_buttons = new QValueList <ODeviceButton>; |
2040 | 2057 | ||
2041 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 2058 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
2042 | s_button *sb = simpad_buttons + i; | 2059 | s_button *sb = simpad_buttons + i; |
2043 | ODeviceButton b; | 2060 | ODeviceButton b; |
2044 | 2061 | ||
2045 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 2062 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
2046 | b. setKeycode ( sb-> code ); | 2063 | b. setKeycode ( sb-> code ); |
2047 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 2064 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
2048 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 2065 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
2049 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 2066 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
2050 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 2067 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
2051 | 2068 | ||
2052 | d-> m_buttons-> append ( b ); | 2069 | d-> m_buttons-> append ( b ); |
2053 | } | 2070 | } |
2054 | } | 2071 | } |
2055 | reloadButtonMapping ( ); | 2072 | reloadButtonMapping ( ); |
2056 | 2073 | ||
2057 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2074 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2058 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2075 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
2059 | } | 2076 | } |
2060 | 2077 | ||
2061 | // SIMpad boardcontrol register CS3 | 2078 | // SIMpad boardcontrol register CS3 |
2062 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 2079 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
2063 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 2080 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
2064 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 2081 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
2065 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 2082 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
2066 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 2083 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
2067 | #define SIMPAD_DISPLAY_ON 0x0010 | 2084 | #define SIMPAD_DISPLAY_ON 0x0010 |
2068 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 2085 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
2069 | #define SIMPAD_MQ_RESET 0x0040 | 2086 | #define SIMPAD_MQ_RESET 0x0040 |
2070 | #define SIMPAD_PCMCIA_RESET 0x0080 | 2087 | #define SIMPAD_PCMCIA_RESET 0x0080 |
2071 | #define SIMPAD_DECT_POWER_ON 0x0100 | 2088 | #define SIMPAD_DECT_POWER_ON 0x0100 |
2072 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 2089 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
2073 | #define SIMPAD_RS232_ON 0x0400 | 2090 | #define SIMPAD_RS232_ON 0x0400 |
2074 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 2091 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
2075 | #define SIMPAD_LED2_ON 0x1000 | 2092 | #define SIMPAD_LED2_ON 0x1000 |
2076 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 2093 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
2077 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 2094 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
2078 | #define SIMPAD_RESET_SIMCARD 0x8000 | 2095 | #define SIMPAD_RESET_SIMCARD 0x8000 |
2079 | 2096 | ||
2080 | //SIMpad touchscreen backlight strength control | 2097 | //SIMpad touchscreen backlight strength control |
2081 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 2098 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
2082 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 2099 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
2083 | 2100 | ||
2084 | QValueList <OLed> SIMpad::ledList ( ) const | 2101 | QValueList <OLed> SIMpad::ledList ( ) const |
2085 | { | 2102 | { |
2086 | QValueList <OLed> vl; | 2103 | QValueList <OLed> vl; |
2087 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 2104 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
2088 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 2105 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
2089 | return vl; | 2106 | return vl; |
2090 | } | 2107 | } |
2091 | 2108 | ||
2092 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 2109 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
2093 | { | 2110 | { |
2094 | QValueList <OLedState> vl; | 2111 | QValueList <OLedState> vl; |
2095 | 2112 | ||
2096 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 2113 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
2097 | vl << Led_Off << Led_On; | 2114 | vl << Led_Off << Led_On; |
2098 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 2115 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
2099 | //vl << Led_Off; | 2116 | //vl << Led_Off; |
2100 | return vl; | 2117 | return vl; |
2101 | } | 2118 | } |
2102 | 2119 | ||
2103 | OLedState SIMpad::ledState ( OLed l ) const | 2120 | OLedState SIMpad::ledState ( OLed l ) const |
2104 | { | 2121 | { |
2105 | switch ( l ) { | 2122 | switch ( l ) { |
2106 | case Led_Power: | 2123 | case Led_Power: |
2107 | return m_leds [0]; | 2124 | return m_leds [0]; |
2108 | //case Led_Mail: | 2125 | //case Led_Mail: |
2109 | //return m_leds [1]; | 2126 | //return m_leds [1]; |
2110 | default: | 2127 | default: |
2111 | return Led_Off; | 2128 | return Led_Off; |
2112 | } | 2129 | } |
2113 | } | 2130 | } |
2114 | 2131 | ||
2115 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 2132 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
2116 | { | 2133 | { |
2117 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 2134 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
2118 | 2135 | ||
2119 | if ( l == Led_Power ) { | 2136 | if ( l == Led_Power ) { |
2120 | if ( fd >= 0 ) { | 2137 | if ( fd >= 0 ) { |
2121 | LED_IN leds; | 2138 | LED_IN leds; |
2122 | ::memset ( &leds, 0, sizeof( leds )); | 2139 | ::memset ( &leds, 0, sizeof( leds )); |
2123 | leds. TotalTime = 0; | 2140 | leds. TotalTime = 0; |
2124 | leds. OnTime = 0; | 2141 | leds. OnTime = 0; |
2125 | leds. OffTime = 1; | 2142 | leds. OffTime = 1; |
2126 | leds. OffOnBlink = 2; | 2143 | leds. OffOnBlink = 2; |
2127 | 2144 | ||
2128 | switch ( st ) { | 2145 | switch ( st ) { |
2129 | case Led_Off : leds. OffOnBlink = 0; break; | 2146 | case Led_Off : leds. OffOnBlink = 0; break; |
2130 | case Led_On : leds. OffOnBlink = 1; break; | 2147 | case Led_On : leds. OffOnBlink = 1; break; |
2131 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 2148 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
2132 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 2149 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
2133 | } | 2150 | } |
2134 | 2151 | ||
2135 | { | 2152 | { |
2136 | /*TODO Implement this like that: | 2153 | /*TODO Implement this like that: |
2137 | read from cs3 | 2154 | read from cs3 |
2138 | && with SIMPAD_LED2_ON | 2155 | && with SIMPAD_LED2_ON |
2139 | write to cs3 */ | 2156 | write to cs3 */ |
2140 | m_leds [0] = st; | 2157 | m_leds [0] = st; |
2141 | return true; | 2158 | return true; |
2142 | } | 2159 | } |
2143 | } | 2160 | } |
2144 | } | 2161 | } |
2145 | return false; | 2162 | return false; |
2146 | } | 2163 | } |
2147 | 2164 | ||
2148 | 2165 | ||
2149 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 2166 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
2150 | { | 2167 | { |
2151 | //TODO | 2168 | //TODO |
2152 | return false; | 2169 | return false; |
2153 | } | 2170 | } |
2154 | 2171 | ||
2155 | void SIMpad::timerEvent ( QTimerEvent * ) | 2172 | void SIMpad::timerEvent ( QTimerEvent * ) |
2156 | { | 2173 | { |
2157 | killTimer ( m_power_timer ); | 2174 | killTimer ( m_power_timer ); |
2158 | m_power_timer = 0; | 2175 | m_power_timer = 0; |
2159 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 2176 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
2160 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 2177 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
2161 | } | 2178 | } |
2162 | 2179 | ||
2163 | 2180 | ||
2164 | void SIMpad::alarmSound ( ) | 2181 | void SIMpad::alarmSound ( ) |
2165 | { | 2182 | { |
2166 | #ifndef QT_NO_SOUND | 2183 | #ifndef QT_NO_SOUND |
2167 | static Sound snd ( "alarm" ); | 2184 | static Sound snd ( "alarm" ); |
2168 | int fd; | 2185 | int fd; |
2169 | int vol; | 2186 | int vol; |
2170 | bool vol_reset = false; | 2187 | bool vol_reset = false; |
2171 | 2188 | ||
2172 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 2189 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
2173 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 2190 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
2174 | Config cfg ( "qpe" ); | 2191 | Config cfg ( "qpe" ); |
2175 | cfg. setGroup ( "Volume" ); | 2192 | cfg. setGroup ( "Volume" ); |
2176 | 2193 | ||
2177 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 2194 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
2178 | if ( volalarm < 0 ) | 2195 | if ( volalarm < 0 ) |
2179 | volalarm = 0; | 2196 | volalarm = 0; |
2180 | else if ( volalarm > 100 ) | 2197 | else if ( volalarm > 100 ) |
2181 | volalarm = 100; | 2198 | volalarm = 100; |
2182 | volalarm |= ( volalarm << 8 ); | 2199 | volalarm |= ( volalarm << 8 ); |
2183 | 2200 | ||
2184 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 2201 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
2185 | vol_reset = true; | 2202 | vol_reset = true; |
2186 | } | 2203 | } |
2187 | } | 2204 | } |
2188 | 2205 | ||
2189 | snd. play ( ); | 2206 | snd. play ( ); |
2190 | while ( !snd. isFinished ( )) | 2207 | while ( !snd. isFinished ( )) |
2191 | qApp-> processEvents ( ); | 2208 | qApp-> processEvents ( ); |
2192 | 2209 | ||
2193 | if ( fd >= 0 ) { | 2210 | if ( fd >= 0 ) { |
2194 | if ( vol_reset ) | 2211 | if ( vol_reset ) |
2195 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 2212 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
2196 | ::close ( fd ); | 2213 | ::close ( fd ); |
2197 | } | 2214 | } |
2198 | #endif | 2215 | #endif |
2199 | } | 2216 | } |
2200 | 2217 | ||
2201 | 2218 | ||
2202 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 2219 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
2203 | { | 2220 | { |
2204 | qDebug( "ODevice for SIMpad: suspend()" ); | 2221 | qDebug( "ODevice for SIMpad: suspend()" ); |
2205 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2222 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2206 | return false; | 2223 | return false; |
2207 | 2224 | ||
2208 | bool res = false; | 2225 | bool res = false; |
2209 | 2226 | ||
2210 | struct timeval tvs, tvn; | 2227 | struct timeval tvs, tvn; |
2211 | ::gettimeofday ( &tvs, 0 ); | 2228 | ::gettimeofday ( &tvs, 0 ); |
2212 | 2229 | ||
2213 | ::sync ( ); // flush fs caches | 2230 | ::sync ( ); // flush fs caches |
2214 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 2231 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
2215 | 2232 | ||
2216 | return res; | 2233 | return res; |
2217 | } | 2234 | } |
2218 | 2235 | ||
2219 | 2236 | ||
2220 | bool SIMpad::setSoftSuspend ( bool soft ) | 2237 | bool SIMpad::setSoftSuspend ( bool soft ) |
2221 | { | 2238 | { |
2222 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 2239 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
2223 | return false; | 2240 | return false; |
2224 | } | 2241 | } |
2225 | 2242 | ||
2226 | 2243 | ||
2227 | bool SIMpad::setDisplayStatus ( bool on ) | 2244 | bool SIMpad::setDisplayStatus ( bool on ) |
2228 | { | 2245 | { |
2229 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 2246 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
2230 | 2247 | ||
2231 | bool res = false; | 2248 | bool res = false; |
2232 | int fd; | 2249 | int fd; |
2233 | 2250 | ||
2234 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 2251 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
2235 | 2252 | ||
2236 | res = ( ::system( (const char*) cmdline ) == 0 ); | 2253 | res = ( ::system( (const char*) cmdline ) == 0 ); |
2237 | 2254 | ||
2238 | return res; | 2255 | return res; |
2239 | } | 2256 | } |
2240 | 2257 | ||
2241 | 2258 | ||
2242 | bool SIMpad::setDisplayBrightness ( int bright ) | 2259 | bool SIMpad::setDisplayBrightness ( int bright ) |
2243 | { | 2260 | { |
2244 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 2261 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
2245 | bool res = false; | 2262 | bool res = false; |
2246 | int fd; | 2263 | int fd; |
2247 | 2264 | ||
2248 | if ( bright > 255 ) | 2265 | if ( bright > 255 ) |
2249 | bright = 255; | 2266 | bright = 255; |
2250 | if ( bright < 1 ) | 2267 | if ( bright < 1 ) |
2251 | bright = 0; | 2268 | bright = 0; |
2252 | 2269 | ||
2253 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 2270 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
2254 | int value = 255 - bright; | 2271 | int value = 255 - bright; |
2255 | const int mask = SIMPAD_BACKLIGHT_MASK; | 2272 | const int mask = SIMPAD_BACKLIGHT_MASK; |
2256 | value = value << 8; | 2273 | value = value << 8; |
2257 | value += mask; | 2274 | value += mask; |
2258 | char writeCommand[100]; | 2275 | char writeCommand[100]; |
2259 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 2276 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
2260 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 2277 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
2261 | ::close ( fd ); | 2278 | ::close ( fd ); |
2262 | } | 2279 | } |
2263 | return res; | 2280 | return res; |
2264 | } | 2281 | } |
2265 | 2282 | ||
2266 | 2283 | ||
2267 | int SIMpad::displayBrightnessResolution ( ) const | 2284 | int SIMpad::displayBrightnessResolution ( ) const |
2268 | { | 2285 | { |
2269 | return 255; // All SIMpad models share the same display | 2286 | return 255; // All SIMpad models share the same display |
2270 | } | 2287 | } |
2271 | 2288 | ||
2272 | /************************************************** | 2289 | /************************************************** |
2273 | * | 2290 | * |
2274 | * Ramses | 2291 | * Ramses |
2275 | * | 2292 | * |
2276 | **************************************************/ | 2293 | **************************************************/ |
2277 | 2294 | ||
2278 | void Ramses::init() | 2295 | void Ramses::init() |
2279 | { | 2296 | { |
2280 | d->m_vendorstr = "M und N"; | 2297 | d->m_vendorstr = "M und N"; |
2281 | d->m_vendor = Vendor_MundN; | 2298 | d->m_vendor = Vendor_MundN; |
2282 | 2299 | ||
2283 | QFile f("/proc/sys/board/ramses"); | 2300 | QFile f("/proc/sys/board/ramses"); |
2284 | 2301 | ||
2285 | d->m_modelstr = "Ramses"; | 2302 | d->m_modelstr = "Ramses"; |
2286 | d->m_model = Model_Ramses_MNCI; | 2303 | d->m_model = Model_Ramses_MNCI; |
2287 | 2304 | ||
2288 | d->m_rotation = Rot0; | 2305 | d->m_rotation = Rot0; |
2289 | d->m_holdtime = 1000; | 2306 | d->m_holdtime = 1000; |
2290 | 2307 | ||
2291 | f.setName("/etc/oz_version"); | 2308 | f.setName("/etc/oz_version"); |
2292 | 2309 | ||
2293 | if (f.open(IO_ReadOnly)) { | 2310 | if (f.open(IO_ReadOnly)) { |
2294 | d->m_systemstr = "OpenEmbedded/Ramses"; | 2311 | d->m_systemstr = "OpenEmbedded/Ramses"; |
2295 | d->m_system = System_OpenZaurus; | 2312 | d->m_system = System_OpenZaurus; |
2296 | 2313 | ||
2297 | QTextStream ts(&f); | 2314 | QTextStream ts(&f); |
2298 | ts.setDevice(&f); | 2315 | ts.setDevice(&f); |
2299 | d->m_sysverstr = ts.readLine(); | 2316 | d->m_sysverstr = ts.readLine(); |
2300 | f.close(); | 2317 | f.close(); |
2301 | } | 2318 | } |
2302 | 2319 | ||
2303 | m_power_timer = 0; | 2320 | m_power_timer = 0; |
2304 | 2321 | ||
2305 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 2322 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
2306 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 2323 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
2307 | #define OC(x...) x | 2324 | #define OC(x...) x |
2308 | #else | 2325 | #else |
2309 | #define OC(x...) | 2326 | #define OC(x...) |
2310 | #endif | 2327 | #endif |
2311 | 2328 | ||
2312 | 2329 | ||
2313 | // This table is true for a Intel XScale PXA 255 | 2330 | // This table is true for a Intel XScale PXA 255 |
2314 | 2331 | ||
2315 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 2332 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
2316 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 2333 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
2317 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 2334 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
2318 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 2335 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
2319 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 2336 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
2320 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 2337 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
2321 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 2338 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
2322 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 2339 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
2323 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 2340 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
2324 | 2341 | ||
2325 | } | 2342 | } |
2326 | 2343 | ||
2327 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2344 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
2328 | { | 2345 | { |
2329 | Q_UNUSED( keycode ); | 2346 | Q_UNUSED( keycode ); |
2330 | Q_UNUSED( modifiers ); | 2347 | Q_UNUSED( modifiers ); |
2331 | Q_UNUSED( isPress ); | 2348 | Q_UNUSED( isPress ); |
2332 | Q_UNUSED( autoRepeat ); | 2349 | Q_UNUSED( autoRepeat ); |
2333 | return false; | 2350 | return false; |
2334 | } | 2351 | } |
2335 | 2352 | ||
2336 | void Ramses::timerEvent(QTimerEvent *) | 2353 | void Ramses::timerEvent(QTimerEvent *) |
2337 | { | 2354 | { |
2338 | killTimer(m_power_timer); | 2355 | killTimer(m_power_timer); |
2339 | m_power_timer = 0; | 2356 | m_power_timer = 0; |
2340 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2357 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2341 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2358 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2342 | } | 2359 | } |
2343 | 2360 | ||
2344 | 2361 | ||
2345 | bool Ramses::setSoftSuspend(bool soft) | 2362 | bool Ramses::setSoftSuspend(bool soft) |
2346 | { | 2363 | { |
2347 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 2364 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
2348 | #if 0 | 2365 | #if 0 |
2349 | bool res = false; | 2366 | bool res = false; |
2350 | int fd; | 2367 | int fd; |
2351 | 2368 | ||
2352 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 2369 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
2353 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 2370 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
2354 | 2371 | ||
2355 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 2372 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
2356 | 2373 | ||
2357 | if (sources >= 0) { | 2374 | if (sources >= 0) { |
2358 | if (soft) | 2375 | if (soft) |
2359 | sources &= ~APM_EVT_POWER_BUTTON; | 2376 | sources &= ~APM_EVT_POWER_BUTTON; |
2360 | else | 2377 | else |
2361 | sources |= APM_EVT_POWER_BUTTON; | 2378 | sources |= APM_EVT_POWER_BUTTON; |
2362 | 2379 | ||
2363 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 2380 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
2364 | res = true; | 2381 | res = true; |
2365 | else | 2382 | else |
2366 | perror("APM_IOCGEVTSRC"); | 2383 | perror("APM_IOCGEVTSRC"); |
2367 | } | 2384 | } |
2368 | else | 2385 | else |
2369 | perror("APM_IOCGEVTSRC"); | 2386 | perror("APM_IOCGEVTSRC"); |
2370 | 2387 | ||
2371 | ::close(fd); | 2388 | ::close(fd); |
2372 | } | 2389 | } |
2373 | else | 2390 | else |
2374 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 2391 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
2375 | 2392 | ||
2376 | return res; | 2393 | return res; |
2377 | #else | 2394 | #else |
2378 | return true; | 2395 | return true; |
2379 | #endif | 2396 | #endif |
2380 | } | 2397 | } |
2381 | 2398 | ||
2382 | bool Ramses::suspend ( ) | 2399 | bool Ramses::suspend ( ) |
2383 | { | 2400 | { |
2384 | qDebug("Ramses::suspend"); | 2401 | qDebug("Ramses::suspend"); |
2385 | return false; | 2402 | return false; |
2386 | } | 2403 | } |
2387 | 2404 | ||
2388 | /** | 2405 | /** |
2389 | * This sets the display on or off | 2406 | * This sets the display on or off |
2390 | */ | 2407 | */ |
2391 | bool Ramses::setDisplayStatus(bool on) | 2408 | bool Ramses::setDisplayStatus(bool on) |
2392 | { | 2409 | { |
2393 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2410 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2394 | #if 0 | 2411 | #if 0 |
2395 | bool res = false; | 2412 | bool res = false; |
2396 | int fd; | 2413 | int fd; |
2397 | 2414 | ||
2398 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2415 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2399 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2416 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2400 | ::close(fd); | 2417 | ::close(fd); |
2401 | } | 2418 | } |
2402 | return res; | 2419 | return res; |
2403 | #else | 2420 | #else |
2404 | return true; | 2421 | return true; |
2405 | #endif | 2422 | #endif |
2406 | } | 2423 | } |
2407 | 2424 | ||
2408 | 2425 | ||
2409 | /* | 2426 | /* |
2410 | * We get something between 0..255 into us | 2427 | * We get something between 0..255 into us |
2411 | */ | 2428 | */ |
2412 | bool Ramses::setDisplayBrightness(int bright) | 2429 | bool Ramses::setDisplayBrightness(int bright) |
2413 | { | 2430 | { |
2414 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2431 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2415 | bool res = false; | 2432 | bool res = false; |
2416 | int fd; | 2433 | int fd; |
2417 | 2434 | ||
2418 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2435 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2419 | 2436 | ||
2420 | if (bright > 255 ) | 2437 | if (bright > 255 ) |
2421 | bright = 255; | 2438 | bright = 255; |
2422 | if (bright < 0) | 2439 | if (bright < 0) |
2423 | bright = 0; | 2440 | bright = 0; |
2424 | 2441 | ||
2425 | // Turn backlight completely off | 2442 | // Turn backlight completely off |
2426 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2443 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2427 | char writeCommand[10]; | 2444 | char writeCommand[10]; |
2428 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2445 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2429 | res = (::write(fd, writeCommand, count) != -1); | 2446 | res = (::write(fd, writeCommand, count) != -1); |
2430 | ::close(fd); | 2447 | ::close(fd); |
2431 | } | 2448 | } |
2432 | 2449 | ||
2433 | // scale backlight brightness to hardware | 2450 | // scale backlight brightness to hardware |
2434 | bright = 500-(bright * 500 / 255); | 2451 | bright = 500-(bright * 500 / 255); |
2435 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2452 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2436 | qDebug(" %d -> pwm1", bright); | 2453 | qDebug(" %d -> pwm1", bright); |
2437 | char writeCommand[100]; | 2454 | char writeCommand[100]; |
2438 | const int count = sprintf(writeCommand, "%d\n", bright); | 2455 | const int count = sprintf(writeCommand, "%d\n", bright); |
2439 | res = (::write(fd, writeCommand, count) != -1); | 2456 | res = (::write(fd, writeCommand, count) != -1); |
2440 | ::close(fd); | 2457 | ::close(fd); |
2441 | } | 2458 | } |
2442 | return res; | 2459 | return res; |
2443 | } | 2460 | } |
2444 | 2461 | ||
2445 | 2462 | ||
2446 | int Ramses::displayBrightnessResolution() const | 2463 | int Ramses::displayBrightnessResolution() const |
2447 | { | 2464 | { |
2448 | return 32; | 2465 | return 32; |
2449 | } | 2466 | } |
2450 | 2467 | ||
2451 | bool Ramses::setDisplayContrast(int contr) | 2468 | bool Ramses::setDisplayContrast(int contr) |
2452 | { | 2469 | { |
2453 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2470 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2454 | bool res = false; | 2471 | bool res = false; |
2455 | int fd; | 2472 | int fd; |
2456 | 2473 | ||
2457 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2474 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2458 | 2475 | ||
2459 | if (contr > 255 ) | 2476 | if (contr > 255 ) |
2460 | contr = 255; | 2477 | contr = 255; |
2461 | if (contr < 0) | 2478 | if (contr < 0) |
2462 | contr = 0; | 2479 | contr = 0; |
2463 | contr = 90 - (contr * 20 / 255); | 2480 | contr = 90 - (contr * 20 / 255); |
2464 | 2481 | ||
2465 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2482 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2466 | qDebug(" %d -> pwm0", contr); | 2483 | qDebug(" %d -> pwm0", contr); |
2467 | char writeCommand[100]; | 2484 | char writeCommand[100]; |
2468 | const int count = sprintf(writeCommand, "%d\n", contr); | 2485 | const int count = sprintf(writeCommand, "%d\n", contr); |
2469 | res = (::write(fd, writeCommand, count) != -1); | 2486 | res = (::write(fd, writeCommand, count) != -1); |
2470 | res = true; | 2487 | res = true; |
2471 | ::close(fd); | 2488 | ::close(fd); |
2472 | } | 2489 | } |
2473 | return res; | 2490 | return res; |
2474 | } | 2491 | } |
2475 | 2492 | ||
2476 | 2493 | ||
2477 | int Ramses::displayContrastResolution() const | 2494 | int Ramses::displayContrastResolution() const |
2478 | { | 2495 | { |
2479 | return 20; | 2496 | return 20; |
2480 | } | 2497 | } |
2481 | 2498 | ||
2482 | 2499 | ||
2483 | /************************************************** | 2500 | /************************************************** |
2484 | * * | 2501 | * * |
2485 | * Jornada * | 2502 | * Jornada * |
2486 | * * | 2503 | * * |
2487 | **************************************************/ | 2504 | **************************************************/ |
2488 | 2505 | ||
2489 | 2506 | ||
2490 | bool Jornada::isJornada ( ) | 2507 | bool Jornada::isJornada ( ) |
2491 | { | 2508 | { |
2492 | QFile f( "/proc/cpuinfo" ); | 2509 | QFile f( "/proc/cpuinfo" ); |
2493 | if ( f. open ( IO_ReadOnly ) ) { | 2510 | if ( f. open ( IO_ReadOnly ) ) { |
2494 | QTextStream ts ( &f ); | 2511 | QTextStream ts ( &f ); |
2495 | QString line; | 2512 | QString line; |
2496 | while( line = ts. readLine ( ) ) { | 2513 | while( line = ts. readLine ( ) ) { |
2497 | if ( line. left ( 8 ) == "Hardware" ) { | 2514 | if ( line. left ( 8 ) == "Hardware" ) { |
2498 | int loc = line. find ( ":" ); | 2515 | int loc = line. find ( ":" ); |
2499 | if ( loc != -1 ) { | 2516 | if ( loc != -1 ) { |
2500 | QString model = | 2517 | QString model = |
2501 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 2518 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
2502 | return ( model == "HP Jornada 56x" ); | 2519 | return ( model == "HP Jornada 56x" ); |
2503 | } | 2520 | } |
2504 | } | 2521 | } |
2505 | } | 2522 | } |
2506 | } | 2523 | } |
2507 | return false; | 2524 | return false; |
2508 | } | 2525 | } |
2509 | 2526 | ||
2510 | void Jornada::init ( ) | 2527 | void Jornada::init ( ) |
2511 | { | 2528 | { |
2512 | d-> m_vendorstr = "HP"; | 2529 | d-> m_vendorstr = "HP"; |
2513 | d-> m_vendor = Vendor_HP; | 2530 | d-> m_vendor = Vendor_HP; |
2514 | d-> m_modelstr = "Jornada 56x"; | 2531 | d-> m_modelstr = "Jornada 56x"; |
2515 | d-> m_model = Model_Jornada_56x; | 2532 | d-> m_model = Model_Jornada_56x; |
2516 | d-> m_systemstr = "Familiar"; | 2533 | d-> m_systemstr = "Familiar"; |
2517 | d-> m_system = System_Familiar; | 2534 | d-> m_system = System_Familiar; |
2518 | d-> m_rotation = Rot0; | 2535 | d-> m_rotation = Rot0; |
2519 | 2536 | ||
2520 | QFile f ( "/etc/familiar-version" ); | 2537 | QFile f ( "/etc/familiar-version" ); |
2521 | f. setName ( "/etc/familiar-version" ); | 2538 | f. setName ( "/etc/familiar-version" ); |
2522 | if ( f. open ( IO_ReadOnly )) { | 2539 | if ( f. open ( IO_ReadOnly )) { |
2523 | 2540 | ||
2524 | QTextStream ts ( &f ); | 2541 | QTextStream ts ( &f ); |
2525 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2542 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2526 | 2543 | ||
2527 | f. close ( ); | 2544 | f. close ( ); |
2528 | } | 2545 | } |
2529 | } | 2546 | } |
2530 | 2547 | ||
2531 | #if 0 | 2548 | #if 0 |
2532 | void Jornada::initButtons ( ) | 2549 | void Jornada::initButtons ( ) |
2533 | { | 2550 | { |
2534 | if ( d-> m_buttons ) | 2551 | if ( d-> m_buttons ) |
2535 | return; | 2552 | return; |
2536 | 2553 | ||
2537 | // Simulation uses iPAQ 3660 device buttons | 2554 | // Simulation uses iPAQ 3660 device buttons |
2538 | 2555 | ||
2539 | qDebug ( "init Buttons" ); | 2556 | qDebug ( "init Buttons" ); |
2540 | d-> m_buttons = new QValueList <ODeviceButton>; | 2557 | d-> m_buttons = new QValueList <ODeviceButton>; |
2541 | 2558 | ||
2542 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 2559 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
2543 | i_button *ib = ipaq_buttons + i; | 2560 | i_button *ib = ipaq_buttons + i; |
2544 | ODeviceButton b; | 2561 | ODeviceButton b; |
2545 | 2562 | ||
2546 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 2563 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
2547 | b. setKeycode ( ib-> code ); | 2564 | b. setKeycode ( ib-> code ); |
2548 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 2565 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
2549 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 2566 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
2550 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 2567 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
2551 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 2568 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
2552 | d-> m_buttons-> append ( b ); | 2569 | d-> m_buttons-> append ( b ); |
2553 | } | 2570 | } |
2554 | } | 2571 | } |
2555 | reloadButtonMapping ( ); | 2572 | reloadButtonMapping ( ); |
2556 | 2573 | ||
2557 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2574 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2558 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 2575 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
2559 | } | 2576 | } |
2560 | #endif | 2577 | #endif |
2561 | int Jornada::displayBrightnessResolution ( ) const | 2578 | int Jornada::displayBrightnessResolution ( ) const |
2562 | { | 2579 | { |
2563 | } | 2580 | } |
2564 | 2581 | ||
2565 | bool Jornada::setDisplayBrightness ( int bright ) | 2582 | bool Jornada::setDisplayBrightness ( int bright ) |
2566 | { | 2583 | { |
2567 | bool res = false; | 2584 | bool res = false; |
2568 | int fd; | 2585 | int fd; |
2569 | 2586 | ||
2570 | if ( bright > 255 ) | 2587 | if ( bright > 255 ) |
2571 | bright = 255; | 2588 | bright = 255; |
2572 | if ( bright < 0 ) | 2589 | if ( bright < 0 ) |
2573 | bright = 0; | 2590 | bright = 0; |
2574 | 2591 | ||
2575 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 2592 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
2576 | FLITE_IN bl; | 2593 | FLITE_IN bl; |
2577 | bl. mode = 1; | 2594 | bl. mode = 1; |
2578 | bl. pwr = bright ? 1 : 0; | 2595 | bl. pwr = bright ? 1 : 0; |
2579 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 2596 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
2580 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 2597 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
2581 | ::close ( fd ); | 2598 | ::close ( fd ); |
2582 | } | 2599 | } |
2583 | return res; | 2600 | return res; |
2584 | } | 2601 | } |
2585 | 2602 | ||
2586 | bool Jornada::setSoftSuspend ( bool soft ) | 2603 | bool Jornada::setSoftSuspend ( bool soft ) |
2587 | { | 2604 | { |
2588 | bool res = false; | 2605 | bool res = false; |
2589 | int fd; | 2606 | int fd; |
2590 | 2607 | ||
2591 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 2608 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
2592 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 2609 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
2593 | res = true; | 2610 | res = true; |
2594 | else | 2611 | else |
2595 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 2612 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
2596 | 2613 | ||
2597 | ::close ( fd ); | 2614 | ::close ( fd ); |
2598 | } | 2615 | } |
2599 | else | 2616 | else |
2600 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 2617 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
2601 | 2618 | ||
2602 | return res; | 2619 | return res; |
2603 | } | 2620 | } |