summaryrefslogtreecommitdiff
path: root/libopie
authorzecke <zecke>2004-02-19 01:01:30 (UTC)
committer zecke <zecke>2004-02-19 01:01:30 (UTC)
commit3b4b9e070f84ce884a98b4112eaee2cef7530308 (patch) (unidiff)
treea63b57ec3368e41ea1482a37a41b4b9df2f30fd4 /libopie
parentab41e301eb7f06af0869844d197e38a7838f3f2d (diff)
downloadopie-3b4b9e070f84ce884a98b4112eaee2cef7530308.zip
opie-3b4b9e070f84ce884a98b4112eaee2cef7530308.tar.gz
opie-3b4b9e070f84ce884a98b4112eaee2cef7530308.tar.bz2
The hardware keys on the H5xxx are rotated by 270°
so rotate the key events
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 35d6cb4..c5a916b 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -565,1545 +565,1552 @@ bool ODevice::setSoftSuspend ( bool /*soft*/ )
565bool ODevice::suspend ( ) 565bool ODevice::suspend ( )
566{ 566{
567 qDebug("ODevice::suspend"); 567 qDebug("ODevice::suspend");
568 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 568 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
569 return false; 569 return false;
570 570
571 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 571 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
572 return false; 572 return false;
573 573
574 bool res = false; 574 bool res = false;
575 575
576 struct timeval tvs, tvn; 576 struct timeval tvs, tvn;
577 ::gettimeofday ( &tvs, 0 ); 577 ::gettimeofday ( &tvs, 0 );
578 578
579 ::sync ( ); // flush fs caches 579 ::sync ( ); // flush fs caches
580 res = ( ::system ( "apm --suspend" ) == 0 ); 580 res = ( ::system ( "apm --suspend" ) == 0 );
581 581
582 // This is needed because the iPAQ apm implementation is asynchronous and we 582 // This is needed because the iPAQ apm implementation is asynchronous and we
583 // can not be sure when exactly the device is really suspended 583 // can not be sure when exactly the device is really suspended
584 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 584 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
585 585
586 if ( res ) { 586 if ( res ) {
587 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 587 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
588 ::usleep ( 200 * 1000 ); 588 ::usleep ( 200 * 1000 );
589 ::gettimeofday ( &tvn, 0 ); 589 ::gettimeofday ( &tvn, 0 );
590 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 590 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
591 } 591 }
592 592
593 return res; 593 return res;
594} 594}
595 595
596//#include <linux/fb.h> better not rely on kernel headers in userspace ... 596//#include <linux/fb.h> better not rely on kernel headers in userspace ...
597 597
598#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 598#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
599 599
600/* VESA Blanking Levels */ 600/* VESA Blanking Levels */
601#define VESA_NO_BLANKING 0 601#define VESA_NO_BLANKING 0
602#define VESA_VSYNC_SUSPEND 1 602#define VESA_VSYNC_SUSPEND 1
603#define VESA_HSYNC_SUSPEND 2 603#define VESA_HSYNC_SUSPEND 2
604#define VESA_POWERDOWN 3 604#define VESA_POWERDOWN 3
605 605
606/** 606/**
607 * This sets the display on or off 607 * This sets the display on or off
608 */ 608 */
609bool ODevice::setDisplayStatus ( bool on ) 609bool ODevice::setDisplayStatus ( bool on )
610{ 610{
611 qDebug("ODevice::setDisplayStatus(%d)", on); 611 qDebug("ODevice::setDisplayStatus(%d)", on);
612 612
613 if ( d-> m_model == Model_Unknown ) 613 if ( d-> m_model == Model_Unknown )
614 return false; 614 return false;
615 615
616 bool res = false; 616 bool res = false;
617 int fd; 617 int fd;
618 618
619 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 619 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
620 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 620 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
621 ::close ( fd ); 621 ::close ( fd );
622 } 622 }
623 return res; 623 return res;
624} 624}
625 625
626/** 626/**
627 * This sets the display brightness 627 * This sets the display brightness
628 * 628 *
629 * @param p The brightness to be set on a scale from 0 to 255 629 * @param p The brightness to be set on a scale from 0 to 255
630 * @return success or failure 630 * @return success or failure
631 */ 631 */
632bool ODevice::setDisplayBrightness ( int p) 632bool ODevice::setDisplayBrightness ( int p)
633{ 633{
634 Q_UNUSED( p ) 634 Q_UNUSED( p )
635 return false; 635 return false;
636} 636}
637 637
638/** 638/**
639 * @return returns the number of steppings on the brightness slider 639 * @return returns the number of steppings on the brightness slider
640 * in the Light-'n-Power settings. 640 * in the Light-'n-Power settings.
641 */ 641 */
642int ODevice::displayBrightnessResolution ( ) const 642int ODevice::displayBrightnessResolution ( ) const
643{ 643{
644 return 16; 644 return 16;
645} 645}
646 646
647/** 647/**
648 * This sets the display contrast 648 * This sets the display contrast
649 * @param p The contrast to be set on a scale from 0 to 255 649 * @param p The contrast to be set on a scale from 0 to 255
650 * @return success or failure 650 * @return success or failure
651 */ 651 */
652bool ODevice::setDisplayContrast ( int p) 652bool ODevice::setDisplayContrast ( int p)
653{ 653{
654 Q_UNUSED( p ) 654 Q_UNUSED( p )
655 return false; 655 return false;
656} 656}
657 657
658/** 658/**
659 * @return return the max value for the brightness settings slider 659 * @return return the max value for the brightness settings slider
660 * or 0 if the device doesn't support setting of a contrast 660 * or 0 if the device doesn't support setting of a contrast
661 */ 661 */
662int ODevice::displayContrastResolution ( ) const 662int ODevice::displayContrastResolution ( ) const
663{ 663{
664 return 0; 664 return 0;
665} 665}
666 666
667/** 667/**
668 * This returns the vendor as string 668 * This returns the vendor as string
669 * @return Vendor as QString 669 * @return Vendor as QString
670 */ 670 */
671QString ODevice::vendorString ( ) const 671QString ODevice::vendorString ( ) const
672{ 672{
673 return d-> m_vendorstr; 673 return d-> m_vendorstr;
674} 674}
675 675
676/** 676/**
677 * This returns the vendor as one of the values of OVendor 677 * This returns the vendor as one of the values of OVendor
678 * @return OVendor 678 * @return OVendor
679 */ 679 */
680OVendor ODevice::vendor ( ) const 680OVendor ODevice::vendor ( ) const
681{ 681{
682 return d-> m_vendor; 682 return d-> m_vendor;
683} 683}
684 684
685/** 685/**
686 * This returns the model as a string 686 * This returns the model as a string
687 * @return A string representing the model 687 * @return A string representing the model
688 */ 688 */
689QString ODevice::modelString ( ) const 689QString ODevice::modelString ( ) const
690{ 690{
691 return d-> m_modelstr; 691 return d-> m_modelstr;
692} 692}
693 693
694/** 694/**
695 * This does return the OModel used 695 * This does return the OModel used
696 */ 696 */
697OModel ODevice::model ( ) const 697OModel ODevice::model ( ) const
698{ 698{
699 return d-> m_model; 699 return d-> m_model;
700} 700}
701 701
702/** 702/**
703 * This does return the systen name 703 * This does return the systen name
704 */ 704 */
705QString ODevice::systemString ( ) const 705QString ODevice::systemString ( ) const
706{ 706{
707 return d-> m_systemstr; 707 return d-> m_systemstr;
708} 708}
709 709
710/** 710/**
711 * Return System as OSystem value 711 * Return System as OSystem value
712 */ 712 */
713OSystem ODevice::system ( ) const 713OSystem ODevice::system ( ) const
714{ 714{
715 return d-> m_system; 715 return d-> m_system;
716} 716}
717 717
718/** 718/**
719 * @return the version string of the base system 719 * @return the version string of the base system
720 */ 720 */
721QString ODevice::systemVersionString ( ) const 721QString ODevice::systemVersionString ( ) const
722{ 722{
723 return d-> m_sysverstr; 723 return d-> m_sysverstr;
724} 724}
725 725
726/** 726/**
727 * @return the current Transformation 727 * @return the current Transformation
728 */ 728 */
729Transformation ODevice::rotation ( ) const 729Transformation ODevice::rotation ( ) const
730{ 730{
731 return d-> m_rotation; 731 return d-> m_rotation;
732} 732}
733 733
734/** 734/**
735 * @return the current rotation direction 735 * @return the current rotation direction
736 */ 736 */
737ODirection ODevice::direction ( ) const 737ODirection ODevice::direction ( ) const
738{ 738{
739 return d-> m_direction; 739 return d-> m_direction;
740} 740}
741 741
742/** 742/**
743 * This plays an alarmSound 743 * This plays an alarmSound
744 */ 744 */
745void ODevice::alarmSound ( ) 745void ODevice::alarmSound ( )
746{ 746{
747#ifndef QT_NO_SOUND 747#ifndef QT_NO_SOUND
748 static Sound snd ( "alarm" ); 748 static Sound snd ( "alarm" );
749 749
750 if ( snd. isFinished ( )) 750 if ( snd. isFinished ( ))
751 snd. play ( ); 751 snd. play ( );
752#endif 752#endif
753} 753}
754 754
755/** 755/**
756 * This plays a key sound 756 * This plays a key sound
757 */ 757 */
758void ODevice::keySound ( ) 758void ODevice::keySound ( )
759{ 759{
760#ifndef QT_NO_SOUND 760#ifndef QT_NO_SOUND
761 static Sound snd ( "keysound" ); 761 static Sound snd ( "keysound" );
762 762
763 if ( snd. isFinished ( )) 763 if ( snd. isFinished ( ))
764 snd. play ( ); 764 snd. play ( );
765#endif 765#endif
766} 766}
767 767
768/** 768/**
769 * This plays a touch sound 769 * This plays a touch sound
770 */ 770 */
771void ODevice::touchSound ( ) 771void ODevice::touchSound ( )
772{ 772{
773#ifndef QT_NO_SOUND 773#ifndef QT_NO_SOUND
774 static Sound snd ( "touchsound" ); 774 static Sound snd ( "touchsound" );
775 775
776 if ( snd. isFinished ( )) 776 if ( snd. isFinished ( ))
777 snd. play ( ); 777 snd. play ( );
778#endif 778#endif
779} 779}
780 780
781/** 781/**
782 * This method will return a list of leds 782 * This method will return a list of leds
783 * available on this device 783 * available on this device
784 * @return a list of LEDs. 784 * @return a list of LEDs.
785 */ 785 */
786QValueList <OLed> ODevice::ledList ( ) const 786QValueList <OLed> ODevice::ledList ( ) const
787{ 787{
788 return QValueList <OLed> ( ); 788 return QValueList <OLed> ( );
789} 789}
790 790
791/** 791/**
792 * This does return the state of the LEDs 792 * This does return the state of the LEDs
793 */ 793 */
794QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 794QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
795{ 795{
796 return QValueList <OLedState> ( ); 796 return QValueList <OLedState> ( );
797} 797}
798 798
799/** 799/**
800 * @return the state for a given OLed 800 * @return the state for a given OLed
801 */ 801 */
802OLedState ODevice::ledState ( OLed /*which*/ ) const 802OLedState ODevice::ledState ( OLed /*which*/ ) const
803{ 803{
804 return Led_Off; 804 return Led_Off;
805} 805}
806 806
807/** 807/**
808 * Set the state for a LED 808 * Set the state for a LED
809 * @param which Which OLed to use 809 * @param which Which OLed to use
810 * @param st The state to set 810 * @param st The state to set
811 * @return success or failure 811 * @return success or failure
812 */ 812 */
813bool ODevice::setLedState ( OLed which, OLedState st ) 813bool ODevice::setLedState ( OLed which, OLedState st )
814{ 814{
815 Q_UNUSED( which ) 815 Q_UNUSED( which )
816 Q_UNUSED( st ) 816 Q_UNUSED( st )
817 return false; 817 return false;
818} 818}
819 819
820/** 820/**
821 * @return if the device has a light sensor 821 * @return if the device has a light sensor
822 */ 822 */
823bool ODevice::hasLightSensor ( ) const 823bool ODevice::hasLightSensor ( ) const
824{ 824{
825 return false; 825 return false;
826} 826}
827 827
828/** 828/**
829 * @return a value from the light sensor 829 * @return a value from the light sensor
830 */ 830 */
831int ODevice::readLightSensor ( ) 831int ODevice::readLightSensor ( )
832{ 832{
833 return -1; 833 return -1;
834} 834}
835 835
836/** 836/**
837 * @return the light sensor resolution 837 * @return the light sensor resolution
838 */ 838 */
839int ODevice::lightSensorResolution ( ) const 839int ODevice::lightSensorResolution ( ) const
840{ 840{
841 return 0; 841 return 0;
842} 842}
843 843
844/** 844/**
845 * @return if the device has a hinge sensor 845 * @return if the device has a hinge sensor
846 */ 846 */
847bool ODevice::hasHingeSensor ( ) const 847bool ODevice::hasHingeSensor ( ) const
848{ 848{
849 return false; 849 return false;
850} 850}
851 851
852/** 852/**
853 * @return a value from the hinge sensor 853 * @return a value from the hinge sensor
854 */ 854 */
855OHingeStatus ODevice::readHingeSensor ( ) 855OHingeStatus ODevice::readHingeSensor ( )
856{ 856{
857 return CASE_UNKNOWN; 857 return CASE_UNKNOWN;
858} 858}
859 859
860/** 860/**
861 * @return a list with CPU frequencies supported by the hardware 861 * @return a list with CPU frequencies supported by the hardware
862 */ 862 */
863const QStrList &ODevice::allowedCpuFrequencies ( ) const 863const QStrList &ODevice::allowedCpuFrequencies ( ) const
864{ 864{
865 return *d->m_cpu_frequencies; 865 return *d->m_cpu_frequencies;
866} 866}
867 867
868 868
869/** 869/**
870 * Set desired CPU frequency 870 * Set desired CPU frequency
871 * 871 *
872 * @param index index into d->m_cpu_frequencies of the frequency to be set 872 * @param index index into d->m_cpu_frequencies of the frequency to be set
873 */ 873 */
874bool ODevice::setCurrentCpuFrequency(uint index) 874bool ODevice::setCurrentCpuFrequency(uint index)
875{ 875{
876 if (index >= d->m_cpu_frequencies->count()) 876 if (index >= d->m_cpu_frequencies->count())
877 return false; 877 return false;
878 878
879 char *freq = d->m_cpu_frequencies->at(index); 879 char *freq = d->m_cpu_frequencies->at(index);
880 qWarning("set freq to %s", freq); 880 qWarning("set freq to %s", freq);
881 881
882 int fd; 882 int fd;
883 883
884 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 884 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
885 char writeCommand[50]; 885 char writeCommand[50];
886 const int count = sprintf(writeCommand, "%s\n", freq); 886 const int count = sprintf(writeCommand, "%s\n", freq);
887 int res = (::write(fd, writeCommand, count) != -1); 887 int res = (::write(fd, writeCommand, count) != -1);
888 ::close(fd); 888 ::close(fd);
889 return res; 889 return res;
890 } 890 }
891 891
892 return false; 892 return false;
893} 893}
894 894
895 895
896/** 896/**
897 * @return a list of hardware buttons 897 * @return a list of hardware buttons
898 */ 898 */
899const QValueList <ODeviceButton> &ODevice::buttons ( ) 899const QValueList <ODeviceButton> &ODevice::buttons ( )
900{ 900{
901 initButtons ( ); 901 initButtons ( );
902 902
903 return *d-> m_buttons; 903 return *d-> m_buttons;
904} 904}
905 905
906/** 906/**
907 * @return The amount of time that would count as a hold 907 * @return The amount of time that would count as a hold
908 */ 908 */
909uint ODevice::buttonHoldTime ( ) const 909uint ODevice::buttonHoldTime ( ) const
910{ 910{
911 return d-> m_holdtime; 911 return d-> m_holdtime;
912} 912}
913 913
914/** 914/**
915 * This method return a ODeviceButton for a key code 915 * This method return a ODeviceButton for a key code
916 * or 0 if no special hardware button is available for the device 916 * or 0 if no special hardware button is available for the device
917 * 917 *
918 * @return The devicebutton or 0l 918 * @return The devicebutton or 0l
919 * @see ODeviceButton 919 * @see ODeviceButton
920 */ 920 */
921const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 921const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
922{ 922{
923 initButtons ( ); 923 initButtons ( );
924 924
925 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 925 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
926 if ( (*it). keycode ( ) == code ) 926 if ( (*it). keycode ( ) == code )
927 return &(*it); 927 return &(*it);
928 } 928 }
929 return 0; 929 return 0;
930} 930}
931 931
932void ODevice::reloadButtonMapping ( ) 932void ODevice::reloadButtonMapping ( )
933{ 933{
934 initButtons ( ); 934 initButtons ( );
935 935
936 Config cfg ( "ButtonSettings" ); 936 Config cfg ( "ButtonSettings" );
937 937
938 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 938 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
939 ODeviceButton &b = ( *d-> m_buttons ) [i]; 939 ODeviceButton &b = ( *d-> m_buttons ) [i];
940 QString group = "Button" + QString::number ( i ); 940 QString group = "Button" + QString::number ( i );
941 941
942 QCString pch, hch; 942 QCString pch, hch;
943 QCString pm, hm; 943 QCString pm, hm;
944 QByteArray pdata, hdata; 944 QByteArray pdata, hdata;
945 945
946 if ( cfg. hasGroup ( group )) { 946 if ( cfg. hasGroup ( group )) {
947 cfg. setGroup ( group ); 947 cfg. setGroup ( group );
948 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 948 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
949 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 949 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
950 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 950 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
951 951
952 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 952 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
953 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 953 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
954 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 954 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
955 } 955 }
956 956
957 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 957 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
958 958
959 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 959 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
960 } 960 }
961} 961}
962 962
963void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 963void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
964{ 964{
965 initButtons ( ); 965 initButtons ( );
966 966
967 QString mb_chan; 967 QString mb_chan;
968 968
969 if ( button >= (int) d-> m_buttons-> count ( )) 969 if ( button >= (int) d-> m_buttons-> count ( ))
970 return; 970 return;
971 971
972 ODeviceButton &b = ( *d-> m_buttons ) [button]; 972 ODeviceButton &b = ( *d-> m_buttons ) [button];
973 b. setPressedAction ( action ); 973 b. setPressedAction ( action );
974 974
975 mb_chan=b. pressedAction ( ). channel ( ); 975 mb_chan=b. pressedAction ( ). channel ( );
976 976
977 Config buttonFile ( "ButtonSettings" ); 977 Config buttonFile ( "ButtonSettings" );
978 buttonFile. setGroup ( "Button" + QString::number ( button )); 978 buttonFile. setGroup ( "Button" + QString::number ( button ));
979 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 979 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
980 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 980 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
981 981
982 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 982 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
983 983
984 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 984 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
985} 985}
986 986
987void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 987void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
988{ 988{
989 initButtons ( ); 989 initButtons ( );
990 990
991 if ( button >= (int) d-> m_buttons-> count ( )) 991 if ( button >= (int) d-> m_buttons-> count ( ))
992 return; 992 return;
993 993
994 ODeviceButton &b = ( *d-> m_buttons ) [button]; 994 ODeviceButton &b = ( *d-> m_buttons ) [button];
995 b. setHeldAction ( action ); 995 b. setHeldAction ( action );
996 996
997 Config buttonFile ( "ButtonSettings" ); 997 Config buttonFile ( "ButtonSettings" );
998 buttonFile. setGroup ( "Button" + QString::number ( button )); 998 buttonFile. setGroup ( "Button" + QString::number ( button ));
999 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 999 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
1000 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 1000 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
1001 1001
1002 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 1002 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
1003 1003
1004 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 1004 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
1005} 1005}
1006void ODevice::virtual_hook(int, void* ){ 1006void ODevice::virtual_hook(int, void* ){
1007 1007
1008} 1008}
1009 1009
1010/************************************************** 1010/**************************************************
1011 * 1011 *
1012 * Yopy 3500/3700 1012 * Yopy 3500/3700
1013 * 1013 *
1014 **************************************************/ 1014 **************************************************/
1015 1015
1016bool Yopy::isYopy ( ) 1016bool Yopy::isYopy ( )
1017{ 1017{
1018 QFile f( "/proc/cpuinfo" ); 1018 QFile f( "/proc/cpuinfo" );
1019 if ( f. open ( IO_ReadOnly ) ) { 1019 if ( f. open ( IO_ReadOnly ) ) {
1020 QTextStream ts ( &f ); 1020 QTextStream ts ( &f );
1021 QString line; 1021 QString line;
1022 while( line = ts. readLine ( ) ) { 1022 while( line = ts. readLine ( ) ) {
1023 if ( line. left ( 8 ) == "Hardware" ) { 1023 if ( line. left ( 8 ) == "Hardware" ) {
1024 int loc = line. find ( ":" ); 1024 int loc = line. find ( ":" );
1025 if ( loc != -1 ) { 1025 if ( loc != -1 ) {
1026 QString model = 1026 QString model =
1027 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1027 line. mid ( loc + 2 ). simplifyWhiteSpace( );
1028 return ( model == "Yopy" ); 1028 return ( model == "Yopy" );
1029 } 1029 }
1030 } 1030 }
1031 } 1031 }
1032 } 1032 }
1033 return false; 1033 return false;
1034} 1034}
1035 1035
1036void Yopy::init ( ) 1036void Yopy::init ( )
1037{ 1037{
1038 d-> m_vendorstr = "G.Mate"; 1038 d-> m_vendorstr = "G.Mate";
1039 d-> m_vendor = Vendor_GMate; 1039 d-> m_vendor = Vendor_GMate;
1040 d-> m_modelstr = "Yopy3700"; 1040 d-> m_modelstr = "Yopy3700";
1041 d-> m_model = Model_Yopy_3700; 1041 d-> m_model = Model_Yopy_3700;
1042 d-> m_rotation = Rot0; 1042 d-> m_rotation = Rot0;
1043 1043
1044 d-> m_systemstr = "Linupy"; 1044 d-> m_systemstr = "Linupy";
1045 d-> m_system = System_Linupy; 1045 d-> m_system = System_Linupy;
1046 1046
1047 QFile f ( "/etc/issue" ); 1047 QFile f ( "/etc/issue" );
1048 if ( f. open ( IO_ReadOnly )) { 1048 if ( f. open ( IO_ReadOnly )) {
1049 QTextStream ts ( &f ); 1049 QTextStream ts ( &f );
1050 ts.readLine(); 1050 ts.readLine();
1051 d-> m_sysverstr = ts. readLine ( ); 1051 d-> m_sysverstr = ts. readLine ( );
1052 f. close ( ); 1052 f. close ( );
1053 } 1053 }
1054} 1054}
1055 1055
1056void Yopy::initButtons ( ) 1056void Yopy::initButtons ( )
1057{ 1057{
1058 if ( d-> m_buttons ) 1058 if ( d-> m_buttons )
1059 return; 1059 return;
1060 1060
1061 d-> m_buttons = new QValueList <ODeviceButton>; 1061 d-> m_buttons = new QValueList <ODeviceButton>;
1062 1062
1063 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1063 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1064 1064
1065 yopy_button *ib = yopy_buttons + i; 1065 yopy_button *ib = yopy_buttons + i;
1066 1066
1067 ODeviceButton b; 1067 ODeviceButton b;
1068 1068
1069 b. setKeycode ( ib-> code ); 1069 b. setKeycode ( ib-> code );
1070 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1070 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1071 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1071 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1072 b. setFactoryPresetPressedAction 1072 b. setFactoryPresetPressedAction
1073 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1073 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1074 b. setFactoryPresetHeldAction 1074 b. setFactoryPresetHeldAction
1075 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1075 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1076 1076
1077 d-> m_buttons-> append ( b ); 1077 d-> m_buttons-> append ( b );
1078 } 1078 }
1079 reloadButtonMapping ( ); 1079 reloadButtonMapping ( );
1080 1080
1081 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1081 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1082 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1082 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1083 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1083 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1084} 1084}
1085 1085
1086bool Yopy::suspend() 1086bool Yopy::suspend()
1087{ 1087{
1088 /* Opie for Yopy does not implement its own power management at the 1088 /* Opie for Yopy does not implement its own power management at the
1089 moment. The public version runs parallel to X, and relies on the 1089 moment. The public version runs parallel to X, and relies on the
1090 existing power management features. */ 1090 existing power management features. */
1091 return false; 1091 return false;
1092} 1092}
1093 1093
1094bool Yopy::setDisplayBrightness(int bright) 1094bool Yopy::setDisplayBrightness(int bright)
1095{ 1095{
1096 /* The code here works, but is disabled as the current version runs 1096 /* The code here works, but is disabled as the current version runs
1097 parallel to X, and relies on the existing backlight demon. */ 1097 parallel to X, and relies on the existing backlight demon. */
1098#if 0 1098#if 0
1099 if ( QFile::exists("/proc/sys/pm/light") ) { 1099 if ( QFile::exists("/proc/sys/pm/light") ) {
1100 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1100 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1101 if (fd >= 0 ) { 1101 if (fd >= 0 ) {
1102 if (bright) 1102 if (bright)
1103 ::write(fd, "1\n", 2); 1103 ::write(fd, "1\n", 2);
1104 else 1104 else
1105 ::write(fd, "0\n", 2); 1105 ::write(fd, "0\n", 2);
1106 ::close(fd); 1106 ::close(fd);
1107 return true; 1107 return true;
1108 } 1108 }
1109 } 1109 }
1110#endif 1110#endif
1111 return false; 1111 return false;
1112} 1112}
1113 1113
1114int Yopy::displayBrightnessResolution() const 1114int Yopy::displayBrightnessResolution() const
1115{ 1115{
1116 return 2; 1116 return 2;
1117} 1117}
1118 1118
1119/************************************************** 1119/**************************************************
1120 * 1120 *
1121 * iPAQ 1121 * iPAQ
1122 * 1122 *
1123 **************************************************/ 1123 **************************************************/
1124 1124
1125void iPAQ::init ( ) 1125void iPAQ::init ( )
1126{ 1126{
1127 d-> m_vendorstr = "HP"; 1127 d-> m_vendorstr = "HP";
1128 d-> m_vendor = Vendor_HP; 1128 d-> m_vendor = Vendor_HP;
1129 1129
1130 QFile f ( "/proc/hal/model" ); 1130 QFile f ( "/proc/hal/model" );
1131 1131
1132 if ( f. open ( IO_ReadOnly )) { 1132 if ( f. open ( IO_ReadOnly )) {
1133 QTextStream ts ( &f ); 1133 QTextStream ts ( &f );
1134 1134
1135 d-> m_modelstr = "H" + ts. readLine ( ); 1135 d-> m_modelstr = "H" + ts. readLine ( );
1136 1136
1137 if ( d-> m_modelstr == "H3100" ) 1137 if ( d-> m_modelstr == "H3100" )
1138 d-> m_model = Model_iPAQ_H31xx; 1138 d-> m_model = Model_iPAQ_H31xx;
1139 else if ( d-> m_modelstr == "H3600" ) 1139 else if ( d-> m_modelstr == "H3600" )
1140 d-> m_model = Model_iPAQ_H36xx; 1140 d-> m_model = Model_iPAQ_H36xx;
1141 else if ( d-> m_modelstr == "H3700" ) 1141 else if ( d-> m_modelstr == "H3700" )
1142 d-> m_model = Model_iPAQ_H37xx; 1142 d-> m_model = Model_iPAQ_H37xx;
1143 else if ( d-> m_modelstr == "H3800" ) 1143 else if ( d-> m_modelstr == "H3800" )
1144 d-> m_model = Model_iPAQ_H38xx; 1144 d-> m_model = Model_iPAQ_H38xx;
1145 else if ( d-> m_modelstr == "H3900" ) 1145 else if ( d-> m_modelstr == "H3900" )
1146 d-> m_model = Model_iPAQ_H39xx; 1146 d-> m_model = Model_iPAQ_H39xx;
1147 else if ( d-> m_modelstr == "H5400" ) 1147 else if ( d-> m_modelstr == "H5400" )
1148 d-> m_model = Model_iPAQ_H5xxx; 1148 d-> m_model = Model_iPAQ_H5xxx;
1149 else 1149 else
1150 d-> m_model = Model_Unknown; 1150 d-> m_model = Model_Unknown;
1151 1151
1152 f. close ( ); 1152 f. close ( );
1153 } 1153 }
1154 1154
1155 switch ( d-> m_model ) { 1155 switch ( d-> m_model ) {
1156 case Model_iPAQ_H31xx: 1156 case Model_iPAQ_H31xx:
1157 case Model_iPAQ_H38xx: 1157 case Model_iPAQ_H38xx:
1158 d-> m_rotation = Rot90; 1158 d-> m_rotation = Rot90;
1159 break; 1159 break;
1160 case Model_iPAQ_H36xx: 1160 case Model_iPAQ_H36xx:
1161 case Model_iPAQ_H37xx: 1161 case Model_iPAQ_H37xx:
1162 case Model_iPAQ_H39xx: 1162 case Model_iPAQ_H39xx:
1163 1163
1164 default: 1164 default:
1165 d-> m_rotation = Rot270; 1165 d-> m_rotation = Rot270;
1166 break; 1166 break;
1167 case Model_iPAQ_H5xxx: 1167 case Model_iPAQ_H5xxx:
1168 d-> m_rotation = Rot0; 1168 d-> m_rotation = Rot0;
1169 } 1169 }
1170 1170
1171 f. setName ( "/etc/familiar-version" ); 1171 f. setName ( "/etc/familiar-version" );
1172 if ( f. open ( IO_ReadOnly )) { 1172 if ( f. open ( IO_ReadOnly )) {
1173 d-> m_systemstr = "Familiar"; 1173 d-> m_systemstr = "Familiar";
1174 d-> m_system = System_Familiar; 1174 d-> m_system = System_Familiar;
1175 1175
1176 QTextStream ts ( &f ); 1176 QTextStream ts ( &f );
1177 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1177 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1178 1178
1179 f. close ( ); 1179 f. close ( );
1180 } else { 1180 } else {
1181 f. setName ( "/etc/oz_version" ); 1181 f. setName ( "/etc/oz_version" );
1182 1182
1183 if ( f. open ( IO_ReadOnly )) { 1183 if ( f. open ( IO_ReadOnly )) {
1184 d-> m_systemstr = "OpenEmbedded/iPaq"; 1184 d-> m_systemstr = "OpenEmbedded/iPaq";
1185 d-> m_system = System_Familiar; 1185 d-> m_system = System_Familiar;
1186 1186
1187 QTextStream ts ( &f ); 1187 QTextStream ts ( &f );
1188 ts.setDevice ( &f ); 1188 ts.setDevice ( &f );
1189 d-> m_sysverstr = ts. readLine ( ); 1189 d-> m_sysverstr = ts. readLine ( );
1190 f. close ( ); 1190 f. close ( );
1191 } 1191 }
1192 } 1192 }
1193 1193
1194 1194
1195 1195
1196 1196
1197 1197
1198 m_leds [0] = m_leds [1] = Led_Off; 1198 m_leds [0] = m_leds [1] = Led_Off;
1199 1199
1200 m_power_timer = 0; 1200 m_power_timer = 0;
1201 1201
1202} 1202}
1203 1203
1204void iPAQ::initButtons ( ) 1204void iPAQ::initButtons ( )
1205{ 1205{
1206 if ( d-> m_buttons ) 1206 if ( d-> m_buttons )
1207 return; 1207 return;
1208 1208
1209 if ( isQWS( ) ) 1209 if ( isQWS( ) )
1210 QWSServer::setKeyboardFilter ( this ); 1210 QWSServer::setKeyboardFilter ( this );
1211 1211
1212 d-> m_buttons = new QValueList <ODeviceButton>; 1212 d-> m_buttons = new QValueList <ODeviceButton>;
1213 1213
1214 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1214 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1215 i_button *ib = ipaq_buttons + i; 1215 i_button *ib = ipaq_buttons + i;
1216 ODeviceButton b; 1216 ODeviceButton b;
1217 1217
1218 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1218 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1219 b. setKeycode ( ib-> code ); 1219 b. setKeycode ( ib-> code );
1220 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1220 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1221 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1221 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1222 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1223 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1224 1224
1225 d-> m_buttons-> append ( b ); 1225 d-> m_buttons-> append ( b );
1226 } 1226 }
1227 } 1227 }
1228 reloadButtonMapping ( ); 1228 reloadButtonMapping ( );
1229 1229
1230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1230 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1231 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1231 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1232} 1232}
1233 1233
1234 1234
1235//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1235//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1236 1236
1237typedef struct { 1237typedef struct {
1238 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1238 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1239 unsigned char TotalTime; /* Units of 5 seconds */ 1239 unsigned char TotalTime; /* Units of 5 seconds */
1240 unsigned char OnTime; /* units of 100m/s */ 1240 unsigned char OnTime; /* units of 100m/s */
1241 unsigned char OffTime; /* units of 100m/s */ 1241 unsigned char OffTime; /* units of 100m/s */
1242} LED_IN; 1242} LED_IN;
1243 1243
1244typedef struct { 1244typedef struct {
1245 unsigned char mode; 1245 unsigned char mode;
1246 unsigned char pwr; 1246 unsigned char pwr;
1247 unsigned char brightness; 1247 unsigned char brightness;
1248} FLITE_IN; 1248} FLITE_IN;
1249 1249
1250#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1250#define LED_ON OD_IOW( 'f', 5, LED_IN )
1251#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1251#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1252 1252
1253 1253
1254QValueList <OLed> iPAQ::ledList ( ) const 1254QValueList <OLed> iPAQ::ledList ( ) const
1255{ 1255{
1256 QValueList <OLed> vl; 1256 QValueList <OLed> vl;
1257 vl << Led_Power; 1257 vl << Led_Power;
1258 1258
1259 if ( d-> m_model == Model_iPAQ_H38xx ) 1259 if ( d-> m_model == Model_iPAQ_H38xx )
1260 vl << Led_BlueTooth; 1260 vl << Led_BlueTooth;
1261 return vl; 1261 return vl;
1262} 1262}
1263 1263
1264QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1264QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1265{ 1265{
1266 QValueList <OLedState> vl; 1266 QValueList <OLedState> vl;
1267 1267
1268 if ( l == Led_Power ) 1268 if ( l == Led_Power )
1269 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1269 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1270 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1270 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1271 vl << Led_Off; // << Led_On << ??? 1271 vl << Led_Off; // << Led_On << ???
1272 1272
1273 return vl; 1273 return vl;
1274} 1274}
1275 1275
1276OLedState iPAQ::ledState ( OLed l ) const 1276OLedState iPAQ::ledState ( OLed l ) const
1277{ 1277{
1278 switch ( l ) { 1278 switch ( l ) {
1279 case Led_Power: 1279 case Led_Power:
1280 return m_leds [0]; 1280 return m_leds [0];
1281 case Led_BlueTooth: 1281 case Led_BlueTooth:
1282 return m_leds [1]; 1282 return m_leds [1];
1283 default: 1283 default:
1284 return Led_Off; 1284 return Led_Off;
1285 } 1285 }
1286} 1286}
1287 1287
1288bool iPAQ::setLedState ( OLed l, OLedState st ) 1288bool iPAQ::setLedState ( OLed l, OLedState st )
1289{ 1289{
1290 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1290 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1291 1291
1292 if ( l == Led_Power ) { 1292 if ( l == Led_Power ) {
1293 if ( fd >= 0 ) { 1293 if ( fd >= 0 ) {
1294 LED_IN leds; 1294 LED_IN leds;
1295 ::memset ( &leds, 0, sizeof( leds )); 1295 ::memset ( &leds, 0, sizeof( leds ));
1296 leds. TotalTime = 0; 1296 leds. TotalTime = 0;
1297 leds. OnTime = 0; 1297 leds. OnTime = 0;
1298 leds. OffTime = 1; 1298 leds. OffTime = 1;
1299 leds. OffOnBlink = 2; 1299 leds. OffOnBlink = 2;
1300 1300
1301 switch ( st ) { 1301 switch ( st ) {
1302 case Led_Off : leds. OffOnBlink = 0; break; 1302 case Led_Off : leds. OffOnBlink = 0; break;
1303 case Led_On : leds. OffOnBlink = 1; break; 1303 case Led_On : leds. OffOnBlink = 1; break;
1304 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1304 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1305 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1305 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1306 } 1306 }
1307 1307
1308 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1308 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1309 m_leds [0] = st; 1309 m_leds [0] = st;
1310 return true; 1310 return true;
1311 } 1311 }
1312 } 1312 }
1313 } 1313 }
1314 return false; 1314 return false;
1315} 1315}
1316 1316
1317 1317
1318bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1318bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1319{ 1319{
1320 int newkeycode = keycode; 1320 int newkeycode = keycode;
1321 1321
1322 switch ( keycode ) { 1322 switch ( keycode ) {
1323 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1323 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1324 case HardKey_Menu: { 1324 case HardKey_Menu: {
1325 if (( d-> m_model == Model_iPAQ_H38xx ) || 1325 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1326 ( d-> m_model == Model_iPAQ_H39xx ) || 1326 ( d-> m_model == Model_iPAQ_H39xx ) ||
1327 ( d-> m_model == Model_iPAQ_H5xxx)) { 1327 ( d-> m_model == Model_iPAQ_H5xxx)) {
1328 newkeycode = HardKey_Mail; 1328 newkeycode = HardKey_Mail;
1329 } 1329 }
1330 break; 1330 break;
1331 } 1331 }
1332 1332
1333 // Rotate cursor keys 180° 1333 // Rotate cursor keys 180° or 270°
1334 case Key_Left : 1334 case Key_Left :
1335 case Key_Right: 1335 case Key_Right:
1336 case Key_Up : 1336 case Key_Up :
1337 case Key_Down : { 1337 case Key_Down : {
1338
1338 if (( d-> m_model == Model_iPAQ_H31xx ) || 1339 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1339 ( d-> m_model == Model_iPAQ_H38xx )) { 1340 ( d-> m_model == Model_iPAQ_H38xx )) {
1340 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1341 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1341 } 1342 }
1343 // Rotate the cursor keys by 270°
1344 // keycode - Key_Left = position of the button starting from left clockwise
1345 // add the rotation to it and modolo. No we've the original offset
1346 // add the offset to the Key_Left key
1347 if ( d-> m_model == Model_iPAQ_H5xxx )
1348 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
1342 break; 1349 break;
1343 } 1350 }
1344 1351
1345 // map Power Button short/long press to F34/F35 1352 // map Power Button short/long press to F34/F35
1346 case Key_SysReq: { 1353 case Key_SysReq: {
1347 if ( isPress ) { 1354 if ( isPress ) {
1348 if ( m_power_timer ) 1355 if ( m_power_timer )
1349 killTimer ( m_power_timer ); 1356 killTimer ( m_power_timer );
1350 m_power_timer = startTimer ( 500 ); 1357 m_power_timer = startTimer ( 500 );
1351 } 1358 }
1352 else if ( m_power_timer ) { 1359 else if ( m_power_timer ) {
1353 killTimer ( m_power_timer ); 1360 killTimer ( m_power_timer );
1354 m_power_timer = 0; 1361 m_power_timer = 0;
1355 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1362 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1356 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1363 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1357 } 1364 }
1358 newkeycode = Key_unknown; 1365 newkeycode = Key_unknown;
1359 break; 1366 break;
1360 } 1367 }
1361 } 1368 }
1362 1369
1363 if ( newkeycode != keycode ) { 1370 if ( newkeycode != keycode ) {
1364 if ( newkeycode != Key_unknown ) 1371 if ( newkeycode != Key_unknown )
1365 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1372 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1366 return true; 1373 return true;
1367 } 1374 }
1368 else 1375 else
1369 return false; 1376 return false;
1370} 1377}
1371 1378
1372void iPAQ::timerEvent ( QTimerEvent * ) 1379void iPAQ::timerEvent ( QTimerEvent * )
1373{ 1380{
1374 killTimer ( m_power_timer ); 1381 killTimer ( m_power_timer );
1375 m_power_timer = 0; 1382 m_power_timer = 0;
1376 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1383 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1377 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1384 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1378} 1385}
1379 1386
1380 1387
1381void iPAQ::alarmSound ( ) 1388void iPAQ::alarmSound ( )
1382{ 1389{
1383#ifndef QT_NO_SOUND 1390#ifndef QT_NO_SOUND
1384 static Sound snd ( "alarm" ); 1391 static Sound snd ( "alarm" );
1385 int fd; 1392 int fd;
1386 int vol; 1393 int vol;
1387 bool vol_reset = false; 1394 bool vol_reset = false;
1388 1395
1389 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1396 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1390 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1397 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1391 Config cfg ( "qpe" ); 1398 Config cfg ( "qpe" );
1392 cfg. setGroup ( "Volume" ); 1399 cfg. setGroup ( "Volume" );
1393 1400
1394 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1401 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1395 if ( volalarm < 0 ) 1402 if ( volalarm < 0 )
1396 volalarm = 0; 1403 volalarm = 0;
1397 else if ( volalarm > 100 ) 1404 else if ( volalarm > 100 )
1398 volalarm = 100; 1405 volalarm = 100;
1399 volalarm |= ( volalarm << 8 ); 1406 volalarm |= ( volalarm << 8 );
1400 1407
1401 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1408 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1402 vol_reset = true; 1409 vol_reset = true;
1403 } 1410 }
1404 } 1411 }
1405 1412
1406 snd. play ( ); 1413 snd. play ( );
1407 while ( !snd. isFinished ( )) 1414 while ( !snd. isFinished ( ))
1408 qApp-> processEvents ( ); 1415 qApp-> processEvents ( );
1409 1416
1410 if ( fd >= 0 ) { 1417 if ( fd >= 0 ) {
1411 if ( vol_reset ) 1418 if ( vol_reset )
1412 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1419 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1413 ::close ( fd ); 1420 ::close ( fd );
1414 } 1421 }
1415#endif 1422#endif
1416} 1423}
1417 1424
1418 1425
1419bool iPAQ::setSoftSuspend ( bool soft ) 1426bool iPAQ::setSoftSuspend ( bool soft )
1420{ 1427{
1421 bool res = false; 1428 bool res = false;
1422 int fd; 1429 int fd;
1423 1430
1424 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1431 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1425 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1432 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1426 res = true; 1433 res = true;
1427 else 1434 else
1428 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1435 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1429 1436
1430 ::close ( fd ); 1437 ::close ( fd );
1431 } 1438 }
1432 else 1439 else
1433 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1440 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1434 1441
1435 return res; 1442 return res;
1436} 1443}
1437 1444
1438 1445
1439bool iPAQ::setDisplayBrightness ( int bright ) 1446bool iPAQ::setDisplayBrightness ( int bright )
1440{ 1447{
1441 bool res = false; 1448 bool res = false;
1442 int fd; 1449 int fd;
1443 1450
1444 if ( bright > 255 ) 1451 if ( bright > 255 )
1445 bright = 255; 1452 bright = 255;
1446 if ( bright < 0 ) 1453 if ( bright < 0 )
1447 bright = 0; 1454 bright = 0;
1448 1455
1449 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1456 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1450 FLITE_IN bl; 1457 FLITE_IN bl;
1451 bl. mode = 1; 1458 bl. mode = 1;
1452 bl. pwr = bright ? 1 : 0; 1459 bl. pwr = bright ? 1 : 0;
1453 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1460 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1454 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1461 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1455 ::close ( fd ); 1462 ::close ( fd );
1456 } 1463 }
1457 return res; 1464 return res;
1458} 1465}
1459 1466
1460int iPAQ::displayBrightnessResolution ( ) const 1467int iPAQ::displayBrightnessResolution ( ) const
1461{ 1468{
1462 switch ( model ( )) { 1469 switch ( model ( )) {
1463 case Model_iPAQ_H31xx: 1470 case Model_iPAQ_H31xx:
1464 case Model_iPAQ_H36xx: 1471 case Model_iPAQ_H36xx:
1465 case Model_iPAQ_H37xx: 1472 case Model_iPAQ_H37xx:
1466 return 128; // really 256, but >128 could damage the LCD 1473 return 128; // really 256, but >128 could damage the LCD
1467 1474
1468 case Model_iPAQ_H38xx: 1475 case Model_iPAQ_H38xx:
1469 case Model_iPAQ_H39xx: 1476 case Model_iPAQ_H39xx:
1470 return 64; 1477 return 64;
1471 case Model_iPAQ_H5xxx: 1478 case Model_iPAQ_H5xxx:
1472 return 255; 1479 return 255;
1473 1480
1474 default: 1481 default:
1475 return 2; 1482 return 2;
1476 } 1483 }
1477} 1484}
1478 1485
1479 1486
1480bool iPAQ::hasLightSensor ( ) const 1487bool iPAQ::hasLightSensor ( ) const
1481{ 1488{
1482 return true; 1489 return true;
1483} 1490}
1484 1491
1485int iPAQ::readLightSensor ( ) 1492int iPAQ::readLightSensor ( )
1486{ 1493{
1487 int fd; 1494 int fd;
1488 int val = -1; 1495 int val = -1;
1489 1496
1490 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1497 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1491 char buffer [8]; 1498 char buffer [8];
1492 1499
1493 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1500 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1494 char *endptr; 1501 char *endptr;
1495 1502
1496 buffer [4] = 0; 1503 buffer [4] = 0;
1497 val = ::strtol ( buffer + 2, &endptr, 16 ); 1504 val = ::strtol ( buffer + 2, &endptr, 16 );
1498 1505
1499 if ( *endptr != 0 ) 1506 if ( *endptr != 0 )
1500 val = -1; 1507 val = -1;
1501 } 1508 }
1502 ::close ( fd ); 1509 ::close ( fd );
1503 } 1510 }
1504 1511
1505 return val; 1512 return val;
1506} 1513}
1507 1514
1508int iPAQ::lightSensorResolution ( ) const 1515int iPAQ::lightSensorResolution ( ) const
1509{ 1516{
1510 return 256; 1517 return 256;
1511} 1518}
1512 1519
1513/************************************************** 1520/**************************************************
1514 * 1521 *
1515 * Zaurus 1522 * Zaurus
1516 * 1523 *
1517 **************************************************/ 1524 **************************************************/
1518 1525
1519// Check whether this device is the sharp zaurus.. 1526// Check whether this device is the sharp zaurus..
1520// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus 1527// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
1521// class up into individual classes. We need three classes 1528// class up into individual classes. We need three classes
1522// 1529//
1523// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) 1530// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
1524// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) 1531// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
1525// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) 1532// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860)
1526// 1533//
1527// Only question right now is: Do we really need to do it? Because as soon 1534// Only question right now is: Do we really need to do it? Because as soon
1528// as the OpenZaurus kernel is ready, there will be a unified interface for all 1535// as the OpenZaurus kernel is ready, there will be a unified interface for all
1529// Zaurus models (concerning apm, backlight, buttons, etc.) 1536// Zaurus models (concerning apm, backlight, buttons, etc.)
1530// 1537//
1531// Comments? - mickeyl. 1538// Comments? - mickeyl.
1532 1539
1533bool Zaurus::isZaurus() 1540bool Zaurus::isZaurus()
1534{ 1541{
1535 1542
1536 // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! 1543 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
1537 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1544 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1538 return true; 1545 return true;
1539 } 1546 }
1540 1547
1541 // On non-embedix kernels, we have to look closer. 1548 // On non-embedix kernels, we have to look closer.
1542 bool is_zaurus = false; 1549 bool is_zaurus = false;
1543 QFile f ( "/proc/cpuinfo" ); 1550 QFile f ( "/proc/cpuinfo" );
1544 if ( f. open ( IO_ReadOnly ) ) { 1551 if ( f. open ( IO_ReadOnly ) ) {
1545 QString model; 1552 QString model;
1546 QFile f ( "/proc/cpuinfo" ); 1553 QFile f ( "/proc/cpuinfo" );
1547 1554
1548 QTextStream ts ( &f ); 1555 QTextStream ts ( &f );
1549 QString line; 1556 QString line;
1550 while( line = ts. readLine ( ) ) { 1557 while( line = ts. readLine ( ) ) {
1551 if ( line. left ( 8 ) == "Hardware" ) 1558 if ( line. left ( 8 ) == "Hardware" )
1552 break; 1559 break;
1553 } 1560 }
1554 int loc = line. find ( ":" ); 1561 int loc = line. find ( ":" );
1555 if ( loc != -1 ) 1562 if ( loc != -1 )
1556 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1563 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1557 1564
1558 if ( model == "Sharp-Collie" 1565 if ( model == "Sharp-Collie"
1559 || model == "Collie" 1566 || model == "Collie"
1560 || model == "SHARP Corgi" 1567 || model == "SHARP Corgi"
1561 || model == "SHARP Shepherd" 1568 || model == "SHARP Shepherd"
1562 || model == "SHARP Poodle" 1569 || model == "SHARP Poodle"
1563 || model == "SHARP Husky" 1570 || model == "SHARP Husky"
1564 ) 1571 )
1565 is_zaurus = true; 1572 is_zaurus = true;
1566 1573
1567 } 1574 }
1568 return is_zaurus; 1575 return is_zaurus;
1569} 1576}
1570 1577
1571 1578
1572void Zaurus::init ( ) 1579void Zaurus::init ( )
1573{ 1580{
1574 d-> m_vendorstr = "Sharp"; 1581 d-> m_vendorstr = "Sharp";
1575 d-> m_vendor = Vendor_Sharp; 1582 d-> m_vendor = Vendor_Sharp;
1576 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 1583 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
1577 1584
1578 // QFile f ( "/proc/filesystems" ); 1585 // QFile f ( "/proc/filesystems" );
1579 QString model; 1586 QString model;
1580 1587
1581 // It isn't a good idea to check the system configuration to 1588 // It isn't a good idea to check the system configuration to
1582 // detect the distribution ! 1589 // detect the distribution !
1583 // Otherwise it may happen that any other distribution is detected as openzaurus, just 1590 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1584 // because it uses a jffs2 filesystem.. 1591 // because it uses a jffs2 filesystem..
1585 // (eilers) 1592 // (eilers)
1586 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1593 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1587 QFile f ("/etc/oz_version"); 1594 QFile f ("/etc/oz_version");
1588 if ( f.exists() ){ 1595 if ( f.exists() ){
1589 d-> m_vendorstr = "OpenZaurus Team"; 1596 d-> m_vendorstr = "OpenZaurus Team";
1590 d-> m_systemstr = "OpenZaurus"; 1597 d-> m_systemstr = "OpenZaurus";
1591 d-> m_system = System_OpenZaurus; 1598 d-> m_system = System_OpenZaurus;
1592 1599
1593 if ( f. open ( IO_ReadOnly )) { 1600 if ( f. open ( IO_ReadOnly )) {
1594 QTextStream ts ( &f ); 1601 QTextStream ts ( &f );
1595 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1602 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1596 f. close ( ); 1603 f. close ( );
1597 } 1604 }
1598 1605
1599 // Openzaurus sometimes uses the embedix kernel! 1606 // Openzaurus sometimes uses the embedix kernel!
1600 // => Check whether this is an embedix kernel 1607 // => Check whether this is an embedix kernel
1601 FILE *uname = popen("uname -r", "r"); 1608 FILE *uname = popen("uname -r", "r");
1602 QString line; 1609 QString line;
1603 if ( f.open(IO_ReadOnly, uname) ) { 1610 if ( f.open(IO_ReadOnly, uname) ) {
1604 QTextStream ts ( &f ); 1611 QTextStream ts ( &f );
1605 line = ts. readLine ( ); 1612 line = ts. readLine ( );
1606 int loc = line. find ( "embedix" ); 1613 int loc = line. find ( "embedix" );
1607 if ( loc != -1 ) 1614 if ( loc != -1 )
1608 m_embedix = true; 1615 m_embedix = true;
1609 else 1616 else
1610 m_embedix = false; 1617 m_embedix = false;
1611 f. close ( ); 1618 f. close ( );
1612 } 1619 }
1613 pclose(uname); 1620 pclose(uname);
1614 } 1621 }
1615 else { 1622 else {
1616 d-> m_systemstr = "Zaurus"; 1623 d-> m_systemstr = "Zaurus";
1617 d-> m_system = System_Zaurus; 1624 d-> m_system = System_Zaurus;
1618 } 1625 }
1619 1626
1620 f. setName ( "/proc/cpuinfo" ); 1627 f. setName ( "/proc/cpuinfo" );
1621 if ( f. open ( IO_ReadOnly ) ) { 1628 if ( f. open ( IO_ReadOnly ) ) {
1622 QTextStream ts ( &f ); 1629 QTextStream ts ( &f );
1623 QString line; 1630 QString line;
1624 while( line = ts. readLine ( ) ) { 1631 while( line = ts. readLine ( ) ) {
1625 if ( line. left ( 8 ) == "Hardware" ) 1632 if ( line. left ( 8 ) == "Hardware" )
1626 break; 1633 break;
1627 } 1634 }
1628 int loc = line. find ( ":" ); 1635 int loc = line. find ( ":" );
1629 if ( loc != -1 ) 1636 if ( loc != -1 )
1630 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1637 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1631 } 1638 }
1632 1639
1633 if ( model == "SHARP Corgi" ) { 1640 if ( model == "SHARP Corgi" ) {
1634 d-> m_model = Model_Zaurus_SLC7x0; 1641 d-> m_model = Model_Zaurus_SLC7x0;
1635 d-> m_modelstr = "Zaurus SL-C700"; 1642 d-> m_modelstr = "Zaurus SL-C700";
1636 } else if ( model == "SHARP Shepherd" ) { 1643 } else if ( model == "SHARP Shepherd" ) {
1637 d-> m_model = Model_Zaurus_SLC7x0; 1644 d-> m_model = Model_Zaurus_SLC7x0;
1638 d-> m_modelstr = "Zaurus SL-C750"; 1645 d-> m_modelstr = "Zaurus SL-C750";
1639 } else if ( model == "SHARP Husky" ) { 1646 } else if ( model == "SHARP Husky" ) {
1640 d-> m_model = Model_Zaurus_SLC7x0; 1647 d-> m_model = Model_Zaurus_SLC7x0;
1641 d-> m_modelstr = "Zaurus SL-C760"; 1648 d-> m_modelstr = "Zaurus SL-C760";
1642 } else if ( model == "SHARP Poodle" ) { 1649 } else if ( model == "SHARP Poodle" ) {
1643 d-> m_model = Model_Zaurus_SLB600; 1650 d-> m_model = Model_Zaurus_SLB600;
1644 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1651 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1645 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 1652 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
1646 d-> m_model = Model_Zaurus_SL5500; 1653 d-> m_model = Model_Zaurus_SL5500;
1647 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1654 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1648 } else { 1655 } else {
1649 d-> m_model = Model_Zaurus_SL5500; 1656 d-> m_model = Model_Zaurus_SL5500;
1650 d-> m_modelstr = "Zaurus (Model unknown)"; 1657 d-> m_modelstr = "Zaurus (Model unknown)";
1651 } 1658 }
1652 1659
1653 bool flipstate = false; 1660 bool flipstate = false;
1654 switch ( d-> m_model ) { 1661 switch ( d-> m_model ) {
1655 case Model_Zaurus_SLA300: 1662 case Model_Zaurus_SLA300:
1656 d-> m_rotation = Rot0; 1663 d-> m_rotation = Rot0;
1657 break; 1664 break;
1658 case Model_Zaurus_SLC7x0: 1665 case Model_Zaurus_SLC7x0:
1659 d-> m_rotation = rotation(); 1666 d-> m_rotation = rotation();
1660 d-> m_direction = direction(); 1667 d-> m_direction = direction();
1661 break; 1668 break;
1662 case Model_Zaurus_SLB600: 1669 case Model_Zaurus_SLB600:
1663 case Model_Zaurus_SL5500: 1670 case Model_Zaurus_SL5500:
1664 case Model_Zaurus_SL5000: 1671 case Model_Zaurus_SL5000:
1665 default: 1672 default:
1666 d-> m_rotation = Rot270; 1673 d-> m_rotation = Rot270;
1667 break; 1674 break;
1668 } 1675 }
1669 m_leds [0] = Led_Off; 1676 m_leds [0] = Led_Off;
1670} 1677}
1671 1678
1672void Zaurus::initButtons ( ) 1679void Zaurus::initButtons ( )
1673{ 1680{
1674 if ( d-> m_buttons ) 1681 if ( d-> m_buttons )
1675 return; 1682 return;
1676 1683
1677 d-> m_buttons = new QValueList <ODeviceButton>; 1684 d-> m_buttons = new QValueList <ODeviceButton>;
1678 1685
1679 struct z_button * pz_buttons; 1686 struct z_button * pz_buttons;
1680 int buttoncount; 1687 int buttoncount;
1681 switch ( d-> m_model ) { 1688 switch ( d-> m_model ) {
1682 case Model_Zaurus_SLC7x0: 1689 case Model_Zaurus_SLC7x0:
1683 pz_buttons = z_buttons_c700; 1690 pz_buttons = z_buttons_c700;
1684 buttoncount = ARRAY_SIZE(z_buttons_c700); 1691 buttoncount = ARRAY_SIZE(z_buttons_c700);
1685 break; 1692 break;
1686 default: 1693 default:
1687 pz_buttons = z_buttons; 1694 pz_buttons = z_buttons;
1688 buttoncount = ARRAY_SIZE(z_buttons); 1695 buttoncount = ARRAY_SIZE(z_buttons);
1689 break; 1696 break;
1690 } 1697 }
1691 1698
1692 for ( int i = 0; i < buttoncount; i++ ) { 1699 for ( int i = 0; i < buttoncount; i++ ) {
1693 struct z_button *zb = pz_buttons + i; 1700 struct z_button *zb = pz_buttons + i;
1694 ODeviceButton b; 1701 ODeviceButton b;
1695 1702
1696 b. setKeycode ( zb-> code ); 1703 b. setKeycode ( zb-> code );
1697 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1704 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1698 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1705 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1699 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), 1706 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
1700 zb-> fpressedaction )); 1707 zb-> fpressedaction ));
1701 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), 1708 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
1702 zb-> fheldaction )); 1709 zb-> fheldaction ));
1703 1710
1704 d-> m_buttons-> append ( b ); 1711 d-> m_buttons-> append ( b );
1705 } 1712 }
1706 1713
1707 reloadButtonMapping ( ); 1714 reloadButtonMapping ( );
1708 1715
1709 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1716 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1710 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 1717 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
1711 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1718 this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1712} 1719}
1713 1720
1714#include <unistd.h> 1721#include <unistd.h>
1715#include <fcntl.h> 1722#include <fcntl.h>
1716#include <sys/ioctl.h> 1723#include <sys/ioctl.h>
1717 1724
1718//#include <asm/sharp_char.h> // including kernel headers is evil ... 1725//#include <asm/sharp_char.h> // including kernel headers is evil ...
1719 1726
1720#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1727#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1721 1728
1722 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1729 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1723#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1730#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1724 1731
1725#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1732#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1726#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1733#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1727#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1734#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1728 1735
1729/* --- for SHARP_BUZZER device --- */ 1736/* --- for SHARP_BUZZER device --- */
1730 1737
1731 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1738 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1732//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1739//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1733 1740
1734#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1741#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1735#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1742#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1736#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1743#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1737#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1744#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1738#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1745#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1739 1746
1740//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1747//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1741//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1748//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1742 1749
1743//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1750//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1744//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1751//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1745//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1752//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1746//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1753//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1747//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1754//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1748//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1755//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1749//#define SHARP_PDA_APPSTART 9 /* application start */ 1756//#define SHARP_PDA_APPSTART 9 /* application start */
1750//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1757//#define SHARP_PDA_APPQUIT 10 /* application ends */
1751 1758
1752//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1759//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1753//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1760//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1754//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1761//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1755//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1762//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1756// 1763//
1757 1764
1758 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1765 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1759#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1766#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1760 1767
1761#define SHARP_IOCTL_GET_ROTATION 0x413c 1768#define SHARP_IOCTL_GET_ROTATION 0x413c
1762 1769
1763typedef struct sharp_led_status { 1770typedef struct sharp_led_status {
1764 int which; /* select which LED status is wanted. */ 1771 int which; /* select which LED status is wanted. */
1765 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1772 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1766} sharp_led_status; 1773} sharp_led_status;
1767 1774
1768#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1775#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1769 1776
1770#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1777#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1771#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1778#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1772#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1779#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1773 1780
1774// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1781// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1775 1782
1776#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1783#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1777#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1784#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1778#define APM_EVT_POWER_BUTTON (1 << 0) 1785#define APM_EVT_POWER_BUTTON (1 << 0)
1779 1786
1780#define FL_IOCTL_STEP_CONTRAST 100 1787#define FL_IOCTL_STEP_CONTRAST 100
1781 1788
1782 1789
1783void Zaurus::buzzer ( int sound ) 1790void Zaurus::buzzer ( int sound )
1784{ 1791{
1785#ifndef QT_NO_SOUND 1792#ifndef QT_NO_SOUND
1786 QString soundname; 1793 QString soundname;
1787 1794
1788 // Not all devices have real sound 1795 // Not all devices have real sound
1789 if ( d->m_model == Model_Zaurus_SLC7x0 1796 if ( d->m_model == Model_Zaurus_SLC7x0
1790 || d->m_model == Model_Zaurus_SLB600 ){ 1797 || d->m_model == Model_Zaurus_SLB600 ){
1791 1798
1792 switch ( sound ){ 1799 switch ( sound ){
1793 case SHARP_BUZ_SCHEDULE_ALARM: 1800 case SHARP_BUZ_SCHEDULE_ALARM:
1794 soundname = "alarm"; 1801 soundname = "alarm";
1795 break; 1802 break;
1796 case SHARP_BUZ_TOUCHSOUND: 1803 case SHARP_BUZ_TOUCHSOUND:
1797 soundname = "touchsound"; 1804 soundname = "touchsound";
1798 break; 1805 break;
1799 case SHARP_BUZ_KEYSOUND: 1806 case SHARP_BUZ_KEYSOUND:
1800 soundname = "keysound"; 1807 soundname = "keysound";
1801 break; 1808 break;
1802 default: 1809 default:
1803 soundname = "alarm"; 1810 soundname = "alarm";
1804 1811
1805 } 1812 }
1806 } 1813 }
1807 1814
1808 // If a soundname is defined, we expect that this device has 1815 // If a soundname is defined, we expect that this device has
1809 // sound capabilities.. Otherwise we expect to have the buzzer 1816 // sound capabilities.. Otherwise we expect to have the buzzer
1810 // device.. 1817 // device..
1811 if ( !soundname.isEmpty() ){ 1818 if ( !soundname.isEmpty() ){
1812 int fd; 1819 int fd;
1813 int vol; 1820 int vol;
1814 bool vol_reset = false; 1821 bool vol_reset = false;
1815 1822
1816 Sound snd ( soundname ); 1823 Sound snd ( soundname );
1817 1824
1818 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1825 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1819 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1826 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1820 Config cfg ( "qpe" ); 1827 Config cfg ( "qpe" );
1821 cfg. setGroup ( "Volume" ); 1828 cfg. setGroup ( "Volume" );
1822 1829
1823 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1830 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1824 if ( volalarm < 0 ) 1831 if ( volalarm < 0 )
1825 volalarm = 0; 1832 volalarm = 0;
1826 else if ( volalarm > 100 ) 1833 else if ( volalarm > 100 )
1827 volalarm = 100; 1834 volalarm = 100;
1828 volalarm |= ( volalarm << 8 ); 1835 volalarm |= ( volalarm << 8 );
1829 1836
1830 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1837 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1831 vol_reset = true; 1838 vol_reset = true;
1832 } 1839 }
1833 } 1840 }
1834 1841
1835 snd. play ( ); 1842 snd. play ( );
1836 while ( !snd. isFinished ( )) 1843 while ( !snd. isFinished ( ))
1837 qApp-> processEvents ( ); 1844 qApp-> processEvents ( );
1838 1845
1839 if ( fd >= 0 ) { 1846 if ( fd >= 0 ) {
1840 if ( vol_reset ) 1847 if ( vol_reset )
1841 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1848 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1842 ::close ( fd ); 1849 ::close ( fd );
1843 } 1850 }
1844 } else { 1851 } else {
1845 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1852 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1846 1853
1847 if ( fd >= 0 ) { 1854 if ( fd >= 0 ) {
1848 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1855 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1849 ::close ( fd ); 1856 ::close ( fd );
1850 } 1857 }
1851 1858
1852 } 1859 }
1853#endif 1860#endif
1854} 1861}
1855 1862
1856 1863
1857void Zaurus::alarmSound ( ) 1864void Zaurus::alarmSound ( )
1858{ 1865{
1859 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1866 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1860} 1867}
1861 1868
1862void Zaurus::touchSound ( ) 1869void Zaurus::touchSound ( )
1863{ 1870{
1864 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1871 buzzer ( SHARP_BUZ_TOUCHSOUND );
1865} 1872}
1866 1873
1867void Zaurus::keySound ( ) 1874void Zaurus::keySound ( )
1868{ 1875{
1869 buzzer ( SHARP_BUZ_KEYSOUND ); 1876 buzzer ( SHARP_BUZ_KEYSOUND );
1870} 1877}
1871 1878
1872 1879
1873QValueList <OLed> Zaurus::ledList ( ) const 1880QValueList <OLed> Zaurus::ledList ( ) const
1874{ 1881{
1875 QValueList <OLed> vl; 1882 QValueList <OLed> vl;
1876 vl << Led_Mail; 1883 vl << Led_Mail;
1877 return vl; 1884 return vl;
1878} 1885}
1879 1886
1880QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1887QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1881{ 1888{
1882 QValueList <OLedState> vl; 1889 QValueList <OLedState> vl;
1883 1890
1884 if ( l == Led_Mail ) 1891 if ( l == Led_Mail )
1885 vl << Led_Off << Led_On << Led_BlinkSlow; 1892 vl << Led_Off << Led_On << Led_BlinkSlow;
1886 return vl; 1893 return vl;
1887} 1894}
1888 1895
1889OLedState Zaurus::ledState ( OLed which ) const 1896OLedState Zaurus::ledState ( OLed which ) const
1890{ 1897{
1891 if ( which == Led_Mail ) 1898 if ( which == Led_Mail )
1892 return m_leds [0]; 1899 return m_leds [0];
1893 else 1900 else
1894 return Led_Off; 1901 return Led_Off;
1895} 1902}
1896 1903
1897bool Zaurus::setLedState ( OLed which, OLedState st ) 1904bool Zaurus::setLedState ( OLed which, OLedState st )
1898{ 1905{
1899 if (!m_embedix) // Currently not supported on non_embedix kernels 1906 if (!m_embedix) // Currently not supported on non_embedix kernels
1900 return false; 1907 return false;
1901 1908
1902 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1909 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1903 1910
1904 if ( which == Led_Mail ) { 1911 if ( which == Led_Mail ) {
1905 if ( fd >= 0 ) { 1912 if ( fd >= 0 ) {
1906 struct sharp_led_status leds; 1913 struct sharp_led_status leds;
1907 ::memset ( &leds, 0, sizeof( leds )); 1914 ::memset ( &leds, 0, sizeof( leds ));
1908 leds. which = SHARP_LED_MAIL_EXISTS; 1915 leds. which = SHARP_LED_MAIL_EXISTS;
1909 bool ok = true; 1916 bool ok = true;
1910 1917
1911 switch ( st ) { 1918 switch ( st ) {
1912 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1919 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1913 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1920 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1914 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1921 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1915 default : ok = false; 1922 default : ok = false;
1916 } 1923 }
1917 1924
1918 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1925 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1919 m_leds [0] = st; 1926 m_leds [0] = st;
1920 return true; 1927 return true;
1921 } 1928 }
1922 } 1929 }
1923 } 1930 }
1924 return false; 1931 return false;
1925} 1932}
1926 1933
1927bool Zaurus::setSoftSuspend ( bool soft ) 1934bool Zaurus::setSoftSuspend ( bool soft )
1928{ 1935{
1929 if (!m_embedix) { 1936 if (!m_embedix) {
1930 /* non-Embedix kernels dont have kernel autosuspend */ 1937 /* non-Embedix kernels dont have kernel autosuspend */
1931 return ODevice::setSoftSuspend( soft ); 1938 return ODevice::setSoftSuspend( soft );
1932 } 1939 }
1933 1940
1934 bool res = false; 1941 bool res = false;
1935 int fd; 1942 int fd;
1936 1943
1937 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1944 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1938 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1945 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1939 1946
1940 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1947 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1941 1948
1942 if ( sources >= 0 ) { 1949 if ( sources >= 0 ) {
1943 if ( soft ) 1950 if ( soft )
1944 sources &= ~APM_EVT_POWER_BUTTON; 1951 sources &= ~APM_EVT_POWER_BUTTON;
1945 else 1952 else
1946 sources |= APM_EVT_POWER_BUTTON; 1953 sources |= APM_EVT_POWER_BUTTON;
1947 1954
1948 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1955 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1949 res = true; 1956 res = true;
1950 else 1957 else
1951 perror ( "APM_IOCGEVTSRC" ); 1958 perror ( "APM_IOCGEVTSRC" );
1952 } 1959 }
1953 else 1960 else
1954 perror ( "APM_IOCGEVTSRC" ); 1961 perror ( "APM_IOCGEVTSRC" );
1955 1962
1956 ::close ( fd ); 1963 ::close ( fd );
1957 } 1964 }
1958 else 1965 else
1959 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1966 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1960 1967
1961 return res; 1968 return res;
1962} 1969}
1963 1970
1964 1971
1965bool Zaurus::setDisplayBrightness ( int bright ) 1972bool Zaurus::setDisplayBrightness ( int bright )
1966{ 1973{
1967 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 1974 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
1968 bool res = false; 1975 bool res = false;
1969 int fd; 1976 int fd;
1970 1977
1971 if ( bright > 255 ) bright = 255; 1978 if ( bright > 255 ) bright = 255;
1972 if ( bright < 0 ) bright = 0; 1979 if ( bright < 0 ) bright = 0;
1973 1980
1974 if ( m_embedix ) 1981 if ( m_embedix )
1975 { 1982 {
1976 if ( d->m_model == Model_Zaurus_SLC7x0 ) 1983 if ( d->m_model == Model_Zaurus_SLC7x0 )
1977 { 1984 {
1978 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 1985 //qDebug( "using special treatment for devices with the corgi backlight interface" );
1979 // special treatment for devices with the corgi backlight interface 1986 // special treatment for devices with the corgi backlight interface
1980 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 1987 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
1981 { 1988 {
1982 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 1989 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 );
1983 char writeCommand[100]; 1990 char writeCommand[100];
1984 const int count = sprintf( writeCommand, "0x%x\n", value ); 1991 const int count = sprintf( writeCommand, "0x%x\n", value );
1985 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1992 res = ( ::write ( fd, writeCommand, count ) != -1 );
1986 ::close ( fd ); 1993 ::close ( fd );
1987 } 1994 }
1988 return res; 1995 return res;
1989 } 1996 }
1990 else 1997 else
1991 { 1998 {
1992 // standard treatment for devices with the dumb embedix frontlight interface 1999 // standard treatment for devices with the dumb embedix frontlight interface
1993 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 2000 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1994 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 2001 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1995 if ( bright && !bl ) 2002 if ( bright && !bl )
1996 bl = 1; 2003 bl = 1;
1997 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 2004 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1998 ::close ( fd ); 2005 ::close ( fd );
1999 } 2006 }
2000 } 2007 }
2001 } 2008 }
2002 else 2009 else
2003 { 2010 {
2004 // special treatment for the OpenZaurus unified interface 2011 // special treatment for the OpenZaurus unified interface
2005 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 2012 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
2006 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 2013 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
2007 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 2014 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
2008 ::close ( fd ); 2015 ::close ( fd );
2009 } 2016 }
2010 } 2017 }
2011 return res; 2018 return res;
2012} 2019}
2013 2020
2014bool Zaurus::suspend ( ) 2021bool Zaurus::suspend ( )
2015{ 2022{
2016 qDebug("ODevice::suspend"); 2023 qDebug("ODevice::suspend");
2017 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2024 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
2018 return false; 2025 return false;
2019 2026
2020 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 2027 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
2021 return false; 2028 return false;
2022 2029
2023 bool res = false; 2030 bool res = false;
2024 2031
2025 struct timeval tvs, tvn; 2032 struct timeval tvs, tvn;
2026 ::gettimeofday ( &tvs, 0 ); 2033 ::gettimeofday ( &tvs, 0 );
2027 2034
2028 ::sync ( ); // flush fs caches 2035 ::sync ( ); // flush fs caches
2029 res = ( ::system ( "apm --suspend" ) == 0 ); 2036 res = ( ::system ( "apm --suspend" ) == 0 );
2030 2037
2031 // This is needed because the iPAQ apm implementation is asynchronous and we 2038 // This is needed because the iPAQ apm implementation is asynchronous and we
2032 // can not be sure when exactly the device is really suspended 2039 // can not be sure when exactly the device is really suspended
2033 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 2040 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
2034 2041
2035 if ( res ) { 2042 if ( res ) {
2036 do { // Yes, wait 15 seconds. This APM bug sucks big time. 2043 do { // Yes, wait 15 seconds. This APM bug sucks big time.
2037 ::usleep ( 200 * 1000 ); 2044 ::usleep ( 200 * 1000 );
2038 ::gettimeofday ( &tvn, 0 ); 2045 ::gettimeofday ( &tvn, 0 );
2039 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 2046 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
2040 } 2047 }
2041 2048
2042 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 2049 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
2043 return res; 2050 return res;
2044} 2051}
2045 2052
2046 2053
2047Transformation Zaurus::rotation ( ) const 2054Transformation Zaurus::rotation ( ) const
2048{ 2055{
2049 Transformation rot; 2056 Transformation rot;
2050 int handle = 0; 2057 int handle = 0;
2051 int retval = 0; 2058 int retval = 0;
2052 2059
2053 switch ( d-> m_model ) { 2060 switch ( d-> m_model ) {
2054 case Model_Zaurus_SLC7x0: 2061 case Model_Zaurus_SLC7x0:
2055 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2062 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2056 if (handle == -1) { 2063 if (handle == -1) {
2057 return Rot270; 2064 return Rot270;
2058 } else { 2065 } else {
2059 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2066 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2060 ::close (handle); 2067 ::close (handle);
2061 2068
2062 if (retval == 2 ) 2069 if (retval == 2 )
2063 rot = Rot0; 2070 rot = Rot0;
2064 else 2071 else
2065 rot = Rot270; 2072 rot = Rot270;
2066 } 2073 }
2067 break; 2074 break;
2068 case Model_Zaurus_SLA300: 2075 case Model_Zaurus_SLA300:
2069 case Model_Zaurus_SLB600: 2076 case Model_Zaurus_SLB600:
2070 case Model_Zaurus_SL5500: 2077 case Model_Zaurus_SL5500:
2071 case Model_Zaurus_SL5000: 2078 case Model_Zaurus_SL5000:
2072 default: 2079 default:
2073 rot = d-> m_rotation; 2080 rot = d-> m_rotation;
2074 break; 2081 break;
2075 } 2082 }
2076 2083
2077 return rot; 2084 return rot;
2078} 2085}
2079ODirection Zaurus::direction ( ) const 2086ODirection Zaurus::direction ( ) const
2080{ 2087{
2081 ODirection dir; 2088 ODirection dir;
2082 int handle = 0; 2089 int handle = 0;
2083 int retval = 0; 2090 int retval = 0;
2084 switch ( d-> m_model ) { 2091 switch ( d-> m_model ) {
2085 case Model_Zaurus_SLC7x0: 2092 case Model_Zaurus_SLC7x0:
2086 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 2093 handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
2087 if (handle == -1) { 2094 if (handle == -1) {
2088 dir = CW; 2095 dir = CW;
2089 } else { 2096 } else {
2090 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 2097 retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
2091 ::close (handle); 2098 ::close (handle);
2092 if (retval == 2 ) 2099 if (retval == 2 )
2093 dir = CCW; 2100 dir = CCW;
2094 else 2101 else
2095 dir = CW; 2102 dir = CW;
2096 } 2103 }
2097 break; 2104 break;
2098 case Model_Zaurus_SLA300: 2105 case Model_Zaurus_SLA300:
2099 case Model_Zaurus_SLB600: 2106 case Model_Zaurus_SLB600:
2100 case Model_Zaurus_SL5500: 2107 case Model_Zaurus_SL5500:
2101 case Model_Zaurus_SL5000: 2108 case Model_Zaurus_SL5000:
2102 default: 2109 default:
2103 dir = d-> m_direction; 2110 dir = d-> m_direction;
2104 break; 2111 break;
2105 } 2112 }
2106 return dir; 2113 return dir;
2107 2114
2108} 2115}
2109 2116