-rw-r--r-- | libopie/odevice.cpp | 7 |
1 files changed, 2 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 80e9a91..58bd663 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -487,265 +487,262 @@ bool iPAQ::setLedState ( OLed l, OLedState st ) | |||
487 | case Led_Off : leds. OffOnBlink = 0; break; | 487 | case Led_Off : leds. OffOnBlink = 0; break; |
488 | case Led_On : leds. OffOnBlink = 1; break; | 488 | case Led_On : leds. OffOnBlink = 1; break; |
489 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 489 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
490 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 490 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
491 | } | 491 | } |
492 | 492 | ||
493 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 493 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
494 | m_leds [0] = st; | 494 | m_leds [0] = st; |
495 | return true; | 495 | return true; |
496 | } | 496 | } |
497 | } | 497 | } |
498 | } | 498 | } |
499 | return false; | 499 | return false; |
500 | } | 500 | } |
501 | 501 | ||
502 | 502 | ||
503 | //QValueList <int> iPAQ::keyList ( ) const | 503 | //QValueList <int> iPAQ::keyList ( ) const |
504 | //{ | 504 | //{ |
505 | //QValueList <int> vl; | 505 | //QValueList <int> vl; |
506 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; | 506 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; |
507 | //return vl; | 507 | //return vl; |
508 | //} | 508 | //} |
509 | 509 | ||
510 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 510 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
511 | { | 511 | { |
512 | int newkeycode = keycode; | 512 | int newkeycode = keycode; |
513 | 513 | ||
514 | 514 | ||
515 | // simple susbstitutions | 515 | // simple susbstitutions |
516 | switch ( d-> m_model ) { | 516 | switch ( d-> m_model ) { |
517 | case Model_iPAQ_H38xx: | 517 | case Model_iPAQ_H38xx: |
518 | // H38xx has no "Q" key anymore - this is now the Mail key | 518 | // H38xx has no "Q" key anymore - this is now the Mail key |
519 | if ( keycode == HardKey_Menu ) | 519 | if ( keycode == HardKey_Menu ) |
520 | newkeycode = HardKey_Mail; | 520 | newkeycode = HardKey_Mail; |
521 | //nobreak | 521 | //nobreak |
522 | 522 | ||
523 | case Model_iPAQ_H31xx: | 523 | case Model_iPAQ_H31xx: |
524 | // Rotate cursor keys 180° | 524 | // Rotate cursor keys 180° |
525 | switch ( keycode ) { | 525 | switch ( keycode ) { |
526 | case Key_Left : newkeycode = Key_Right; break; | 526 | case Key_Left : newkeycode = Key_Right; break; |
527 | case Key_Right: newkeycode = Key_Left; break; | 527 | case Key_Right: newkeycode = Key_Left; break; |
528 | case Key_Up : newkeycode = Key_Down; break; | 528 | case Key_Up : newkeycode = Key_Down; break; |
529 | case Key_Down : newkeycode = Key_Up; break; | 529 | case Key_Down : newkeycode = Key_Up; break; |
530 | } | 530 | } |
531 | //nobreak; | 531 | //nobreak; |
532 | 532 | ||
533 | case Model_iPAQ_H36xx: | 533 | case Model_iPAQ_H36xx: |
534 | case Model_iPAQ_H37xx: | 534 | case Model_iPAQ_H37xx: |
535 | // map Power Button short/long press to F34/F35 | 535 | // map Power Button short/long press to F34/F35 |
536 | if ( keycode == Key_SysReq ) { | 536 | if ( keycode == Key_SysReq ) { |
537 | if ( isPress ) { | 537 | if ( isPress ) { |
538 | if ( m_power_timer ) | 538 | if ( m_power_timer ) |
539 | killTimer ( m_power_timer ); | 539 | killTimer ( m_power_timer ); |
540 | m_power_timer = startTimer ( 500 ); | 540 | m_power_timer = startTimer ( 500 ); |
541 | } | 541 | } |
542 | else if ( m_power_timer ) { | 542 | else if ( m_power_timer ) { |
543 | killTimer ( m_power_timer ); | 543 | killTimer ( m_power_timer ); |
544 | m_power_timer = 0; | 544 | m_power_timer = 0; |
545 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 545 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
546 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 546 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
547 | } | 547 | } |
548 | newkeycode = Key_unknown; | 548 | newkeycode = Key_unknown; |
549 | } | 549 | } |
550 | //nobreak; | 550 | //nobreak; |
551 | 551 | ||
552 | default: | 552 | default: |
553 | break; | 553 | break; |
554 | } | 554 | } |
555 | 555 | ||
556 | if ( newkeycode != keycode ) { | 556 | if ( newkeycode != keycode ) { |
557 | if ( newkeycode != Key_unknown ) | 557 | if ( newkeycode != Key_unknown ) |
558 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 558 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
559 | return true; | 559 | return true; |
560 | } | 560 | } |
561 | else | 561 | else |
562 | return false; | 562 | return false; |
563 | } | 563 | } |
564 | 564 | ||
565 | void iPAQ::timerEvent ( QTimerEvent * ) | 565 | void iPAQ::timerEvent ( QTimerEvent * ) |
566 | { | 566 | { |
567 | killTimer ( m_power_timer ); | 567 | killTimer ( m_power_timer ); |
568 | m_power_timer = 0; | 568 | m_power_timer = 0; |
569 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 569 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
570 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 570 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
571 | } | 571 | } |
572 | 572 | ||
573 | 573 | ||
574 | void iPAQ::alarmSound ( ) | 574 | void iPAQ::alarmSound ( ) |
575 | { | 575 | { |
576 | #if defined( QT_QWS_IPAQ ) // IPAQ | 576 | #if defined( QT_QWS_IPAQ ) // IPAQ |
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 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { | ||
585 | |||
586 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 584 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
587 | Config cfg ( "qpe" ); | 585 | Config cfg ( "qpe" ); |
588 | cfg. setGroup ( "Volume" ); | 586 | cfg. setGroup ( "Volume" ); |
589 | 587 | ||
590 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 588 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
591 | if ( volalarm < 0 ) | 589 | if ( volalarm < 0 ) |
592 | volalarm = 0; | 590 | volalarm = 0; |
593 | else if ( volalarm > 100 ) | 591 | else if ( volalarm > 100 ) |
594 | volalarm = 100; | 592 | volalarm = 100; |
595 | volalarm |= ( volalarm << 8 ); | 593 | volalarm |= ( volalarm << 8 ); |
596 | 594 | ||
597 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 595 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
598 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 596 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
599 | vol_reset = true; | 597 | vol_reset = true; |
600 | } | 598 | } |
601 | } | 599 | } |
602 | } | 600 | } |
603 | 601 | ||
604 | snd. play ( ); | 602 | snd. play ( ); |
605 | while ( !snd. isFinished ( )) | 603 | while ( !snd. isFinished ( )) |
606 | qApp-> processEvents ( ); | 604 | qApp-> processEvents ( ); |
607 | 605 | ||
608 | if ( fd >= 0 ) { | 606 | if ( fd >= 0 ) { |
609 | if ( vol_reset ) | 607 | if ( vol_reset ) |
610 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 608 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
611 | ::close ( fd ); | 609 | ::close ( fd ); |
612 | } | 610 | } |
613 | #endif | 611 | #endif |
614 | #endif | 612 | #endif |
615 | } | 613 | } |
616 | 614 | ||
617 | 615 | ||
618 | bool iPAQ::setSoftSuspend ( bool soft ) | 616 | bool iPAQ::setSoftSuspend ( bool soft ) |
619 | { | 617 | { |
620 | bool res = false; | 618 | bool res = false; |
621 | int fd; | 619 | int fd; |
622 | 620 | ||
623 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 621 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
624 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 622 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
625 | res = true; | 623 | res = true; |
626 | else | 624 | else |
627 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 625 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
628 | 626 | ||
629 | ::close ( fd ); | 627 | ::close ( fd ); |
630 | } | 628 | } |
631 | else | 629 | else |
632 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 630 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
633 | 631 | ||
634 | return res; | 632 | return res; |
635 | } | 633 | } |
636 | 634 | ||
637 | 635 | ||
638 | bool iPAQ::setDisplayBrightness ( int bright ) | 636 | bool iPAQ::setDisplayBrightness ( int bright ) |
639 | { | 637 | { |
640 | bool res = false; | 638 | bool res = false; |
641 | int fd; | 639 | int fd; |
642 | 640 | ||
643 | if ( bright > 255 ) | 641 | if ( bright > 255 ) |
644 | bright = 255; | 642 | bright = 255; |
645 | if ( bright < 0 ) | 643 | if ( bright < 0 ) |
646 | bright = 0; | 644 | bright = 0; |
647 | 645 | ||
648 | // 128 is the maximum if you want a decent lifetime for the LCD | 646 | // 128 is the maximum if you want a decent lifetime for the LCD |
649 | 647 | ||
650 | if ( bright > 1 ) | 648 | if ( bright > 1 ) |
651 | bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic | 649 | bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic |
652 | //bright = ( bright + 1 ) / 2; | 650 | //bright = ( bright + 1 ) / 2; |
653 | 651 | ||
654 | if ((( fd = ::open ( "/dev/ts", O_WRONLY )) >= 0 ) || | 652 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
655 | (( fd = ::open ( "/dev/h3600_ts", O_WRONLY )) >= 0 )) { | ||
656 | FLITE_IN bl; | 653 | FLITE_IN bl; |
657 | bl. mode = 1; | 654 | bl. mode = 1; |
658 | bl. pwr = bright ? 1 : 0; | 655 | bl. pwr = bright ? 1 : 0; |
659 | bl. brightness = bright; | 656 | bl. brightness = bright; |
660 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 657 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
661 | ::close ( fd ); | 658 | ::close ( fd ); |
662 | } | 659 | } |
663 | return res; | 660 | return res; |
664 | } | 661 | } |
665 | 662 | ||
666 | int iPAQ::displayBrightnessResolution ( ) const | 663 | int iPAQ::displayBrightnessResolution ( ) const |
667 | { | 664 | { |
668 | return 255; // really 128, but logarithmic control is smoother this way | 665 | return 255; // really 128, but logarithmic control is smoother this way |
669 | } | 666 | } |
670 | 667 | ||
671 | 668 | ||
672 | /************************************************** | 669 | /************************************************** |
673 | * | 670 | * |
674 | * Zaurus | 671 | * Zaurus |
675 | * | 672 | * |
676 | **************************************************/ | 673 | **************************************************/ |
677 | 674 | ||
678 | 675 | ||
679 | 676 | ||
680 | void Zaurus::init ( ) | 677 | void Zaurus::init ( ) |
681 | { | 678 | { |
682 | d-> m_modelstr = "Zaurus SL5000"; | 679 | d-> m_modelstr = "Zaurus SL5000"; |
683 | d-> m_model = Model_Zaurus_SL5000; | 680 | d-> m_model = Model_Zaurus_SL5000; |
684 | d-> m_vendorstr = "Sharp"; | 681 | d-> m_vendorstr = "Sharp"; |
685 | d-> m_vendor = Vendor_Sharp; | 682 | d-> m_vendor = Vendor_Sharp; |
686 | 683 | ||
687 | QFile f ( "/proc/filesystems" ); | 684 | QFile f ( "/proc/filesystems" ); |
688 | 685 | ||
689 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 686 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
690 | d-> m_systemstr = "OpenZaurus"; | 687 | d-> m_systemstr = "OpenZaurus"; |
691 | d-> m_system = System_OpenZaurus; | 688 | d-> m_system = System_OpenZaurus; |
692 | 689 | ||
693 | f. close ( ); | 690 | f. close ( ); |
694 | 691 | ||
695 | f. setName ( "/etc/oz_version" ); | 692 | f. setName ( "/etc/oz_version" ); |
696 | if ( f. open ( IO_ReadOnly )) { | 693 | if ( f. open ( IO_ReadOnly )) { |
697 | QTextStream ts ( &f ); | 694 | QTextStream ts ( &f ); |
698 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 695 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
699 | f. close ( ); | 696 | f. close ( ); |
700 | } | 697 | } |
701 | } | 698 | } |
702 | else { | 699 | else { |
703 | d-> m_systemstr = "Zaurus"; | 700 | d-> m_systemstr = "Zaurus"; |
704 | d-> m_system = System_Zaurus; | 701 | d-> m_system = System_Zaurus; |
705 | } | 702 | } |
706 | 703 | ||
707 | 704 | ||
708 | m_leds [0] = Led_Off; | 705 | m_leds [0] = Led_Off; |
709 | } | 706 | } |
710 | 707 | ||
711 | #include <unistd.h> | 708 | #include <unistd.h> |
712 | #include <fcntl.h> | 709 | #include <fcntl.h> |
713 | #include <sys/ioctl.h> | 710 | #include <sys/ioctl.h> |
714 | 711 | ||
715 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 712 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
716 | 713 | ||
717 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 714 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
718 | 715 | ||
719 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 716 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
720 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 717 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
721 | 718 | ||
722 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 719 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
723 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 720 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
724 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 721 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
725 | 722 | ||
726 | /* --- for SHARP_BUZZER device --- */ | 723 | /* --- for SHARP_BUZZER device --- */ |
727 | 724 | ||
728 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 725 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
729 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 726 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
730 | 727 | ||
731 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 728 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
732 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 729 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
733 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 730 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
734 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 731 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
735 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 732 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
736 | 733 | ||
737 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 734 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
738 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 735 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
739 | 736 | ||
740 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 737 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
741 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 738 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
742 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 739 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
743 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 740 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
744 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 741 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
745 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 742 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
746 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 743 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
747 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 744 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
748 | 745 | ||
749 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 746 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
750 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 747 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
751 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 748 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |