summaryrefslogtreecommitdiff
authorzecke <zecke>2005-10-07 18:21:10 (UTC)
committer zecke <zecke>2005-10-07 18:21:10 (UTC)
commitd5beae7038e36633480cc3e17134a85b6d68fbc7 (patch) (unidiff)
tree632f5ae52296438e1ff6b4a6c669395da912a3bb
parent0bad2116a1ceed19956b94889cb034781f35146d (diff)
downloadopie-d5beae7038e36633480cc3e17134a85b6d68fbc7.zip
opie-d5beae7038e36633480cc3e17134a85b6d68fbc7.tar.gz
opie-d5beae7038e36633480cc3e17134a85b6d68fbc7.tar.bz2
libopie2/opiecore/device/odevice_ipaq.cpp:
-make it compile. This line should have been H1940 in the patch. Now I even compiled libopiecore before comitting ;)
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 52da2d9..2d734a4 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -153,312 +153,312 @@ void iPAQ::init(const QString& model)
153 d->m_model = Model_iPAQ_H191x; 153 d->m_model = Model_iPAQ_H191x;
154 else if ( d->m_modelstr == "H1940" ) 154 else if ( d->m_modelstr == "H1940" )
155 d->m_model = Model_iPAQ_H1940; 155 d->m_model = Model_iPAQ_H1940;
156 else 156 else
157 d->m_model = Model_Unknown; 157 d->m_model = Model_Unknown;
158 158
159 switch ( d->m_model ) { 159 switch ( d->m_model ) {
160 case Model_iPAQ_H31xx: 160 case Model_iPAQ_H31xx:
161 case Model_iPAQ_H38xx: 161 case Model_iPAQ_H38xx:
162 d->m_rotation = Rot90; 162 d->m_rotation = Rot90;
163 break; 163 break;
164 case Model_iPAQ_H5xxx: 164 case Model_iPAQ_H5xxx:
165 case Model_iPAQ_H22xx: 165 case Model_iPAQ_H22xx:
166 case Model_iPAQ_H191x: 166 case Model_iPAQ_H191x:
167 case Model_iPAQ_H1940: 167 case Model_iPAQ_H1940:
168 d->m_rotation = Rot0; 168 d->m_rotation = Rot0;
169 break; 169 break;
170 case Model_iPAQ_H36xx: 170 case Model_iPAQ_H36xx:
171 case Model_iPAQ_H37xx: 171 case Model_iPAQ_H37xx:
172 case Model_iPAQ_H39xx: 172 case Model_iPAQ_H39xx:
173 default: 173 default:
174 d->m_rotation = Rot270; 174 d->m_rotation = Rot270;
175 break; 175 break;
176 176
177 } 177 }
178 178
179 m_leds [0] = m_leds [1] = Led_Off; 179 m_leds [0] = m_leds [1] = Led_Off;
180 180
181 m_power_timer = 0; 181 m_power_timer = 0;
182 182
183} 183}
184 184
185void iPAQ::initButtons() 185void iPAQ::initButtons()
186{ 186{
187 if ( d->m_buttons ) 187 if ( d->m_buttons )
188 return; 188 return;
189 189
190 if ( isQWS( ) ) { 190 if ( isQWS( ) ) {
191 addPreHandler(this); 191 addPreHandler(this);
192 } 192 }
193 193
194 d->m_buttons = new QValueList <ODeviceButton>; 194 d->m_buttons = new QValueList <ODeviceButton>;
195 195
196 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 196 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
197 i_button *ib = ipaq_buttons + i; 197 i_button *ib = ipaq_buttons + i;
198 ODeviceButton b; 198 ODeviceButton b;
199 199
200 if (( ib->model & d->m_model ) == d->m_model ) { 200 if (( ib->model & d->m_model ) == d->m_model ) {
201 b. setKeycode ( ib->code ); 201 b. setKeycode ( ib->code );
202 b. setUserText ( QObject::tr ( "Button", ib->utext )); 202 b. setUserText ( QObject::tr ( "Button", ib->utext ));
203 b. setPixmap ( OResource::loadPixmap ( ib->pix )); 203 b. setPixmap ( OResource::loadPixmap ( ib->pix ));
204 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction )); 204 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib->fpressedservice ), ib->fpressedaction ));
205 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction )); 205 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
206 206
207 d->m_buttons->append ( b ); 207 d->m_buttons->append ( b );
208 } 208 }
209 } 209 }
210 reloadButtonMapping(); 210 reloadButtonMapping();
211} 211}
212 212
213QValueList <OLed> iPAQ::ledList() const 213QValueList <OLed> iPAQ::ledList() const
214{ 214{
215 QValueList <OLed> vl; 215 QValueList <OLed> vl;
216 vl << Led_Power; 216 vl << Led_Power;
217 217
218 if ( d->m_model == Model_iPAQ_H38xx ) 218 if ( d->m_model == Model_iPAQ_H38xx )
219 vl << Led_BlueTooth; 219 vl << Led_BlueTooth;
220 return vl; 220 return vl;
221} 221}
222 222
223QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 223QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
224{ 224{
225 QValueList <OLedState> vl; 225 QValueList <OLedState> vl;
226 226
227 if ( l == Led_Power ) 227 if ( l == Led_Power )
228 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 228 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
229 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx ) 229 else if ( l == Led_BlueTooth && d->m_model == Model_iPAQ_H38xx )
230 vl << Led_Off; // << Led_On << ??? 230 vl << Led_Off; // << Led_On << ???
231 231
232 return vl; 232 return vl;
233} 233}
234 234
235OLedState iPAQ::ledState ( OLed l ) const 235OLedState iPAQ::ledState ( OLed l ) const
236{ 236{
237 switch ( l ) { 237 switch ( l ) {
238 case Led_Power: 238 case Led_Power:
239 return m_leds [0]; 239 return m_leds [0];
240 case Led_BlueTooth: 240 case Led_BlueTooth:
241 return m_leds [1]; 241 return m_leds [1];
242 default: 242 default:
243 return Led_Off; 243 return Led_Off;
244 } 244 }
245} 245}
246 246
247bool iPAQ::setLedState ( OLed l, OLedState st ) 247bool iPAQ::setLedState ( OLed l, OLedState st )
248{ 248{
249 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 249 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
250 250
251 if ( l == Led_Power ) { 251 if ( l == Led_Power ) {
252 if ( fd >= 0 ) { 252 if ( fd >= 0 ) {
253 LED_IN leds; 253 LED_IN leds;
254 ::memset ( &leds, 0, sizeof( leds )); 254 ::memset ( &leds, 0, sizeof( leds ));
255 leds. TotalTime = 0; 255 leds. TotalTime = 0;
256 leds. OnTime = 0; 256 leds. OnTime = 0;
257 leds. OffTime = 1; 257 leds. OffTime = 1;
258 leds. OffOnBlink = 2; 258 leds. OffOnBlink = 2;
259 259
260 switch ( st ) { 260 switch ( st ) {
261 case Led_Off : leds. OffOnBlink = 0; break; 261 case Led_Off : leds. OffOnBlink = 0; break;
262 case Led_On : leds. OffOnBlink = 1; break; 262 case Led_On : leds. OffOnBlink = 1; break;
263 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 263 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
264 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 264 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
265 } 265 }
266 266
267 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 267 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
268 m_leds [0] = st; 268 m_leds [0] = st;
269 return true; 269 return true;
270 } 270 }
271 } 271 }
272 } 272 }
273 return false; 273 return false;
274} 274}
275 275
276 276
277bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 277bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
278{ 278{
279 int newkeycode = keycode; 279 int newkeycode = keycode;
280 280
281 switch ( keycode ) { 281 switch ( keycode ) {
282 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 282 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
283 case HardKey_Menu: { 283 case HardKey_Menu: {
284 if (( d->m_model == Model_iPAQ_H38xx ) || 284 if (( d->m_model == Model_iPAQ_H38xx ) ||
285 ( d->m_model == Model_iPAQ_H39xx ) || 285 ( d->m_model == Model_iPAQ_H39xx ) ||
286 ( d->m_model == Model_iPAQ_H5xxx)) { 286 ( d->m_model == Model_iPAQ_H5xxx)) {
287 newkeycode = HardKey_Mail; 287 newkeycode = HardKey_Mail;
288 } 288 }
289 break; 289 break;
290 } 290 }
291 291
292 // Rotate cursor keys 180 or 270 292 // Rotate cursor keys 180 or 270
293 case Key_Left : 293 case Key_Left :
294 case Key_Right: 294 case Key_Right:
295 case Key_Up : 295 case Key_Up :
296 case Key_Down : { 296 case Key_Down : {
297 if (( d->m_model == Model_iPAQ_H31xx ) || 297 if (( d->m_model == Model_iPAQ_H31xx ) ||
298 ( d->m_model == Model_iPAQ_H38xx )) { 298 ( d->m_model == Model_iPAQ_H38xx )) {
299 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 299 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
300 } 300 }
301 // Rotate the cursor keys by 270 301 // Rotate the cursor keys by 270
302 // keycode - Key_Left = position of the button starting from left clockwise 302 // keycode - Key_Left = position of the button starting from left clockwise
303 // add the rotation to it and modolo. No we've the original offset 303 // add the rotation to it and modolo. No we've the original offset
304 // add the offset to the Key_Left key 304 // add the offset to the Key_Left key
305 if (( d->m_model == Model_iPAQ_H5xxx ) || 305 if (( d->m_model == Model_iPAQ_H5xxx ) ||
306 ( d->m_model == Model_iPAQ_H191x ) || 306 ( d->m_model == Model_iPAQ_H191x ) ||
307 ( d->m_model == Model_iPAQ_H1940 )) 307 ( d->m_model == Model_iPAQ_H1940 ))
308 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 308 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
309 break; 309 break;
310 } 310 }
311 311
312 // map Power Button short/long press to F34/F35 312 // map Power Button short/long press to F34/F35
313 case Key_SysReq: { 313 case Key_SysReq: {
314 if ( isPress ) { 314 if ( isPress ) {
315 if ( m_power_timer ) 315 if ( m_power_timer )
316 killTimer ( m_power_timer ); 316 killTimer ( m_power_timer );
317 m_power_timer = startTimer ( 500 ); 317 m_power_timer = startTimer ( 500 );
318 } 318 }
319 else if ( m_power_timer ) { 319 else if ( m_power_timer ) {
320 killTimer ( m_power_timer ); 320 killTimer ( m_power_timer );
321 m_power_timer = 0; 321 m_power_timer = 0;
322 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 322 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
323 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 323 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
324 } 324 }
325 newkeycode = Key_unknown; 325 newkeycode = Key_unknown;
326 break; 326 break;
327 } 327 }
328 } 328 }
329 329
330 if ( newkeycode != keycode ) { 330 if ( newkeycode != keycode ) {
331 if ( newkeycode != Key_unknown ) 331 if ( newkeycode != Key_unknown )
332 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 332 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
333 return true; 333 return true;
334 } 334 }
335 else 335 else
336 return false; 336 return false;
337} 337}
338 338
339void iPAQ::timerEvent ( QTimerEvent * ) 339void iPAQ::timerEvent ( QTimerEvent * )
340{ 340{
341 killTimer ( m_power_timer ); 341 killTimer ( m_power_timer );
342 m_power_timer = 0; 342 m_power_timer = 0;
343 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 343 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
344 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 344 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
345} 345}
346 346
347 347
348void iPAQ::playAlarmSound() 348void iPAQ::playAlarmSound()
349{ 349{
350#ifndef QT_NO_SOUND 350#ifndef QT_NO_SOUND
351 static Sound snd ( "alarm" ); 351 static Sound snd ( "alarm" );
352 if(!snd.isFinished()) 352 if(!snd.isFinished())
353 return; 353 return;
354 354
355 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 355 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
356 snd. play(); 356 snd. play();
357#endif 357#endif
358} 358}
359 359
360bool iPAQ::setDisplayBrightness ( int bright ) 360bool iPAQ::setDisplayBrightness ( int bright )
361{ 361{
362 bool res = false; 362 bool res = false;
363 int fd; 363 int fd;
364 364
365 if ( bright > 255 ) 365 if ( bright > 255 )
366 bright = 255; 366 bright = 255;
367 if ( bright < 0 ) 367 if ( bright < 0 )
368 bright = 0; 368 bright = 0;
369 369
370 QString cmdline; 370 QString cmdline;
371 371
372 switch ( model()) { 372 switch ( model()) {
373 case Model_iPAQ_H191x: 373 case Model_iPAQ_H191x:
374 if ( !bright ) 374 if ( !bright )
375 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power"); 375 cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power");
376 else 376 else
377 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright ); 377 cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright );
378 // No Global::shellQuote as we gurantee it to be sane 378 // No Global::shellQuote as we gurantee it to be sane
379 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 379 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
380 break; 380 break;
381 default: 381 default:
382 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 382 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
383 FLITE_IN bl; 383 FLITE_IN bl;
384 bl. mode = 1; 384 bl. mode = 1;
385 bl. pwr = bright ? 1 : 0; 385 bl. pwr = bright ? 1 : 0;
386 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 386 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
387 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 387 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
388 ::close ( fd ); 388 ::close ( fd );
389 } 389 }
390 } 390 }
391 return res; 391 return res;
392} 392}
393 393
394int iPAQ::displayBrightnessResolution() const 394int iPAQ::displayBrightnessResolution() const
395{ 395{
396 switch ( model()) { 396 switch ( model()) {
397 case Model_iPAQ_H31xx: 397 case Model_iPAQ_H31xx:
398 case Model_iPAQ_H36xx: 398 case Model_iPAQ_H36xx:
399 case Model_iPAQ_H37xx: 399 case Model_iPAQ_H37xx:
400 return 128; // really 256, but >128 could damage the LCD 400 return 128; // really 256, but >128 could damage the LCD
401 401
402 case Model_iPAQ_H38xx: 402 case Model_iPAQ_H38xx:
403 case Model_iPAQ_H39xx: 403 case Model_iPAQ_H39xx:
404 return 64; 404 return 64;
405 case Model_iPAQ_H5xxx: 405 case Model_iPAQ_H5xxx:
406 return 255; 406 return 255;
407 case Model_iPAQ_H191x: 407 case Model_iPAQ_H191x:
408 return 183; 408 return 183;
409 case Model_iPAQ_H191x: 409 case Model_iPAQ_H1940:
410 return 44; 410 return 44;
411 default: 411 default:
412 return 2; 412 return 2;
413 } 413 }
414} 414}
415 415
416bool iPAQ::setDisplayStatus ( bool on ) 416bool iPAQ::setDisplayStatus ( bool on )
417{ 417{
418 bool res = false; 418 bool res = false;
419 419
420 QString cmdline; 420 QString cmdline;
421 421
422 if ( model() == Model_iPAQ_H191x ) { 422 if ( model() == Model_iPAQ_H191x ) {
423 cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" ); 423 cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
424 } else { 424 } else {
425 return OAbstractMobileDevice::setDisplayStatus(on); 425 return OAbstractMobileDevice::setDisplayStatus(on);
426 } 426 }
427 427
428 res = ( ::system( QFile::encodeName(cmdline) ) == 0 ); 428 res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
429 429
430 return res; 430 return res;
431} 431}
432 432
433bool iPAQ::hasLightSensor() const 433bool iPAQ::hasLightSensor() const
434{ 434{
435 return true; 435 return true;
436} 436}
437 437
438int iPAQ::readLightSensor() 438int iPAQ::readLightSensor()
439{ 439{
440 int fd; 440 int fd;
441 int val = -1; 441 int val = -1;
442 442
443 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 443 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
444 char buffer [8]; 444 char buffer [8];
445 445
446 if ( ::read ( fd, buffer, 5 ) == 5 ) { 446 if ( ::read ( fd, buffer, 5 ) == 5 ) {
447 char *endptr; 447 char *endptr;
448 448
449 buffer [4] = 0; 449 buffer [4] = 0;
450 val = ::strtol ( buffer + 2, &endptr, 16 ); 450 val = ::strtol ( buffer + 2, &endptr, 16 );
451 451
452 if ( *endptr != 0 ) 452 if ( *endptr != 0 )
453 val = -1; 453 val = -1;
454 } 454 }
455 ::close ( fd ); 455 ::close ( fd );
456 } 456 }
457 457
458 return val; 458 return val;
459} 459}
460 460
461int iPAQ::lightSensorResolution() const 461int iPAQ::lightSensorResolution() const
462{ 462{
463 return 256; 463 return 256;
464} 464}