summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
authorkergoth <kergoth>2003-04-01 02:15:50 (UTC)
committer kergoth <kergoth>2003-04-01 02:15:50 (UTC)
commite74e3a64223b5b57ca0c23c77ba06c63e648f09a (patch) (unidiff)
treea3783391e604a49a52d9cbb8d9934ad6f1f8f415 /libopie/odevice.cpp
parentf23b042e2ac0a8b31a51c1059dee281156dd5ce9 (diff)
downloadopie-e74e3a64223b5b57ca0c23c77ba06c63e648f09a.zip
opie-e74e3a64223b5b57ca0c23c77ba06c63e648f09a.tar.gz
opie-e74e3a64223b5b57ca0c23c77ba06c63e648f09a.tar.bz2
Set appropriate default rotation for SL-A300.
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 377945d..55ba7bd 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -890,261 +890,263 @@ bool iPAQ::setDisplayBrightness ( int bright )
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
909int iPAQ::displayBrightnessResolution ( ) const 909int 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
927bool iPAQ::hasLightSensor ( ) const 927bool iPAQ::hasLightSensor ( ) const
928{ 928{
929 return true; 929 return true;
930} 930}
931 931
932int iPAQ::readLightSensor ( ) 932int 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
955int iPAQ::lightSensorResolution ( ) const 955int 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
968void Zaurus::init ( ) 968void 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:
1019 d-> m_rotation = Rot0;
1020 break;
1018 case Model_Zaurus_SLC700: 1021 case Model_Zaurus_SLC700:
1019 /* note for C700, we must check the display rotation 1022 /* note for C700, we must check the display rotation
1020 * sensor to set an appropriate value 1023 * sensor to set an appropriate value
1021 */ 1024 */
1022 case Model_Zaurus_SLA300:
1023 case Model_Zaurus_SLB600: 1025 case Model_Zaurus_SLB600:
1024 case Model_Zaurus_SL5500: 1026 case Model_Zaurus_SL5500:
1025 case Model_Zaurus_SL5000: 1027 case Model_Zaurus_SL5000:
1026 default: 1028 default:
1027 d-> m_rotation = Rot270; 1029 d-> m_rotation = Rot270;
1028 break; 1030 break;
1029 } 1031 }
1030 m_leds [0] = Led_Off; 1032 m_leds [0] = Led_Off;
1031} 1033}
1032 1034
1033void Zaurus::initButtons ( ) 1035void Zaurus::initButtons ( )
1034{ 1036{
1035 if ( d-> m_buttons ) 1037 if ( d-> m_buttons )
1036 return; 1038 return;
1037 1039
1038 d-> m_buttons = new QValueList <ODeviceButton>; 1040 d-> m_buttons = new QValueList <ODeviceButton>;
1039 1041
1040 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++ ) {
1041 z_button *zb = z_buttons + i; 1043 z_button *zb = z_buttons + i;
1042 ODeviceButton b; 1044 ODeviceButton b;
1043 1045
1044 b. setKeycode ( zb-> code ); 1046 b. setKeycode ( zb-> code );
1045 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1047 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1046 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1048 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1047 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1049 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1048 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1050 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1049 1051
1050 d-> m_buttons-> append ( b ); 1052 d-> m_buttons-> append ( b );
1051 } 1053 }
1052 1054
1053 reloadButtonMapping ( ); 1055 reloadButtonMapping ( );
1054 1056
1055 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1057 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1056 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 & )));
1057} 1059}
1058 1060
1059#include <unistd.h> 1061#include <unistd.h>
1060#include <fcntl.h> 1062#include <fcntl.h>
1061#include <sys/ioctl.h> 1063#include <sys/ioctl.h>
1062 1064
1063//#include <asm/sharp_char.h> // including kernel headers is evil ... 1065//#include <asm/sharp_char.h> // including kernel headers is evil ...
1064 1066
1065#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1067#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1066 1068
1067 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1069 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1068#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1070#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1069 1071
1070#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1072#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1071#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1073#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1072#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1074#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1073 1075
1074/* --- for SHARP_BUZZER device --- */ 1076/* --- for SHARP_BUZZER device --- */
1075 1077
1076 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1078 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1077//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1079//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1078 1080
1079#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1081#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1080#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1082#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1081#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1083#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1082#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1084#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1083#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1085#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1084 1086
1085//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1087//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1086//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1088//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1087 1089
1088//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1090//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1089//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1091//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1090//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1092//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1091//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1093//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1092//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1094//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1093//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1095//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1094//#define SHARP_PDA_APPSTART 9 /* application start */ 1096//#define SHARP_PDA_APPSTART 9 /* application start */
1095//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1097//#define SHARP_PDA_APPQUIT 10 /* application ends */
1096 1098
1097//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1099//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1098//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1100//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1099//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1101//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1100//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1102//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1101// 1103//
1102 1104
1103 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1105 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1104#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1106#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1105 1107
1106typedef struct sharp_led_status { 1108typedef struct sharp_led_status {
1107 int which; /* select which LED status is wanted. */ 1109 int which; /* select which LED status is wanted. */
1108 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 */
1109} sharp_led_status; 1111} sharp_led_status;
1110 1112
1111#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1113#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1112 1114
1113#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 */
1114#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1116#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1115#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 */
1116 1118
1117// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1119// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1118 1120
1119#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1121#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1120#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1122#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1121#define APM_EVT_POWER_BUTTON (1 << 0) 1123#define APM_EVT_POWER_BUTTON (1 << 0)
1122 1124
1123#define FL_IOCTL_STEP_CONTRAST 100 1125#define FL_IOCTL_STEP_CONTRAST 100
1124 1126
1125 1127
1126void Zaurus::buzzer ( int sound ) 1128void Zaurus::buzzer ( int sound )
1127{ 1129{
1128 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 1130 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
1129 1131
1130 if ( fd >= 0 ) 1132 if ( fd >= 0 )
1131 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1133 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1132} 1134}
1133 1135
1134 1136
1135void Zaurus::alarmSound ( ) 1137void Zaurus::alarmSound ( )
1136{ 1138{
1137 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1139 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1138} 1140}
1139 1141
1140void Zaurus::touchSound ( ) 1142void Zaurus::touchSound ( )
1141{ 1143{
1142 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1144 buzzer ( SHARP_BUZ_TOUCHSOUND );
1143} 1145}
1144 1146
1145void Zaurus::keySound ( ) 1147void Zaurus::keySound ( )
1146{ 1148{
1147 buzzer ( SHARP_BUZ_KEYSOUND ); 1149 buzzer ( SHARP_BUZ_KEYSOUND );
1148} 1150}
1149 1151
1150 1152