author | sandman <sandman> | 2002-12-17 23:38:52 (UTC) |
---|---|---|
committer | sandman <sandman> | 2002-12-17 23:38:52 (UTC) |
commit | 96a9654c2fccce382a4a9ad5d2d0b991b4191468 (patch) (unidiff) | |
tree | 4ecc6cbec54d3bc51fabfed4c51b494ef4c75583 | |
parent | 9a30159e1b0ac09b0be5918daae8c9530bf17d1d (diff) | |
download | opie-96a9654c2fccce382a4a9ad5d2d0b991b4191468.zip opie-96a9654c2fccce382a4a9ad5d2d0b991b4191468.tar.gz opie-96a9654c2fccce382a4a9ad5d2d0b991b4191468.tar.bz2 |
fix for alarm volume handling on iPAQs
-rw-r--r-- | libopie/odevice.cpp | 6 |
1 files changed, 2 insertions, 4 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 9fd3ae2..c947630 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -531,132 +531,130 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
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 ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
596 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 596 | vol_reset = true; |
597 | vol_reset = true; | ||
598 | } | ||
599 | } | 597 | } |
600 | } | 598 | } |
601 | 599 | ||
602 | snd. play ( ); | 600 | snd. play ( ); |
603 | while ( !snd. isFinished ( )) | 601 | while ( !snd. isFinished ( )) |
604 | qApp-> processEvents ( ); | 602 | qApp-> processEvents ( ); |
605 | 603 | ||
606 | if ( fd >= 0 ) { | 604 | if ( fd >= 0 ) { |
607 | if ( vol_reset ) | 605 | if ( vol_reset ) |
608 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 606 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
609 | ::close ( fd ); | 607 | ::close ( fd ); |
610 | } | 608 | } |
611 | #endif | 609 | #endif |
612 | } | 610 | } |
613 | 611 | ||
614 | 612 | ||
615 | bool iPAQ::setSoftSuspend ( bool soft ) | 613 | bool iPAQ::setSoftSuspend ( bool soft ) |
616 | { | 614 | { |
617 | bool res = false; | 615 | bool res = false; |
618 | int fd; | 616 | int fd; |
619 | 617 | ||
620 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 618 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
621 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 619 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
622 | res = true; | 620 | res = true; |
623 | else | 621 | else |
624 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 622 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
625 | 623 | ||
626 | ::close ( fd ); | 624 | ::close ( fd ); |
627 | } | 625 | } |
628 | else | 626 | else |
629 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 627 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
630 | 628 | ||
631 | return res; | 629 | return res; |
632 | } | 630 | } |
633 | 631 | ||
634 | 632 | ||
635 | bool iPAQ::setDisplayBrightness ( int bright ) | 633 | bool iPAQ::setDisplayBrightness ( int bright ) |
636 | { | 634 | { |
637 | bool res = false; | 635 | bool res = false; |
638 | int fd; | 636 | int fd; |
639 | 637 | ||
640 | if ( bright > 255 ) | 638 | if ( bright > 255 ) |
641 | bright = 255; | 639 | bright = 255; |
642 | if ( bright < 0 ) | 640 | if ( bright < 0 ) |
643 | bright = 0; | 641 | bright = 0; |
644 | 642 | ||
645 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 643 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
646 | FLITE_IN bl; | 644 | FLITE_IN bl; |
647 | bl. mode = 1; | 645 | bl. mode = 1; |
648 | bl. pwr = bright ? 1 : 0; | 646 | bl. pwr = bright ? 1 : 0; |
649 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 647 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
650 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 648 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
651 | ::close ( fd ); | 649 | ::close ( fd ); |
652 | } | 650 | } |
653 | return res; | 651 | return res; |
654 | } | 652 | } |
655 | 653 | ||
656 | int iPAQ::displayBrightnessResolution ( ) const | 654 | int iPAQ::displayBrightnessResolution ( ) const |
657 | { | 655 | { |
658 | switch ( model ( )) { | 656 | switch ( model ( )) { |
659 | case Model_iPAQ_H31xx: | 657 | case Model_iPAQ_H31xx: |
660 | case Model_iPAQ_H36xx: | 658 | case Model_iPAQ_H36xx: |
661 | case Model_iPAQ_H37xx: | 659 | case Model_iPAQ_H37xx: |
662 | return 128; // really 256, but >128 could damage the LCD | 660 | return 128; // really 256, but >128 could damage the LCD |