summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_ipaq.cpp
Unidiff
Diffstat (limited to 'libopie2/opiecore/device/odevice_ipaq.cpp') (more/less context) (show whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 6dc1295..b18fd32 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -356,170 +356,169 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b
356 if ( newkeycode != keycode ) { 356 if ( newkeycode != keycode ) {
357 if ( newkeycode != Key_unknown ) 357 if ( newkeycode != Key_unknown )
358 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 358 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
359 return true; 359 return true;
360 } 360 }
361 else 361 else
362 return false; 362 return false;
363} 363}
364 364
365void iPAQ::timerEvent ( QTimerEvent * ) 365void iPAQ::timerEvent ( QTimerEvent * )
366{ 366{
367 killTimer ( m_power_timer ); 367 killTimer ( m_power_timer );
368 m_power_timer = 0; 368 m_power_timer = 0;
369 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 369 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
370 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 370 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
371} 371}
372 372
373 373
374void iPAQ::playAlarmSound() 374void iPAQ::playAlarmSound()
375{ 375{
376#ifndef QT_NO_SOUND 376#ifndef QT_NO_SOUND
377 static Sound snd ( "alarm" ); 377 static Sound snd ( "alarm" );
378 if(!snd.isFinished()) 378 if(!snd.isFinished())
379 return; 379 return;
380 380
381 changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); 381 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
382 snd. play(); 382 snd. play();
383#endif 383#endif
384} 384}
385 385
386bool iPAQ::setDisplayBrightness ( int bright ) 386bool iPAQ::setDisplayBrightness ( int bright )
387{ 387{
388 bool res = false; 388 bool res = false;
389 int fd; 389 int fd;
390 390
391 if ( bright > 255 ) 391 if ( bright > 255 )
392 bright = 255; 392 bright = 255;
393 if ( bright < 0 ) 393 if ( bright < 0 )
394 bright = 0; 394 bright = 0;
395 395
396 QDir sysClass( "/sys/class/backlight/" ); 396 QDir sysClass( "/sys/class/backlight/" );
397 sysClass.setFilter(QDir::Dirs); 397 sysClass.setFilter(QDir::Dirs);
398 if ( sysClass.exists() && sysClass.count() > 2 ) { 398 if ( sysClass.exists() && sysClass.count() > 2 ) {
399 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/brightness" ); 399 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/brightness" );
400 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK ); 400 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
401 if ( fd ) { 401 if ( fd ) {
402 char buf[100]; 402 char buf[100];
403 int val = bright * displayBrightnessResolution() / 255; 403 int val = bright * displayBrightnessResolution() / 255;
404 int len = ::snprintf( &buf[0], sizeof buf, "%d", val ); 404 int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
405 res = ( ::write( fd, &buf[0], len ) == 0 ); 405 res = ( ::write( fd, &buf[0], len ) == 0 );
406 ::close( fd ); 406 ::close( fd );
407 } 407 }
408 } else { 408 } else {
409 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 409 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
410 FLITE_IN bl; 410 FLITE_IN bl;
411 bl. mode = 1; 411 bl. mode = 1;
412 bl. pwr = bright ? 1 : 0; 412 bl. pwr = bright ? 1 : 0;
413 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 413 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
414 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 414 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
415 ::close ( fd ); 415 ::close ( fd );
416 } 416 }
417 } 417 }
418 418
419 return res; 419 return res;
420} 420}
421 421
422int iPAQ::displayBrightnessResolution() const 422int iPAQ::displayBrightnessResolution() const
423{ 423{
424 int res = 16; 424 int res = 16;
425 425
426 QDir sysClass( "/sys/class/backlight/" ); 426 QDir sysClass( "/sys/class/backlight/" );
427 sysClass.setFilter(QDir::Dirs); 427 sysClass.setFilter(QDir::Dirs);
428 if ( sysClass.exists() && sysClass.count() > 2 ) { 428 if ( sysClass.exists() && sysClass.count() > 2 ) {
429 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" ); 429 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/max_brightness" );
430 int fd = ::open( sysClassPath, O_RDONLY|O_NONBLOCK ); 430 int fd = ::open( sysClassPath, O_RDONLY|O_NONBLOCK );
431 if ( fd ) { 431 if ( fd ) {
432 char buf[100]; 432 char buf[100];
433 if ( ::read( fd, &buf[0], sizeof buf ) ) 433 if ( ::read( fd, &buf[0], sizeof buf ) )
434 ::sscanf( &buf[0], "%d", &res ); 434 ::sscanf( &buf[0], "%d", &res );
435 ::close( fd ); 435 ::close( fd );
436 } 436 }
437 return res; 437 return res;
438 } 438 }
439 439
440 switch ( model()) { 440 switch ( model()) {
441 case Model_iPAQ_H31xx: 441 case Model_iPAQ_H31xx:
442 case Model_iPAQ_H36xx: 442 case Model_iPAQ_H36xx:
443 case Model_iPAQ_H37xx: 443 case Model_iPAQ_H37xx:
444 return 128; // really 256, but >128 could damage the LCD 444 return 128; // really 256, but >128 could damage the LCD
445 445
446 case Model_iPAQ_H38xx: 446 case Model_iPAQ_H38xx:
447 case Model_iPAQ_H39xx: 447 case Model_iPAQ_H39xx:
448 return 64; 448 return 64;
449 case Model_iPAQ_H5xxx: 449 case Model_iPAQ_H5xxx:
450 case Model_iPAQ_HX4700: 450 case Model_iPAQ_HX4700:
451 case Model_iPAQ_H4xxx: 451 case Model_iPAQ_H4xxx:
452 return 255;
453 case Model_iPAQ_H191x: 452 case Model_iPAQ_H191x:
454 return 7; 453 return 255;
455 case Model_iPAQ_H1940: 454 case Model_iPAQ_H1940:
456 return 44; 455 return 44;
457 default: 456 default:
458 return 2; 457 return 2;
459 } 458 }
460} 459}
461 460
462bool iPAQ::setDisplayStatus ( bool on ) 461bool iPAQ::setDisplayStatus ( bool on )
463{ 462{
464 bool res = false; 463 bool res = false;
465 464
466 QString cmdline; 465 QString cmdline;
467 466
468 QDir sysClass( "/sys/class/lcd/" ); 467 QDir sysClass( "/sys/class/lcd/" );
469 sysClass.setFilter(QDir::Dirs); 468 sysClass.setFilter(QDir::Dirs);
470 if ( sysClass.exists() && sysClass.count() > 2 ) { 469 if ( sysClass.exists() && sysClass.count() > 2 ) {
471 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/power" ); 470 QString sysClassPath = sysClass.absFilePath( sysClass[2] + "/power" );
472 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK ); 471 int fd = ::open( sysClassPath, O_WRONLY|O_NONBLOCK );
473 if ( fd ) { 472 if ( fd ) {
474 char buf[10]; 473 char buf[10];
475 buf[0] = on ? 0 : 4; 474 buf[0] = on ? 0 : 4;
476 buf[1] = '\0'; 475 buf[1] = '\0';
477 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 476 res = ( ::write( fd, &buf[0], 2 ) == 0 );
478 ::close( fd ); 477 ::close( fd );
479 } 478 }
480 } else { 479 } else {
481 res = OAbstractMobileDevice::setDisplayStatus(on); 480 res = OAbstractMobileDevice::setDisplayStatus(on);
482 } 481 }
483 482
484 return res; 483 return res;
485} 484}
486 485
487bool iPAQ::hasLightSensor() const 486bool iPAQ::hasLightSensor() const
488{ 487{
489 switch (model()) { 488 switch (model()) {
490 case Model_iPAQ_H191x: 489 case Model_iPAQ_H191x:
491 case Model_iPAQ_H22xx: 490 case Model_iPAQ_H22xx:
492 case Model_iPAQ_H4xxx: 491 case Model_iPAQ_H4xxx:
493 return false; 492 return false;
494 default: 493 default:
495 return true; 494 return true;
496 } 495 }
497} 496}
498 497
499int iPAQ::readLightSensor() 498int iPAQ::readLightSensor()
500{ 499{
501 int fd; 500 int fd;
502 int val = -1; 501 int val = -1;
503 502
504 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 503 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
505 char buffer [8]; 504 char buffer [8];
506 505
507 if ( ::read ( fd, buffer, 5 ) == 5 ) { 506 if ( ::read ( fd, buffer, 5 ) == 5 ) {
508 char *endptr; 507 char *endptr;
509 508
510 buffer [4] = 0; 509 buffer [4] = 0;
511 val = ::strtol ( buffer + 2, &endptr, 16 ); 510 val = ::strtol ( buffer + 2, &endptr, 16 );
512 511
513 if ( *endptr != 0 ) 512 if ( *endptr != 0 )
514 val = -1; 513 val = -1;
515 } 514 }
516 ::close ( fd ); 515 ::close ( fd );
517 } 516 }
518 517
519 return val; 518 return val;
520} 519}
521 520
522int iPAQ::lightSensorResolution() const 521int iPAQ::lightSensorResolution() const
523{ 522{
524 return 256; 523 return 256;
525} 524}