summaryrefslogtreecommitdiff
path: root/libopie
authoreilers <eilers>2003-11-17 17:27:44 (UTC)
committer eilers <eilers>2003-11-17 17:27:44 (UTC)
commite8bba52dc9443d3aadcc2c221fa62ba37ea5c712 (patch) (unidiff)
treeddd09027e169cecb392fb7d956f55631d5bf4ef7 /libopie
parent2e6030553ecc21845ebb9987dffd6c252760a94d (diff)
downloadopie-e8bba52dc9443d3aadcc2c221fa62ba37ea5c712.zip
opie-e8bba52dc9443d3aadcc2c221fa62ba37ea5c712.tar.gz
opie-e8bba52dc9443d3aadcc2c221fa62ba37ea5c712.tar.bz2
Merging the corgie-patches from Branch manually.. (no cvs -j would caused
a big mess .. ;) ) Changed the keysound handling for zaurus: Just all C7x0 and the 5600 will use the sounddevice.. All other will use the old /dev/sharp_buz device..
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index fef623a..58254a7 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -947,1005 +947,1008 @@ void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
947 947
948 ODeviceButton &b = ( *d-> m_buttons ) [button]; 948 ODeviceButton &b = ( *d-> m_buttons ) [button];
949 b. setPressedAction ( action ); 949 b. setPressedAction ( action );
950 950
951 mb_chan=b. pressedAction ( ). channel ( ); 951 mb_chan=b. pressedAction ( ). channel ( );
952 952
953 Config buttonFile ( "ButtonSettings" ); 953 Config buttonFile ( "ButtonSettings" );
954 buttonFile. setGroup ( "Button" + QString::number ( button )); 954 buttonFile. setGroup ( "Button" + QString::number ( button ));
955 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 955 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
956 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 956 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
957 957
958 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 958 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
959 959
960 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 960 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
961} 961}
962 962
963void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 963void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
964{ 964{
965 initButtons ( ); 965 initButtons ( );
966 966
967 if ( button >= (int) d-> m_buttons-> count ( )) 967 if ( button >= (int) d-> m_buttons-> count ( ))
968 return; 968 return;
969 969
970 ODeviceButton &b = ( *d-> m_buttons ) [button]; 970 ODeviceButton &b = ( *d-> m_buttons ) [button];
971 b. setHeldAction ( action ); 971 b. setHeldAction ( action );
972 972
973 Config buttonFile ( "ButtonSettings" ); 973 Config buttonFile ( "ButtonSettings" );
974 buttonFile. setGroup ( "Button" + QString::number ( button )); 974 buttonFile. setGroup ( "Button" + QString::number ( button ));
975 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 975 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
976 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 976 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
977 977
978 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 978 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
979 979
980 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 980 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
981} 981}
982void ODevice::virtual_hook(int, void* ){ 982void ODevice::virtual_hook(int, void* ){
983 983
984} 984}
985 985
986/************************************************** 986/**************************************************
987 * 987 *
988 * Yopy 3500/3700 988 * Yopy 3500/3700
989 * 989 *
990 **************************************************/ 990 **************************************************/
991 991
992bool Yopy::isYopy ( ) 992bool Yopy::isYopy ( )
993{ 993{
994 QFile f( "/proc/cpuinfo" ); 994 QFile f( "/proc/cpuinfo" );
995 if ( f. open ( IO_ReadOnly ) ) { 995 if ( f. open ( IO_ReadOnly ) ) {
996 QTextStream ts ( &f ); 996 QTextStream ts ( &f );
997 QString line; 997 QString line;
998 while( line = ts. readLine ( ) ) { 998 while( line = ts. readLine ( ) ) {
999 if ( line. left ( 8 ) == "Hardware" ) { 999 if ( line. left ( 8 ) == "Hardware" ) {
1000 int loc = line. find ( ":" ); 1000 int loc = line. find ( ":" );
1001 if ( loc != -1 ) { 1001 if ( loc != -1 ) {
1002 QString model = 1002 QString model =
1003 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1003 line. mid ( loc + 2 ). simplifyWhiteSpace( );
1004 return ( model == "Yopy" ); 1004 return ( model == "Yopy" );
1005 } 1005 }
1006 } 1006 }
1007 } 1007 }
1008 } 1008 }
1009 return false; 1009 return false;
1010} 1010}
1011 1011
1012void Yopy::init ( ) 1012void Yopy::init ( )
1013{ 1013{
1014 d-> m_vendorstr = "G.Mate"; 1014 d-> m_vendorstr = "G.Mate";
1015 d-> m_vendor = Vendor_GMate; 1015 d-> m_vendor = Vendor_GMate;
1016 d-> m_modelstr = "Yopy3700"; 1016 d-> m_modelstr = "Yopy3700";
1017 d-> m_model = Model_Yopy_3700; 1017 d-> m_model = Model_Yopy_3700;
1018 d-> m_rotation = Rot0; 1018 d-> m_rotation = Rot0;
1019 1019
1020 d-> m_systemstr = "Linupy"; 1020 d-> m_systemstr = "Linupy";
1021 d-> m_system = System_Linupy; 1021 d-> m_system = System_Linupy;
1022 1022
1023 QFile f ( "/etc/issue" ); 1023 QFile f ( "/etc/issue" );
1024 if ( f. open ( IO_ReadOnly )) { 1024 if ( f. open ( IO_ReadOnly )) {
1025 QTextStream ts ( &f ); 1025 QTextStream ts ( &f );
1026 ts.readLine(); 1026 ts.readLine();
1027 d-> m_sysverstr = ts. readLine ( ); 1027 d-> m_sysverstr = ts. readLine ( );
1028 f. close ( ); 1028 f. close ( );
1029 } 1029 }
1030} 1030}
1031 1031
1032void Yopy::initButtons ( ) 1032void Yopy::initButtons ( )
1033{ 1033{
1034 if ( d-> m_buttons ) 1034 if ( d-> m_buttons )
1035 return; 1035 return;
1036 1036
1037 d-> m_buttons = new QValueList <ODeviceButton>; 1037 d-> m_buttons = new QValueList <ODeviceButton>;
1038 1038
1039 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1039 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1040 1040
1041 yopy_button *ib = yopy_buttons + i; 1041 yopy_button *ib = yopy_buttons + i;
1042 1042
1043 ODeviceButton b; 1043 ODeviceButton b;
1044 1044
1045 b. setKeycode ( ib-> code ); 1045 b. setKeycode ( ib-> code );
1046 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1046 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1047 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1047 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1048 b. setFactoryPresetPressedAction 1048 b. setFactoryPresetPressedAction
1049 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1049 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1050 b. setFactoryPresetHeldAction 1050 b. setFactoryPresetHeldAction
1051 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1051 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1052 1052
1053 d-> m_buttons-> append ( b ); 1053 d-> m_buttons-> append ( b );
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 & )), 1058 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1059 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1059 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1060} 1060}
1061 1061
1062bool Yopy::suspend() 1062bool Yopy::suspend()
1063{ 1063{
1064 /* Opie for Yopy does not implement its own power management at the 1064 /* Opie for Yopy does not implement its own power management at the
1065 moment. The public version runs parallel to X, and relies on the 1065 moment. The public version runs parallel to X, and relies on the
1066 existing power management features. */ 1066 existing power management features. */
1067 return false; 1067 return false;
1068} 1068}
1069 1069
1070bool Yopy::setDisplayBrightness(int bright) 1070bool Yopy::setDisplayBrightness(int bright)
1071{ 1071{
1072 /* The code here works, but is disabled as the current version runs 1072 /* The code here works, but is disabled as the current version runs
1073 parallel to X, and relies on the existing backlight demon. */ 1073 parallel to X, and relies on the existing backlight demon. */
1074#if 0 1074#if 0
1075 if ( QFile::exists("/proc/sys/pm/light") ) { 1075 if ( QFile::exists("/proc/sys/pm/light") ) {
1076 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1076 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1077 if (fd >= 0 ) { 1077 if (fd >= 0 ) {
1078 if (bright) 1078 if (bright)
1079 ::write(fd, "1\n", 2); 1079 ::write(fd, "1\n", 2);
1080 else 1080 else
1081 ::write(fd, "0\n", 2); 1081 ::write(fd, "0\n", 2);
1082 ::close(fd); 1082 ::close(fd);
1083 return true; 1083 return true;
1084 } 1084 }
1085 } 1085 }
1086#endif 1086#endif
1087 return false; 1087 return false;
1088} 1088}
1089 1089
1090int Yopy::displayBrightnessResolution() const 1090int Yopy::displayBrightnessResolution() const
1091{ 1091{
1092 return 2; 1092 return 2;
1093} 1093}
1094 1094
1095/************************************************** 1095/**************************************************
1096 * 1096 *
1097 * iPAQ 1097 * iPAQ
1098 * 1098 *
1099 **************************************************/ 1099 **************************************************/
1100 1100
1101void iPAQ::init ( ) 1101void iPAQ::init ( )
1102{ 1102{
1103 d-> m_vendorstr = "HP"; 1103 d-> m_vendorstr = "HP";
1104 d-> m_vendor = Vendor_HP; 1104 d-> m_vendor = Vendor_HP;
1105 1105
1106 QFile f ( "/proc/hal/model" ); 1106 QFile f ( "/proc/hal/model" );
1107 1107
1108 if ( f. open ( IO_ReadOnly )) { 1108 if ( f. open ( IO_ReadOnly )) {
1109 QTextStream ts ( &f ); 1109 QTextStream ts ( &f );
1110 1110
1111 d-> m_modelstr = "H" + ts. readLine ( ); 1111 d-> m_modelstr = "H" + ts. readLine ( );
1112 1112
1113 if ( d-> m_modelstr == "H3100" ) 1113 if ( d-> m_modelstr == "H3100" )
1114 d-> m_model = Model_iPAQ_H31xx; 1114 d-> m_model = Model_iPAQ_H31xx;
1115 else if ( d-> m_modelstr == "H3600" ) 1115 else if ( d-> m_modelstr == "H3600" )
1116 d-> m_model = Model_iPAQ_H36xx; 1116 d-> m_model = Model_iPAQ_H36xx;
1117 else if ( d-> m_modelstr == "H3700" ) 1117 else if ( d-> m_modelstr == "H3700" )
1118 d-> m_model = Model_iPAQ_H37xx; 1118 d-> m_model = Model_iPAQ_H37xx;
1119 else if ( d-> m_modelstr == "H3800" ) 1119 else if ( d-> m_modelstr == "H3800" )
1120 d-> m_model = Model_iPAQ_H38xx; 1120 d-> m_model = Model_iPAQ_H38xx;
1121 else if ( d-> m_modelstr == "H3900" ) 1121 else if ( d-> m_modelstr == "H3900" )
1122 d-> m_model = Model_iPAQ_H39xx; 1122 d-> m_model = Model_iPAQ_H39xx;
1123 else if ( d-> m_modelstr == "H5400" ) 1123 else if ( d-> m_modelstr == "H5400" )
1124 d-> m_model = Model_iPAQ_H5xxx; 1124 d-> m_model = Model_iPAQ_H5xxx;
1125 else 1125 else
1126 d-> m_model = Model_Unknown; 1126 d-> m_model = Model_Unknown;
1127 1127
1128 f. close ( ); 1128 f. close ( );
1129 } 1129 }
1130 1130
1131 switch ( d-> m_model ) { 1131 switch ( d-> m_model ) {
1132 case Model_iPAQ_H31xx: 1132 case Model_iPAQ_H31xx:
1133 case Model_iPAQ_H38xx: 1133 case Model_iPAQ_H38xx:
1134 d-> m_rotation = Rot90; 1134 d-> m_rotation = Rot90;
1135 break; 1135 break;
1136 case Model_iPAQ_H36xx: 1136 case Model_iPAQ_H36xx:
1137 case Model_iPAQ_H37xx: 1137 case Model_iPAQ_H37xx:
1138 case Model_iPAQ_H39xx: 1138 case Model_iPAQ_H39xx:
1139
1139 default: 1140 default:
1140 d-> m_rotation = Rot270; 1141 d-> m_rotation = Rot270;
1141 break; 1142 break;
1142 case Model_iPAQ_H5xxx: 1143 case Model_iPAQ_H5xxx:
1143 d-> m_rotation = Rot0; 1144 d-> m_rotation = Rot0;
1144 } 1145 }
1145 1146
1146 f. setName ( "/etc/familiar-version" ); 1147 f. setName ( "/etc/familiar-version" );
1147 if ( f. open ( IO_ReadOnly )) { 1148 if ( f. open ( IO_ReadOnly )) {
1148 d-> m_systemstr = "Familiar"; 1149 d-> m_systemstr = "Familiar";
1149 d-> m_system = System_Familiar; 1150 d-> m_system = System_Familiar;
1150 1151
1151 QTextStream ts ( &f ); 1152 QTextStream ts ( &f );
1152 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1153 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1153 1154
1154 f. close ( ); 1155 f. close ( );
1155 } else { 1156 } else {
1156 f. setName ( "/etc/oz_version" ); 1157 f. setName ( "/etc/oz_version" );
1157 1158
1158 if ( f. open ( IO_ReadOnly )) { 1159 if ( f. open ( IO_ReadOnly )) {
1159 d-> m_systemstr = "OpenEmbedded/iPaq"; 1160 d-> m_systemstr = "OpenEmbedded/iPaq";
1160 d-> m_system = System_Familiar; 1161 d-> m_system = System_Familiar;
1161 1162
1162 QTextStream ts ( &f ); 1163 QTextStream ts ( &f );
1163 ts.setDevice ( &f ); 1164 ts.setDevice ( &f );
1164 d-> m_sysverstr = ts. readLine ( ); 1165 d-> m_sysverstr = ts. readLine ( );
1165 f. close ( ); 1166 f. close ( );
1166 } 1167 }
1167 } 1168 }
1168 1169
1169 1170
1170 1171
1171 1172
1172 1173
1173 m_leds [0] = m_leds [1] = Led_Off; 1174 m_leds [0] = m_leds [1] = Led_Off;
1174 1175
1175 m_power_timer = 0; 1176 m_power_timer = 0;
1176 1177
1177} 1178}
1178 1179
1179void iPAQ::initButtons ( ) 1180void iPAQ::initButtons ( )
1180{ 1181{
1181 if ( d-> m_buttons ) 1182 if ( d-> m_buttons )
1182 return; 1183 return;
1183 1184
1184 if ( isQWS( ) ) 1185 if ( isQWS( ) )
1185 QWSServer::setKeyboardFilter ( this ); 1186 QWSServer::setKeyboardFilter ( this );
1186 1187
1187 d-> m_buttons = new QValueList <ODeviceButton>; 1188 d-> m_buttons = new QValueList <ODeviceButton>;
1188 1189
1189 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1190 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1190 i_button *ib = ipaq_buttons + i; 1191 i_button *ib = ipaq_buttons + i;
1191 ODeviceButton b; 1192 ODeviceButton b;
1192 1193
1193 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1194 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1194 b. setKeycode ( ib-> code ); 1195 b. setKeycode ( ib-> code );
1195 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1196 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1196 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1197 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1197 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1198 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1198 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1199 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1199 1200
1200 d-> m_buttons-> append ( b ); 1201 d-> m_buttons-> append ( b );
1201 } 1202 }
1202 } 1203 }
1203 reloadButtonMapping ( ); 1204 reloadButtonMapping ( );
1204 1205
1205 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1206 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1206 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1207 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1207} 1208}
1208 1209
1209 1210
1210//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1211//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1211 1212
1212typedef struct { 1213typedef struct {
1213 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1214 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1214 unsigned char TotalTime; /* Units of 5 seconds */ 1215 unsigned char TotalTime; /* Units of 5 seconds */
1215 unsigned char OnTime; /* units of 100m/s */ 1216 unsigned char OnTime; /* units of 100m/s */
1216 unsigned char OffTime; /* units of 100m/s */ 1217 unsigned char OffTime; /* units of 100m/s */
1217} LED_IN; 1218} LED_IN;
1218 1219
1219typedef struct { 1220typedef struct {
1220 unsigned char mode; 1221 unsigned char mode;
1221 unsigned char pwr; 1222 unsigned char pwr;
1222 unsigned char brightness; 1223 unsigned char brightness;
1223} FLITE_IN; 1224} FLITE_IN;
1224 1225
1225#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1226#define LED_ON OD_IOW( 'f', 5, LED_IN )
1226#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1227#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1227 1228
1228 1229
1229QValueList <OLed> iPAQ::ledList ( ) const 1230QValueList <OLed> iPAQ::ledList ( ) const
1230{ 1231{
1231 QValueList <OLed> vl; 1232 QValueList <OLed> vl;
1232 vl << Led_Power; 1233 vl << Led_Power;
1233 1234
1234 if ( d-> m_model == Model_iPAQ_H38xx ) 1235 if ( d-> m_model == Model_iPAQ_H38xx )
1235 vl << Led_BlueTooth; 1236 vl << Led_BlueTooth;
1236 return vl; 1237 return vl;
1237} 1238}
1238 1239
1239QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1240QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1240{ 1241{
1241 QValueList <OLedState> vl; 1242 QValueList <OLedState> vl;
1242 1243
1243 if ( l == Led_Power ) 1244 if ( l == Led_Power )
1244 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1245 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1245 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1246 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1246 vl << Led_Off; // << Led_On << ??? 1247 vl << Led_Off; // << Led_On << ???
1247 1248
1248 return vl; 1249 return vl;
1249} 1250}
1250 1251
1251OLedState iPAQ::ledState ( OLed l ) const 1252OLedState iPAQ::ledState ( OLed l ) const
1252{ 1253{
1253 switch ( l ) { 1254 switch ( l ) {
1254 case Led_Power: 1255 case Led_Power:
1255 return m_leds [0]; 1256 return m_leds [0];
1256 case Led_BlueTooth: 1257 case Led_BlueTooth:
1257 return m_leds [1]; 1258 return m_leds [1];
1258 default: 1259 default:
1259 return Led_Off; 1260 return Led_Off;
1260 } 1261 }
1261} 1262}
1262 1263
1263bool iPAQ::setLedState ( OLed l, OLedState st ) 1264bool iPAQ::setLedState ( OLed l, OLedState st )
1264{ 1265{
1265 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1266 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1266 1267
1267 if ( l == Led_Power ) { 1268 if ( l == Led_Power ) {
1268 if ( fd >= 0 ) { 1269 if ( fd >= 0 ) {
1269 LED_IN leds; 1270 LED_IN leds;
1270 ::memset ( &leds, 0, sizeof( leds )); 1271 ::memset ( &leds, 0, sizeof( leds ));
1271 leds. TotalTime = 0; 1272 leds. TotalTime = 0;
1272 leds. OnTime = 0; 1273 leds. OnTime = 0;
1273 leds. OffTime = 1; 1274 leds. OffTime = 1;
1274 leds. OffOnBlink = 2; 1275 leds. OffOnBlink = 2;
1275 1276
1276 switch ( st ) { 1277 switch ( st ) {
1277 case Led_Off : leds. OffOnBlink = 0; break; 1278 case Led_Off : leds. OffOnBlink = 0; break;
1278 case Led_On : leds. OffOnBlink = 1; break; 1279 case Led_On : leds. OffOnBlink = 1; break;
1279 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1280 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1280 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1281 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1281 } 1282 }
1282 1283
1283 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1284 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1284 m_leds [0] = st; 1285 m_leds [0] = st;
1285 return true; 1286 return true;
1286 } 1287 }
1287 } 1288 }
1288 } 1289 }
1289 return false; 1290 return false;
1290} 1291}
1291 1292
1292 1293
1293bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1294bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1294{ 1295{
1295 int newkeycode = keycode; 1296 int newkeycode = keycode;
1296 1297
1297 switch ( keycode ) { 1298 switch ( keycode ) {
1298 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1299 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1299 case HardKey_Menu: { 1300 case HardKey_Menu: {
1300 if (( d-> m_model == Model_iPAQ_H38xx ) || 1301 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1301 ( d-> m_model == Model_iPAQ_H39xx ) || 1302 ( d-> m_model == Model_iPAQ_H39xx ) ||
1302 ( d-> m_model == Model_iPAQ_H5xxx)) { 1303 ( d-> m_model == Model_iPAQ_H5xxx)) {
1303 newkeycode = HardKey_Mail; 1304 newkeycode = HardKey_Mail;
1304 } 1305 }
1305 break; 1306 break;
1306 } 1307 }
1307 1308
1308 // Rotate cursor keys 180° 1309 // Rotate cursor keys 180°
1309 case Key_Left : 1310 case Key_Left :
1310 case Key_Right: 1311 case Key_Right:
1311 case Key_Up : 1312 case Key_Up :
1312 case Key_Down : { 1313 case Key_Down : {
1313 if (( d-> m_model == Model_iPAQ_H31xx ) || 1314 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1314 ( d-> m_model == Model_iPAQ_H38xx )) { 1315 ( d-> m_model == Model_iPAQ_H38xx )) {
1315 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1316 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1316 } 1317 }
1317 break; 1318 break;
1318 } 1319 }
1319 1320
1320 // map Power Button short/long press to F34/F35 1321 // map Power Button short/long press to F34/F35
1321 case Key_SysReq: { 1322 case Key_SysReq: {
1322 if ( isPress ) { 1323 if ( isPress ) {
1323 if ( m_power_timer ) 1324 if ( m_power_timer )
1324 killTimer ( m_power_timer ); 1325 killTimer ( m_power_timer );
1325 m_power_timer = startTimer ( 500 ); 1326 m_power_timer = startTimer ( 500 );
1326 } 1327 }
1327 else if ( m_power_timer ) { 1328 else if ( m_power_timer ) {
1328 killTimer ( m_power_timer ); 1329 killTimer ( m_power_timer );
1329 m_power_timer = 0; 1330 m_power_timer = 0;
1330 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1331 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1331 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1332 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1332 } 1333 }
1333 newkeycode = Key_unknown; 1334 newkeycode = Key_unknown;
1334 break; 1335 break;
1335 } 1336 }
1336 } 1337 }
1337 1338
1338 if ( newkeycode != keycode ) { 1339 if ( newkeycode != keycode ) {
1339 if ( newkeycode != Key_unknown ) 1340 if ( newkeycode != Key_unknown )
1340 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1341 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1341 return true; 1342 return true;
1342 } 1343 }
1343 else 1344 else
1344 return false; 1345 return false;
1345} 1346}
1346 1347
1347void iPAQ::timerEvent ( QTimerEvent * ) 1348void iPAQ::timerEvent ( QTimerEvent * )
1348{ 1349{
1349 killTimer ( m_power_timer ); 1350 killTimer ( m_power_timer );
1350 m_power_timer = 0; 1351 m_power_timer = 0;
1351 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1352 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1352 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1353 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1353} 1354}
1354 1355
1355 1356
1356void iPAQ::alarmSound ( ) 1357void iPAQ::alarmSound ( )
1357{ 1358{
1358#ifndef QT_NO_SOUND 1359#ifndef QT_NO_SOUND
1359 static Sound snd ( "alarm" ); 1360 static Sound snd ( "alarm" );
1360 int fd; 1361 int fd;
1361 int vol; 1362 int vol;
1362 bool vol_reset = false; 1363 bool vol_reset = false;
1363 1364
1364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1365 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1366 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1366 Config cfg ( "qpe" ); 1367 Config cfg ( "qpe" );
1367 cfg. setGroup ( "Volume" ); 1368 cfg. setGroup ( "Volume" );
1368 1369
1369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1370 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1370 if ( volalarm < 0 ) 1371 if ( volalarm < 0 )
1371 volalarm = 0; 1372 volalarm = 0;
1372 else if ( volalarm > 100 ) 1373 else if ( volalarm > 100 )
1373 volalarm = 100; 1374 volalarm = 100;
1374 volalarm |= ( volalarm << 8 ); 1375 volalarm |= ( volalarm << 8 );
1375 1376
1376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1377 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1377 vol_reset = true; 1378 vol_reset = true;
1378 } 1379 }
1379 } 1380 }
1380 1381
1381 snd. play ( ); 1382 snd. play ( );
1382 while ( !snd. isFinished ( )) 1383 while ( !snd. isFinished ( ))
1383 qApp-> processEvents ( ); 1384 qApp-> processEvents ( );
1384 1385
1385 if ( fd >= 0 ) { 1386 if ( fd >= 0 ) {
1386 if ( vol_reset ) 1387 if ( vol_reset )
1387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1388 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1388 ::close ( fd ); 1389 ::close ( fd );
1389 } 1390 }
1390#endif 1391#endif
1391} 1392}
1392 1393
1393 1394
1394bool iPAQ::setSoftSuspend ( bool soft ) 1395bool iPAQ::setSoftSuspend ( bool soft )
1395{ 1396{
1396 bool res = false; 1397 bool res = false;
1397 int fd; 1398 int fd;
1398 1399
1399 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1400 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1400 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1401 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1401 res = true; 1402 res = true;
1402 else 1403 else
1403 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1404 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1404 1405
1405 ::close ( fd ); 1406 ::close ( fd );
1406 } 1407 }
1407 else 1408 else
1408 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1409 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1409 1410
1410 return res; 1411 return res;
1411} 1412}
1412 1413
1413 1414
1414bool iPAQ::setDisplayBrightness ( int bright ) 1415bool iPAQ::setDisplayBrightness ( int bright )
1415{ 1416{
1416 bool res = false; 1417 bool res = false;
1417 int fd; 1418 int fd;
1418 1419
1419 if ( bright > 255 ) 1420 if ( bright > 255 )
1420 bright = 255; 1421 bright = 255;
1421 if ( bright < 0 ) 1422 if ( bright < 0 )
1422 bright = 0; 1423 bright = 0;
1423 1424
1424 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1425 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1425 FLITE_IN bl; 1426 FLITE_IN bl;
1426 bl. mode = 1; 1427 bl. mode = 1;
1427 bl. pwr = bright ? 1 : 0; 1428 bl. pwr = bright ? 1 : 0;
1428 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1429 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1429 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1430 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1430 ::close ( fd ); 1431 ::close ( fd );
1431 } 1432 }
1432 return res; 1433 return res;
1433} 1434}
1434 1435
1435int iPAQ::displayBrightnessResolution ( ) const 1436int iPAQ::displayBrightnessResolution ( ) const
1436{ 1437{
1437 switch ( model ( )) { 1438 switch ( model ( )) {
1438 case Model_iPAQ_H31xx: 1439 case Model_iPAQ_H31xx:
1439 case Model_iPAQ_H36xx: 1440 case Model_iPAQ_H36xx:
1440 case Model_iPAQ_H37xx: 1441 case Model_iPAQ_H37xx:
1441 return 128; // really 256, but >128 could damage the LCD 1442 return 128; // really 256, but >128 could damage the LCD
1442 1443
1443 case Model_iPAQ_H38xx: 1444 case Model_iPAQ_H38xx:
1444 case Model_iPAQ_H39xx: 1445 case Model_iPAQ_H39xx:
1445 return 64; 1446 return 64;
1446 case Model_iPAQ_H5xxx: 1447 case Model_iPAQ_H5xxx:
1447 return 255; 1448 return 255;
1448 1449
1449 default: 1450 default:
1450 return 2; 1451 return 2;
1451 } 1452 }
1452} 1453}
1453 1454
1454 1455
1455bool iPAQ::hasLightSensor ( ) const 1456bool iPAQ::hasLightSensor ( ) const
1456{ 1457{
1457 return true; 1458 return true;
1458} 1459}
1459 1460
1460int iPAQ::readLightSensor ( ) 1461int iPAQ::readLightSensor ( )
1461{ 1462{
1462 int fd; 1463 int fd;
1463 int val = -1; 1464 int val = -1;
1464 1465
1465 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1466 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1466 char buffer [8]; 1467 char buffer [8];
1467 1468
1468 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1469 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1469 char *endptr; 1470 char *endptr;
1470 1471
1471 buffer [4] = 0; 1472 buffer [4] = 0;
1472 val = ::strtol ( buffer + 2, &endptr, 16 ); 1473 val = ::strtol ( buffer + 2, &endptr, 16 );
1473 1474
1474 if ( *endptr != 0 ) 1475 if ( *endptr != 0 )
1475 val = -1; 1476 val = -1;
1476 } 1477 }
1477 ::close ( fd ); 1478 ::close ( fd );
1478 } 1479 }
1479 1480
1480 return val; 1481 return val;
1481} 1482}
1482 1483
1483int iPAQ::lightSensorResolution ( ) const 1484int iPAQ::lightSensorResolution ( ) const
1484{ 1485{
1485 return 256; 1486 return 256;
1486} 1487}
1487 1488
1488/************************************************** 1489/**************************************************
1489 * 1490 *
1490 * Zaurus 1491 * Zaurus
1491 * 1492 *
1492 **************************************************/ 1493 **************************************************/
1493 1494
1494// Check whether this device is the sharp zaurus.. 1495// Check whether this device is the sharp zaurus..
1495bool Zaurus::isZaurus() 1496bool Zaurus::isZaurus()
1496{ 1497{
1497 1498
1498 // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! 1499 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
1499 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1500 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1500 return true; 1501 return true;
1501 } 1502 }
1502 1503
1503 // On non-embedix kenrnels, we have too look closer. 1504 // On non-embedix kernels, we have to look closer.
1504 bool is_zaurus = false; 1505 bool is_zaurus = false;
1505 QFile f ( "/proc/cpuinfo" ); 1506 QFile f ( "/proc/cpuinfo" );
1506 if ( f. open ( IO_ReadOnly ) ) { 1507 if ( f. open ( IO_ReadOnly ) ) {
1507 QString model; 1508 QString model;
1508 QFile f ( "/proc/cpuinfo" ); 1509 QFile f ( "/proc/cpuinfo" );
1509 1510
1510 QTextStream ts ( &f ); 1511 QTextStream ts ( &f );
1511 QString line; 1512 QString line;
1512 while( line = ts. readLine ( ) ) { 1513 while( line = ts. readLine ( ) ) {
1513 if ( line. left ( 8 ) == "Hardware" ) 1514 if ( line. left ( 8 ) == "Hardware" )
1514 break; 1515 break;
1515 } 1516 }
1516 int loc = line. find ( ":" ); 1517 int loc = line. find ( ":" );
1517 if ( loc != -1 ) 1518 if ( loc != -1 )
1518 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1519 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1519 1520
1520 if ( model == "Sharp-Collie" 1521 if ( model == "Sharp-Collie"
1521 || model == "Collie" 1522 || model == "Collie"
1522 || model == "SHARP Corgi" 1523 || model == "SHARP Corgi"
1523 || model == "SHARP Shepherd" 1524 || model == "SHARP Shepherd"
1524 || model == "SHARP Poodle" 1525 || model == "SHARP Poodle"
1526 || model == "SHARP Husky" )
1525 ) 1527 )
1526 is_zaurus = true; 1528 is_zaurus = true;
1527 1529
1528 } 1530 }
1529 return is_zaurus; 1531 return is_zaurus;
1530} 1532}
1531 1533
1532 1534
1533void Zaurus::init ( ) 1535void Zaurus::init ( )
1534{ 1536{
1535 d-> m_vendorstr = "Sharp"; 1537 d-> m_vendorstr = "Sharp";
1536 d-> m_vendor = Vendor_Sharp; 1538 d-> m_vendor = Vendor_Sharp;
1537 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 1539 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
1538 1540
1539 // QFile f ( "/proc/filesystems" ); 1541 // QFile f ( "/proc/filesystems" );
1540 QString model; 1542 QString model;
1541 1543
1542 // It isn't a good idea to check the system configuration to 1544 // It isn't a good idea to check the system configuration to
1543 // detect the distribution ! 1545 // detect the distribution !
1544 // Otherwise it may happen that any other distribution is detected as openzaurus, just 1546 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1545 // because it uses a jffs2 filesystem.. 1547 // because it uses a jffs2 filesystem..
1546 // (eilers) 1548 // (eilers)
1547 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1549 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1548 QFile f ("/etc/oz_version"); 1550 QFile f ("/etc/oz_version");
1549 if ( f.exists() ){ 1551 if ( f.exists() ){
1550 d-> m_vendorstr = "OpenZaurus Team"; 1552 d-> m_vendorstr = "OpenZaurus Team";
1551 d-> m_systemstr = "OpenZaurus"; 1553 d-> m_systemstr = "OpenZaurus";
1552 d-> m_system = System_OpenZaurus; 1554 d-> m_system = System_OpenZaurus;
1553 1555
1554 if ( f. open ( IO_ReadOnly )) { 1556 if ( f. open ( IO_ReadOnly )) {
1555 QTextStream ts ( &f ); 1557 QTextStream ts ( &f );
1556 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1558 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1557 f. close ( ); 1559 f. close ( );
1558 } 1560 }
1559 1561
1560 // Openzaurus sometimes uses the embedix kernel! 1562 // Openzaurus sometimes uses the embedix kernel!
1561 // => Check whether this is an embedix kernel 1563 // => Check whether this is an embedix kernel
1562 FILE *uname = popen("uname -r", "r"); 1564 FILE *uname = popen("uname -r", "r");
1563 QString line; 1565 QString line;
1564 if ( f.open(IO_ReadOnly, uname) ) { 1566 if ( f.open(IO_ReadOnly, uname) ) {
1565 QTextStream ts ( &f ); 1567 QTextStream ts ( &f );
1566 line = ts. readLine ( ); 1568 line = ts. readLine ( );
1567 int loc = line. find ( "embedix" ); 1569 int loc = line. find ( "embedix" );
1568 if ( loc != -1 ) 1570 if ( loc != -1 )
1569 m_embedix = true; 1571 m_embedix = true;
1570 else 1572 else
1571 m_embedix = false; 1573 m_embedix = false;
1572 f. close ( ); 1574 f. close ( );
1573 } 1575 }
1574 pclose(uname); 1576 pclose(uname);
1575 } 1577 }
1576 else { 1578 else {
1577 d-> m_systemstr = "Zaurus"; 1579 d-> m_systemstr = "Zaurus";
1578 d-> m_system = System_Zaurus; 1580 d-> m_system = System_Zaurus;
1579 } 1581 }
1580 1582
1581 f. setName ( "/proc/cpuinfo" ); 1583 f. setName ( "/proc/cpuinfo" );
1582 if ( f. open ( IO_ReadOnly ) ) { 1584 if ( f. open ( IO_ReadOnly ) ) {
1583 QTextStream ts ( &f ); 1585 QTextStream ts ( &f );
1584 QString line; 1586 QString line;
1585 while( line = ts. readLine ( ) ) { 1587 while( line = ts. readLine ( ) ) {
1586 if ( line. left ( 8 ) == "Hardware" ) 1588 if ( line. left ( 8 ) == "Hardware" )
1587 break; 1589 break;
1588 } 1590 }
1589 int loc = line. find ( ":" ); 1591 int loc = line. find ( ":" );
1590 if ( loc != -1 ) 1592 if ( loc != -1 )
1591 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1593 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1592 } 1594 }
1593 1595
1594 if ( model == "SHARP Corgi" ) { 1596 if ( model == "SHARP Corgi" ) {
1595 d-> m_model = Model_Zaurus_SLC700; 1597 d-> m_model = Model_Zaurus_SLC7x0;
1596 d-> m_modelstr = "Zaurus SL-C700"; 1598 d-> m_modelstr = "Zaurus SL-C700";
1597 } else if ( model == "SHARP Shepherd" ) { 1599 } else if ( model == "SHARP Shepherd" ) {
1598 d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers) 1600 d-> m_model = Model_Zaurus_SLC7x0;
1599 d-> m_modelstr = "Zaurus SL-C750"; 1601 d-> m_modelstr = "Zaurus SL-C750";
1602 } else if ( model == "SHARP Husky" ) {
1603 d-> m_model = Model_Zaurus_SLC7x0;
1604 d-> m_modelstr = "Zaurus SL-C760";
1600 } else if ( model == "SHARP Poodle" ) { 1605 } else if ( model == "SHARP Poodle" ) {
1601 d-> m_model = Model_Zaurus_SLB600; 1606 d-> m_model = Model_Zaurus_SLB600;
1602 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1607 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1603 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 1608 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
1604 d-> m_model = Model_Zaurus_SL5500; 1609 d-> m_model = Model_Zaurus_SL5500;
1605 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1610 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1606 } else { 1611 } else {
1607 d-> m_model = Model_Zaurus_SL5500; 1612 d-> m_model = Model_Zaurus_SL5500;
1608 d-> m_modelstr = "Zaurus (Model unknown)"; 1613 d-> m_modelstr = "Zaurus (Model unknown)";
1609 } 1614 }
1610 1615
1611 bool flipstate = false; 1616 bool flipstate = false;
1612 switch ( d-> m_model ) { 1617 switch ( d-> m_model ) {
1613 case Model_Zaurus_SLA300: 1618 case Model_Zaurus_SLA300:
1614 d-> m_rotation = Rot0; 1619 d-> m_rotation = Rot0;
1615 break; 1620 break;
1616 case Model_Zaurus_SLC700: 1621 case Model_Zaurus_SLC7x0:
1617 // Note: need to 1) set flipstate based on physical screen orientation 1622 // Note: need to 1) set flipstate based on physical screen orientation
1618 // and 2) check to see if the user overrode the rotation direction 1623 // and 2) check to see if the user overrode the rotation direction
1619 // using appearance, and if so, remove that item from the Config to 1624 // using appearance, and if so, remove that item from the Config to
1620 // ensure the rotate applet flips us back to the previous state. 1625 // ensure the rotate applet flips us back to the previous state.
1621 if ( flipstate ) { 1626 if ( flipstate ) {
1622 // 480x640 1627 // 480x640
1623 d-> m_rotation = Rot0; 1628 d-> m_rotation = Rot0;
1624 d-> m_direction = CW; 1629 d-> m_direction = CW;
1625 } else { 1630 } else {
1626 // 640x480 1631 // 640x480
1627 d-> m_rotation = Rot270; 1632 d-> m_rotation = Rot270;
1628 d-> m_direction = CCW; 1633 d-> m_direction = CCW;
1629 } 1634 }
1630 break; 1635 break;
1631 case Model_Zaurus_SLB600: 1636 case Model_Zaurus_SLB600:
1632 case Model_Zaurus_SL5500: 1637 case Model_Zaurus_SL5500:
1633 case Model_Zaurus_SL5000: 1638 case Model_Zaurus_SL5000:
1634 default: 1639 default:
1635 d-> m_rotation = Rot270; 1640 d-> m_rotation = Rot270;
1636 break; 1641 break;
1637 } 1642 }
1638 m_leds [0] = Led_Off; 1643 m_leds [0] = Led_Off;
1639} 1644}
1640 1645
1641void Zaurus::initButtons ( ) 1646void Zaurus::initButtons ( )
1642{ 1647{
1643 if ( d-> m_buttons ) 1648 if ( d-> m_buttons )
1644 return; 1649 return;
1645 1650
1646 d-> m_buttons = new QValueList <ODeviceButton>; 1651 d-> m_buttons = new QValueList <ODeviceButton>;
1647 1652
1648 struct z_button * pz_buttons; 1653 struct z_button * pz_buttons;
1649 int buttoncount; 1654 int buttoncount;
1650 switch ( d-> m_model ) { 1655 switch ( d-> m_model ) {
1651 case Model_Zaurus_SLC700: 1656 case Model_Zaurus_SLC7x0:
1652 pz_buttons = z_buttons_c700; 1657 pz_buttons = z_buttons_c700;
1653 buttoncount = ARRAY_SIZE(z_buttons_c700); 1658 buttoncount = ARRAY_SIZE(z_buttons_c700);
1654 break; 1659 break;
1655 default: 1660 default:
1656 pz_buttons = z_buttons; 1661 pz_buttons = z_buttons;
1657 buttoncount = ARRAY_SIZE(z_buttons); 1662 buttoncount = ARRAY_SIZE(z_buttons);
1658 break; 1663 break;
1659 } 1664 }
1660 1665
1661 for ( int i = 0; i < buttoncount; i++ ) { 1666 for ( int i = 0; i < buttoncount; i++ ) {
1662 struct z_button *zb = pz_buttons + i; 1667 struct z_button *zb = pz_buttons + i;
1663 ODeviceButton b; 1668 ODeviceButton b;
1664 1669
1665 b. setKeycode ( zb-> code ); 1670 b. setKeycode ( zb-> code );
1666 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1671 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1667 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1672 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1668 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), 1673 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
1669 zb-> fpressedaction )); 1674 zb-> fpressedaction ));
1670 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), 1675 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
1671 zb-> fheldaction )); 1676 zb-> fheldaction ));
1672 1677
1673 d-> m_buttons-> append ( b ); 1678 d-> m_buttons-> append ( b );
1674 } 1679 }
1675 1680
1676 reloadButtonMapping ( ); 1681 reloadButtonMapping ( );
1677 1682
1678 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1683 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1679 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 1684 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
1680 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1685 this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1681} 1686}
1682 1687
1683#include <unistd.h> 1688#include <unistd.h>
1684#include <fcntl.h> 1689#include <fcntl.h>
1685#include <sys/ioctl.h> 1690#include <sys/ioctl.h>
1686 1691
1687//#include <asm/sharp_char.h> // including kernel headers is evil ... 1692//#include <asm/sharp_char.h> // including kernel headers is evil ...
1688 1693
1689#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1694#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1690 1695
1691 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1696 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1692#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1697#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1693 1698
1694#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1699#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1695#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1700#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1696#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1701#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1697 1702
1698/* --- for SHARP_BUZZER device --- */ 1703/* --- for SHARP_BUZZER device --- */
1699 1704
1700 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1705 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1701//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1706//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1702 1707
1703#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1708#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1704#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1709#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1705#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1710#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1706#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1711#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1707#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1712#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1708 1713
1709//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1714//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1710//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1715//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1711 1716
1712//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1717//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1713//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1718//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1714//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1719//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1715//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1720//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1716//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1721//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1717//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1722//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1718//#define SHARP_PDA_APPSTART 9 /* application start */ 1723//#define SHARP_PDA_APPSTART 9 /* application start */
1719//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1724//#define SHARP_PDA_APPQUIT 10 /* application ends */
1720 1725
1721//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1726//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1722//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1727//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1723//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1728//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1724//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1729//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1725// 1730//
1726 1731
1727 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1732 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1728#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1733#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1729 1734
1730typedef struct sharp_led_status { 1735typedef struct sharp_led_status {
1731 int which; /* select which LED status is wanted. */ 1736 int which; /* select which LED status is wanted. */
1732 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1737 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1733} sharp_led_status; 1738} sharp_led_status;
1734 1739
1735#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1740#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1736 1741
1737#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1742#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1738#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1743#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1739#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1744#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1740 1745
1741// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1746// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1742 1747
1743#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1748#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1744#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1749#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1745#define APM_EVT_POWER_BUTTON (1 << 0) 1750#define APM_EVT_POWER_BUTTON (1 << 0)
1746 1751
1747#define FL_IOCTL_STEP_CONTRAST 100 1752#define FL_IOCTL_STEP_CONTRAST 100
1748 1753
1749 1754
1750void Zaurus::buzzer ( int sound ) 1755void Zaurus::buzzer ( int sound )
1751{ 1756{
1752#ifndef QT_NO_SOUND 1757#ifndef QT_NO_SOUND
1753 QString soundname; 1758 QString soundname;
1754 1759
1755 // Not all devices have real sound. But I expect 1760 // Not all devices have real sound
1756 // that Openzaurus now has a sound driver which 1761 if ( d->m_model == Model_Zaurus_SLC7x0
1757 // I will use instead the buzzer... 1762 || d->m_model == Model_Zaurus_SLB600 ){
1758 if ( ( d->m_model == Model_Zaurus_SLC700 )
1759 || d->m_system == System_OpenZaurus ){
1760 1763
1761 switch ( sound ){ 1764 switch ( sound ){
1762 case SHARP_BUZ_SCHEDULE_ALARM: 1765 case SHARP_BUZ_SCHEDULE_ALARM:
1763 soundname = "alarm"; 1766 soundname = "alarm";
1764 break; 1767 break;
1765 case SHARP_BUZ_TOUCHSOUND: 1768 case SHARP_BUZ_TOUCHSOUND:
1766 soundname = "touchsound"; 1769 soundname = "touchsound";
1767 break; 1770 break;
1768 case SHARP_BUZ_KEYSOUND: 1771 case SHARP_BUZ_KEYSOUND:
1769 soundname = "keysound"; 1772 soundname = "keysound";
1770 break; 1773 break;
1771 default: 1774 default:
1772 soundname = "alarm"; 1775 soundname = "alarm";
1773 1776
1774 } 1777 }
1775 } 1778 }
1776 1779
1777 // If a soundname is defined, we expect that this device has 1780 // If a soundname is defined, we expect that this device has
1778 // sound capabilities.. Otherwise we expect to have the buzzer 1781 // sound capabilities.. Otherwise we expect to have the buzzer
1779 // device.. 1782 // device..
1780 if ( !soundname.isEmpty() ){ 1783 if ( !soundname.isEmpty() ){
1781 int fd; 1784 int fd;
1782 int vol; 1785 int vol;
1783 bool vol_reset = false; 1786 bool vol_reset = false;
1784 1787
1785 Sound snd ( soundname ); 1788 Sound snd ( soundname );
1786 1789
1787 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1790 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1788 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1791 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1789 Config cfg ( "qpe" ); 1792 Config cfg ( "qpe" );
1790 cfg. setGroup ( "Volume" ); 1793 cfg. setGroup ( "Volume" );
1791 1794
1792 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1795 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1793 if ( volalarm < 0 ) 1796 if ( volalarm < 0 )
1794 volalarm = 0; 1797 volalarm = 0;
1795 else if ( volalarm > 100 ) 1798 else if ( volalarm > 100 )
1796 volalarm = 100; 1799 volalarm = 100;
1797 volalarm |= ( volalarm << 8 ); 1800 volalarm |= ( volalarm << 8 );
1798 1801
1799 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1802 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1800 vol_reset = true; 1803 vol_reset = true;
1801 } 1804 }
1802 } 1805 }
1803 1806
1804 snd. play ( ); 1807 snd. play ( );
1805 while ( !snd. isFinished ( )) 1808 while ( !snd. isFinished ( ))
1806 qApp-> processEvents ( ); 1809 qApp-> processEvents ( );
1807 1810
1808 if ( fd >= 0 ) { 1811 if ( fd >= 0 ) {
1809 if ( vol_reset ) 1812 if ( vol_reset )
1810 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1813 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1811 ::close ( fd ); 1814 ::close ( fd );
1812 } 1815 }
1813 } else { 1816 } else {
1814 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1817 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1815 1818
1816 if ( fd >= 0 ) { 1819 if ( fd >= 0 ) {
1817 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1820 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1818 ::close ( fd ); 1821 ::close ( fd );
1819 } 1822 }
1820 1823
1821 } 1824 }
1822#endif 1825#endif
1823} 1826}
1824 1827
1825 1828
1826void Zaurus::alarmSound ( ) 1829void Zaurus::alarmSound ( )
1827{ 1830{
1828 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1831 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1829} 1832}
1830 1833
1831void Zaurus::touchSound ( ) 1834void Zaurus::touchSound ( )
1832{ 1835{
1833 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1836 buzzer ( SHARP_BUZ_TOUCHSOUND );
1834} 1837}
1835 1838
1836void Zaurus::keySound ( ) 1839void Zaurus::keySound ( )
1837{ 1840{
1838 buzzer ( SHARP_BUZ_KEYSOUND ); 1841 buzzer ( SHARP_BUZ_KEYSOUND );
1839} 1842}
1840 1843
1841 1844
1842QValueList <OLed> Zaurus::ledList ( ) const 1845QValueList <OLed> Zaurus::ledList ( ) const
1843{ 1846{
1844 QValueList <OLed> vl; 1847 QValueList <OLed> vl;
1845 vl << Led_Mail; 1848 vl << Led_Mail;
1846 return vl; 1849 return vl;
1847} 1850}
1848 1851
1849QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1852QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1850{ 1853{
1851 QValueList <OLedState> vl; 1854 QValueList <OLedState> vl;
1852 1855
1853 if ( l == Led_Mail ) 1856 if ( l == Led_Mail )
1854 vl << Led_Off << Led_On << Led_BlinkSlow; 1857 vl << Led_Off << Led_On << Led_BlinkSlow;
1855 return vl; 1858 return vl;
1856} 1859}
1857 1860
1858OLedState Zaurus::ledState ( OLed which ) const 1861OLedState Zaurus::ledState ( OLed which ) const
1859{ 1862{
1860 if ( which == Led_Mail ) 1863 if ( which == Led_Mail )
1861 return m_leds [0]; 1864 return m_leds [0];
1862 else 1865 else
1863 return Led_Off; 1866 return Led_Off;
1864} 1867}
1865 1868
1866bool Zaurus::setLedState ( OLed which, OLedState st ) 1869bool Zaurus::setLedState ( OLed which, OLedState st )
1867{ 1870{
1868 if (!m_embedix) // Currently not supported on non_embedix kernels 1871 if (!m_embedix) // Currently not supported on non_embedix kernels
1869 return false; 1872 return false;
1870 1873
1871 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1874 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1872 1875
1873 if ( which == Led_Mail ) { 1876 if ( which == Led_Mail ) {
1874 if ( fd >= 0 ) { 1877 if ( fd >= 0 ) {
1875 struct sharp_led_status leds; 1878 struct sharp_led_status leds;
1876 ::memset ( &leds, 0, sizeof( leds )); 1879 ::memset ( &leds, 0, sizeof( leds ));
1877 leds. which = SHARP_LED_MAIL_EXISTS; 1880 leds. which = SHARP_LED_MAIL_EXISTS;
1878 bool ok = true; 1881 bool ok = true;
1879 1882
1880 switch ( st ) { 1883 switch ( st ) {
1881 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1884 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1882 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1885 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1883 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1886 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1884 default : ok = false; 1887 default : ok = false;
1885 } 1888 }
1886 1889
1887 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1890 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1888 m_leds [0] = st; 1891 m_leds [0] = st;
1889 return true; 1892 return true;
1890 } 1893 }
1891 } 1894 }
1892 } 1895 }
1893 return false; 1896 return false;
1894} 1897}
1895 1898
1896bool Zaurus::setSoftSuspend ( bool soft ) 1899bool Zaurus::setSoftSuspend ( bool soft )
1897{ 1900{
1898 if (!m_embedix) { 1901 if (!m_embedix) {
1899 /* non-Embedix kernels dont have kernel autosuspend */ 1902 /* non-Embedix kernels dont have kernel autosuspend */
1900 return ODevice::setSoftSuspend( soft ); 1903 return ODevice::setSoftSuspend( soft );
1901 } 1904 }
1902 1905
1903 bool res = false; 1906 bool res = false;
1904 int fd; 1907 int fd;
1905 1908
1906 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1909 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1907 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1910 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1908 1911
1909 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1912 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1910 1913
1911 if ( sources >= 0 ) { 1914 if ( sources >= 0 ) {
1912 if ( soft ) 1915 if ( soft )
1913 sources &= ~APM_EVT_POWER_BUTTON; 1916 sources &= ~APM_EVT_POWER_BUTTON;
1914 else 1917 else
1915 sources |= APM_EVT_POWER_BUTTON; 1918 sources |= APM_EVT_POWER_BUTTON;
1916 1919
1917 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1920 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1918 res = true; 1921 res = true;
1919 else 1922 else
1920 perror ( "APM_IOCGEVTSRC" ); 1923 perror ( "APM_IOCGEVTSRC" );
1921 } 1924 }
1922 else 1925 else
1923 perror ( "APM_IOCGEVTSRC" ); 1926 perror ( "APM_IOCGEVTSRC" );
1924 1927
1925 ::close ( fd ); 1928 ::close ( fd );
1926 } 1929 }
1927 else 1930 else
1928 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1931 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1929 1932
1930 return res; 1933 return res;
1931} 1934}
1932 1935
1933 1936
1934bool Zaurus::setDisplayBrightness ( int bright ) 1937bool Zaurus::setDisplayBrightness ( int bright )
1935{ 1938{
1936 bool res = false; 1939 bool res = false;
1937 int fd; 1940 int fd;
1938 1941
1939 if ( bright > 255 ) 1942 if ( bright > 255 )
1940 bright = 255; 1943 bright = 255;
1941 if ( bright < 0 ) 1944 if ( bright < 0 )
1942 bright = 0; 1945 bright = 0;
1943 1946
1944 if (m_embedix) { 1947 if (m_embedix) {
1945 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1948 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1946 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1949 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1947 if ( bright && !bl ) 1950 if ( bright && !bl )
1948 bl = 1; 1951 bl = 1;
1949 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1952 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1950 ::close ( fd ); 1953 ::close ( fd );
1951 } 1954 }