author | kergoth <kergoth> | 2002-12-12 00:28:48 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-12-12 00:28:48 (UTC) |
commit | cb783a8ddbeb6c85481c5b1a807f21be83817255 (patch) (unidiff) | |
tree | ba7823d58f7cf34d8fffd5818ea5e1ff72432182 | |
parent | 474b8efcacfffb04bf72f486eca7b1455a2b81dd (diff) | |
download | opie-cb783a8ddbeb6c85481c5b1a807f21be83817255.zip opie-cb783a8ddbeb6c85481c5b1a807f21be83817255.tar.gz opie-cb783a8ddbeb6c85481c5b1a807f21be83817255.tar.bz2 |
Proper zaurus model checking for ODevice
-rw-r--r-- | libopie/odevice.cpp | 19 | ||||
-rw-r--r-- | libopie/odevice.h | 1 |
2 files changed, 18 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index bc43c52..a33d4ad 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -525,409 +525,424 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
525 | } | 525 | } |
526 | 526 | ||
527 | // Rotate cursor keys 180° | 527 | // Rotate cursor keys 180° |
528 | case Key_Left : | 528 | case Key_Left : |
529 | case Key_Right: | 529 | case Key_Right: |
530 | case Key_Up : | 530 | case Key_Up : |
531 | case Key_Down : { | 531 | case Key_Down : { |
532 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 532 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
533 | ( d-> m_model == Model_iPAQ_H38xx )) { | 533 | ( d-> m_model == Model_iPAQ_H38xx )) { |
534 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 534 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
535 | } | 535 | } |
536 | break; | 536 | break; |
537 | } | 537 | } |
538 | 538 | ||
539 | // map Power Button short/long press to F34/F35 | 539 | // map Power Button short/long press to F34/F35 |
540 | case Key_SysReq: { | 540 | case Key_SysReq: { |
541 | if ( isPress ) { | 541 | if ( isPress ) { |
542 | if ( m_power_timer ) | 542 | if ( m_power_timer ) |
543 | killTimer ( m_power_timer ); | 543 | killTimer ( m_power_timer ); |
544 | m_power_timer = startTimer ( 500 ); | 544 | m_power_timer = startTimer ( 500 ); |
545 | } | 545 | } |
546 | else if ( m_power_timer ) { | 546 | else if ( m_power_timer ) { |
547 | killTimer ( m_power_timer ); | 547 | killTimer ( m_power_timer ); |
548 | m_power_timer = 0; | 548 | m_power_timer = 0; |
549 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 549 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
550 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 550 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
551 | } | 551 | } |
552 | newkeycode = Key_unknown; | 552 | newkeycode = Key_unknown; |
553 | break; | 553 | break; |
554 | } | 554 | } |
555 | } | 555 | } |
556 | 556 | ||
557 | if ( newkeycode != keycode ) { | 557 | if ( newkeycode != keycode ) { |
558 | if ( newkeycode != Key_unknown ) | 558 | if ( newkeycode != Key_unknown ) |
559 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 559 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
560 | return true; | 560 | return true; |
561 | } | 561 | } |
562 | else | 562 | else |
563 | return false; | 563 | return false; |
564 | } | 564 | } |
565 | 565 | ||
566 | void iPAQ::timerEvent ( QTimerEvent * ) | 566 | void iPAQ::timerEvent ( QTimerEvent * ) |
567 | { | 567 | { |
568 | killTimer ( m_power_timer ); | 568 | killTimer ( m_power_timer ); |
569 | m_power_timer = 0; | 569 | m_power_timer = 0; |
570 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 570 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
571 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 571 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
572 | } | 572 | } |
573 | 573 | ||
574 | 574 | ||
575 | void iPAQ::alarmSound ( ) | 575 | void iPAQ::alarmSound ( ) |
576 | { | 576 | { |
577 | #ifndef QT_NO_SOUND | 577 | #ifndef QT_NO_SOUND |
578 | static Sound snd ( "alarm" ); | 578 | static Sound snd ( "alarm" ); |
579 | int fd; | 579 | int fd; |
580 | int vol; | 580 | int vol; |
581 | bool vol_reset = false; | 581 | bool vol_reset = false; |
582 | 582 | ||
583 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 583 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
584 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 584 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
585 | Config cfg ( "qpe" ); | 585 | Config cfg ( "qpe" ); |
586 | cfg. setGroup ( "Volume" ); | 586 | cfg. setGroup ( "Volume" ); |
587 | 587 | ||
588 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 588 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
589 | if ( volalarm < 0 ) | 589 | if ( volalarm < 0 ) |
590 | volalarm = 0; | 590 | volalarm = 0; |
591 | else if ( volalarm > 100 ) | 591 | else if ( volalarm > 100 ) |
592 | volalarm = 100; | 592 | volalarm = 100; |
593 | volalarm |= ( volalarm << 8 ); | 593 | volalarm |= ( volalarm << 8 ); |
594 | 594 | ||
595 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 595 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
596 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 596 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
597 | vol_reset = true; | 597 | vol_reset = true; |
598 | } | 598 | } |
599 | } | 599 | } |
600 | } | 600 | } |
601 | 601 | ||
602 | snd. play ( ); | 602 | snd. play ( ); |
603 | while ( !snd. isFinished ( )) | 603 | while ( !snd. isFinished ( )) |
604 | qApp-> processEvents ( ); | 604 | qApp-> processEvents ( ); |
605 | 605 | ||
606 | if ( fd >= 0 ) { | 606 | if ( fd >= 0 ) { |
607 | if ( vol_reset ) | 607 | if ( vol_reset ) |
608 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 608 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
609 | ::close ( fd ); | 609 | ::close ( fd ); |
610 | } | 610 | } |
611 | #endif | 611 | #endif |
612 | } | 612 | } |
613 | 613 | ||
614 | 614 | ||
615 | bool iPAQ::setSoftSuspend ( bool soft ) | 615 | bool iPAQ::setSoftSuspend ( bool soft ) |
616 | { | 616 | { |
617 | bool res = false; | 617 | bool res = false; |
618 | int fd; | 618 | int fd; |
619 | 619 | ||
620 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 620 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
621 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 621 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
622 | res = true; | 622 | res = true; |
623 | else | 623 | else |
624 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 624 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
625 | 625 | ||
626 | ::close ( fd ); | 626 | ::close ( fd ); |
627 | } | 627 | } |
628 | else | 628 | else |
629 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 629 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
630 | 630 | ||
631 | return res; | 631 | return res; |
632 | } | 632 | } |
633 | 633 | ||
634 | 634 | ||
635 | bool iPAQ::setDisplayBrightness ( int bright ) | 635 | bool iPAQ::setDisplayBrightness ( int bright ) |
636 | { | 636 | { |
637 | bool res = false; | 637 | bool res = false; |
638 | int fd; | 638 | int fd; |
639 | 639 | ||
640 | if ( bright > 255 ) | 640 | if ( bright > 255 ) |
641 | bright = 255; | 641 | bright = 255; |
642 | if ( bright < 0 ) | 642 | if ( bright < 0 ) |
643 | bright = 0; | 643 | bright = 0; |
644 | 644 | ||
645 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 645 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
646 | FLITE_IN bl; | 646 | FLITE_IN bl; |
647 | bl. mode = 1; | 647 | bl. mode = 1; |
648 | bl. pwr = bright ? 1 : 0; | 648 | bl. pwr = bright ? 1 : 0; |
649 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 649 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
650 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 650 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
651 | ::close ( fd ); | 651 | ::close ( fd ); |
652 | } | 652 | } |
653 | return res; | 653 | return res; |
654 | } | 654 | } |
655 | 655 | ||
656 | int iPAQ::displayBrightnessResolution ( ) const | 656 | int iPAQ::displayBrightnessResolution ( ) const |
657 | { | 657 | { |
658 | switch ( model ( )) { | 658 | switch ( model ( )) { |
659 | case Model_iPAQ_H31xx: | 659 | case Model_iPAQ_H31xx: |
660 | case Model_iPAQ_H36xx: | 660 | case Model_iPAQ_H36xx: |
661 | case Model_iPAQ_H37xx: | 661 | case Model_iPAQ_H37xx: |
662 | return 128; // really 256, but >128 could damage the LCD | 662 | return 128; // really 256, but >128 could damage the LCD |
663 | 663 | ||
664 | case Model_iPAQ_H38xx: | 664 | case Model_iPAQ_H38xx: |
665 | case Model_iPAQ_H39xx: | 665 | case Model_iPAQ_H39xx: |
666 | return 64; | 666 | return 64; |
667 | 667 | ||
668 | default: | 668 | default: |
669 | return 2; | 669 | return 2; |
670 | } | 670 | } |
671 | } | 671 | } |
672 | 672 | ||
673 | 673 | ||
674 | bool iPAQ::hasLightSensor ( ) const | 674 | bool iPAQ::hasLightSensor ( ) const |
675 | { | 675 | { |
676 | return true; | 676 | return true; |
677 | } | 677 | } |
678 | 678 | ||
679 | int iPAQ::readLightSensor ( ) | 679 | int iPAQ::readLightSensor ( ) |
680 | { | 680 | { |
681 | int fd; | 681 | int fd; |
682 | int val = -1; | 682 | int val = -1; |
683 | 683 | ||
684 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 684 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
685 | char buffer [8]; | 685 | char buffer [8]; |
686 | 686 | ||
687 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 687 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
688 | char *endptr; | 688 | char *endptr; |
689 | 689 | ||
690 | buffer [4] = 0; | 690 | buffer [4] = 0; |
691 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 691 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
692 | 692 | ||
693 | if ( *endptr != 0 ) | 693 | if ( *endptr != 0 ) |
694 | val = -1; | 694 | val = -1; |
695 | } | 695 | } |
696 | ::close ( fd ); | 696 | ::close ( fd ); |
697 | } | 697 | } |
698 | 698 | ||
699 | return val; | 699 | return val; |
700 | } | 700 | } |
701 | 701 | ||
702 | int iPAQ::lightSensorResolution ( ) const | 702 | int iPAQ::lightSensorResolution ( ) const |
703 | { | 703 | { |
704 | return 256; | 704 | return 256; |
705 | } | 705 | } |
706 | 706 | ||
707 | /************************************************** | 707 | /************************************************** |
708 | * | 708 | * |
709 | * Zaurus | 709 | * Zaurus |
710 | * | 710 | * |
711 | **************************************************/ | 711 | **************************************************/ |
712 | 712 | ||
713 | 713 | ||
714 | 714 | ||
715 | void Zaurus::init ( ) | 715 | void Zaurus::init ( ) |
716 | { | 716 | { |
717 | d-> m_modelstr = "Zaurus SL5000"; | ||
718 | d-> m_model = Model_Zaurus_SL5000; | ||
719 | d-> m_vendorstr = "Sharp"; | 717 | d-> m_vendorstr = "Sharp"; |
720 | d-> m_vendor = Vendor_Sharp; | 718 | d-> m_vendor = Vendor_Sharp; |
721 | 719 | ||
722 | QFile f ( "/proc/filesystems" ); | 720 | QFile f ( "/proc/filesystems" ); |
723 | 721 | ||
724 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 722 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
725 | d-> m_systemstr = "OpenZaurus"; | 723 | d-> m_systemstr = "OpenZaurus"; |
726 | d-> m_system = System_OpenZaurus; | 724 | d-> m_system = System_OpenZaurus; |
727 | 725 | ||
728 | f. close ( ); | 726 | f. close ( ); |
729 | 727 | ||
730 | f. setName ( "/etc/oz_version" ); | 728 | f. setName ( "/etc/oz_version" ); |
731 | if ( f. open ( IO_ReadOnly )) { | 729 | if ( f. open ( IO_ReadOnly )) { |
732 | QTextStream ts ( &f ); | 730 | QTextStream ts ( &f ); |
733 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 731 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
734 | f. close ( ); | 732 | f. close ( ); |
735 | } | 733 | } |
736 | } | 734 | } |
737 | else { | 735 | else { |
738 | d-> m_systemstr = "Zaurus"; | 736 | d-> m_systemstr = "Zaurus"; |
739 | d-> m_system = System_Zaurus; | 737 | d-> m_system = System_Zaurus; |
740 | } | 738 | } |
741 | 739 | ||
740 | f. setName ( "/proc/deviceinfo/product" ); | ||
741 | if ( f. open ( IO_ReadOnly ) ) { | ||
742 | QTextStream ts ( &f ); | ||
743 | QString model = ts. readLine ( ); | ||
744 | f. close ( ); | ||
745 | if ( model == "SL-5000D" ) { | ||
746 | d-> m_model = Model_Zaurus_SL5000; | ||
747 | d-> m_modelstr = "Zaurus SL-5000D"; | ||
748 | } else if ( model == "SL-5500" ) { | ||
749 | d-> m_model = Model_Zaurus_SL5500; | ||
750 | d-> m_modelstr = "Zaurus SL-5500"; | ||
751 | } | ||
752 | } | ||
753 | else { | ||
754 | d-> m_model = Model_Zaurus_SL5000; | ||
755 | d-> m_modelstr = "Zaurus SL-5000D (unverified)"; | ||
756 | } | ||
742 | 757 | ||
743 | m_leds [0] = Led_Off; | 758 | m_leds [0] = Led_Off; |
744 | } | 759 | } |
745 | 760 | ||
746 | #include <unistd.h> | 761 | #include <unistd.h> |
747 | #include <fcntl.h> | 762 | #include <fcntl.h> |
748 | #include <sys/ioctl.h> | 763 | #include <sys/ioctl.h> |
749 | 764 | ||
750 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 765 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
751 | 766 | ||
752 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 767 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
753 | 768 | ||
754 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 769 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
755 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 770 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
756 | 771 | ||
757 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 772 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
758 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 773 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
759 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 774 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
760 | 775 | ||
761 | /* --- for SHARP_BUZZER device --- */ | 776 | /* --- for SHARP_BUZZER device --- */ |
762 | 777 | ||
763 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 778 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
764 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 779 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
765 | 780 | ||
766 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 781 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
767 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 782 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
768 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 783 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
769 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 784 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
770 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 785 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
771 | 786 | ||
772 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 787 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
773 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 788 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
774 | 789 | ||
775 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 790 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
776 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 791 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
777 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 792 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
778 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 793 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
779 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 794 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
780 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 795 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
781 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 796 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
782 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 797 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
783 | 798 | ||
784 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 799 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
785 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 800 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
786 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 801 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
787 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 802 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
788 | // | 803 | // |
789 | 804 | ||
790 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 805 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
791 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 806 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
792 | 807 | ||
793 | typedef struct sharp_led_status { | 808 | typedef struct sharp_led_status { |
794 | int which; /* select which LED status is wanted. */ | 809 | int which; /* select which LED status is wanted. */ |
795 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 810 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
796 | } sharp_led_status; | 811 | } sharp_led_status; |
797 | 812 | ||
798 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 813 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
799 | 814 | ||
800 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 815 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
801 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 816 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
802 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 817 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
803 | 818 | ||
804 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 819 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
805 | 820 | ||
806 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 821 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
807 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 822 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
808 | #define APM_EVT_POWER_BUTTON (1 << 0) | 823 | #define APM_EVT_POWER_BUTTON (1 << 0) |
809 | 824 | ||
810 | #define FL_IOCTL_STEP_CONTRAST 100 | 825 | #define FL_IOCTL_STEP_CONTRAST 100 |
811 | 826 | ||
812 | 827 | ||
813 | void Zaurus::buzzer ( int sound ) | 828 | void Zaurus::buzzer ( int sound ) |
814 | { | 829 | { |
815 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 830 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); |
816 | 831 | ||
817 | if ( fd >= 0 ) | 832 | if ( fd >= 0 ) |
818 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 833 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
819 | } | 834 | } |
820 | 835 | ||
821 | 836 | ||
822 | void Zaurus::alarmSound ( ) | 837 | void Zaurus::alarmSound ( ) |
823 | { | 838 | { |
824 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 839 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
825 | } | 840 | } |
826 | 841 | ||
827 | void Zaurus::touchSound ( ) | 842 | void Zaurus::touchSound ( ) |
828 | { | 843 | { |
829 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 844 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
830 | } | 845 | } |
831 | 846 | ||
832 | void Zaurus::keySound ( ) | 847 | void Zaurus::keySound ( ) |
833 | { | 848 | { |
834 | buzzer ( SHARP_BUZ_KEYSOUND ); | 849 | buzzer ( SHARP_BUZ_KEYSOUND ); |
835 | } | 850 | } |
836 | 851 | ||
837 | 852 | ||
838 | QValueList <OLed> Zaurus::ledList ( ) const | 853 | QValueList <OLed> Zaurus::ledList ( ) const |
839 | { | 854 | { |
840 | QValueList <OLed> vl; | 855 | QValueList <OLed> vl; |
841 | vl << Led_Mail; | 856 | vl << Led_Mail; |
842 | return vl; | 857 | return vl; |
843 | } | 858 | } |
844 | 859 | ||
845 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 860 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
846 | { | 861 | { |
847 | QValueList <OLedState> vl; | 862 | QValueList <OLedState> vl; |
848 | 863 | ||
849 | if ( l == Led_Mail ) | 864 | if ( l == Led_Mail ) |
850 | vl << Led_Off << Led_On << Led_BlinkSlow; | 865 | vl << Led_Off << Led_On << Led_BlinkSlow; |
851 | return vl; | 866 | return vl; |
852 | } | 867 | } |
853 | 868 | ||
854 | OLedState Zaurus::ledState ( OLed which ) const | 869 | OLedState Zaurus::ledState ( OLed which ) const |
855 | { | 870 | { |
856 | if ( which == Led_Mail ) | 871 | if ( which == Led_Mail ) |
857 | return m_leds [0]; | 872 | return m_leds [0]; |
858 | else | 873 | else |
859 | return Led_Off; | 874 | return Led_Off; |
860 | } | 875 | } |
861 | 876 | ||
862 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 877 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
863 | { | 878 | { |
864 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 879 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
865 | 880 | ||
866 | if ( which == Led_Mail ) { | 881 | if ( which == Led_Mail ) { |
867 | if ( fd >= 0 ) { | 882 | if ( fd >= 0 ) { |
868 | struct sharp_led_status leds; | 883 | struct sharp_led_status leds; |
869 | ::memset ( &leds, 0, sizeof( leds )); | 884 | ::memset ( &leds, 0, sizeof( leds )); |
870 | leds. which = SHARP_LED_MAIL_EXISTS; | 885 | leds. which = SHARP_LED_MAIL_EXISTS; |
871 | bool ok = true; | 886 | bool ok = true; |
872 | 887 | ||
873 | switch ( st ) { | 888 | switch ( st ) { |
874 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 889 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
875 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 890 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
876 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 891 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
877 | default : ok = false; | 892 | default : ok = false; |
878 | } | 893 | } |
879 | 894 | ||
880 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 895 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
881 | m_leds [0] = st; | 896 | m_leds [0] = st; |
882 | return true; | 897 | return true; |
883 | } | 898 | } |
884 | } | 899 | } |
885 | } | 900 | } |
886 | return false; | 901 | return false; |
887 | } | 902 | } |
888 | 903 | ||
889 | bool Zaurus::setSoftSuspend ( bool soft ) | 904 | bool Zaurus::setSoftSuspend ( bool soft ) |
890 | { | 905 | { |
891 | bool res = false; | 906 | bool res = false; |
892 | int fd; | 907 | int fd; |
893 | 908 | ||
894 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 909 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
895 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 910 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
896 | 911 | ||
897 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 912 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
898 | 913 | ||
899 | if ( sources >= 0 ) { | 914 | if ( sources >= 0 ) { |
900 | if ( soft ) | 915 | if ( soft ) |
901 | sources &= ~APM_EVT_POWER_BUTTON; | 916 | sources &= ~APM_EVT_POWER_BUTTON; |
902 | else | 917 | else |
903 | sources |= APM_EVT_POWER_BUTTON; | 918 | sources |= APM_EVT_POWER_BUTTON; |
904 | 919 | ||
905 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 920 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
906 | res = true; | 921 | res = true; |
907 | else | 922 | else |
908 | perror ( "APM_IOCGEVTSRC" ); | 923 | perror ( "APM_IOCGEVTSRC" ); |
909 | } | 924 | } |
910 | else | 925 | else |
911 | perror ( "APM_IOCGEVTSRC" ); | 926 | perror ( "APM_IOCGEVTSRC" ); |
912 | 927 | ||
913 | ::close ( fd ); | 928 | ::close ( fd ); |
914 | } | 929 | } |
915 | else | 930 | else |
916 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 931 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
917 | 932 | ||
918 | return res; | 933 | return res; |
919 | } | 934 | } |
920 | 935 | ||
921 | 936 | ||
922 | bool Zaurus::setDisplayBrightness ( int bright ) | 937 | bool Zaurus::setDisplayBrightness ( int bright ) |
923 | { | 938 | { |
924 | bool res = false; | 939 | bool res = false; |
925 | int fd; | 940 | int fd; |
926 | 941 | ||
927 | if ( bright > 255 ) | 942 | if ( bright > 255 ) |
928 | bright = 255; | 943 | bright = 255; |
929 | if ( bright < 0 ) | 944 | if ( bright < 0 ) |
930 | bright = 0; | 945 | bright = 0; |
931 | 946 | ||
932 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 947 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
933 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 948 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
diff --git a/libopie/odevice.h b/libopie/odevice.h index e50009c..86491d4 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -1,149 +1,150 @@ | |||
1 | /* This file is part of the OPIE libraries | 1 | /* This file is part of the OPIE libraries |
2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) | 2 | Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) |
3 | 3 | ||
4 | This library is free software; you can redistribute it and/or | 4 | This library is free software; you can redistribute it and/or |
5 | modify it under the terms of the GNU Library General Public | 5 | modify it under the terms of the GNU Library General Public |
6 | License as published by the Free Software Foundation; either | 6 | License as published by the Free Software Foundation; either |
7 | version 2 of the License, or (at your option) any later version. | 7 | version 2 of the License, or (at your option) any later version. |
8 | 8 | ||
9 | This library is distributed in the hope that it will be useful, | 9 | This library is distributed in the hope that it will be useful, |
10 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 11 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
12 | Library General Public License for more details. | 12 | Library General Public License for more details. |
13 | 13 | ||
14 | You should have received a copy of the GNU Library General Public License | 14 | You should have received a copy of the GNU Library General Public License |
15 | along with this library; see the file COPYING.LIB. If not, write to | 15 | along with this library; see the file COPYING.LIB. If not, write to |
16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 16 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
17 | Boston, MA 02111-1307, USA. | 17 | Boston, MA 02111-1307, USA. |
18 | */ | 18 | */ |
19 | 19 | ||
20 | #ifndef _LIBOPIE_ODEVICE_H_ | 20 | #ifndef _LIBOPIE_ODEVICE_H_ |
21 | #define _LIBOPIE_ODEVICE_H_ | 21 | #define _LIBOPIE_ODEVICE_H_ |
22 | 22 | ||
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qnamespace.h> | 24 | #include <qnamespace.h> |
25 | 25 | ||
26 | class ODeviceData; | 26 | class ODeviceData; |
27 | 27 | ||
28 | namespace Opie { | 28 | namespace Opie { |
29 | 29 | ||
30 | enum OModel { | 30 | enum OModel { |
31 | Model_Unknown, | 31 | Model_Unknown, |
32 | 32 | ||
33 | Model_Series_Mask = 0xff000000, | 33 | Model_Series_Mask = 0xff000000, |
34 | 34 | ||
35 | Model_iPAQ = ( 1 << 24 ), | 35 | Model_iPAQ = ( 1 << 24 ), |
36 | 36 | ||
37 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 37 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
38 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 38 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
39 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 39 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
40 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 40 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
41 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 41 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
42 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 42 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
43 | 43 | ||
44 | Model_Zaurus = ( 2 << 24 ), | 44 | Model_Zaurus = ( 2 << 24 ), |
45 | 45 | ||
46 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 46 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
47 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | ||
47 | }; | 48 | }; |
48 | 49 | ||
49 | enum OVendor { | 50 | enum OVendor { |
50 | Vendor_Unknown, | 51 | Vendor_Unknown, |
51 | 52 | ||
52 | Vendor_HP, | 53 | Vendor_HP, |
53 | Vendor_Sharp | 54 | Vendor_Sharp |
54 | }; | 55 | }; |
55 | 56 | ||
56 | enum OSystem { | 57 | enum OSystem { |
57 | System_Unknown, | 58 | System_Unknown, |
58 | 59 | ||
59 | System_Familiar, | 60 | System_Familiar, |
60 | System_Zaurus, | 61 | System_Zaurus, |
61 | System_OpenZaurus | 62 | System_OpenZaurus |
62 | }; | 63 | }; |
63 | 64 | ||
64 | enum OLedState { | 65 | enum OLedState { |
65 | Led_Off, | 66 | Led_Off, |
66 | Led_On, | 67 | Led_On, |
67 | Led_BlinkSlow, | 68 | Led_BlinkSlow, |
68 | Led_BlinkFast | 69 | Led_BlinkFast |
69 | }; | 70 | }; |
70 | 71 | ||
71 | enum OLed { | 72 | enum OLed { |
72 | Led_Mail, | 73 | Led_Mail, |
73 | Led_Power, | 74 | Led_Power, |
74 | Led_BlueTooth | 75 | Led_BlueTooth |
75 | }; | 76 | }; |
76 | 77 | ||
77 | enum OHardKey { | 78 | enum OHardKey { |
78 | HardKey_Datebook = Qt::Key_F9, | 79 | HardKey_Datebook = Qt::Key_F9, |
79 | HardKey_Contacts = Qt::Key_F10, | 80 | HardKey_Contacts = Qt::Key_F10, |
80 | HardKey_Menu = Qt::Key_F11, | 81 | HardKey_Menu = Qt::Key_F11, |
81 | HardKey_Home = Qt::Key_F12, | 82 | HardKey_Home = Qt::Key_F12, |
82 | HardKey_Mail = Qt::Key_F14, | 83 | HardKey_Mail = Qt::Key_F14, |
83 | HardKey_Record = Qt::Key_F24, | 84 | HardKey_Record = Qt::Key_F24, |
84 | HardKey_Suspend = Qt::Key_F34, | 85 | HardKey_Suspend = Qt::Key_F34, |
85 | HardKey_Backlight = Qt::Key_F35, | 86 | HardKey_Backlight = Qt::Key_F35, |
86 | }; | 87 | }; |
87 | 88 | ||
88 | 89 | ||
89 | class ODevice | 90 | class ODevice |
90 | { | 91 | { |
91 | private: | 92 | private: |
92 | ODevice ( const ODevice & ); | 93 | ODevice ( const ODevice & ); |
93 | 94 | ||
94 | protected: | 95 | protected: |
95 | ODevice ( ); | 96 | ODevice ( ); |
96 | virtual void init ( ); | 97 | virtual void init ( ); |
97 | 98 | ||
98 | ODeviceData *d; | 99 | ODeviceData *d; |
99 | 100 | ||
100 | public: | 101 | public: |
101 | virtual ~ODevice ( ); | 102 | virtual ~ODevice ( ); |
102 | 103 | ||
103 | static ODevice *inst ( ); | 104 | static ODevice *inst ( ); |
104 | 105 | ||
105 | 106 | ||
106 | 107 | ||
107 | // information | 108 | // information |
108 | 109 | ||
109 | QString modelString ( ) const; | 110 | QString modelString ( ) const; |
110 | OModel model ( ) const; | 111 | OModel model ( ) const; |
111 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 112 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
112 | 113 | ||
113 | QString vendorString ( ) const; | 114 | QString vendorString ( ) const; |
114 | OVendor vendor ( ) const; | 115 | OVendor vendor ( ) const; |
115 | 116 | ||
116 | QString systemString ( ) const; | 117 | QString systemString ( ) const; |
117 | OSystem system ( ) const; | 118 | OSystem system ( ) const; |
118 | 119 | ||
119 | QString systemVersionString ( ) const; | 120 | QString systemVersionString ( ) const; |
120 | 121 | ||
121 | // system | 122 | // system |
122 | 123 | ||
123 | virtual bool setSoftSuspend ( bool on ); | 124 | virtual bool setSoftSuspend ( bool on ); |
124 | virtual bool suspend ( ); | 125 | virtual bool suspend ( ); |
125 | 126 | ||
126 | virtual bool setDisplayStatus ( bool on ); | 127 | virtual bool setDisplayStatus ( bool on ); |
127 | virtual bool setDisplayBrightness ( int brightness ); | 128 | virtual bool setDisplayBrightness ( int brightness ); |
128 | virtual int displayBrightnessResolution ( ) const; | 129 | virtual int displayBrightnessResolution ( ) const; |
129 | 130 | ||
130 | // input / output | 131 | // input / output |
131 | 132 | ||
132 | virtual void alarmSound ( ); | 133 | virtual void alarmSound ( ); |
133 | virtual void keySound ( ); | 134 | virtual void keySound ( ); |
134 | virtual void touchSound ( ); | 135 | virtual void touchSound ( ); |
135 | 136 | ||
136 | virtual QValueList <OLed> ledList ( ) const; | 137 | virtual QValueList <OLed> ledList ( ) const; |
137 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 138 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
138 | virtual OLedState ledState ( OLed led ) const; | 139 | virtual OLedState ledState ( OLed led ) const; |
139 | virtual bool setLedState ( OLed led, OLedState st ); | 140 | virtual bool setLedState ( OLed led, OLedState st ); |
140 | 141 | ||
141 | virtual bool hasLightSensor ( ) const; | 142 | virtual bool hasLightSensor ( ) const; |
142 | virtual int readLightSensor ( ); | 143 | virtual int readLightSensor ( ); |
143 | virtual int lightSensorResolution ( ) const; | 144 | virtual int lightSensorResolution ( ) const; |
144 | }; | 145 | }; |
145 | 146 | ||
146 | } | 147 | } |
147 | 148 | ||
148 | #endif | 149 | #endif |
149 | 150 | ||