-rw-r--r-- | libopie/odevice.cpp | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 75426f9..80e9a91 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -435,212 +435,212 @@ typedef struct { | |||
435 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 435 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
436 | 436 | ||
437 | 437 | ||
438 | 438 | ||
439 | QValueList <OLed> iPAQ::ledList ( ) const | 439 | QValueList <OLed> iPAQ::ledList ( ) const |
440 | { | 440 | { |
441 | QValueList <OLed> vl; | 441 | QValueList <OLed> vl; |
442 | vl << Led_Power; | 442 | vl << Led_Power; |
443 | 443 | ||
444 | if ( d-> m_model == Model_iPAQ_H38xx ) | 444 | if ( d-> m_model == Model_iPAQ_H38xx ) |
445 | vl << Led_BlueTooth; | 445 | vl << Led_BlueTooth; |
446 | return vl; | 446 | return vl; |
447 | } | 447 | } |
448 | 448 | ||
449 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 449 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
450 | { | 450 | { |
451 | QValueList <OLedState> vl; | 451 | QValueList <OLedState> vl; |
452 | 452 | ||
453 | if ( l == Led_Power ) | 453 | if ( l == Led_Power ) |
454 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 454 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
455 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 455 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
456 | vl << Led_Off; // << Led_On << ??? | 456 | vl << Led_Off; // << Led_On << ??? |
457 | 457 | ||
458 | return vl; | 458 | return vl; |
459 | } | 459 | } |
460 | 460 | ||
461 | OLedState iPAQ::ledState ( OLed l ) const | 461 | OLedState iPAQ::ledState ( OLed l ) const |
462 | { | 462 | { |
463 | switch ( l ) { | 463 | switch ( l ) { |
464 | case Led_Power: | 464 | case Led_Power: |
465 | return m_leds [0]; | 465 | return m_leds [0]; |
466 | case Led_BlueTooth: | 466 | case Led_BlueTooth: |
467 | return m_leds [1]; | 467 | return m_leds [1]; |
468 | default: | 468 | default: |
469 | return Led_Off; | 469 | return Led_Off; |
470 | } | 470 | } |
471 | } | 471 | } |
472 | 472 | ||
473 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 473 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
474 | { | 474 | { |
475 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 475 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
476 | 476 | ||
477 | if ( l == Led_Power ) { | 477 | if ( l == Led_Power ) { |
478 | if ( fd >= 0 ) { | 478 | if ( fd >= 0 ) { |
479 | LED_IN leds; | 479 | LED_IN leds; |
480 | ::memset ( &leds, 0, sizeof( leds )); | 480 | ::memset ( &leds, 0, sizeof( leds )); |
481 | leds. TotalTime = 0; | 481 | leds. TotalTime = 0; |
482 | leds. OnTime = 0; | 482 | leds. OnTime = 0; |
483 | leds. OffTime = 1; | 483 | leds. OffTime = 1; |
484 | leds. OffOnBlink = 2; | 484 | leds. OffOnBlink = 2; |
485 | 485 | ||
486 | switch ( st ) { | 486 | switch ( 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 | break; | 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 | break; | 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 )) { | 584 | (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { |
585 | 585 | ||
586 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 586 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
587 | Config cfg ( "qpe" ); | 587 | Config cfg ( "qpe" ); |
588 | cfg. setGroup ( "Volume" ); | 588 | cfg. setGroup ( "Volume" ); |
589 | 589 | ||
590 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 590 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
591 | if ( volalarm < 0 ) | 591 | if ( volalarm < 0 ) |
592 | volalarm = 0; | 592 | volalarm = 0; |
593 | else if ( volalarm > 100 ) | 593 | else if ( volalarm > 100 ) |
594 | volalarm = 100; | 594 | volalarm = 100; |
595 | volalarm |= ( volalarm << 8 ); | 595 | volalarm |= ( volalarm << 8 ); |
596 | 596 | ||
597 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 597 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
598 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 598 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
599 | vol_reset = true; | 599 | vol_reset = true; |
600 | } | 600 | } |
601 | } | 601 | } |
602 | } | 602 | } |
603 | 603 | ||
604 | snd. play ( ); | 604 | snd. play ( ); |
605 | while ( !snd. isFinished ( )) | 605 | while ( !snd. isFinished ( )) |
606 | qApp-> processEvents ( ); | 606 | qApp-> processEvents ( ); |
607 | 607 | ||
608 | if ( fd >= 0 ) { | 608 | if ( fd >= 0 ) { |
609 | if ( vol_reset ) | 609 | if ( vol_reset ) |
610 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 610 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
611 | ::close ( fd ); | 611 | ::close ( fd ); |
612 | } | 612 | } |
613 | #endif | 613 | #endif |
614 | #endif | 614 | #endif |
615 | } | 615 | } |
616 | 616 | ||
617 | 617 | ||
618 | bool iPAQ::setSoftSuspend ( bool soft ) | 618 | bool iPAQ::setSoftSuspend ( bool soft ) |
619 | { | 619 | { |
620 | bool res = false; | 620 | bool res = false; |
621 | int fd; | 621 | int fd; |
622 | 622 | ||
623 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 623 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
624 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 624 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
625 | res = true; | 625 | res = true; |
626 | else | 626 | else |
627 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 627 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
628 | 628 | ||
629 | ::close ( fd ); | 629 | ::close ( fd ); |
630 | } | 630 | } |
631 | else | 631 | else |
632 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 632 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
633 | 633 | ||
634 | return res; | 634 | return res; |
635 | } | 635 | } |
636 | 636 | ||
637 | 637 | ||
638 | bool iPAQ::setDisplayBrightness ( int bright ) | 638 | bool iPAQ::setDisplayBrightness ( int bright ) |
639 | { | 639 | { |
640 | bool res = false; | 640 | bool res = false; |
641 | int fd; | 641 | int fd; |
642 | 642 | ||
643 | if ( bright > 255 ) | 643 | if ( bright > 255 ) |
644 | bright = 255; | 644 | bright = 255; |
645 | if ( bright < 0 ) | 645 | if ( bright < 0 ) |
646 | bright = 0; | 646 | bright = 0; |