-rw-r--r-- | libopie/odevice.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 55ba7bd..cea4f35 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -874,390 +874,392 @@ bool iPAQ::setSoftSuspend ( bool soft ) | |||
874 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 874 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
875 | res = true; | 875 | res = true; |
876 | else | 876 | else |
877 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 877 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
878 | 878 | ||
879 | ::close ( fd ); | 879 | ::close ( fd ); |
880 | } | 880 | } |
881 | else | 881 | else |
882 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 882 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
883 | 883 | ||
884 | return res; | 884 | return res; |
885 | } | 885 | } |
886 | 886 | ||
887 | 887 | ||
888 | bool iPAQ::setDisplayBrightness ( int bright ) | 888 | bool iPAQ::setDisplayBrightness ( int bright ) |
889 | { | 889 | { |
890 | bool res = false; | 890 | bool res = false; |
891 | int fd; | 891 | int fd; |
892 | 892 | ||
893 | if ( bright > 255 ) | 893 | if ( bright > 255 ) |
894 | bright = 255; | 894 | bright = 255; |
895 | if ( bright < 0 ) | 895 | if ( bright < 0 ) |
896 | bright = 0; | 896 | bright = 0; |
897 | 897 | ||
898 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 898 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
899 | FLITE_IN bl; | 899 | FLITE_IN bl; |
900 | bl. mode = 1; | 900 | bl. mode = 1; |
901 | bl. pwr = bright ? 1 : 0; | 901 | bl. pwr = bright ? 1 : 0; |
902 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 902 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
903 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 903 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
904 | ::close ( fd ); | 904 | ::close ( fd ); |
905 | } | 905 | } |
906 | return res; | 906 | return res; |
907 | } | 907 | } |
908 | 908 | ||
909 | int iPAQ::displayBrightnessResolution ( ) const | 909 | int iPAQ::displayBrightnessResolution ( ) const |
910 | { | 910 | { |
911 | switch ( model ( )) { | 911 | switch ( model ( )) { |
912 | case Model_iPAQ_H31xx: | 912 | case Model_iPAQ_H31xx: |
913 | case Model_iPAQ_H36xx: | 913 | case Model_iPAQ_H36xx: |
914 | case Model_iPAQ_H37xx: | 914 | case Model_iPAQ_H37xx: |
915 | return 128; // really 256, but >128 could damage the LCD | 915 | return 128; // really 256, but >128 could damage the LCD |
916 | 916 | ||
917 | case Model_iPAQ_H38xx: | 917 | case Model_iPAQ_H38xx: |
918 | case Model_iPAQ_H39xx: | 918 | case Model_iPAQ_H39xx: |
919 | return 64; | 919 | return 64; |
920 | 920 | ||
921 | default: | 921 | default: |
922 | return 2; | 922 | return 2; |
923 | } | 923 | } |
924 | } | 924 | } |
925 | 925 | ||
926 | 926 | ||
927 | bool iPAQ::hasLightSensor ( ) const | 927 | bool iPAQ::hasLightSensor ( ) const |
928 | { | 928 | { |
929 | return true; | 929 | return true; |
930 | } | 930 | } |
931 | 931 | ||
932 | int iPAQ::readLightSensor ( ) | 932 | int iPAQ::readLightSensor ( ) |
933 | { | 933 | { |
934 | int fd; | 934 | int fd; |
935 | int val = -1; | 935 | int val = -1; |
936 | 936 | ||
937 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 937 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
938 | char buffer [8]; | 938 | char buffer [8]; |
939 | 939 | ||
940 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 940 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
941 | char *endptr; | 941 | char *endptr; |
942 | 942 | ||
943 | buffer [4] = 0; | 943 | buffer [4] = 0; |
944 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 944 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
945 | 945 | ||
946 | if ( *endptr != 0 ) | 946 | if ( *endptr != 0 ) |
947 | val = -1; | 947 | val = -1; |
948 | } | 948 | } |
949 | ::close ( fd ); | 949 | ::close ( fd ); |
950 | } | 950 | } |
951 | 951 | ||
952 | return val; | 952 | return val; |
953 | } | 953 | } |
954 | 954 | ||
955 | int iPAQ::lightSensorResolution ( ) const | 955 | int iPAQ::lightSensorResolution ( ) const |
956 | { | 956 | { |
957 | return 256; | 957 | return 256; |
958 | } | 958 | } |
959 | 959 | ||
960 | /************************************************** | 960 | /************************************************** |
961 | * | 961 | * |
962 | * Zaurus | 962 | * Zaurus |
963 | * | 963 | * |
964 | **************************************************/ | 964 | **************************************************/ |
965 | 965 | ||
966 | 966 | ||
967 | 967 | ||
968 | void Zaurus::init ( ) | 968 | void Zaurus::init ( ) |
969 | { | 969 | { |
970 | d-> m_vendorstr = "Sharp"; | 970 | d-> m_vendorstr = "Sharp"; |
971 | d-> m_vendor = Vendor_Sharp; | 971 | d-> m_vendor = Vendor_Sharp; |
972 | 972 | ||
973 | QFile f ( "/proc/filesystems" ); | 973 | QFile f ( "/proc/filesystems" ); |
974 | 974 | ||
975 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 975 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
976 | d-> m_vendorstr = "OpenZaurus Team"; | 976 | d-> m_vendorstr = "OpenZaurus Team"; |
977 | d-> m_systemstr = "OpenZaurus"; | 977 | d-> m_systemstr = "OpenZaurus"; |
978 | d-> m_system = System_OpenZaurus; | 978 | d-> m_system = System_OpenZaurus; |
979 | 979 | ||
980 | f. close ( ); | 980 | f. close ( ); |
981 | 981 | ||
982 | f. setName ( "/etc/oz_version" ); | 982 | f. setName ( "/etc/oz_version" ); |
983 | if ( f. open ( IO_ReadOnly )) { | 983 | if ( f. open ( IO_ReadOnly )) { |
984 | QTextStream ts ( &f ); | 984 | QTextStream ts ( &f ); |
985 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 985 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
986 | f. close ( ); | 986 | f. close ( ); |
987 | } | 987 | } |
988 | } | 988 | } |
989 | else { | 989 | else { |
990 | d-> m_systemstr = "Zaurus"; | 990 | d-> m_systemstr = "Zaurus"; |
991 | d-> m_system = System_Zaurus; | 991 | d-> m_system = System_Zaurus; |
992 | } | 992 | } |
993 | 993 | ||
994 | f. setName ( "/proc/deviceinfo/product" ); | 994 | f. setName ( "/proc/deviceinfo/product" ); |
995 | if ( f. open ( IO_ReadOnly ) ) { | 995 | if ( f. open ( IO_ReadOnly ) ) { |
996 | QTextStream ts ( &f ); | 996 | QTextStream ts ( &f ); |
997 | QString model = ts. readLine ( ); | 997 | QString model = ts. readLine ( ); |
998 | f. close ( ); | 998 | f. close ( ); |
999 | 999 | ||
1000 | d-> m_modelstr = QString("Zaurus ") + model; | 1000 | d-> m_modelstr = QString("Zaurus ") + model; |
1001 | if ( model == "SL-5500" ) | 1001 | if ( model == "SL-5500" ) |
1002 | d-> m_model = Model_Zaurus_SL5500; | 1002 | d-> m_model = Model_Zaurus_SL5500; |
1003 | else if ( model == "SL-C700" ) | 1003 | else if ( model == "SL-C700" ) |
1004 | d-> m_model = Model_Zaurus_SLC700; | 1004 | d-> m_model = Model_Zaurus_SLC700; |
1005 | else if ( model == "SL-A300" ) | 1005 | else if ( model == "SL-A300" ) |
1006 | d-> m_model = Model_Zaurus_SLA300; | 1006 | d-> m_model = Model_Zaurus_SLA300; |
1007 | else if ( model == "SL-B600" || model == "SL-5600" ) | 1007 | else if ( model == "SL-B600" || model == "SL-5600" ) |
1008 | d-> m_model = Model_Zaurus_SLB600; | 1008 | d-> m_model = Model_Zaurus_SLB600; |
1009 | else | 1009 | else |
1010 | d-> m_model = Model_Zaurus_SL5000; | 1010 | d-> m_model = Model_Zaurus_SL5000; |
1011 | } | 1011 | } |
1012 | else { | 1012 | else { |
1013 | d-> m_model = Model_Zaurus_SL5000; | 1013 | d-> m_model = Model_Zaurus_SL5000; |
1014 | d-> m_modelstr = "Zaurus (model unknown)"; | 1014 | d-> m_modelstr = "Zaurus (model unknown)"; |
1015 | } | 1015 | } |
1016 | 1016 | ||
1017 | switch ( d-> m_model ) { | 1017 | switch ( d-> m_model ) { |
1018 | case Model_Zaurus_SLA300: | 1018 | case Model_Zaurus_SLA300: |
1019 | d-> m_rotation = Rot0; | 1019 | d-> m_rotation = Rot0; |
1020 | break; | 1020 | break; |
1021 | case Model_Zaurus_SLC700: | 1021 | case Model_Zaurus_SLC700: |
1022 | /* note for C700, we must check the display rotation | 1022 | /* note for C700, we must check the display rotation |
1023 | * sensor to set an appropriate value | 1023 | * sensor to set an appropriate value |
1024 | */ | 1024 | */ |
1025 | case Model_Zaurus_SLB600: | 1025 | case Model_Zaurus_SLB600: |
1026 | case Model_Zaurus_SL5500: | 1026 | case Model_Zaurus_SL5500: |
1027 | case Model_Zaurus_SL5000: | 1027 | case Model_Zaurus_SL5000: |
1028 | default: | 1028 | default: |
1029 | d-> m_rotation = Rot270; | 1029 | d-> m_rotation = Rot270; |
1030 | break; | 1030 | break; |
1031 | } | 1031 | } |
1032 | m_leds [0] = Led_Off; | 1032 | m_leds [0] = Led_Off; |
1033 | } | 1033 | } |
1034 | 1034 | ||
1035 | void Zaurus::initButtons ( ) | 1035 | void Zaurus::initButtons ( ) |
1036 | { | 1036 | { |
1037 | if ( d-> m_buttons ) | 1037 | if ( d-> m_buttons ) |
1038 | return; | 1038 | return; |
1039 | 1039 | ||
1040 | d-> m_buttons = new QValueList <ODeviceButton>; | 1040 | d-> m_buttons = new QValueList <ODeviceButton>; |
1041 | 1041 | ||
1042 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 1042 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
1043 | z_button *zb = z_buttons + i; | 1043 | z_button *zb = z_buttons + i; |
1044 | ODeviceButton b; | 1044 | ODeviceButton b; |
1045 | 1045 | ||
1046 | b. setKeycode ( zb-> code ); | 1046 | b. setKeycode ( zb-> code ); |
1047 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1047 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1048 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1048 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1049 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1049 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1050 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1050 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1051 | 1051 | ||
1052 | d-> m_buttons-> append ( b ); | 1052 | d-> m_buttons-> append ( b ); |
1053 | } | 1053 | } |
1054 | 1054 | ||
1055 | reloadButtonMapping ( ); | 1055 | reloadButtonMapping ( ); |
1056 | 1056 | ||
1057 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1057 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1058 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1058 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1059 | } | 1059 | } |
1060 | 1060 | ||
1061 | #include <unistd.h> | 1061 | #include <unistd.h> |
1062 | #include <fcntl.h> | 1062 | #include <fcntl.h> |
1063 | #include <sys/ioctl.h> | 1063 | #include <sys/ioctl.h> |
1064 | 1064 | ||
1065 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1065 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1066 | 1066 | ||
1067 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1067 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1068 | 1068 | ||
1069 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1069 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1070 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1070 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1071 | 1071 | ||
1072 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1072 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1073 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1073 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1074 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1074 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1075 | 1075 | ||
1076 | /* --- for SHARP_BUZZER device --- */ | 1076 | /* --- for SHARP_BUZZER device --- */ |
1077 | 1077 | ||
1078 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1078 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1079 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1079 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1080 | 1080 | ||
1081 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1081 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1082 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1082 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1083 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1083 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1084 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1084 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1085 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1085 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1086 | 1086 | ||
1087 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1087 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1088 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1088 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1089 | 1089 | ||
1090 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1090 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1091 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1091 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1092 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1092 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1093 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1093 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1094 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1094 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1095 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1095 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1096 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1096 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1097 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1097 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1098 | 1098 | ||
1099 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1099 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1100 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1100 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1101 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1101 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1102 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1102 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1103 | // | 1103 | // |
1104 | 1104 | ||
1105 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1105 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1106 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1106 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1107 | 1107 | ||
1108 | typedef struct sharp_led_status { | 1108 | typedef struct sharp_led_status { |
1109 | int which; /* select which LED status is wanted. */ | 1109 | int which; /* select which LED status is wanted. */ |
1110 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1110 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1111 | } sharp_led_status; | 1111 | } sharp_led_status; |
1112 | 1112 | ||
1113 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1113 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1114 | 1114 | ||
1115 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1115 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1116 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1116 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1117 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1117 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1118 | 1118 | ||
1119 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1119 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1120 | 1120 | ||
1121 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1121 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1122 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1122 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1123 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1123 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1124 | 1124 | ||
1125 | #define FL_IOCTL_STEP_CONTRAST 100 | 1125 | #define FL_IOCTL_STEP_CONTRAST 100 |
1126 | 1126 | ||
1127 | 1127 | ||
1128 | void Zaurus::buzzer ( int sound ) | 1128 | void Zaurus::buzzer ( int sound ) |
1129 | { | 1129 | { |
1130 | static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); | 1130 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1131 | 1131 | ||
1132 | if ( fd >= 0 ) | 1132 | if ( fd >= 0 ) { |
1133 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1133 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1134 | ::close ( fd ); | ||
1135 | } | ||
1134 | } | 1136 | } |
1135 | 1137 | ||
1136 | 1138 | ||
1137 | void Zaurus::alarmSound ( ) | 1139 | void Zaurus::alarmSound ( ) |
1138 | { | 1140 | { |
1139 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1141 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1140 | } | 1142 | } |
1141 | 1143 | ||
1142 | void Zaurus::touchSound ( ) | 1144 | void Zaurus::touchSound ( ) |
1143 | { | 1145 | { |
1144 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1146 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1145 | } | 1147 | } |
1146 | 1148 | ||
1147 | void Zaurus::keySound ( ) | 1149 | void Zaurus::keySound ( ) |
1148 | { | 1150 | { |
1149 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1151 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1150 | } | 1152 | } |
1151 | 1153 | ||
1152 | 1154 | ||
1153 | QValueList <OLed> Zaurus::ledList ( ) const | 1155 | QValueList <OLed> Zaurus::ledList ( ) const |
1154 | { | 1156 | { |
1155 | QValueList <OLed> vl; | 1157 | QValueList <OLed> vl; |
1156 | vl << Led_Mail; | 1158 | vl << Led_Mail; |
1157 | return vl; | 1159 | return vl; |
1158 | } | 1160 | } |
1159 | 1161 | ||
1160 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1162 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1161 | { | 1163 | { |
1162 | QValueList <OLedState> vl; | 1164 | QValueList <OLedState> vl; |
1163 | 1165 | ||
1164 | if ( l == Led_Mail ) | 1166 | if ( l == Led_Mail ) |
1165 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1167 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1166 | return vl; | 1168 | return vl; |
1167 | } | 1169 | } |
1168 | 1170 | ||
1169 | OLedState Zaurus::ledState ( OLed which ) const | 1171 | OLedState Zaurus::ledState ( OLed which ) const |
1170 | { | 1172 | { |
1171 | if ( which == Led_Mail ) | 1173 | if ( which == Led_Mail ) |
1172 | return m_leds [0]; | 1174 | return m_leds [0]; |
1173 | else | 1175 | else |
1174 | return Led_Off; | 1176 | return Led_Off; |
1175 | } | 1177 | } |
1176 | 1178 | ||
1177 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1179 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1178 | { | 1180 | { |
1179 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1181 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1180 | 1182 | ||
1181 | if ( which == Led_Mail ) { | 1183 | if ( which == Led_Mail ) { |
1182 | if ( fd >= 0 ) { | 1184 | if ( fd >= 0 ) { |
1183 | struct sharp_led_status leds; | 1185 | struct sharp_led_status leds; |
1184 | ::memset ( &leds, 0, sizeof( leds )); | 1186 | ::memset ( &leds, 0, sizeof( leds )); |
1185 | leds. which = SHARP_LED_MAIL_EXISTS; | 1187 | leds. which = SHARP_LED_MAIL_EXISTS; |
1186 | bool ok = true; | 1188 | bool ok = true; |
1187 | 1189 | ||
1188 | switch ( st ) { | 1190 | switch ( st ) { |
1189 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1191 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1190 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1192 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1191 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1193 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1192 | default : ok = false; | 1194 | default : ok = false; |
1193 | } | 1195 | } |
1194 | 1196 | ||
1195 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1197 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1196 | m_leds [0] = st; | 1198 | m_leds [0] = st; |
1197 | return true; | 1199 | return true; |
1198 | } | 1200 | } |
1199 | } | 1201 | } |
1200 | } | 1202 | } |
1201 | return false; | 1203 | return false; |
1202 | } | 1204 | } |
1203 | 1205 | ||
1204 | bool Zaurus::setSoftSuspend ( bool soft ) | 1206 | bool Zaurus::setSoftSuspend ( bool soft ) |
1205 | { | 1207 | { |
1206 | bool res = false; | 1208 | bool res = false; |
1207 | int fd; | 1209 | int fd; |
1208 | 1210 | ||
1209 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1211 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1210 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1212 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1211 | 1213 | ||
1212 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1214 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1213 | 1215 | ||
1214 | if ( sources >= 0 ) { | 1216 | if ( sources >= 0 ) { |
1215 | if ( soft ) | 1217 | if ( soft ) |
1216 | sources &= ~APM_EVT_POWER_BUTTON; | 1218 | sources &= ~APM_EVT_POWER_BUTTON; |
1217 | else | 1219 | else |
1218 | sources |= APM_EVT_POWER_BUTTON; | 1220 | sources |= APM_EVT_POWER_BUTTON; |
1219 | 1221 | ||
1220 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1222 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1221 | res = true; | 1223 | res = true; |
1222 | else | 1224 | else |
1223 | perror ( "APM_IOCGEVTSRC" ); | 1225 | perror ( "APM_IOCGEVTSRC" ); |
1224 | } | 1226 | } |
1225 | else | 1227 | else |
1226 | perror ( "APM_IOCGEVTSRC" ); | 1228 | perror ( "APM_IOCGEVTSRC" ); |
1227 | 1229 | ||
1228 | ::close ( fd ); | 1230 | ::close ( fd ); |
1229 | } | 1231 | } |
1230 | else | 1232 | else |
1231 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1233 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1232 | 1234 | ||
1233 | return res; | 1235 | return res; |
1234 | } | 1236 | } |
1235 | 1237 | ||
1236 | 1238 | ||
1237 | bool Zaurus::setDisplayBrightness ( int bright ) | 1239 | bool Zaurus::setDisplayBrightness ( int bright ) |
1238 | { | 1240 | { |
1239 | bool res = false; | 1241 | bool res = false; |
1240 | int fd; | 1242 | int fd; |
1241 | 1243 | ||
1242 | if ( bright > 255 ) | 1244 | if ( bright > 255 ) |
1243 | bright = 255; | 1245 | bright = 255; |
1244 | if ( bright < 0 ) | 1246 | if ( bright < 0 ) |
1245 | bright = 0; | 1247 | bright = 0; |
1246 | 1248 | ||
1247 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1249 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1248 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1250 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1249 | if ( bright && !bl ) | 1251 | if ( bright && !bl ) |
1250 | bl = 1; | 1252 | bl = 1; |
1251 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1253 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1252 | ::close ( fd ); | 1254 | ::close ( fd ); |
1253 | } | 1255 | } |
1254 | return res; | 1256 | return res; |
1255 | } | 1257 | } |
1256 | 1258 | ||
1257 | 1259 | ||
1258 | int Zaurus::displayBrightnessResolution ( ) const | 1260 | int Zaurus::displayBrightnessResolution ( ) const |
1259 | { | 1261 | { |
1260 | return 5; | 1262 | return 5; |
1261 | } | 1263 | } |
1262 | 1264 | ||
1263 | 1265 | ||