summaryrefslogtreecommitdiff
authorzecke <zecke>2003-06-11 09:46:50 (UTC)
committer zecke <zecke>2003-06-11 09:46:50 (UTC)
commit4d05b57498f6b2f135ecd55e5fde5e6ebc21c160 (patch) (unidiff)
treea5b52535c5e24da86acaf5b753dfa886d808cab0
parent22be97432c25bad67b4fb241977670657facb3af (diff)
downloadopie-4d05b57498f6b2f135ecd55e5fde5e6ebc21c160.zip
opie-4d05b57498f6b2f135ecd55e5fde5e6ebc21c160.tar.gz
opie-4d05b57498f6b2f135ecd55e5fde5e6ebc21c160.tar.bz2
add the virtual hook in HEAD as well
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp4
-rw-r--r--libopie/odevice.h2
2 files changed, 5 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index d6e6892..993aedf 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -404,904 +404,906 @@ ODevice *ODevice::inst ( )
404/************************************************** 404/**************************************************
405 * 405 *
406 * common 406 * common
407 * 407 *
408 **************************************************/ 408 **************************************************/
409 409
410 410
411ODevice::ODevice ( ) 411ODevice::ODevice ( )
412{ 412{
413 d = new ODeviceData; 413 d = new ODeviceData;
414 414
415 d-> m_modelstr = "Unknown"; 415 d-> m_modelstr = "Unknown";
416 d-> m_model = Model_Unknown; 416 d-> m_model = Model_Unknown;
417 d-> m_vendorstr = "Unknown"; 417 d-> m_vendorstr = "Unknown";
418 d-> m_vendor = Vendor_Unknown; 418 d-> m_vendor = Vendor_Unknown;
419 d-> m_systemstr = "Unknown"; 419 d-> m_systemstr = "Unknown";
420 d-> m_system = System_Unknown; 420 d-> m_system = System_Unknown;
421 d-> m_sysverstr = "0.0"; 421 d-> m_sysverstr = "0.0";
422 d-> m_rotation = Rot0; 422 d-> m_rotation = Rot0;
423 d-> m_direction = CW; 423 d-> m_direction = CW;
424 424
425 d-> m_holdtime = 1000; // 1000ms 425 d-> m_holdtime = 1000; // 1000ms
426 d-> m_buttons = 0; 426 d-> m_buttons = 0;
427 d-> m_cpu_frequencies = new QStrList; 427 d-> m_cpu_frequencies = new QStrList;
428} 428}
429 429
430void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 430void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
431{ 431{
432 if ( msg == "deviceButtonMappingChanged()" ) { 432 if ( msg == "deviceButtonMappingChanged()" ) {
433 reloadButtonMapping ( ); 433 reloadButtonMapping ( );
434 } 434 }
435} 435}
436 436
437void ODevice::init ( ) 437void ODevice::init ( )
438{ 438{
439} 439}
440 440
441/** 441/**
442 * This method initialises the button mapping 442 * This method initialises the button mapping
443 */ 443 */
444void ODevice::initButtons ( ) 444void ODevice::initButtons ( )
445{ 445{
446 if ( d-> m_buttons ) 446 if ( d-> m_buttons )
447 return; 447 return;
448 448
449 // Simulation uses iPAQ 3660 device buttons 449 // Simulation uses iPAQ 3660 device buttons
450 450
451 qDebug ( "init Buttons" ); 451 qDebug ( "init Buttons" );
452 d-> m_buttons = new QValueList <ODeviceButton>; 452 d-> m_buttons = new QValueList <ODeviceButton>;
453 453
454 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 454 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
455 i_button *ib = ipaq_buttons + i; 455 i_button *ib = ipaq_buttons + i;
456 ODeviceButton b; 456 ODeviceButton b;
457 457
458 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 458 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
459 b. setKeycode ( ib-> code ); 459 b. setKeycode ( ib-> code );
460 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 460 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
461 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 461 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
462 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 462 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
463 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 463 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
464 d-> m_buttons-> append ( b ); 464 d-> m_buttons-> append ( b );
465 } 465 }
466 } 466 }
467 reloadButtonMapping ( ); 467 reloadButtonMapping ( );
468 468
469 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 469 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
470 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 470 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
471} 471}
472 472
473ODevice::~ODevice ( ) 473ODevice::~ODevice ( )
474{ 474{
475 delete d; 475 delete d;
476} 476}
477 477
478bool ODevice::setSoftSuspend ( bool /*soft*/ ) 478bool ODevice::setSoftSuspend ( bool /*soft*/ )
479{ 479{
480 return false; 480 return false;
481} 481}
482 482
483//#include <linux/apm_bios.h> 483//#include <linux/apm_bios.h>
484 484
485#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 485#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
486 486
487/** 487/**
488 * This method will try to suspend the device 488 * This method will try to suspend the device
489 * It only works if the user is the QWS Server and the apm application 489 * It only works if the user is the QWS Server and the apm application
490 * is installed. 490 * is installed.
491 * It tries to suspend and then waits some time cause some distributions 491 * It tries to suspend and then waits some time cause some distributions
492 * do have asynchronus apm implementations. 492 * do have asynchronus apm implementations.
493 * This method will either fail and return false or it'll suspend the 493 * This method will either fail and return false or it'll suspend the
494 * device and return once the device got woken up 494 * device and return once the device got woken up
495 * 495 *
496 * @return if the device got suspended 496 * @return if the device got suspended
497 */ 497 */
498bool ODevice::suspend ( ) 498bool ODevice::suspend ( )
499{ 499{
500 qDebug("ODevice::suspend"); 500 qDebug("ODevice::suspend");
501 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 501 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
502 return false; 502 return false;
503 503
504 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 504 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
505 return false; 505 return false;
506 506
507 bool res = false; 507 bool res = false;
508 508
509 struct timeval tvs, tvn; 509 struct timeval tvs, tvn;
510 ::gettimeofday ( &tvs, 0 ); 510 ::gettimeofday ( &tvs, 0 );
511 511
512 ::sync ( ); // flush fs caches 512 ::sync ( ); // flush fs caches
513 res = ( ::system ( "apm --suspend" ) == 0 ); 513 res = ( ::system ( "apm --suspend" ) == 0 );
514 514
515 // This is needed because the iPAQ apm implementation is asynchronous and we 515 // This is needed because the iPAQ apm implementation is asynchronous and we
516 // can not be sure when exactly the device is really suspended 516 // can not be sure when exactly the device is really suspended
517 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 517 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
518 518
519 if ( res ) { 519 if ( res ) {
520 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 520 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
521 ::usleep ( 200 * 1000 ); 521 ::usleep ( 200 * 1000 );
522 ::gettimeofday ( &tvn, 0 ); 522 ::gettimeofday ( &tvn, 0 );
523 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 523 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
524 } 524 }
525 525
526 return res; 526 return res;
527} 527}
528 528
529//#include <linux/fb.h> better not rely on kernel headers in userspace ... 529//#include <linux/fb.h> better not rely on kernel headers in userspace ...
530 530
531#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 531#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
532 532
533/* VESA Blanking Levels */ 533/* VESA Blanking Levels */
534#define VESA_NO_BLANKING 0 534#define VESA_NO_BLANKING 0
535#define VESA_VSYNC_SUSPEND 1 535#define VESA_VSYNC_SUSPEND 1
536#define VESA_HSYNC_SUSPEND 2 536#define VESA_HSYNC_SUSPEND 2
537#define VESA_POWERDOWN 3 537#define VESA_POWERDOWN 3
538 538
539/** 539/**
540 * This sets the display on or off 540 * This sets the display on or off
541 */ 541 */
542bool ODevice::setDisplayStatus ( bool on ) 542bool ODevice::setDisplayStatus ( bool on )
543{ 543{
544 qDebug("ODevice::setDisplayStatus(%d)", on); 544 qDebug("ODevice::setDisplayStatus(%d)", on);
545 545
546 if ( d-> m_model == Model_Unknown ) 546 if ( d-> m_model == Model_Unknown )
547 return false; 547 return false;
548 548
549 bool res = false; 549 bool res = false;
550 int fd; 550 int fd;
551 551
552 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 552 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
553 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 553 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
554 ::close ( fd ); 554 ::close ( fd );
555 } 555 }
556 return res; 556 return res;
557} 557}
558 558
559/** 559/**
560 * This sets the display brightness 560 * This sets the display brightness
561 * 561 *
562 * @param p The brightness to be set on a scale from 0 to 255 562 * @param p The brightness to be set on a scale from 0 to 255
563 * @return success or failure 563 * @return success or failure
564 */ 564 */
565bool ODevice::setDisplayBrightness ( int p) 565bool ODevice::setDisplayBrightness ( int p)
566{ 566{
567 Q_UNUSED( p ) 567 Q_UNUSED( p )
568 return false; 568 return false;
569} 569}
570 570
571/** 571/**
572 * @return returns the number of steppings on the brightness slider 572 * @return returns the number of steppings on the brightness slider
573 * in the Light-'n-Power settings. 573 * in the Light-'n-Power settings.
574 */ 574 */
575int ODevice::displayBrightnessResolution ( ) const 575int ODevice::displayBrightnessResolution ( ) const
576{ 576{
577 return 16; 577 return 16;
578} 578}
579 579
580/** 580/**
581 * This sets the display contrast 581 * This sets the display contrast
582 * @param p The contrast to be set on a scale from 0 to 255 582 * @param p The contrast to be set on a scale from 0 to 255
583 * @return success or failure 583 * @return success or failure
584 */ 584 */
585bool ODevice::setDisplayContrast ( int p) 585bool ODevice::setDisplayContrast ( int p)
586{ 586{
587 Q_UNUSED( p ) 587 Q_UNUSED( p )
588 return false; 588 return false;
589} 589}
590 590
591/** 591/**
592 * @return return the max value for the brightness settings slider 592 * @return return the max value for the brightness settings slider
593 * or 0 if the device doesn't support setting of a contrast 593 * or 0 if the device doesn't support setting of a contrast
594 */ 594 */
595int ODevice::displayContrastResolution ( ) const 595int ODevice::displayContrastResolution ( ) const
596{ 596{
597 return 0; 597 return 0;
598} 598}
599 599
600/** 600/**
601 * This returns the vendor as string 601 * This returns the vendor as string
602 * @return Vendor as QString 602 * @return Vendor as QString
603 */ 603 */
604QString ODevice::vendorString ( ) const 604QString ODevice::vendorString ( ) const
605{ 605{
606 return d-> m_vendorstr; 606 return d-> m_vendorstr;
607} 607}
608 608
609/** 609/**
610 * This returns the vendor as one of the values of OVendor 610 * This returns the vendor as one of the values of OVendor
611 * @return OVendor 611 * @return OVendor
612 */ 612 */
613OVendor ODevice::vendor ( ) const 613OVendor ODevice::vendor ( ) const
614{ 614{
615 return d-> m_vendor; 615 return d-> m_vendor;
616} 616}
617 617
618/** 618/**
619 * This returns the model as a string 619 * This returns the model as a string
620 * @return A string representing the model 620 * @return A string representing the model
621 */ 621 */
622QString ODevice::modelString ( ) const 622QString ODevice::modelString ( ) const
623{ 623{
624 return d-> m_modelstr; 624 return d-> m_modelstr;
625} 625}
626 626
627/** 627/**
628 * This does return the OModel used 628 * This does return the OModel used
629 */ 629 */
630OModel ODevice::model ( ) const 630OModel ODevice::model ( ) const
631{ 631{
632 return d-> m_model; 632 return d-> m_model;
633} 633}
634 634
635/** 635/**
636 * This does return the systen name 636 * This does return the systen name
637 */ 637 */
638QString ODevice::systemString ( ) const 638QString ODevice::systemString ( ) const
639{ 639{
640 return d-> m_systemstr; 640 return d-> m_systemstr;
641} 641}
642 642
643/** 643/**
644 * Return System as OSystem value 644 * Return System as OSystem value
645 */ 645 */
646OSystem ODevice::system ( ) const 646OSystem ODevice::system ( ) const
647{ 647{
648 return d-> m_system; 648 return d-> m_system;
649} 649}
650 650
651/** 651/**
652 * @return the version string of the base system 652 * @return the version string of the base system
653 */ 653 */
654QString ODevice::systemVersionString ( ) const 654QString ODevice::systemVersionString ( ) const
655{ 655{
656 return d-> m_sysverstr; 656 return d-> m_sysverstr;
657} 657}
658 658
659/** 659/**
660 * @return the current Transformation 660 * @return the current Transformation
661 */ 661 */
662Transformation ODevice::rotation ( ) const 662Transformation ODevice::rotation ( ) const
663{ 663{
664 return d-> m_rotation; 664 return d-> m_rotation;
665} 665}
666 666
667/** 667/**
668 * @return the current rotation direction 668 * @return the current rotation direction
669 */ 669 */
670ODirection ODevice::direction ( ) const 670ODirection ODevice::direction ( ) const
671{ 671{
672 return d-> m_direction; 672 return d-> m_direction;
673} 673}
674 674
675/** 675/**
676 * This plays an alarmSound 676 * This plays an alarmSound
677 */ 677 */
678void ODevice::alarmSound ( ) 678void ODevice::alarmSound ( )
679{ 679{
680#ifndef QT_NO_SOUND 680#ifndef QT_NO_SOUND
681 static Sound snd ( "alarm" ); 681 static Sound snd ( "alarm" );
682 682
683 if ( snd. isFinished ( )) 683 if ( snd. isFinished ( ))
684 snd. play ( ); 684 snd. play ( );
685#endif 685#endif
686} 686}
687 687
688/** 688/**
689 * This plays a key sound 689 * This plays a key sound
690 */ 690 */
691void ODevice::keySound ( ) 691void ODevice::keySound ( )
692{ 692{
693#ifndef QT_NO_SOUND 693#ifndef QT_NO_SOUND
694 static Sound snd ( "keysound" ); 694 static Sound snd ( "keysound" );
695 695
696 if ( snd. isFinished ( )) 696 if ( snd. isFinished ( ))
697 snd. play ( ); 697 snd. play ( );
698#endif 698#endif
699} 699}
700 700
701/** 701/**
702 * This plays a touch sound 702 * This plays a touch sound
703 */ 703 */
704void ODevice::touchSound ( ) 704void ODevice::touchSound ( )
705{ 705{
706#ifndef QT_NO_SOUND 706#ifndef QT_NO_SOUND
707 static Sound snd ( "touchsound" ); 707 static Sound snd ( "touchsound" );
708 708
709 if ( snd. isFinished ( )) 709 if ( snd. isFinished ( ))
710 snd. play ( ); 710 snd. play ( );
711#endif 711#endif
712} 712}
713 713
714/** 714/**
715 * This method will return a list of leds 715 * This method will return a list of leds
716 * available on this device 716 * available on this device
717 * @return a list of LEDs. 717 * @return a list of LEDs.
718 */ 718 */
719QValueList <OLed> ODevice::ledList ( ) const 719QValueList <OLed> ODevice::ledList ( ) const
720{ 720{
721 return QValueList <OLed> ( ); 721 return QValueList <OLed> ( );
722} 722}
723 723
724/** 724/**
725 * This does return the state of the LEDs 725 * This does return the state of the LEDs
726 */ 726 */
727QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 727QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
728{ 728{
729 return QValueList <OLedState> ( ); 729 return QValueList <OLedState> ( );
730} 730}
731 731
732/** 732/**
733 * @return the state for a given OLed 733 * @return the state for a given OLed
734 */ 734 */
735OLedState ODevice::ledState ( OLed /*which*/ ) const 735OLedState ODevice::ledState ( OLed /*which*/ ) const
736{ 736{
737 return Led_Off; 737 return Led_Off;
738} 738}
739 739
740/** 740/**
741 * Set the state for a LED 741 * Set the state for a LED
742 * @param which Which OLed to use 742 * @param which Which OLed to use
743 * @param st The state to set 743 * @param st The state to set
744 * @return success or failure 744 * @return success or failure
745 */ 745 */
746bool ODevice::setLedState ( OLed which, OLedState st ) 746bool ODevice::setLedState ( OLed which, OLedState st )
747{ 747{
748 Q_UNUSED( which ) 748 Q_UNUSED( which )
749 Q_UNUSED( st ) 749 Q_UNUSED( st )
750 return false; 750 return false;
751} 751}
752 752
753/** 753/**
754 * @return if the device has a light sensor 754 * @return if the device has a light sensor
755 */ 755 */
756bool ODevice::hasLightSensor ( ) const 756bool ODevice::hasLightSensor ( ) const
757{ 757{
758 return false; 758 return false;
759} 759}
760 760
761/** 761/**
762 * @return a value from the light senso 762 * @return a value from the light senso
763 */ 763 */
764int ODevice::readLightSensor ( ) 764int ODevice::readLightSensor ( )
765{ 765{
766 return -1; 766 return -1;
767} 767}
768 768
769/** 769/**
770 * @return the light sensor resolution whatever that is ;) 770 * @return the light sensor resolution whatever that is ;)
771 */ 771 */
772int ODevice::lightSensorResolution ( ) const 772int ODevice::lightSensorResolution ( ) const
773{ 773{
774 return 0; 774 return 0;
775} 775}
776 776
777/** 777/**
778 * @return a list with CPU frequencies supported by the hardware 778 * @return a list with CPU frequencies supported by the hardware
779 */ 779 */
780const QStrList &ODevice::allowedCpuFrequencies ( ) const 780const QStrList &ODevice::allowedCpuFrequencies ( ) const
781{ 781{
782 return *d->m_cpu_frequencies; 782 return *d->m_cpu_frequencies;
783} 783}
784 784
785 785
786/** 786/**
787 * Set desired CPU frequency 787 * Set desired CPU frequency
788 * 788 *
789 * @param index index into d->m_cpu_frequencies of the frequency to be set 789 * @param index index into d->m_cpu_frequencies of the frequency to be set
790 */ 790 */
791bool ODevice::setCurrentCpuFrequency(uint index) 791bool ODevice::setCurrentCpuFrequency(uint index)
792{ 792{
793 if (index >= d->m_cpu_frequencies->count()) 793 if (index >= d->m_cpu_frequencies->count())
794 return false; 794 return false;
795 795
796 char *freq = d->m_cpu_frequencies->at(index); 796 char *freq = d->m_cpu_frequencies->at(index);
797 qWarning("set freq to %s", freq); 797 qWarning("set freq to %s", freq);
798 798
799 int fd; 799 int fd;
800 800
801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 801 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
802 char writeCommand[50]; 802 char writeCommand[50];
803 const int count = sprintf(writeCommand, "%s\n", freq); 803 const int count = sprintf(writeCommand, "%s\n", freq);
804 int res = (::write(fd, writeCommand, count) != -1); 804 int res = (::write(fd, writeCommand, count) != -1);
805 ::close(fd); 805 ::close(fd);
806 return res; 806 return res;
807 } 807 }
808 808
809 return false; 809 return false;
810} 810}
811 811
812 812
813/** 813/**
814 * @return a list of hardware buttons 814 * @return a list of hardware buttons
815 */ 815 */
816const QValueList <ODeviceButton> &ODevice::buttons ( ) 816const QValueList <ODeviceButton> &ODevice::buttons ( )
817{ 817{
818 initButtons ( ); 818 initButtons ( );
819 819
820 return *d-> m_buttons; 820 return *d-> m_buttons;
821} 821}
822 822
823/** 823/**
824 * @return The amount of time that would count as a hold 824 * @return The amount of time that would count as a hold
825 */ 825 */
826uint ODevice::buttonHoldTime ( ) const 826uint ODevice::buttonHoldTime ( ) const
827{ 827{
828 return d-> m_holdtime; 828 return d-> m_holdtime;
829} 829}
830 830
831/** 831/**
832 * This method return a ODeviceButton for a key code 832 * This method return a ODeviceButton for a key code
833 * or 0 if no special hardware button is available for the device 833 * or 0 if no special hardware button is available for the device
834 * 834 *
835 * @return The devicebutton or 0l 835 * @return The devicebutton or 0l
836 * @see ODeviceButton 836 * @see ODeviceButton
837 */ 837 */
838const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 838const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
839{ 839{
840 initButtons ( ); 840 initButtons ( );
841 841
842 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 842 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
843 if ( (*it). keycode ( ) == code ) 843 if ( (*it). keycode ( ) == code )
844 return &(*it); 844 return &(*it);
845 } 845 }
846 return 0; 846 return 0;
847} 847}
848 848
849void ODevice::reloadButtonMapping ( ) 849void ODevice::reloadButtonMapping ( )
850{ 850{
851 initButtons ( ); 851 initButtons ( );
852 852
853 Config cfg ( "ButtonSettings" ); 853 Config cfg ( "ButtonSettings" );
854 854
855 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 855 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
856 ODeviceButton &b = ( *d-> m_buttons ) [i]; 856 ODeviceButton &b = ( *d-> m_buttons ) [i];
857 QString group = "Button" + QString::number ( i ); 857 QString group = "Button" + QString::number ( i );
858 858
859 QCString pch, hch; 859 QCString pch, hch;
860 QCString pm, hm; 860 QCString pm, hm;
861 QByteArray pdata, hdata; 861 QByteArray pdata, hdata;
862 862
863 if ( cfg. hasGroup ( group )) { 863 if ( cfg. hasGroup ( group )) {
864 cfg. setGroup ( group ); 864 cfg. setGroup ( group );
865 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 865 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
866 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 866 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
867 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 867 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
868 868
869 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 869 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
870 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 870 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
871 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 871 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
872 } 872 }
873 873
874 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 874 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
875 875
876 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 876 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
877 } 877 }
878} 878}
879 879
880void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 880void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
881{ 881{
882 initButtons ( ); 882 initButtons ( );
883 883
884 QString mb_chan; 884 QString mb_chan;
885 885
886 if ( button >= (int) d-> m_buttons-> count ( )) 886 if ( button >= (int) d-> m_buttons-> count ( ))
887 return; 887 return;
888 888
889 ODeviceButton &b = ( *d-> m_buttons ) [button]; 889 ODeviceButton &b = ( *d-> m_buttons ) [button];
890 b. setPressedAction ( action ); 890 b. setPressedAction ( action );
891 891
892 mb_chan=b. pressedAction ( ). channel ( ); 892 mb_chan=b. pressedAction ( ). channel ( );
893 893
894 Config buttonFile ( "ButtonSettings" ); 894 Config buttonFile ( "ButtonSettings" );
895 buttonFile. setGroup ( "Button" + QString::number ( button )); 895 buttonFile. setGroup ( "Button" + QString::number ( button ));
896 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 896 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
897 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 897 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
898 898
899 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 899 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
900 900
901 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 901 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
902} 902}
903 903
904void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 904void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
905{ 905{
906 initButtons ( ); 906 initButtons ( );
907 907
908 if ( button >= (int) d-> m_buttons-> count ( )) 908 if ( button >= (int) d-> m_buttons-> count ( ))
909 return; 909 return;
910 910
911 ODeviceButton &b = ( *d-> m_buttons ) [button]; 911 ODeviceButton &b = ( *d-> m_buttons ) [button];
912 b. setHeldAction ( action ); 912 b. setHeldAction ( action );
913 913
914 Config buttonFile ( "ButtonSettings" ); 914 Config buttonFile ( "ButtonSettings" );
915 buttonFile. setGroup ( "Button" + QString::number ( button )); 915 buttonFile. setGroup ( "Button" + QString::number ( button ));
916 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 916 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
917 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 917 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
918 918
919 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 919 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
920 920
921 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 921 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
922} 922}
923void ODevice::virtual_hook( int id, void* data ) {
923 924
925}
924 926
925 927
926 928
927/************************************************** 929/**************************************************
928 * 930 *
929 * iPAQ 931 * iPAQ
930 * 932 *
931 **************************************************/ 933 **************************************************/
932 934
933void iPAQ::init ( ) 935void iPAQ::init ( )
934{ 936{
935 d-> m_vendorstr = "HP"; 937 d-> m_vendorstr = "HP";
936 d-> m_vendor = Vendor_HP; 938 d-> m_vendor = Vendor_HP;
937 939
938 QFile f ( "/proc/hal/model" ); 940 QFile f ( "/proc/hal/model" );
939 941
940 if ( f. open ( IO_ReadOnly )) { 942 if ( f. open ( IO_ReadOnly )) {
941 QTextStream ts ( &f ); 943 QTextStream ts ( &f );
942 944
943 d-> m_modelstr = "H" + ts. readLine ( ); 945 d-> m_modelstr = "H" + ts. readLine ( );
944 946
945 if ( d-> m_modelstr == "H3100" ) 947 if ( d-> m_modelstr == "H3100" )
946 d-> m_model = Model_iPAQ_H31xx; 948 d-> m_model = Model_iPAQ_H31xx;
947 else if ( d-> m_modelstr == "H3600" ) 949 else if ( d-> m_modelstr == "H3600" )
948 d-> m_model = Model_iPAQ_H36xx; 950 d-> m_model = Model_iPAQ_H36xx;
949 else if ( d-> m_modelstr == "H3700" ) 951 else if ( d-> m_modelstr == "H3700" )
950 d-> m_model = Model_iPAQ_H37xx; 952 d-> m_model = Model_iPAQ_H37xx;
951 else if ( d-> m_modelstr == "H3800" ) 953 else if ( d-> m_modelstr == "H3800" )
952 d-> m_model = Model_iPAQ_H38xx; 954 d-> m_model = Model_iPAQ_H38xx;
953 else if ( d-> m_modelstr == "H3900" ) 955 else if ( d-> m_modelstr == "H3900" )
954 d-> m_model = Model_iPAQ_H39xx; 956 d-> m_model = Model_iPAQ_H39xx;
955 else 957 else
956 d-> m_model = Model_Unknown; 958 d-> m_model = Model_Unknown;
957 959
958 f. close ( ); 960 f. close ( );
959 } 961 }
960 962
961 switch ( d-> m_model ) { 963 switch ( d-> m_model ) {
962 case Model_iPAQ_H31xx: 964 case Model_iPAQ_H31xx:
963 case Model_iPAQ_H38xx: 965 case Model_iPAQ_H38xx:
964 d-> m_rotation = Rot90; 966 d-> m_rotation = Rot90;
965 break; 967 break;
966 case Model_iPAQ_H36xx: 968 case Model_iPAQ_H36xx:
967 case Model_iPAQ_H37xx: 969 case Model_iPAQ_H37xx:
968 case Model_iPAQ_H39xx: 970 case Model_iPAQ_H39xx:
969 default: 971 default:
970 d-> m_rotation = Rot270; 972 d-> m_rotation = Rot270;
971 break; 973 break;
972 } 974 }
973 975
974 f. setName ( "/etc/familiar-version" ); 976 f. setName ( "/etc/familiar-version" );
975 if ( f. open ( IO_ReadOnly )) { 977 if ( f. open ( IO_ReadOnly )) {
976 d-> m_systemstr = "Familiar"; 978 d-> m_systemstr = "Familiar";
977 d-> m_system = System_Familiar; 979 d-> m_system = System_Familiar;
978 980
979 QTextStream ts ( &f ); 981 QTextStream ts ( &f );
980 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 982 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
981 983
982 f. close ( ); 984 f. close ( );
983 } else { 985 } else {
984 f. setName ( "/etc/oz_version" ); 986 f. setName ( "/etc/oz_version" );
985 987
986 if ( f. open ( IO_ReadOnly )) { 988 if ( f. open ( IO_ReadOnly )) {
987 d-> m_systemstr = "OpenEmbedded/iPaq"; 989 d-> m_systemstr = "OpenEmbedded/iPaq";
988 d-> m_system = System_Familiar; 990 d-> m_system = System_Familiar;
989 991
990 QTextStream ts ( &f ); 992 QTextStream ts ( &f );
991 ts.setDevice ( &f ); 993 ts.setDevice ( &f );
992 d-> m_sysverstr = ts. readLine ( ); 994 d-> m_sysverstr = ts. readLine ( );
993 f. close ( ); 995 f. close ( );
994 } 996 }
995 } 997 }
996 998
997 999
998 1000
999 1001
1000 1002
1001 m_leds [0] = m_leds [1] = Led_Off; 1003 m_leds [0] = m_leds [1] = Led_Off;
1002 1004
1003 m_power_timer = 0; 1005 m_power_timer = 0;
1004 1006
1005} 1007}
1006 1008
1007void iPAQ::initButtons ( ) 1009void iPAQ::initButtons ( )
1008{ 1010{
1009 if ( d-> m_buttons ) 1011 if ( d-> m_buttons )
1010 return; 1012 return;
1011 1013
1012 if ( isQWS( ) ) 1014 if ( isQWS( ) )
1013 QWSServer::setKeyboardFilter ( this ); 1015 QWSServer::setKeyboardFilter ( this );
1014 1016
1015 d-> m_buttons = new QValueList <ODeviceButton>; 1017 d-> m_buttons = new QValueList <ODeviceButton>;
1016 1018
1017 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1019 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1018 i_button *ib = ipaq_buttons + i; 1020 i_button *ib = ipaq_buttons + i;
1019 ODeviceButton b; 1021 ODeviceButton b;
1020 1022
1021 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1023 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1022 b. setKeycode ( ib-> code ); 1024 b. setKeycode ( ib-> code );
1023 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1025 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1024 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1026 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1025 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1027 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1026 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1028 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1027 1029
1028 d-> m_buttons-> append ( b ); 1030 d-> m_buttons-> append ( b );
1029 } 1031 }
1030 } 1032 }
1031 reloadButtonMapping ( ); 1033 reloadButtonMapping ( );
1032 1034
1033 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1035 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1034 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1036 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1035} 1037}
1036 1038
1037 1039
1038//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1040//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1039 1041
1040typedef struct { 1042typedef struct {
1041 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1043 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1042 unsigned char TotalTime; /* Units of 5 seconds */ 1044 unsigned char TotalTime; /* Units of 5 seconds */
1043 unsigned char OnTime; /* units of 100m/s */ 1045 unsigned char OnTime; /* units of 100m/s */
1044 unsigned char OffTime; /* units of 100m/s */ 1046 unsigned char OffTime; /* units of 100m/s */
1045} LED_IN; 1047} LED_IN;
1046 1048
1047typedef struct { 1049typedef struct {
1048 unsigned char mode; 1050 unsigned char mode;
1049 unsigned char pwr; 1051 unsigned char pwr;
1050 unsigned char brightness; 1052 unsigned char brightness;
1051} FLITE_IN; 1053} FLITE_IN;
1052 1054
1053#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1055#define LED_ON OD_IOW( 'f', 5, LED_IN )
1054#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1056#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1055 1057
1056 1058
1057QValueList <OLed> iPAQ::ledList ( ) const 1059QValueList <OLed> iPAQ::ledList ( ) const
1058{ 1060{
1059 QValueList <OLed> vl; 1061 QValueList <OLed> vl;
1060 vl << Led_Power; 1062 vl << Led_Power;
1061 1063
1062 if ( d-> m_model == Model_iPAQ_H38xx ) 1064 if ( d-> m_model == Model_iPAQ_H38xx )
1063 vl << Led_BlueTooth; 1065 vl << Led_BlueTooth;
1064 return vl; 1066 return vl;
1065} 1067}
1066 1068
1067QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1069QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1068{ 1070{
1069 QValueList <OLedState> vl; 1071 QValueList <OLedState> vl;
1070 1072
1071 if ( l == Led_Power ) 1073 if ( l == Led_Power )
1072 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1074 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1073 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1075 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1074 vl << Led_Off; // << Led_On << ??? 1076 vl << Led_Off; // << Led_On << ???
1075 1077
1076 return vl; 1078 return vl;
1077} 1079}
1078 1080
1079OLedState iPAQ::ledState ( OLed l ) const 1081OLedState iPAQ::ledState ( OLed l ) const
1080{ 1082{
1081 switch ( l ) { 1083 switch ( l ) {
1082 case Led_Power: 1084 case Led_Power:
1083 return m_leds [0]; 1085 return m_leds [0];
1084 case Led_BlueTooth: 1086 case Led_BlueTooth:
1085 return m_leds [1]; 1087 return m_leds [1];
1086 default: 1088 default:
1087 return Led_Off; 1089 return Led_Off;
1088 } 1090 }
1089} 1091}
1090 1092
1091bool iPAQ::setLedState ( OLed l, OLedState st ) 1093bool iPAQ::setLedState ( OLed l, OLedState st )
1092{ 1094{
1093 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1095 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1094 1096
1095 if ( l == Led_Power ) { 1097 if ( l == Led_Power ) {
1096 if ( fd >= 0 ) { 1098 if ( fd >= 0 ) {
1097 LED_IN leds; 1099 LED_IN leds;
1098 ::memset ( &leds, 0, sizeof( leds )); 1100 ::memset ( &leds, 0, sizeof( leds ));
1099 leds. TotalTime = 0; 1101 leds. TotalTime = 0;
1100 leds. OnTime = 0; 1102 leds. OnTime = 0;
1101 leds. OffTime = 1; 1103 leds. OffTime = 1;
1102 leds. OffOnBlink = 2; 1104 leds. OffOnBlink = 2;
1103 1105
1104 switch ( st ) { 1106 switch ( st ) {
1105 case Led_Off : leds. OffOnBlink = 0; break; 1107 case Led_Off : leds. OffOnBlink = 0; break;
1106 case Led_On : leds. OffOnBlink = 1; break; 1108 case Led_On : leds. OffOnBlink = 1; break;
1107 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1109 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1108 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1110 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1109 } 1111 }
1110 1112
1111 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1113 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1112 m_leds [0] = st; 1114 m_leds [0] = st;
1113 return true; 1115 return true;
1114 } 1116 }
1115 } 1117 }
1116 } 1118 }
1117 return false; 1119 return false;
1118} 1120}
1119 1121
1120 1122
1121bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1123bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1122{ 1124{
1123 int newkeycode = keycode; 1125 int newkeycode = keycode;
1124 1126
1125 switch ( keycode ) { 1127 switch ( keycode ) {
1126 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1128 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1127 case HardKey_Menu: { 1129 case HardKey_Menu: {
1128 if (( d-> m_model == Model_iPAQ_H38xx ) || 1130 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1129 ( d-> m_model == Model_iPAQ_H39xx )) { 1131 ( d-> m_model == Model_iPAQ_H39xx )) {
1130 newkeycode = HardKey_Mail; 1132 newkeycode = HardKey_Mail;
1131 } 1133 }
1132 break; 1134 break;
1133 } 1135 }
1134 1136
1135 // Rotate cursor keys 180° 1137 // Rotate cursor keys 180°
1136 case Key_Left : 1138 case Key_Left :
1137 case Key_Right: 1139 case Key_Right:
1138 case Key_Up : 1140 case Key_Up :
1139 case Key_Down : { 1141 case Key_Down : {
1140 if (( d-> m_model == Model_iPAQ_H31xx ) || 1142 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1141 ( d-> m_model == Model_iPAQ_H38xx )) { 1143 ( d-> m_model == Model_iPAQ_H38xx )) {
1142 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1144 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1143 } 1145 }
1144 break; 1146 break;
1145 } 1147 }
1146 1148
1147 // map Power Button short/long press to F34/F35 1149 // map Power Button short/long press to F34/F35
1148 case Key_SysReq: { 1150 case Key_SysReq: {
1149 if ( isPress ) { 1151 if ( isPress ) {
1150 if ( m_power_timer ) 1152 if ( m_power_timer )
1151 killTimer ( m_power_timer ); 1153 killTimer ( m_power_timer );
1152 m_power_timer = startTimer ( 500 ); 1154 m_power_timer = startTimer ( 500 );
1153 } 1155 }
1154 else if ( m_power_timer ) { 1156 else if ( m_power_timer ) {
1155 killTimer ( m_power_timer ); 1157 killTimer ( m_power_timer );
1156 m_power_timer = 0; 1158 m_power_timer = 0;
1157 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1159 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1158 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1160 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1159 } 1161 }
1160 newkeycode = Key_unknown; 1162 newkeycode = Key_unknown;
1161 break; 1163 break;
1162 } 1164 }
1163 } 1165 }
1164 1166
1165 if ( newkeycode != keycode ) { 1167 if ( newkeycode != keycode ) {
1166 if ( newkeycode != Key_unknown ) 1168 if ( newkeycode != Key_unknown )
1167 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1169 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1168 return true; 1170 return true;
1169 } 1171 }
1170 else 1172 else
1171 return false; 1173 return false;
1172} 1174}
1173 1175
1174void iPAQ::timerEvent ( QTimerEvent * ) 1176void iPAQ::timerEvent ( QTimerEvent * )
1175{ 1177{
1176 killTimer ( m_power_timer ); 1178 killTimer ( m_power_timer );
1177 m_power_timer = 0; 1179 m_power_timer = 0;
1178 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1180 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1179 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1181 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1180} 1182}
1181 1183
1182 1184
1183void iPAQ::alarmSound ( ) 1185void iPAQ::alarmSound ( )
1184{ 1186{
1185#ifndef QT_NO_SOUND 1187#ifndef QT_NO_SOUND
1186 static Sound snd ( "alarm" ); 1188 static Sound snd ( "alarm" );
1187 int fd; 1189 int fd;
1188 int vol; 1190 int vol;
1189 bool vol_reset = false; 1191 bool vol_reset = false;
1190 1192
1191 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1193 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1192 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1194 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1193 Config cfg ( "qpe" ); 1195 Config cfg ( "qpe" );
1194 cfg. setGroup ( "Volume" ); 1196 cfg. setGroup ( "Volume" );
1195 1197
1196 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1198 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1197 if ( volalarm < 0 ) 1199 if ( volalarm < 0 )
1198 volalarm = 0; 1200 volalarm = 0;
1199 else if ( volalarm > 100 ) 1201 else if ( volalarm > 100 )
1200 volalarm = 100; 1202 volalarm = 100;
1201 volalarm |= ( volalarm << 8 ); 1203 volalarm |= ( volalarm << 8 );
1202 1204
1203 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1205 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1204 vol_reset = true; 1206 vol_reset = true;
1205 } 1207 }
1206 } 1208 }
1207 1209
1208 snd. play ( ); 1210 snd. play ( );
1209 while ( !snd. isFinished ( )) 1211 while ( !snd. isFinished ( ))
1210 qApp-> processEvents ( ); 1212 qApp-> processEvents ( );
1211 1213
1212 if ( fd >= 0 ) { 1214 if ( fd >= 0 ) {
1213 if ( vol_reset ) 1215 if ( vol_reset )
1214 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1216 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1215 ::close ( fd ); 1217 ::close ( fd );
1216 } 1218 }
1217#endif 1219#endif
1218} 1220}
1219 1221
1220 1222
1221bool iPAQ::setSoftSuspend ( bool soft ) 1223bool iPAQ::setSoftSuspend ( bool soft )
1222{ 1224{
1223 bool res = false; 1225 bool res = false;
1224 int fd; 1226 int fd;
1225 1227
1226 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1228 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1227 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1229 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1228 res = true; 1230 res = true;
1229 else 1231 else
1230 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1232 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1231 1233
1232 ::close ( fd ); 1234 ::close ( fd );
1233 } 1235 }
1234 else 1236 else
1235 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1237 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1236 1238
1237 return res; 1239 return res;
1238} 1240}
1239 1241
1240 1242
1241bool iPAQ::setDisplayBrightness ( int bright ) 1243bool iPAQ::setDisplayBrightness ( int bright )
1242{ 1244{
1243 bool res = false; 1245 bool res = false;
1244 int fd; 1246 int fd;
1245 1247
1246 if ( bright > 255 ) 1248 if ( bright > 255 )
1247 bright = 255; 1249 bright = 255;
1248 if ( bright < 0 ) 1250 if ( bright < 0 )
1249 bright = 0; 1251 bright = 0;
1250 1252
1251 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1253 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1252 FLITE_IN bl; 1254 FLITE_IN bl;
1253 bl. mode = 1; 1255 bl. mode = 1;
1254 bl. pwr = bright ? 1 : 0; 1256 bl. pwr = bright ? 1 : 0;
1255 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1257 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1256 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1258 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1257 ::close ( fd ); 1259 ::close ( fd );
1258 } 1260 }
1259 return res; 1261 return res;
1260} 1262}
1261 1263
1262int iPAQ::displayBrightnessResolution ( ) const 1264int iPAQ::displayBrightnessResolution ( ) const
1263{ 1265{
1264 switch ( model ( )) { 1266 switch ( model ( )) {
1265 case Model_iPAQ_H31xx: 1267 case Model_iPAQ_H31xx:
1266 case Model_iPAQ_H36xx: 1268 case Model_iPAQ_H36xx:
1267 case Model_iPAQ_H37xx: 1269 case Model_iPAQ_H37xx:
1268 return 128; // really 256, but >128 could damage the LCD 1270 return 128; // really 256, but >128 could damage the LCD
1269 1271
1270 case Model_iPAQ_H38xx: 1272 case Model_iPAQ_H38xx:
1271 case Model_iPAQ_H39xx: 1273 case Model_iPAQ_H39xx:
1272 return 64; 1274 return 64;
1273 1275
1274 default: 1276 default:
1275 return 2; 1277 return 2;
1276 } 1278 }
1277} 1279}
1278 1280
1279 1281
1280bool iPAQ::hasLightSensor ( ) const 1282bool iPAQ::hasLightSensor ( ) const
1281{ 1283{
1282 return true; 1284 return true;
1283} 1285}
1284 1286
1285int iPAQ::readLightSensor ( ) 1287int iPAQ::readLightSensor ( )
1286{ 1288{
1287 int fd; 1289 int fd;
1288 int val = -1; 1290 int val = -1;
1289 1291
1290 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1292 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1291 char buffer [8]; 1293 char buffer [8];
1292 1294
1293 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1295 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1294 char *endptr; 1296 char *endptr;
1295 1297
1296 buffer [4] = 0; 1298 buffer [4] = 0;
1297 val = ::strtol ( buffer + 2, &endptr, 16 ); 1299 val = ::strtol ( buffer + 2, &endptr, 16 );
1298 1300
1299 if ( *endptr != 0 ) 1301 if ( *endptr != 0 )
1300 val = -1; 1302 val = -1;
1301 } 1303 }
1302 ::close ( fd ); 1304 ::close ( fd );
1303 } 1305 }
1304 1306
1305 return val; 1307 return val;
1306} 1308}
1307 1309
diff --git a/libopie/odevice.h b/libopie/odevice.h
index f2f6467..a232d69 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,248 +1,250 @@
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 <qobject.h> 23#include <qobject.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qnamespace.h> 25#include <qnamespace.h>
26#include <qstrlist.h> 26#include <qstrlist.h>
27 27
28#include <opie/odevicebutton.h> 28#include <opie/odevicebutton.h>
29 29
30#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 30#include <qpe/qpeapplication.h> /* for Transformation enum.. */
31 31
32class ODeviceData; 32class ODeviceData;
33 33
34namespace Opie { 34namespace Opie {
35 35
36/** 36/**
37 * The available devices 37 * The available devices
38 */ 38 */
39enum OModel { 39enum OModel {
40 Model_Unknown, // = 0 40 Model_Unknown, // = 0
41 41
42 Model_Series_Mask = 0xff000000, 42 Model_Series_Mask = 0xff000000,
43 43
44 Model_iPAQ = ( 1 << 24 ), 44 Model_iPAQ = ( 1 << 24 ),
45 45
46 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 46 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
47 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 47 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
48 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 48 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
49 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 49 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
50 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 50 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
51 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 51 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
52 52
53 Model_Zaurus = ( 2 << 24 ), 53 Model_Zaurus = ( 2 << 24 ),
54 54
55 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 55 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
56 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 56 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
57 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 57 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
58 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 58 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
59 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ), 59 Model_Zaurus_SLC700 = ( Model_Zaurus | 0x000005 ),
60 60
61 Model_SIMpad = ( 3 << 24 ), 61 Model_SIMpad = ( 3 << 24 ),
62 62
63 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 63 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
64 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 64 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
65 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 65 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
66 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 66 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
67 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 67 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
68 68
69 Model_Ramses = ( 4 << 24 ), 69 Model_Ramses = ( 4 << 24 ),
70 70
71 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 71 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
72 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 72 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
73}; 73};
74 74
75/** 75/**
76 * The vendor of the device 76 * The vendor of the device
77 */ 77 */
78enum OVendor { 78enum OVendor {
79 Vendor_Unknown, 79 Vendor_Unknown,
80 80
81 Vendor_HP, 81 Vendor_HP,
82 Vendor_Sharp, 82 Vendor_Sharp,
83 Vendor_SIEMENS, 83 Vendor_SIEMENS,
84 Vendor_MundN, 84 Vendor_MundN,
85}; 85};
86 86
87/** 87/**
88 * The System used 88 * The System used
89 */ 89 */
90enum OSystem { 90enum OSystem {
91 System_Unknown, 91 System_Unknown,
92 92
93 System_Familiar, 93 System_Familiar,
94 System_Zaurus, 94 System_Zaurus,
95 System_OpenZaurus 95 System_OpenZaurus
96}; 96};
97 97
98enum OLedState { 98enum OLedState {
99 Led_Off, 99 Led_Off,
100 Led_On, 100 Led_On,
101 Led_BlinkSlow, 101 Led_BlinkSlow,
102 Led_BlinkFast 102 Led_BlinkFast
103}; 103};
104 104
105enum OLed { 105enum OLed {
106 Led_Mail, 106 Led_Mail,
107 Led_Power, 107 Led_Power,
108 Led_BlueTooth 108 Led_BlueTooth
109}; 109};
110 110
111enum OHardKey { 111enum OHardKey {
112 HardKey_Datebook = Qt::Key_F9, 112 HardKey_Datebook = Qt::Key_F9,
113 HardKey_Contacts = Qt::Key_F10, 113 HardKey_Contacts = Qt::Key_F10,
114 HardKey_Menu = Qt::Key_F11, 114 HardKey_Menu = Qt::Key_F11,
115 HardKey_Home = Qt::Key_F12, 115 HardKey_Home = Qt::Key_F12,
116 HardKey_Mail = Qt::Key_F13, 116 HardKey_Mail = Qt::Key_F13,
117 HardKey_Record = Qt::Key_F24, 117 HardKey_Record = Qt::Key_F24,
118 HardKey_Suspend = Qt::Key_F34, 118 HardKey_Suspend = Qt::Key_F34,
119 HardKey_Backlight = Qt::Key_F35, 119 HardKey_Backlight = Qt::Key_F35,
120}; 120};
121 121
122enum ODirection { 122enum ODirection {
123 CW = 0, 123 CW = 0,
124 CCW = 1, 124 CCW = 1,
125 Flip = 2, 125 Flip = 2,
126}; 126};
127 127
128/** 128/**
129 * A singleton which gives informations about device specefic option 129 * A singleton which gives informations about device specefic option
130 * like the Hardware used, LEDs, the Base Distribution and 130 * like the Hardware used, LEDs, the Base Distribution and
131 * hardware key mappings. 131 * hardware key mappings.
132 * 132 *
133 * @short A small class for device specefic options 133 * @short A small class for device specefic options
134 * @see QObject 134 * @see QObject
135 * @author Robert Griebl 135 * @author Robert Griebl
136 * @version 1.0 136 * @version 1.0
137 */ 137 */
138class ODevice : public QObject { 138class ODevice : public QObject {
139 Q_OBJECT 139 Q_OBJECT
140 140
141private: 141private:
142 /* disable copy */ 142 /* disable copy */
143 ODevice ( const ODevice & ); 143 ODevice ( const ODevice & );
144 144
145protected: 145protected:
146 ODevice ( ); 146 ODevice ( );
147 virtual void init ( ); 147 virtual void init ( );
148 virtual void initButtons ( ); 148 virtual void initButtons ( );
149 149
150 ODeviceData *d; 150 ODeviceData *d;
151 151
152public: 152public:
153 // sandman do we want to allow destructions? -zecke? 153 // sandman do we want to allow destructions? -zecke?
154 virtual ~ODevice ( ); 154 virtual ~ODevice ( );
155 155
156 static ODevice *inst ( ); 156 static ODevice *inst ( );
157 157
158 // information 158 // information
159 159
160 QString modelString ( ) const; 160 QString modelString ( ) const;
161 OModel model ( ) const; 161 OModel model ( ) const;
162 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 162 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
163 163
164 QString vendorString ( ) const; 164 QString vendorString ( ) const;
165 OVendor vendor ( ) const; 165 OVendor vendor ( ) const;
166 166
167 QString systemString ( ) const; 167 QString systemString ( ) const;
168 OSystem system ( ) const; 168 OSystem system ( ) const;
169 169
170 QString systemVersionString ( ) const; 170 QString systemVersionString ( ) const;
171 171
172 Transformation rotation ( ) const; 172 Transformation rotation ( ) const;
173 ODirection direction ( ) const; 173 ODirection direction ( ) const;
174 174
175// system 175// system
176 176
177 virtual bool setSoftSuspend ( bool on ); 177 virtual bool setSoftSuspend ( bool on );
178 virtual bool suspend ( ); 178 virtual bool suspend ( );
179 179
180 virtual bool setDisplayStatus ( bool on ); 180 virtual bool setDisplayStatus ( bool on );
181 virtual bool setDisplayBrightness ( int brightness ); 181 virtual bool setDisplayBrightness ( int brightness );
182 virtual int displayBrightnessResolution ( ) const; 182 virtual int displayBrightnessResolution ( ) const;
183 virtual bool setDisplayContrast ( int contrast ); 183 virtual bool setDisplayContrast ( int contrast );
184 virtual int displayContrastResolution ( ) const; 184 virtual int displayContrastResolution ( ) const;
185 185
186// input / output 186// input / output
187 //FIXME playAlarmSound and al might be better -zecke 187 //FIXME playAlarmSound and al might be better -zecke
188 virtual void alarmSound ( ); 188 virtual void alarmSound ( );
189 virtual void keySound ( ); 189 virtual void keySound ( );
190 virtual void touchSound ( ); 190 virtual void touchSound ( );
191 191
192 virtual QValueList <OLed> ledList ( ) const; 192 virtual QValueList <OLed> ledList ( ) const;
193 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 193 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
194 virtual OLedState ledState ( OLed led ) const; 194 virtual OLedState ledState ( OLed led ) const;
195 virtual bool setLedState ( OLed led, OLedState st ); 195 virtual bool setLedState ( OLed led, OLedState st );
196 196
197 virtual bool hasLightSensor ( ) const; 197 virtual bool hasLightSensor ( ) const;
198 virtual int readLightSensor ( ); 198 virtual int readLightSensor ( );
199 virtual int lightSensorResolution ( ) const; 199 virtual int lightSensorResolution ( ) const;
200 200
201 const QStrList &allowedCpuFrequencies() const; 201 const QStrList &allowedCpuFrequencies() const;
202 bool setCurrentCpuFrequency(uint index); 202 bool setCurrentCpuFrequency(uint index);
203 203
204 /** 204 /**
205 * Returns the available buttons on this device. The number and location 205 * Returns the available buttons on this device. The number and location
206 * of buttons will vary depending on the device. Button numbers will be assigned 206 * of buttons will vary depending on the device. Button numbers will be assigned
207 * by the device manufacturer and will be from most preferred button to least preffered 207 * by the device manufacturer and will be from most preferred button to least preffered
208 * button. Note that this list only contains "user mappable" buttons. 208 * button. Note that this list only contains "user mappable" buttons.
209 */ 209 */
210 const QValueList<ODeviceButton> &buttons ( ); 210 const QValueList<ODeviceButton> &buttons ( );
211 211
212 /** 212 /**
213 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 213 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
214 * returns 0L 214 * returns 0L
215 */ 215 */
216 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 216 const ODeviceButton *buttonForKeycode ( ushort keyCode );
217 217
218 /** 218 /**
219 * Reassigns the pressed action for \a button. To return to the factory 219 * Reassigns the pressed action for \a button. To return to the factory
220 * default pass an empty string as \a qcopMessage. 220 * default pass an empty string as \a qcopMessage.
221 */ 221 */
222 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 222 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
223 223
224 /** 224 /**
225 * Reassigns the held action for \a button. To return to the factory 225 * Reassigns the held action for \a button. To return to the factory
226 * default pass an empty string as \a qcopMessage. 226 * default pass an empty string as \a qcopMessage.
227 */ 227 */
228 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 228 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
229 229
230 /** 230 /**
231 * How long (in ms) you have to press a button for a "hold" action 231 * How long (in ms) you have to press a button for a "hold" action
232 */ 232 */
233 uint buttonHoldTime ( ) const; 233 uint buttonHoldTime ( ) const;
234 234
235signals: 235signals:
236 void buttonMappingChanged ( ); 236 void buttonMappingChanged ( );
237 237
238private slots: 238private slots:
239 void systemMessage ( const QCString &, const QByteArray & ); 239 void systemMessage ( const QCString &, const QByteArray & );
240 240
241protected: 241protected:
242 void reloadButtonMapping ( ); 242 void reloadButtonMapping ( );
243 /* ugly virtual hook */
244 virtual void virtual_hook( int id, void* data );
243}; 245};
244 246
245} 247}
246 248
247#endif 249#endif
248 250