author | mickeyl <mickeyl> | 2003-05-07 13:44:23 (UTC) |
---|---|---|
committer | mickeyl <mickeyl> | 2003-05-07 13:44:23 (UTC) |
commit | 4619398b4712062e65d1919156edea38785c590e (patch) (unidiff) | |
tree | 4d00604960974ca16f9d40468bce4c096e2a76b0 /libopie | |
parent | 83f53eede83728c131b1134ae0a674a7d8f6f00a (diff) | |
download | opie-4619398b4712062e65d1919156edea38785c590e.zip opie-4619398b4712062e65d1919156edea38785c590e.tar.gz opie-4619398b4712062e65d1919156edea38785c590e.tar.bz2 |
fix bug kergoth introduced in rev 1.43
fd was an integer static to the function which means that the assignment only
happens once. This is ok, when we don't close the device, but not if we close
it after usage. Thanks to eilers for confirming! I wonder why noone else spotted this...
-rw-r--r-- | libopie/odevice.cpp | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 62e3569..7d862cd 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -1051,392 +1051,392 @@ bool iPAQ::setDisplayBrightness ( int bright ) | |||
1051 | ::close ( fd ); | 1051 | ::close ( fd ); |
1052 | } | 1052 | } |
1053 | return res; | 1053 | return res; |
1054 | } | 1054 | } |
1055 | 1055 | ||
1056 | int iPAQ::displayBrightnessResolution ( ) const | 1056 | int iPAQ::displayBrightnessResolution ( ) const |
1057 | { | 1057 | { |
1058 | switch ( model ( )) { | 1058 | switch ( model ( )) { |
1059 | case Model_iPAQ_H31xx: | 1059 | case Model_iPAQ_H31xx: |
1060 | case Model_iPAQ_H36xx: | 1060 | case Model_iPAQ_H36xx: |
1061 | case Model_iPAQ_H37xx: | 1061 | case Model_iPAQ_H37xx: |
1062 | return 128; // really 256, but >128 could damage the LCD | 1062 | return 128; // really 256, but >128 could damage the LCD |
1063 | 1063 | ||
1064 | case Model_iPAQ_H38xx: | 1064 | case Model_iPAQ_H38xx: |
1065 | case Model_iPAQ_H39xx: | 1065 | case Model_iPAQ_H39xx: |
1066 | return 64; | 1066 | return 64; |
1067 | 1067 | ||
1068 | default: | 1068 | default: |
1069 | return 2; | 1069 | return 2; |
1070 | } | 1070 | } |
1071 | } | 1071 | } |
1072 | 1072 | ||
1073 | 1073 | ||
1074 | bool iPAQ::hasLightSensor ( ) const | 1074 | bool iPAQ::hasLightSensor ( ) const |
1075 | { | 1075 | { |
1076 | return true; | 1076 | return true; |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | int iPAQ::readLightSensor ( ) | 1079 | int iPAQ::readLightSensor ( ) |
1080 | { | 1080 | { |
1081 | int fd; | 1081 | int fd; |
1082 | int val = -1; | 1082 | int val = -1; |
1083 | 1083 | ||
1084 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1084 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1085 | char buffer [8]; | 1085 | char buffer [8]; |
1086 | 1086 | ||
1087 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1087 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1088 | char *endptr; | 1088 | char *endptr; |
1089 | 1089 | ||
1090 | buffer [4] = 0; | 1090 | buffer [4] = 0; |
1091 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1091 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1092 | 1092 | ||
1093 | if ( *endptr != 0 ) | 1093 | if ( *endptr != 0 ) |
1094 | val = -1; | 1094 | val = -1; |
1095 | } | 1095 | } |
1096 | ::close ( fd ); | 1096 | ::close ( fd ); |
1097 | } | 1097 | } |
1098 | 1098 | ||
1099 | return val; | 1099 | return val; |
1100 | } | 1100 | } |
1101 | 1101 | ||
1102 | int iPAQ::lightSensorResolution ( ) const | 1102 | int iPAQ::lightSensorResolution ( ) const |
1103 | { | 1103 | { |
1104 | return 256; | 1104 | return 256; |
1105 | } | 1105 | } |
1106 | 1106 | ||
1107 | /************************************************** | 1107 | /************************************************** |
1108 | * | 1108 | * |
1109 | * Zaurus | 1109 | * Zaurus |
1110 | * | 1110 | * |
1111 | **************************************************/ | 1111 | **************************************************/ |
1112 | 1112 | ||
1113 | 1113 | ||
1114 | 1114 | ||
1115 | void Zaurus::init ( ) | 1115 | void Zaurus::init ( ) |
1116 | { | 1116 | { |
1117 | d-> m_vendorstr = "Sharp"; | 1117 | d-> m_vendorstr = "Sharp"; |
1118 | d-> m_vendor = Vendor_Sharp; | 1118 | d-> m_vendor = Vendor_Sharp; |
1119 | 1119 | ||
1120 | QFile f ( "/proc/filesystems" ); | 1120 | QFile f ( "/proc/filesystems" ); |
1121 | QString model; | 1121 | QString model; |
1122 | 1122 | ||
1123 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1123 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1124 | d-> m_vendorstr = "OpenZaurus Team"; | 1124 | d-> m_vendorstr = "OpenZaurus Team"; |
1125 | d-> m_systemstr = "OpenZaurus"; | 1125 | d-> m_systemstr = "OpenZaurus"; |
1126 | d-> m_system = System_OpenZaurus; | 1126 | d-> m_system = System_OpenZaurus; |
1127 | 1127 | ||
1128 | f. close ( ); | 1128 | f. close ( ); |
1129 | 1129 | ||
1130 | f. setName ( "/etc/oz_version" ); | 1130 | f. setName ( "/etc/oz_version" ); |
1131 | if ( f. open ( IO_ReadOnly )) { | 1131 | if ( f. open ( IO_ReadOnly )) { |
1132 | QTextStream ts ( &f ); | 1132 | QTextStream ts ( &f ); |
1133 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1133 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1134 | f. close ( ); | 1134 | f. close ( ); |
1135 | } | 1135 | } |
1136 | } | 1136 | } |
1137 | else { | 1137 | else { |
1138 | d-> m_systemstr = "Zaurus"; | 1138 | d-> m_systemstr = "Zaurus"; |
1139 | d-> m_system = System_Zaurus; | 1139 | d-> m_system = System_Zaurus; |
1140 | } | 1140 | } |
1141 | 1141 | ||
1142 | f. setName ( "/proc/cpuinfo" ); | 1142 | f. setName ( "/proc/cpuinfo" ); |
1143 | if ( f. open ( IO_ReadOnly ) ) { | 1143 | if ( f. open ( IO_ReadOnly ) ) { |
1144 | QTextStream ts ( &f ); | 1144 | QTextStream ts ( &f ); |
1145 | QString line; | 1145 | QString line; |
1146 | while( line = ts. readLine ( ) ) { | 1146 | while( line = ts. readLine ( ) ) { |
1147 | if ( line. left ( 8 ) == "Hardware" ) | 1147 | if ( line. left ( 8 ) == "Hardware" ) |
1148 | break; | 1148 | break; |
1149 | } | 1149 | } |
1150 | int loc = line. find ( ":" ); | 1150 | int loc = line. find ( ":" ); |
1151 | if ( loc != -1 ) | 1151 | if ( loc != -1 ) |
1152 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1152 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1153 | } | 1153 | } |
1154 | 1154 | ||
1155 | if ( model == "SHARP Corgi" ) { | 1155 | if ( model == "SHARP Corgi" ) { |
1156 | d-> m_model = Model_Zaurus_SLC700; | 1156 | d-> m_model = Model_Zaurus_SLC700; |
1157 | d-> m_modelstr = "Zaurus SL-C700"; | 1157 | d-> m_modelstr = "Zaurus SL-C700"; |
1158 | } else if ( model == "SHARP Poodle" ) { | 1158 | } else if ( model == "SHARP Poodle" ) { |
1159 | d-> m_model = Model_Zaurus_SLB600; | 1159 | d-> m_model = Model_Zaurus_SLB600; |
1160 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1160 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1161 | } else if ( model = "Sharp-Collie" ) { | 1161 | } else if ( model = "Sharp-Collie" ) { |
1162 | d-> m_model = Model_Zaurus_SL5500; | 1162 | d-> m_model = Model_Zaurus_SL5500; |
1163 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1163 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1164 | } else { | 1164 | } else { |
1165 | d-> m_model = Model_Zaurus_SL5500; | 1165 | d-> m_model = Model_Zaurus_SL5500; |
1166 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1166 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1167 | } | 1167 | } |
1168 | 1168 | ||
1169 | bool flipstate = false; | 1169 | bool flipstate = false; |
1170 | switch ( d-> m_model ) { | 1170 | switch ( d-> m_model ) { |
1171 | case Model_Zaurus_SLA300: | 1171 | case Model_Zaurus_SLA300: |
1172 | d-> m_rotation = Rot0; | 1172 | d-> m_rotation = Rot0; |
1173 | break; | 1173 | break; |
1174 | case Model_Zaurus_SLC700: | 1174 | case Model_Zaurus_SLC700: |
1175 | // Note: need to 1) set flipstate based on physical screen orientation | 1175 | // Note: need to 1) set flipstate based on physical screen orientation |
1176 | // and 2) check to see if the user overrode the rotation direction | 1176 | // and 2) check to see if the user overrode the rotation direction |
1177 | // using appearance, and if so, remove that item from the Config to | 1177 | // using appearance, and if so, remove that item from the Config to |
1178 | // ensure the rotate applet flips us back to the previous state. | 1178 | // ensure the rotate applet flips us back to the previous state. |
1179 | if ( flipstate ) { | 1179 | if ( flipstate ) { |
1180 | // 480x640 | 1180 | // 480x640 |
1181 | d-> m_rotation = Rot0; | 1181 | d-> m_rotation = Rot0; |
1182 | d-> m_direction = CW; | 1182 | d-> m_direction = CW; |
1183 | } else { | 1183 | } else { |
1184 | // 640x480 | 1184 | // 640x480 |
1185 | d-> m_rotation = Rot270; | 1185 | d-> m_rotation = Rot270; |
1186 | d-> m_direction = CCW; | 1186 | d-> m_direction = CCW; |
1187 | } | 1187 | } |
1188 | break; | 1188 | break; |
1189 | case Model_Zaurus_SLB600: | 1189 | case Model_Zaurus_SLB600: |
1190 | case Model_Zaurus_SL5500: | 1190 | case Model_Zaurus_SL5500: |
1191 | case Model_Zaurus_SL5000: | 1191 | case Model_Zaurus_SL5000: |
1192 | default: | 1192 | default: |
1193 | d-> m_rotation = Rot270; | 1193 | d-> m_rotation = Rot270; |
1194 | break; | 1194 | break; |
1195 | } | 1195 | } |
1196 | m_leds [0] = Led_Off; | 1196 | m_leds [0] = Led_Off; |
1197 | } | 1197 | } |
1198 | 1198 | ||
1199 | void Zaurus::initButtons ( ) | 1199 | void Zaurus::initButtons ( ) |
1200 | { | 1200 | { |
1201 | if ( d-> m_buttons ) | 1201 | if ( d-> m_buttons ) |
1202 | return; | 1202 | return; |
1203 | 1203 | ||
1204 | d-> m_buttons = new QValueList <ODeviceButton>; | 1204 | d-> m_buttons = new QValueList <ODeviceButton>; |
1205 | 1205 | ||
1206 | struct z_button * pz_buttons; | 1206 | struct z_button * pz_buttons; |
1207 | int buttoncount; | 1207 | int buttoncount; |
1208 | switch ( d-> m_model ) { | 1208 | switch ( d-> m_model ) { |
1209 | case Model_Zaurus_SLC700: | 1209 | case Model_Zaurus_SLC700: |
1210 | pz_buttons = z_buttons_c700; | 1210 | pz_buttons = z_buttons_c700; |
1211 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1211 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1212 | break; | 1212 | break; |
1213 | default: | 1213 | default: |
1214 | pz_buttons = z_buttons; | 1214 | pz_buttons = z_buttons; |
1215 | buttoncount = ARRAY_SIZE(z_buttons); | 1215 | buttoncount = ARRAY_SIZE(z_buttons); |
1216 | break; | 1216 | break; |
1217 | } | 1217 | } |
1218 | 1218 | ||
1219 | for ( int i = 0; i < buttoncount; i++ ) { | 1219 | for ( int i = 0; i < buttoncount; i++ ) { |
1220 | struct z_button *zb = pz_buttons + i; | 1220 | struct z_button *zb = pz_buttons + i; |
1221 | ODeviceButton b; | 1221 | ODeviceButton b; |
1222 | 1222 | ||
1223 | b. setKeycode ( zb-> code ); | 1223 | b. setKeycode ( zb-> code ); |
1224 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1224 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1225 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1225 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1226 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1226 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1227 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1227 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1228 | 1228 | ||
1229 | d-> m_buttons-> append ( b ); | 1229 | d-> m_buttons-> append ( b ); |
1230 | } | 1230 | } |
1231 | 1231 | ||
1232 | reloadButtonMapping ( ); | 1232 | reloadButtonMapping ( ); |
1233 | 1233 | ||
1234 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1234 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1235 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1235 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1236 | } | 1236 | } |
1237 | 1237 | ||
1238 | #include <unistd.h> | 1238 | #include <unistd.h> |
1239 | #include <fcntl.h> | 1239 | #include <fcntl.h> |
1240 | #include <sys/ioctl.h> | 1240 | #include <sys/ioctl.h> |
1241 | 1241 | ||
1242 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1242 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1243 | 1243 | ||
1244 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1244 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1245 | 1245 | ||
1246 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1246 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1247 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1247 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1248 | 1248 | ||
1249 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1249 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1250 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1250 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1251 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1251 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1252 | 1252 | ||
1253 | /* --- for SHARP_BUZZER device --- */ | 1253 | /* --- for SHARP_BUZZER device --- */ |
1254 | 1254 | ||
1255 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1255 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1256 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1256 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1257 | 1257 | ||
1258 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1258 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1259 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1259 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1260 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1260 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1261 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1261 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1262 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1262 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1263 | 1263 | ||
1264 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1264 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1265 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1265 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1266 | 1266 | ||
1267 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1267 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1268 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1268 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1269 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1269 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1270 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1270 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1271 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1271 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1272 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1272 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1273 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1273 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1274 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1274 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1275 | 1275 | ||
1276 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1276 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1277 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1277 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1278 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1278 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1279 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1279 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1280 | // | 1280 | // |
1281 | 1281 | ||
1282 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1282 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1283 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1283 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1284 | 1284 | ||
1285 | typedef struct sharp_led_status { | 1285 | typedef struct sharp_led_status { |
1286 | int which; /* select which LED status is wanted. */ | 1286 | int which; /* select which LED status is wanted. */ |
1287 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1287 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1288 | } sharp_led_status; | 1288 | } sharp_led_status; |
1289 | 1289 | ||
1290 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1290 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1291 | 1291 | ||
1292 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1292 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1293 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1293 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1294 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1294 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1295 | 1295 | ||
1296 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1296 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1297 | 1297 | ||
1298 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1298 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1299 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1299 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1300 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1300 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1301 | 1301 | ||
1302 | #define FL_IOCTL_STEP_CONTRAST 100 | 1302 | #define FL_IOCTL_STEP_CONTRAST 100 |
1303 | 1303 | ||
1304 | 1304 | ||
1305 | void Zaurus::buzzer ( int sound ) | 1305 | void Zaurus::buzzer ( int sound ) |
1306 | { | 1306 | { |
1307 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1307 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1308 | 1308 | ||
1309 | if ( fd >= 0 ) { | 1309 | if ( fd >= 0 ) { |
1310 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1310 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1311 | ::close ( fd ); | 1311 | ::close ( fd ); |
1312 | } | 1312 | } |
1313 | } | 1313 | } |
1314 | 1314 | ||
1315 | 1315 | ||
1316 | void Zaurus::alarmSound ( ) | 1316 | void Zaurus::alarmSound ( ) |
1317 | { | 1317 | { |
1318 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1318 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1319 | } | 1319 | } |
1320 | 1320 | ||
1321 | void Zaurus::touchSound ( ) | 1321 | void Zaurus::touchSound ( ) |
1322 | { | 1322 | { |
1323 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1323 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1324 | } | 1324 | } |
1325 | 1325 | ||
1326 | void Zaurus::keySound ( ) | 1326 | void Zaurus::keySound ( ) |
1327 | { | 1327 | { |
1328 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1328 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1329 | } | 1329 | } |
1330 | 1330 | ||
1331 | 1331 | ||
1332 | QValueList <OLed> Zaurus::ledList ( ) const | 1332 | QValueList <OLed> Zaurus::ledList ( ) const |
1333 | { | 1333 | { |
1334 | QValueList <OLed> vl; | 1334 | QValueList <OLed> vl; |
1335 | vl << Led_Mail; | 1335 | vl << Led_Mail; |
1336 | return vl; | 1336 | return vl; |
1337 | } | 1337 | } |
1338 | 1338 | ||
1339 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1339 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1340 | { | 1340 | { |
1341 | QValueList <OLedState> vl; | 1341 | QValueList <OLedState> vl; |
1342 | 1342 | ||
1343 | if ( l == Led_Mail ) | 1343 | if ( l == Led_Mail ) |
1344 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1344 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1345 | return vl; | 1345 | return vl; |
1346 | } | 1346 | } |
1347 | 1347 | ||
1348 | OLedState Zaurus::ledState ( OLed which ) const | 1348 | OLedState Zaurus::ledState ( OLed which ) const |
1349 | { | 1349 | { |
1350 | if ( which == Led_Mail ) | 1350 | if ( which == Led_Mail ) |
1351 | return m_leds [0]; | 1351 | return m_leds [0]; |
1352 | else | 1352 | else |
1353 | return Led_Off; | 1353 | return Led_Off; |
1354 | } | 1354 | } |
1355 | 1355 | ||
1356 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1356 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1357 | { | 1357 | { |
1358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1358 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1359 | 1359 | ||
1360 | if ( which == Led_Mail ) { | 1360 | if ( which == Led_Mail ) { |
1361 | if ( fd >= 0 ) { | 1361 | if ( fd >= 0 ) { |
1362 | struct sharp_led_status leds; | 1362 | struct sharp_led_status leds; |
1363 | ::memset ( &leds, 0, sizeof( leds )); | 1363 | ::memset ( &leds, 0, sizeof( leds )); |
1364 | leds. which = SHARP_LED_MAIL_EXISTS; | 1364 | leds. which = SHARP_LED_MAIL_EXISTS; |
1365 | bool ok = true; | 1365 | bool ok = true; |
1366 | 1366 | ||
1367 | switch ( st ) { | 1367 | switch ( st ) { |
1368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1368 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1369 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1370 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1371 | default : ok = false; | 1371 | default : ok = false; |
1372 | } | 1372 | } |
1373 | 1373 | ||
1374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1374 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1375 | m_leds [0] = st; | 1375 | m_leds [0] = st; |
1376 | return true; | 1376 | return true; |
1377 | } | 1377 | } |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | return false; | 1380 | return false; |
1381 | } | 1381 | } |
1382 | 1382 | ||
1383 | bool Zaurus::setSoftSuspend ( bool soft ) | 1383 | bool Zaurus::setSoftSuspend ( bool soft ) |
1384 | { | 1384 | { |
1385 | bool res = false; | 1385 | bool res = false; |
1386 | int fd; | 1386 | int fd; |
1387 | 1387 | ||
1388 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1388 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1389 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1389 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1390 | 1390 | ||
1391 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1391 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1392 | 1392 | ||
1393 | if ( sources >= 0 ) { | 1393 | if ( sources >= 0 ) { |
1394 | if ( soft ) | 1394 | if ( soft ) |
1395 | sources &= ~APM_EVT_POWER_BUTTON; | 1395 | sources &= ~APM_EVT_POWER_BUTTON; |
1396 | else | 1396 | else |
1397 | sources |= APM_EVT_POWER_BUTTON; | 1397 | sources |= APM_EVT_POWER_BUTTON; |
1398 | 1398 | ||
1399 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1399 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1400 | res = true; | 1400 | res = true; |
1401 | else | 1401 | else |
1402 | perror ( "APM_IOCGEVTSRC" ); | 1402 | perror ( "APM_IOCGEVTSRC" ); |
1403 | } | 1403 | } |
1404 | else | 1404 | else |
1405 | perror ( "APM_IOCGEVTSRC" ); | 1405 | perror ( "APM_IOCGEVTSRC" ); |
1406 | 1406 | ||
1407 | ::close ( fd ); | 1407 | ::close ( fd ); |
1408 | } | 1408 | } |
1409 | else | 1409 | else |
1410 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1410 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1411 | 1411 | ||
1412 | return res; | 1412 | return res; |
1413 | } | 1413 | } |
1414 | 1414 | ||
1415 | 1415 | ||
1416 | bool Zaurus::setDisplayBrightness ( int bright ) | 1416 | bool Zaurus::setDisplayBrightness ( int bright ) |
1417 | { | 1417 | { |
1418 | bool res = false; | 1418 | bool res = false; |
1419 | int fd; | 1419 | int fd; |
1420 | 1420 | ||
1421 | if ( bright > 255 ) | 1421 | if ( bright > 255 ) |
1422 | bright = 255; | 1422 | bright = 255; |
1423 | if ( bright < 0 ) | 1423 | if ( bright < 0 ) |
1424 | bright = 0; | 1424 | bright = 0; |
1425 | 1425 | ||
1426 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1426 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1427 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1427 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1428 | if ( bright && !bl ) | 1428 | if ( bright && !bl ) |
1429 | bl = 1; | 1429 | bl = 1; |
1430 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1430 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1431 | ::close ( fd ); | 1431 | ::close ( fd ); |
1432 | } | 1432 | } |
1433 | return res; | 1433 | return res; |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | 1436 | ||
1437 | int Zaurus::displayBrightnessResolution ( ) const | 1437 | int Zaurus::displayBrightnessResolution ( ) const |
1438 | { | 1438 | { |
1439 | return 5; | 1439 | return 5; |
1440 | } | 1440 | } |
1441 | 1441 | ||
1442 | 1442 | ||