-rw-r--r-- | libopie/odevice.cpp | 12 | ||||
-rw-r--r-- | libopie/odevice.h | 1 |
2 files changed, 8 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 160568b..f808960 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -431,274 +431,278 @@ void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | |||
431 | reloadButtonMapping ( ); | 431 | reloadButtonMapping ( ); |
432 | } | 432 | } |
433 | } | 433 | } |
434 | 434 | ||
435 | void ODevice::init ( ) | 435 | void ODevice::init ( ) |
436 | { | 436 | { |
437 | } | 437 | } |
438 | 438 | ||
439 | /** | 439 | /** |
440 | * This method initialises the button mapping | 440 | * This method initialises the button mapping |
441 | */ | 441 | */ |
442 | void ODevice::initButtons ( ) | 442 | void ODevice::initButtons ( ) |
443 | { | 443 | { |
444 | if ( d-> m_buttons ) | 444 | if ( d-> m_buttons ) |
445 | return; | 445 | return; |
446 | 446 | ||
447 | // Simulation uses iPAQ 3660 device buttons | 447 | // Simulation uses iPAQ 3660 device buttons |
448 | 448 | ||
449 | qDebug ( "init Buttons" ); | 449 | qDebug ( "init Buttons" ); |
450 | d-> m_buttons = new QValueList <ODeviceButton>; | 450 | d-> m_buttons = new QValueList <ODeviceButton>; |
451 | 451 | ||
452 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 452 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
453 | i_button *ib = ipaq_buttons + i; | 453 | i_button *ib = ipaq_buttons + i; |
454 | ODeviceButton b; | 454 | ODeviceButton b; |
455 | 455 | ||
456 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 456 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
457 | b. setKeycode ( ib-> code ); | 457 | b. setKeycode ( ib-> code ); |
458 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 458 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
459 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 459 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
460 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 460 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
461 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 461 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
462 | d-> m_buttons-> append ( b ); | 462 | d-> m_buttons-> append ( b ); |
463 | } | 463 | } |
464 | } | 464 | } |
465 | reloadButtonMapping ( ); | 465 | reloadButtonMapping ( ); |
466 | 466 | ||
467 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 467 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
468 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 468 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
469 | } | 469 | } |
470 | 470 | ||
471 | ODevice::~ODevice ( ) | 471 | ODevice::~ODevice ( ) |
472 | { | 472 | { |
473 | delete d; | 473 | delete d; |
474 | } | 474 | } |
475 | 475 | ||
476 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 476 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
477 | { | 477 | { |
478 | return false; | 478 | return false; |
479 | } | 479 | } |
480 | 480 | ||
481 | //#include <linux/apm_bios.h> | 481 | //#include <linux/apm_bios.h> |
482 | 482 | ||
483 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 483 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
484 | 484 | ||
485 | /** | 485 | /** |
486 | * This method will try to suspend the device | 486 | * This method will try to suspend the device |
487 | * It only works if the user is the QWS Server and the apm application | 487 | * It only works if the user is the QWS Server and the apm application |
488 | * is installed. | 488 | * is installed. |
489 | * It tries to suspend and then waits some time cause some distributions | 489 | * It tries to suspend and then waits some time cause some distributions |
490 | * do have asynchronus apm implementations. | 490 | * do have asynchronus apm implementations. |
491 | * This method will either fail and return false or it'll suspend the | 491 | * This method will either fail and return false or it'll suspend the |
492 | * device and return once the device got woken up | 492 | * device and return once the device got woken up |
493 | * | 493 | * |
494 | * @return if the device got suspended | 494 | * @return if the device got suspended |
495 | */ | 495 | */ |
496 | bool ODevice::suspend ( ) | 496 | bool ODevice::suspend ( ) |
497 | { | 497 | { |
498 | qDebug("ODevice::suspend"); | 498 | qDebug("ODevice::suspend"); |
499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 499 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
500 | return false; | 500 | return false; |
501 | 501 | ||
502 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 502 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
503 | return false; | 503 | return false; |
504 | 504 | ||
505 | bool res = false; | 505 | bool res = false; |
506 | 506 | ||
507 | struct timeval tvs, tvn; | 507 | struct timeval tvs, tvn; |
508 | ::gettimeofday ( &tvs, 0 ); | 508 | ::gettimeofday ( &tvs, 0 ); |
509 | 509 | ||
510 | ::sync ( ); // flush fs caches | 510 | ::sync ( ); // flush fs caches |
511 | res = ( ::system ( "apm --suspend" ) == 0 ); | 511 | res = ( ::system ( "apm --suspend" ) == 0 ); |
512 | 512 | ||
513 | // This is needed because the iPAQ apm implementation is asynchronous and we | 513 | // This is needed because the iPAQ apm implementation is asynchronous and we |
514 | // can not be sure when exactly the device is really suspended | 514 | // can not be sure when exactly the device is really suspended |
515 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 515 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
516 | 516 | ||
517 | if ( res ) { | 517 | if ( res ) { |
518 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 518 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
519 | ::usleep ( 200 * 1000 ); | 519 | ::usleep ( 200 * 1000 ); |
520 | ::gettimeofday ( &tvn, 0 ); | 520 | ::gettimeofday ( &tvn, 0 ); |
521 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 521 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
522 | } | 522 | } |
523 | 523 | ||
524 | return res; | 524 | return res; |
525 | } | 525 | } |
526 | 526 | ||
527 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 527 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
528 | 528 | ||
529 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 529 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
530 | 530 | ||
531 | /* VESA Blanking Levels */ | 531 | /* VESA Blanking Levels */ |
532 | #define VESA_NO_BLANKING 0 | 532 | #define VESA_NO_BLANKING 0 |
533 | #define VESA_VSYNC_SUSPEND 1 | 533 | #define VESA_VSYNC_SUSPEND 1 |
534 | #define VESA_HSYNC_SUSPEND 2 | 534 | #define VESA_HSYNC_SUSPEND 2 |
535 | #define VESA_POWERDOWN 3 | 535 | #define VESA_POWERDOWN 3 |
536 | 536 | ||
537 | /** | 537 | /** |
538 | * This sets the display on or off | 538 | * This sets the display on or off |
539 | */ | 539 | */ |
540 | bool ODevice::setDisplayStatus ( bool on ) | 540 | bool ODevice::setDisplayStatus ( bool on ) |
541 | { | 541 | { |
542 | qDebug("ODevice::setDisplayStatus(%d)", on); | 542 | qDebug("ODevice::setDisplayStatus(%d)", on); |
543 | 543 | ||
544 | if ( d-> m_model == Model_Unknown ) | 544 | if ( d-> m_model == Model_Unknown ) |
545 | return false; | 545 | return false; |
546 | 546 | ||
547 | bool res = false; | 547 | bool res = false; |
548 | int fd; | 548 | int fd; |
549 | 549 | ||
550 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 550 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
551 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 551 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
552 | ::close ( fd ); | 552 | ::close ( fd ); |
553 | } | 553 | } |
554 | return res; | 554 | return res; |
555 | } | 555 | } |
556 | 556 | ||
557 | /** | 557 | /** |
558 | * This sets the display brightness | 558 | * This sets the display brightness |
559 | * | ||
560 | * @param p The brightness to be set on a scale from 0 to 255 | ||
559 | * @return success or failure | 561 | * @return success or failure |
560 | */ | 562 | */ |
561 | bool ODevice::setDisplayBrightness ( int p) | 563 | bool ODevice::setDisplayBrightness ( int p) |
562 | { | 564 | { |
563 | Q_UNUSED( p ) | 565 | Q_UNUSED( p ) |
564 | return false; | 566 | return false; |
565 | } | 567 | } |
566 | 568 | ||
567 | /** | 569 | /** |
568 | * @return return the max value for the brightness settings slider | 570 | * @return returns the number of steppings on the brightness slider |
571 | * in the Light-'n-Power settings. | ||
569 | */ | 572 | */ |
570 | int ODevice::displayBrightnessResolution ( ) const | 573 | int ODevice::displayBrightnessResolution ( ) const |
571 | { | 574 | { |
572 | return 16; | 575 | return 16; |
573 | } | 576 | } |
574 | 577 | ||
575 | /** | 578 | /** |
576 | * This sets the display contrast | 579 | * This sets the display contrast |
580 | * @param p The contrast to be set on a scale from 0 to 255 | ||
577 | * @return success or failure | 581 | * @return success or failure |
578 | */ | 582 | */ |
579 | bool ODevice::setDisplayContrast ( int p) | 583 | bool ODevice::setDisplayContrast ( int p) |
580 | { | 584 | { |
581 | Q_UNUSED( p ) | 585 | Q_UNUSED( p ) |
582 | return false; | 586 | return false; |
583 | } | 587 | } |
584 | 588 | ||
585 | /** | 589 | /** |
586 | * @return return the max value for the brightness settings slider | 590 | * @return return the max value for the brightness settings slider |
587 | * or 0 if the device doesn't support setting of a contrast | 591 | * or 0 if the device doesn't support setting of a contrast |
588 | */ | 592 | */ |
589 | int ODevice::displayContrastResolution ( ) const | 593 | int ODevice::displayContrastResolution ( ) const |
590 | { | 594 | { |
591 | return 0; | 595 | return 0; |
592 | } | 596 | } |
593 | 597 | ||
594 | /** | 598 | /** |
595 | * This returns the vendor as string | 599 | * This returns the vendor as string |
596 | * @return Vendor as QString | 600 | * @return Vendor as QString |
597 | */ | 601 | */ |
598 | QString ODevice::vendorString ( ) const | 602 | QString ODevice::vendorString ( ) const |
599 | { | 603 | { |
600 | return d-> m_vendorstr; | 604 | return d-> m_vendorstr; |
601 | } | 605 | } |
602 | 606 | ||
603 | /** | 607 | /** |
604 | * This returns the vendor as one of the values of OVendor | 608 | * This returns the vendor as one of the values of OVendor |
605 | * @return OVendor | 609 | * @return OVendor |
606 | */ | 610 | */ |
607 | OVendor ODevice::vendor ( ) const | 611 | OVendor ODevice::vendor ( ) const |
608 | { | 612 | { |
609 | return d-> m_vendor; | 613 | return d-> m_vendor; |
610 | } | 614 | } |
611 | 615 | ||
612 | /** | 616 | /** |
613 | * This returns the model as a string | 617 | * This returns the model as a string |
614 | * @return A string representing the model | 618 | * @return A string representing the model |
615 | */ | 619 | */ |
616 | QString ODevice::modelString ( ) const | 620 | QString ODevice::modelString ( ) const |
617 | { | 621 | { |
618 | return d-> m_modelstr; | 622 | return d-> m_modelstr; |
619 | } | 623 | } |
620 | 624 | ||
621 | /** | 625 | /** |
622 | * This does return the OModel used | 626 | * This does return the OModel used |
623 | */ | 627 | */ |
624 | OModel ODevice::model ( ) const | 628 | OModel ODevice::model ( ) const |
625 | { | 629 | { |
626 | return d-> m_model; | 630 | return d-> m_model; |
627 | } | 631 | } |
628 | 632 | ||
629 | /** | 633 | /** |
630 | * This does return the systen name | 634 | * This does return the systen name |
631 | */ | 635 | */ |
632 | QString ODevice::systemString ( ) const | 636 | QString ODevice::systemString ( ) const |
633 | { | 637 | { |
634 | return d-> m_systemstr; | 638 | return d-> m_systemstr; |
635 | } | 639 | } |
636 | 640 | ||
637 | /** | 641 | /** |
638 | * Return System as OSystem value | 642 | * Return System as OSystem value |
639 | */ | 643 | */ |
640 | OSystem ODevice::system ( ) const | 644 | OSystem ODevice::system ( ) const |
641 | { | 645 | { |
642 | return d-> m_system; | 646 | return d-> m_system; |
643 | } | 647 | } |
644 | 648 | ||
645 | /** | 649 | /** |
646 | * @return the version string of the base system | 650 | * @return the version string of the base system |
647 | */ | 651 | */ |
648 | QString ODevice::systemVersionString ( ) const | 652 | QString ODevice::systemVersionString ( ) const |
649 | { | 653 | { |
650 | return d-> m_sysverstr; | 654 | return d-> m_sysverstr; |
651 | } | 655 | } |
652 | 656 | ||
653 | /** | 657 | /** |
654 | * @return the current Transformation | 658 | * @return the current Transformation |
655 | */ | 659 | */ |
656 | Transformation ODevice::rotation ( ) const | 660 | Transformation ODevice::rotation ( ) const |
657 | { | 661 | { |
658 | return d-> m_rotation; | 662 | return d-> m_rotation; |
659 | } | 663 | } |
660 | 664 | ||
661 | /** | 665 | /** |
662 | * @return the current rotation direction | 666 | * @return the current rotation direction |
663 | */ | 667 | */ |
664 | ODirection ODevice::direction ( ) const | 668 | ODirection ODevice::direction ( ) const |
665 | { | 669 | { |
666 | return d-> m_direction; | 670 | return d-> m_direction; |
667 | } | 671 | } |
668 | 672 | ||
669 | /** | 673 | /** |
670 | * This plays an alarmSound | 674 | * This plays an alarmSound |
671 | */ | 675 | */ |
672 | void ODevice::alarmSound ( ) | 676 | void ODevice::alarmSound ( ) |
673 | { | 677 | { |
674 | #ifndef QT_NO_SOUND | 678 | #ifndef QT_NO_SOUND |
675 | static Sound snd ( "alarm" ); | 679 | static Sound snd ( "alarm" ); |
676 | 680 | ||
677 | if ( snd. isFinished ( )) | 681 | if ( snd. isFinished ( )) |
678 | snd. play ( ); | 682 | snd. play ( ); |
679 | #endif | 683 | #endif |
680 | } | 684 | } |
681 | 685 | ||
682 | /** | 686 | /** |
683 | * This plays a key sound | 687 | * This plays a key sound |
684 | */ | 688 | */ |
685 | void ODevice::keySound ( ) | 689 | void ODevice::keySound ( ) |
686 | { | 690 | { |
687 | #ifndef QT_NO_SOUND | 691 | #ifndef QT_NO_SOUND |
688 | static Sound snd ( "keysound" ); | 692 | static Sound snd ( "keysound" ); |
689 | 693 | ||
690 | if ( snd. isFinished ( )) | 694 | if ( snd. isFinished ( )) |
691 | snd. play ( ); | 695 | snd. play ( ); |
692 | #endif | 696 | #endif |
693 | } | 697 | } |
694 | 698 | ||
695 | /** | 699 | /** |
696 | * This plays a touch sound | 700 | * This plays a touch sound |
697 | */ | 701 | */ |
698 | void ODevice::touchSound ( ) | 702 | void ODevice::touchSound ( ) |
699 | { | 703 | { |
700 | #ifndef QT_NO_SOUND | 704 | #ifndef QT_NO_SOUND |
701 | static Sound snd ( "touchsound" ); | 705 | static Sound snd ( "touchsound" ); |
702 | 706 | ||
703 | if ( snd. isFinished ( )) | 707 | if ( snd. isFinished ( )) |
704 | snd. play ( ); | 708 | snd. play ( ); |
@@ -1945,154 +1949,154 @@ void Ramses::init() | |||
1945 | } | 1949 | } |
1946 | 1950 | ||
1947 | m_power_timer = 0; | 1951 | m_power_timer = 0; |
1948 | 1952 | ||
1949 | } | 1953 | } |
1950 | 1954 | ||
1951 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 1955 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
1952 | { | 1956 | { |
1953 | Q_UNUSED( keycode ); | 1957 | Q_UNUSED( keycode ); |
1954 | Q_UNUSED( modifiers ); | 1958 | Q_UNUSED( modifiers ); |
1955 | Q_UNUSED( isPress ); | 1959 | Q_UNUSED( isPress ); |
1956 | Q_UNUSED( autoRepeat ); | 1960 | Q_UNUSED( autoRepeat ); |
1957 | return false; | 1961 | return false; |
1958 | } | 1962 | } |
1959 | 1963 | ||
1960 | void Ramses::timerEvent(QTimerEvent *) | 1964 | void Ramses::timerEvent(QTimerEvent *) |
1961 | { | 1965 | { |
1962 | killTimer(m_power_timer); | 1966 | killTimer(m_power_timer); |
1963 | m_power_timer = 0; | 1967 | m_power_timer = 0; |
1964 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 1968 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
1965 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 1969 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
1966 | } | 1970 | } |
1967 | 1971 | ||
1968 | 1972 | ||
1969 | bool Ramses::setSoftSuspend(bool soft) | 1973 | bool Ramses::setSoftSuspend(bool soft) |
1970 | { | 1974 | { |
1971 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 1975 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
1972 | #if 0 | 1976 | #if 0 |
1973 | bool res = false; | 1977 | bool res = false; |
1974 | int fd; | 1978 | int fd; |
1975 | 1979 | ||
1976 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 1980 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
1977 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 1981 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
1978 | 1982 | ||
1979 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 1983 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
1980 | 1984 | ||
1981 | if (sources >= 0) { | 1985 | if (sources >= 0) { |
1982 | if (soft) | 1986 | if (soft) |
1983 | sources &= ~APM_EVT_POWER_BUTTON; | 1987 | sources &= ~APM_EVT_POWER_BUTTON; |
1984 | else | 1988 | else |
1985 | sources |= APM_EVT_POWER_BUTTON; | 1989 | sources |= APM_EVT_POWER_BUTTON; |
1986 | 1990 | ||
1987 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 1991 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
1988 | res = true; | 1992 | res = true; |
1989 | else | 1993 | else |
1990 | perror("APM_IOCGEVTSRC"); | 1994 | perror("APM_IOCGEVTSRC"); |
1991 | } | 1995 | } |
1992 | else | 1996 | else |
1993 | perror("APM_IOCGEVTSRC"); | 1997 | perror("APM_IOCGEVTSRC"); |
1994 | 1998 | ||
1995 | ::close(fd); | 1999 | ::close(fd); |
1996 | } | 2000 | } |
1997 | else | 2001 | else |
1998 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 2002 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
1999 | 2003 | ||
2000 | return res; | 2004 | return res; |
2001 | #else | 2005 | #else |
2002 | return true; | 2006 | return true; |
2003 | #endif | 2007 | #endif |
2004 | } | 2008 | } |
2005 | 2009 | ||
2006 | bool Ramses::suspend ( ) | 2010 | bool Ramses::suspend ( ) |
2007 | { | 2011 | { |
2008 | qDebug("Ramses::suspend"); | 2012 | qDebug("Ramses::suspend"); |
2009 | } | 2013 | } |
2010 | 2014 | ||
2011 | /** | 2015 | /** |
2012 | * This sets the display on or off | 2016 | * This sets the display on or off |
2013 | */ | 2017 | */ |
2014 | bool Ramses::setDisplayStatus(bool on) | 2018 | bool Ramses::setDisplayStatus(bool on) |
2015 | { | 2019 | { |
2016 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2020 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2017 | #if 0 | 2021 | #if 0 |
2018 | bool res = false; | 2022 | bool res = false; |
2019 | int fd; | 2023 | int fd; |
2020 | 2024 | ||
2021 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2025 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2022 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2026 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2023 | ::close(fd); | 2027 | ::close(fd); |
2024 | } | 2028 | } |
2025 | return res; | 2029 | return res; |
2026 | #else | 2030 | #else |
2027 | return true; | 2031 | return true; |
2028 | #endif | 2032 | #endif |
2029 | } | 2033 | } |
2030 | 2034 | ||
2031 | 2035 | ||
2032 | /* | 2036 | /* |
2033 | * We get something between 0..255 into us | 2037 | * We get something between 0..255 into us |
2034 | */ | 2038 | */ |
2035 | bool Ramses::setDisplayBrightness(int bright) | 2039 | bool Ramses::setDisplayBrightness(int bright) |
2036 | { | 2040 | { |
2037 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2041 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2038 | bool res = false; | 2042 | bool res = false; |
2039 | int fd; | 2043 | int fd; |
2040 | 2044 | ||
2041 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2045 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2042 | 2046 | ||
2043 | if (bright > 255 ) | 2047 | if (bright > 255 ) |
2044 | bright = 255; | 2048 | bright = 255; |
2045 | if (bright < 0) | 2049 | if (bright < 0) |
2046 | bright = 0; | 2050 | bright = 0; |
2047 | bright = 500-(bright * 500 / 255); | 2051 | bright = 500-(bright * 500 / 255); |
2048 | 2052 | ||
2049 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2053 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2050 | qDebug(" %d -> pwm1", bright); | 2054 | qDebug(" %d -> pwm1", bright); |
2051 | char writeCommand[100]; | 2055 | char writeCommand[100]; |
2052 | const int count = sprintf(writeCommand, "%d\n", bright); | 2056 | const int count = sprintf(writeCommand, "%d\n", bright); |
2053 | res = (::write(fd, writeCommand, count) != -1); | 2057 | res = (::write(fd, writeCommand, count) != -1); |
2054 | ::close(fd); | 2058 | ::close(fd); |
2055 | } else { | 2059 | } else { |
2056 | qWarning("no write"); | 2060 | qWarning("no write"); |
2057 | } | 2061 | } |
2058 | return res; | 2062 | return res; |
2059 | } | 2063 | } |
2060 | 2064 | ||
2061 | 2065 | ||
2062 | int Ramses::displayBrightnessResolution() const | 2066 | int Ramses::displayBrightnessResolution() const |
2063 | { | 2067 | { |
2064 | return 32; | 2068 | return 32; |
2065 | } | 2069 | } |
2066 | 2070 | ||
2067 | bool Ramses::setDisplayContrast(int contr) | 2071 | bool Ramses::setDisplayContrast(int contr) |
2068 | { | 2072 | { |
2069 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2073 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2070 | bool res = false; | 2074 | bool res = false; |
2071 | int fd; | 2075 | int fd; |
2072 | 2076 | ||
2073 | // pwm0 contrast: 35 steps 65..100 (dunkel->hell) | 2077 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2074 | 2078 | ||
2075 | if (contr > 255 ) | 2079 | if (contr > 255 ) |
2076 | contr = 255; | 2080 | contr = 255; |
2077 | if (contr < 0) | 2081 | if (contr < 0) |
2078 | contr = 0; | 2082 | contr = 0; |
2079 | contr = 65 + (contr * 350 / 255); | 2083 | contr = 90 - (contr * 20 / 255); |
2080 | 2084 | ||
2081 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2085 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2082 | qDebug(" %d -> pwm0", contr); | 2086 | qDebug(" %d -> pwm0", contr); |
2083 | char writeCommand[100]; | 2087 | char writeCommand[100]; |
2084 | const int count = sprintf(writeCommand, "%d\n", contr); | 2088 | const int count = sprintf(writeCommand, "%d\n", contr); |
2085 | res = (::write(fd, writeCommand, count) != -1); | 2089 | res = (::write(fd, writeCommand, count) != -1); |
2086 | res = true; | 2090 | res = true; |
2087 | ::close(fd); | 2091 | ::close(fd); |
2088 | } else { | 2092 | } else { |
2089 | qWarning("no write"); | 2093 | qWarning("no write"); |
2090 | } | 2094 | } |
2091 | return res; | 2095 | return res; |
2092 | } | 2096 | } |
2093 | 2097 | ||
2094 | 2098 | ||
2095 | int Ramses::displayContrastResolution() const | 2099 | int Ramses::displayContrastResolution() const |
2096 | { | 2100 | { |
2097 | return 32; | 2101 | return 20; |
2098 | } | 2102 | } |
diff --git a/libopie/odevice.h b/libopie/odevice.h index 6c4830e..0974e8d 100644 --- a/libopie/odevice.h +++ b/libopie/odevice.h | |||
@@ -4,243 +4,242 @@ | |||
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 <qobject.h> | 23 | #include <qobject.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qnamespace.h> | 25 | #include <qnamespace.h> |
26 | 26 | ||
27 | #include <opie/odevicebutton.h> | 27 | #include <opie/odevicebutton.h> |
28 | 28 | ||
29 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ | 29 | #include <qpe/qpeapplication.h> /* for Transformation enum.. */ |
30 | 30 | ||
31 | class ODeviceData; | 31 | class ODeviceData; |
32 | 32 | ||
33 | namespace Opie { | 33 | namespace Opie { |
34 | 34 | ||
35 | /** | 35 | /** |
36 | * The available devices | 36 | * The available devices |
37 | */ | 37 | */ |
38 | enum OModel { | 38 | enum OModel { |
39 | Model_Unknown, // = 0 | 39 | Model_Unknown, // = 0 |
40 | 40 | ||
41 | Model_Series_Mask = 0xff000000, | 41 | Model_Series_Mask = 0xff000000, |
42 | 42 | ||
43 | Model_iPAQ = ( 1 << 24 ), | 43 | Model_iPAQ = ( 1 << 24 ), |
44 | 44 | ||
45 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), | 45 | Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), |
46 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), | 46 | Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), |
47 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), | 47 | Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), |
48 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), | 48 | Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), |
49 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), | 49 | Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), |
50 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), | 50 | Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), |
51 | 51 | ||
52 | Model_Zaurus = ( 2 << 24 ), | 52 | Model_Zaurus = ( 2 << 24 ), |
53 | 53 | ||
54 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), | 54 | Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), |
55 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), | 55 | Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), |
56 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), | 56 | Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), |
57 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), | 57 | Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), |
58 | Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), | 58 | Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), |
59 | 59 | ||
60 | Model_SIMpad = ( 3 << 24 ), | 60 | Model_SIMpad = ( 3 << 24 ), |
61 | 61 | ||
62 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), | 62 | Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), |
63 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), | 63 | Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), |
64 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), | 64 | Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), |
65 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), | 65 | Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), |
66 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), | 66 | Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), |
67 | 67 | ||
68 | Model_Ramses = ( 4 << 24 ), | 68 | Model_Ramses = ( 4 << 24 ), |
69 | 69 | ||
70 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), | 70 | Model_Ramses_All = ( Model_Ramses | 0xffffff ), |
71 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), | 71 | Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), |
72 | }; | 72 | }; |
73 | 73 | ||
74 | /** | 74 | /** |
75 | * The vendor of the device | 75 | * The vendor of the device |
76 | */ | 76 | */ |
77 | enum OVendor { | 77 | enum OVendor { |
78 | Vendor_Unknown, | 78 | Vendor_Unknown, |
79 | 79 | ||
80 | Vendor_HP, | 80 | Vendor_HP, |
81 | Vendor_Sharp, | 81 | Vendor_Sharp, |
82 | Vendor_SIEMENS, | 82 | Vendor_SIEMENS, |
83 | Vendor_MundN, | 83 | Vendor_MundN, |
84 | }; | 84 | }; |
85 | 85 | ||
86 | /** | 86 | /** |
87 | * The System used | 87 | * The System used |
88 | */ | 88 | */ |
89 | enum OSystem { | 89 | enum OSystem { |
90 | System_Unknown, | 90 | System_Unknown, |
91 | 91 | ||
92 | System_Familiar, | 92 | System_Familiar, |
93 | System_Zaurus, | 93 | System_Zaurus, |
94 | System_OpenZaurus | 94 | System_OpenZaurus |
95 | }; | 95 | }; |
96 | 96 | ||
97 | enum OLedState { | 97 | enum OLedState { |
98 | Led_Off, | 98 | Led_Off, |
99 | Led_On, | 99 | Led_On, |
100 | Led_BlinkSlow, | 100 | Led_BlinkSlow, |
101 | Led_BlinkFast | 101 | Led_BlinkFast |
102 | }; | 102 | }; |
103 | 103 | ||
104 | enum OLed { | 104 | enum OLed { |
105 | Led_Mail, | 105 | Led_Mail, |
106 | Led_Power, | 106 | Led_Power, |
107 | Led_BlueTooth | 107 | Led_BlueTooth |
108 | }; | 108 | }; |
109 | 109 | ||
110 | enum OHardKey { | 110 | enum OHardKey { |
111 | HardKey_Datebook = Qt::Key_F9, | 111 | HardKey_Datebook = Qt::Key_F9, |
112 | HardKey_Contacts = Qt::Key_F10, | 112 | HardKey_Contacts = Qt::Key_F10, |
113 | HardKey_Menu = Qt::Key_F11, | 113 | HardKey_Menu = Qt::Key_F11, |
114 | HardKey_Home = Qt::Key_F12, | 114 | HardKey_Home = Qt::Key_F12, |
115 | HardKey_Mail = Qt::Key_F13, | 115 | HardKey_Mail = Qt::Key_F13, |
116 | HardKey_Record = Qt::Key_F24, | 116 | HardKey_Record = Qt::Key_F24, |
117 | HardKey_Suspend = Qt::Key_F34, | 117 | HardKey_Suspend = Qt::Key_F34, |
118 | HardKey_Backlight = Qt::Key_F35, | 118 | HardKey_Backlight = Qt::Key_F35, |
119 | }; | 119 | }; |
120 | 120 | ||
121 | enum ODirection { | 121 | enum ODirection { |
122 | CW = 0, | 122 | CW = 0, |
123 | CCW = 1, | 123 | CCW = 1, |
124 | Flip = 2, | 124 | Flip = 2, |
125 | }; | 125 | }; |
126 | 126 | ||
127 | /** | 127 | /** |
128 | * A singleton which gives informations about device specefic option | 128 | * A singleton which gives informations about device specefic option |
129 | * like the Hardware used, LEDs, the Base Distribution and | 129 | * like the Hardware used, LEDs, the Base Distribution and |
130 | * hardware key mappings. | 130 | * hardware key mappings. |
131 | * | 131 | * |
132 | * | ||
133 | * @short A small class for device specefic options | 132 | * @short A small class for device specefic options |
134 | * @see QObject | 133 | * @see QObject |
135 | * @author Robert Griebl | 134 | * @author Robert Griebl |
136 | * @version 1.0 | 135 | * @version 1.0 |
137 | */ | 136 | */ |
138 | class ODevice : public QObject { | 137 | class ODevice : public QObject { |
139 | Q_OBJECT | 138 | Q_OBJECT |
140 | 139 | ||
141 | private: | 140 | private: |
142 | /* disable copy */ | 141 | /* disable copy */ |
143 | ODevice ( const ODevice & ); | 142 | ODevice ( const ODevice & ); |
144 | 143 | ||
145 | protected: | 144 | protected: |
146 | ODevice ( ); | 145 | ODevice ( ); |
147 | virtual void init ( ); | 146 | virtual void init ( ); |
148 | virtual void initButtons ( ); | 147 | virtual void initButtons ( ); |
149 | 148 | ||
150 | ODeviceData *d; | 149 | ODeviceData *d; |
151 | 150 | ||
152 | public: | 151 | public: |
153 | // sandman do we want to allow destructions? -zecke? | 152 | // sandman do we want to allow destructions? -zecke? |
154 | virtual ~ODevice ( ); | 153 | virtual ~ODevice ( ); |
155 | 154 | ||
156 | 155 | ||
157 | static ODevice *inst ( ); | 156 | static ODevice *inst ( ); |
158 | 157 | ||
159 | // information | 158 | // information |
160 | 159 | ||
161 | QString modelString ( ) const; | 160 | QString modelString ( ) const; |
162 | OModel model ( ) const; | 161 | OModel model ( ) const; |
163 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } | 162 | inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } |
164 | 163 | ||
165 | QString vendorString ( ) const; | 164 | QString vendorString ( ) const; |
166 | OVendor vendor ( ) const; | 165 | OVendor vendor ( ) const; |
167 | 166 | ||
168 | QString systemString ( ) const; | 167 | QString systemString ( ) const; |
169 | OSystem system ( ) const; | 168 | OSystem system ( ) const; |
170 | 169 | ||
171 | QString systemVersionString ( ) const; | 170 | QString systemVersionString ( ) const; |
172 | 171 | ||
173 | Transformation rotation ( ) const; | 172 | Transformation rotation ( ) const; |
174 | ODirection direction ( ) const; | 173 | ODirection direction ( ) const; |
175 | 174 | ||
176 | // system | 175 | // system |
177 | 176 | ||
178 | virtual bool setSoftSuspend ( bool on ); | 177 | virtual bool setSoftSuspend ( bool on ); |
179 | virtual bool suspend ( ); | 178 | virtual bool suspend ( ); |
180 | 179 | ||
181 | virtual bool setDisplayStatus ( bool on ); | 180 | virtual bool setDisplayStatus ( bool on ); |
182 | virtual bool setDisplayBrightness ( int brightness ); | 181 | virtual bool setDisplayBrightness ( int brightness ); |
183 | virtual int displayBrightnessResolution ( ) const; | 182 | virtual int displayBrightnessResolution ( ) const; |
184 | virtual bool setDisplayContrast ( int contrast ); | 183 | virtual bool setDisplayContrast ( int contrast ); |
185 | virtual int displayContrastResolution ( ) const; | 184 | virtual int displayContrastResolution ( ) const; |
186 | 185 | ||
187 | // input / output | 186 | // input / output |
188 | //FIXME playAlarmSound and al might be better -zecke | 187 | //FIXME playAlarmSound and al might be better -zecke |
189 | virtual void alarmSound ( ); | 188 | virtual void alarmSound ( ); |
190 | virtual void keySound ( ); | 189 | virtual void keySound ( ); |
191 | virtual void touchSound ( ); | 190 | virtual void touchSound ( ); |
192 | 191 | ||
193 | virtual QValueList <OLed> ledList ( ) const; | 192 | virtual QValueList <OLed> ledList ( ) const; |
194 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; | 193 | virtual QValueList <OLedState> ledStateList ( OLed led ) const; |
195 | virtual OLedState ledState ( OLed led ) const; | 194 | virtual OLedState ledState ( OLed led ) const; |
196 | virtual bool setLedState ( OLed led, OLedState st ); | 195 | virtual bool setLedState ( OLed led, OLedState st ); |
197 | 196 | ||
198 | virtual bool hasLightSensor ( ) const; | 197 | virtual bool hasLightSensor ( ) const; |
199 | virtual int readLightSensor ( ); | 198 | virtual int readLightSensor ( ); |
200 | virtual int lightSensorResolution ( ) const; | 199 | virtual int lightSensorResolution ( ) const; |
201 | 200 | ||
202 | /** | 201 | /** |
203 | * Returns the available buttons on this device. The number and location | 202 | * Returns the available buttons on this device. The number and location |
204 | * of buttons will vary depending on the device. Button numbers will be assigned | 203 | * of buttons will vary depending on the device. Button numbers will be assigned |
205 | * by the device manufacturer and will be from most preferred button to least preffered | 204 | * by the device manufacturer and will be from most preferred button to least preffered |
206 | * button. Note that this list only contains "user mappable" buttons. | 205 | * button. Note that this list only contains "user mappable" buttons. |
207 | */ | 206 | */ |
208 | const QValueList<ODeviceButton> &buttons ( ); | 207 | const QValueList<ODeviceButton> &buttons ( ); |
209 | 208 | ||
210 | /** | 209 | /** |
211 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it | 210 | * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it |
212 | * returns 0L | 211 | * returns 0L |
213 | */ | 212 | */ |
214 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); | 213 | const ODeviceButton *buttonForKeycode ( ushort keyCode ); |
215 | 214 | ||
216 | /** | 215 | /** |
217 | * Reassigns the pressed action for \a button. To return to the factory | 216 | * Reassigns the pressed action for \a button. To return to the factory |
218 | * default pass an empty string as \a qcopMessage. | 217 | * default pass an empty string as \a qcopMessage. |
219 | */ | 218 | */ |
220 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); | 219 | void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); |
221 | 220 | ||
222 | /** | 221 | /** |
223 | * Reassigns the held action for \a button. To return to the factory | 222 | * Reassigns the held action for \a button. To return to the factory |
224 | * default pass an empty string as \a qcopMessage. | 223 | * default pass an empty string as \a qcopMessage. |
225 | */ | 224 | */ |
226 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); | 225 | void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); |
227 | 226 | ||
228 | /** | 227 | /** |
229 | * How long (in ms) you have to press a button for a "hold" action | 228 | * How long (in ms) you have to press a button for a "hold" action |
230 | */ | 229 | */ |
231 | uint buttonHoldTime ( ) const; | 230 | uint buttonHoldTime ( ) const; |
232 | 231 | ||
233 | signals: | 232 | signals: |
234 | void buttonMappingChanged ( ); | 233 | void buttonMappingChanged ( ); |
235 | 234 | ||
236 | private slots: | 235 | private slots: |
237 | void systemMessage ( const QCString &, const QByteArray & ); | 236 | void systemMessage ( const QCString &, const QByteArray & ); |
238 | 237 | ||
239 | protected: | 238 | protected: |
240 | void reloadButtonMapping ( ); | 239 | void reloadButtonMapping ( ); |
241 | }; | 240 | }; |
242 | 241 | ||
243 | } | 242 | } |
244 | 243 | ||
245 | #endif | 244 | #endif |
246 | 245 | ||