-rw-r--r-- | libopie/odevice.cpp | 72 |
1 files changed, 35 insertions, 37 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index d8415ad..bc43c52 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -325,426 +325,424 @@ void ODevice::touchSound ( ) | |||
325 | 325 | ||
326 | 326 | ||
327 | QValueList <OLed> ODevice::ledList ( ) const | 327 | QValueList <OLed> ODevice::ledList ( ) const |
328 | { | 328 | { |
329 | return QValueList <OLed> ( ); | 329 | return QValueList <OLed> ( ); |
330 | } | 330 | } |
331 | 331 | ||
332 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 332 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
333 | { | 333 | { |
334 | return QValueList <OLedState> ( ); | 334 | return QValueList <OLedState> ( ); |
335 | } | 335 | } |
336 | 336 | ||
337 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 337 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
338 | { | 338 | { |
339 | return Led_Off; | 339 | return Led_Off; |
340 | } | 340 | } |
341 | 341 | ||
342 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) | 342 | bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) |
343 | { | 343 | { |
344 | return false; | 344 | return false; |
345 | } | 345 | } |
346 | 346 | ||
347 | bool ODevice::hasLightSensor ( ) const | 347 | bool ODevice::hasLightSensor ( ) const |
348 | { | 348 | { |
349 | return false; | 349 | return false; |
350 | } | 350 | } |
351 | 351 | ||
352 | int ODevice::readLightSensor ( ) | 352 | int ODevice::readLightSensor ( ) |
353 | { | 353 | { |
354 | return -1; | 354 | return -1; |
355 | } | 355 | } |
356 | 356 | ||
357 | int ODevice::lightSensorResolution ( ) const | 357 | int ODevice::lightSensorResolution ( ) const |
358 | { | 358 | { |
359 | return 0; | 359 | return 0; |
360 | } | 360 | } |
361 | 361 | ||
362 | //QValueList <int> ODevice::keyList ( ) const | 362 | //QValueList <int> ODevice::keyList ( ) const |
363 | //{ | 363 | //{ |
364 | //return QValueList <int> ( ); | 364 | //return QValueList <int> ( ); |
365 | //} | 365 | //} |
366 | 366 | ||
367 | 367 | ||
368 | 368 | ||
369 | /************************************************** | 369 | /************************************************** |
370 | * | 370 | * |
371 | * iPAQ | 371 | * iPAQ |
372 | * | 372 | * |
373 | **************************************************/ | 373 | **************************************************/ |
374 | 374 | ||
375 | void iPAQ::init ( ) | 375 | void iPAQ::init ( ) |
376 | { | 376 | { |
377 | d-> m_vendorstr = "HP"; | 377 | d-> m_vendorstr = "HP"; |
378 | d-> m_vendor = Vendor_HP; | 378 | d-> m_vendor = Vendor_HP; |
379 | 379 | ||
380 | QFile f ( "/proc/hal/model" ); | 380 | QFile f ( "/proc/hal/model" ); |
381 | 381 | ||
382 | if ( f. open ( IO_ReadOnly )) { | 382 | if ( f. open ( IO_ReadOnly )) { |
383 | QTextStream ts ( &f ); | 383 | QTextStream ts ( &f ); |
384 | 384 | ||
385 | d-> m_modelstr = "H" + ts. readLine ( ); | 385 | d-> m_modelstr = "H" + ts. readLine ( ); |
386 | 386 | ||
387 | if ( d-> m_modelstr == "H3100" ) | 387 | if ( d-> m_modelstr == "H3100" ) |
388 | d-> m_model = Model_iPAQ_H31xx; | 388 | d-> m_model = Model_iPAQ_H31xx; |
389 | else if ( d-> m_modelstr == "H3600" ) | 389 | else if ( d-> m_modelstr == "H3600" ) |
390 | d-> m_model = Model_iPAQ_H36xx; | 390 | d-> m_model = Model_iPAQ_H36xx; |
391 | else if ( d-> m_modelstr == "H3700" ) | 391 | else if ( d-> m_modelstr == "H3700" ) |
392 | d-> m_model = Model_iPAQ_H37xx; | 392 | d-> m_model = Model_iPAQ_H37xx; |
393 | else if ( d-> m_modelstr == "H3800" ) | 393 | else if ( d-> m_modelstr == "H3800" ) |
394 | d-> m_model = Model_iPAQ_H38xx; | 394 | d-> m_model = Model_iPAQ_H38xx; |
395 | else if ( d-> m_modelstr == "H3900" ) | 395 | else if ( d-> m_modelstr == "H3900" ) |
396 | d-> m_model = Model_iPAQ_H39xx; | 396 | d-> m_model = Model_iPAQ_H39xx; |
397 | else | 397 | else |
398 | d-> m_model = Model_Unknown; | 398 | d-> m_model = Model_Unknown; |
399 | 399 | ||
400 | f. close ( ); | 400 | f. close ( ); |
401 | } | 401 | } |
402 | 402 | ||
403 | f. setName ( "/etc/familiar-version" ); | 403 | f. setName ( "/etc/familiar-version" ); |
404 | if ( f. open ( IO_ReadOnly )) { | 404 | if ( f. open ( IO_ReadOnly )) { |
405 | d-> m_systemstr = "Familiar"; | 405 | d-> m_systemstr = "Familiar"; |
406 | d-> m_system = System_Familiar; | 406 | d-> m_system = System_Familiar; |
407 | 407 | ||
408 | QTextStream ts ( &f ); | 408 | QTextStream ts ( &f ); |
409 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 409 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
410 | 410 | ||
411 | f. close ( ); | 411 | f. close ( ); |
412 | } | 412 | } |
413 | 413 | ||
414 | m_leds [0] = m_leds [1] = Led_Off; | 414 | m_leds [0] = m_leds [1] = Led_Off; |
415 | 415 | ||
416 | m_power_timer = 0; | 416 | m_power_timer = 0; |
417 | 417 | ||
418 | if ( d-> m_qwsserver ) | 418 | if ( d-> m_qwsserver ) |
419 | QWSServer::setKeyboardFilter ( this ); | 419 | QWSServer::setKeyboardFilter ( this ); |
420 | } | 420 | } |
421 | 421 | ||
422 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 422 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
423 | 423 | ||
424 | typedef struct { | 424 | typedef struct { |
425 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 425 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
426 | unsigned char TotalTime; /* Units of 5 seconds */ | 426 | unsigned char TotalTime; /* Units of 5 seconds */ |
427 | unsigned char OnTime; /* units of 100m/s */ | 427 | unsigned char OnTime; /* units of 100m/s */ |
428 | unsigned char OffTime; /* units of 100m/s */ | 428 | unsigned char OffTime; /* units of 100m/s */ |
429 | } LED_IN; | 429 | } LED_IN; |
430 | 430 | ||
431 | typedef struct { | 431 | typedef struct { |
432 | unsigned char mode; | 432 | unsigned char mode; |
433 | unsigned char pwr; | 433 | unsigned char pwr; |
434 | unsigned char brightness; | 434 | unsigned char brightness; |
435 | } FLITE_IN; | 435 | } FLITE_IN; |
436 | 436 | ||
437 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 437 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
438 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 438 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
439 | 439 | ||
440 | 440 | ||
441 | 441 | ||
442 | QValueList <OLed> iPAQ::ledList ( ) const | 442 | QValueList <OLed> iPAQ::ledList ( ) const |
443 | { | 443 | { |
444 | QValueList <OLed> vl; | 444 | QValueList <OLed> vl; |
445 | vl << Led_Power; | 445 | vl << Led_Power; |
446 | 446 | ||
447 | if ( d-> m_model == Model_iPAQ_H38xx ) | 447 | if ( d-> m_model == Model_iPAQ_H38xx ) |
448 | vl << Led_BlueTooth; | 448 | vl << Led_BlueTooth; |
449 | return vl; | 449 | return vl; |
450 | } | 450 | } |
451 | 451 | ||
452 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 452 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
453 | { | 453 | { |
454 | QValueList <OLedState> vl; | 454 | QValueList <OLedState> vl; |
455 | 455 | ||
456 | if ( l == Led_Power ) | 456 | if ( l == Led_Power ) |
457 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 457 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
458 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 458 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
459 | vl << Led_Off; // << Led_On << ??? | 459 | vl << Led_Off; // << Led_On << ??? |
460 | 460 | ||
461 | return vl; | 461 | return vl; |
462 | } | 462 | } |
463 | 463 | ||
464 | OLedState iPAQ::ledState ( OLed l ) const | 464 | OLedState iPAQ::ledState ( OLed l ) const |
465 | { | 465 | { |
466 | switch ( l ) { | 466 | switch ( l ) { |
467 | case Led_Power: | 467 | case Led_Power: |
468 | return m_leds [0]; | 468 | return m_leds [0]; |
469 | case Led_BlueTooth: | 469 | case Led_BlueTooth: |
470 | return m_leds [1]; | 470 | return m_leds [1]; |
471 | default: | 471 | default: |
472 | return Led_Off; | 472 | return Led_Off; |
473 | } | 473 | } |
474 | } | 474 | } |
475 | 475 | ||
476 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 476 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
477 | { | 477 | { |
478 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 478 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
479 | 479 | ||
480 | if ( l == Led_Power ) { | 480 | if ( l == Led_Power ) { |
481 | if ( fd >= 0 ) { | 481 | if ( fd >= 0 ) { |
482 | LED_IN leds; | 482 | LED_IN leds; |
483 | ::memset ( &leds, 0, sizeof( leds )); | 483 | ::memset ( &leds, 0, sizeof( leds )); |
484 | leds. TotalTime = 0; | 484 | leds. TotalTime = 0; |
485 | leds. OnTime = 0; | 485 | leds. OnTime = 0; |
486 | leds. OffTime = 1; | 486 | leds. OffTime = 1; |
487 | leds. OffOnBlink = 2; | 487 | leds. OffOnBlink = 2; |
488 | 488 | ||
489 | switch ( st ) { | 489 | switch ( st ) { |
490 | case Led_Off : leds. OffOnBlink = 0; break; | 490 | case Led_Off : leds. OffOnBlink = 0; break; |
491 | case Led_On : leds. OffOnBlink = 1; break; | 491 | case Led_On : leds. OffOnBlink = 1; break; |
492 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 492 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
493 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 493 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
494 | } | 494 | } |
495 | 495 | ||
496 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 496 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
497 | m_leds [0] = st; | 497 | m_leds [0] = st; |
498 | return true; | 498 | return true; |
499 | } | 499 | } |
500 | } | 500 | } |
501 | } | 501 | } |
502 | return false; | 502 | return false; |
503 | } | 503 | } |
504 | 504 | ||
505 | 505 | ||
506 | //QValueList <int> iPAQ::keyList ( ) const | 506 | //QValueList <int> iPAQ::keyList ( ) const |
507 | //{ | 507 | //{ |
508 | //QValueList <int> vl; | 508 | //QValueList <int> vl; |
509 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; | 509 | //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; |
510 | //return vl; | 510 | //return vl; |
511 | //} | 511 | //} |
512 | 512 | ||
513 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 513 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
514 | { | 514 | { |
515 | int newkeycode = keycode; | 515 | int newkeycode = keycode; |
516 | 516 | ||
517 | 517 | switch ( keycode ) { | |
518 | // simple susbstitutions | 518 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
519 | switch ( d-> m_model ) { | 519 | case HardKey_Menu: { |
520 | case Model_iPAQ_H38xx: | 520 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
521 | // H38xx has no "Q" key anymore - this is now the Mail key | 521 | ( d-> m_model == Model_iPAQ_H39xx )) { |
522 | if ( keycode == HardKey_Menu ) | ||
523 | newkeycode = HardKey_Mail; | 522 | newkeycode = HardKey_Mail; |
524 | //nobreak | ||
525 | |||
526 | case Model_iPAQ_H31xx: | ||
527 | // Rotate cursor keys 180° | ||
528 | switch ( keycode ) { | ||
529 | case Key_Left : newkeycode = Key_Right; break; | ||
530 | case Key_Right: newkeycode = Key_Left; break; | ||
531 | case Key_Up : newkeycode = Key_Down; break; | ||
532 | case Key_Down : newkeycode = Key_Up; break; | ||
533 | } | 523 | } |
534 | //nobreak; | 524 | break; |
535 | 525 | } | |
536 | case Model_iPAQ_H36xx: | 526 | |
537 | case Model_iPAQ_H37xx: | 527 | // Rotate cursor keys 180° |
538 | // map Power Button short/long press to F34/F35 | 528 | case Key_Left : |
539 | if ( keycode == Key_SysReq ) { | 529 | case Key_Right: |
540 | if ( isPress ) { | 530 | case Key_Up : |
541 | if ( m_power_timer ) | 531 | case Key_Down : { |
542 | killTimer ( m_power_timer ); | 532 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
543 | m_power_timer = startTimer ( 500 ); | 533 | ( d-> m_model == Model_iPAQ_H38xx )) { |
544 | } | 534 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
545 | else if ( m_power_timer ) { | ||
546 | killTimer ( m_power_timer ); | ||
547 | m_power_timer = 0; | ||
548 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | ||
549 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | ||
550 | } | ||
551 | newkeycode = Key_unknown; | ||
552 | } | 535 | } |
553 | //nobreak; | ||
554 | |||
555 | default: | ||
556 | break; | 536 | break; |
557 | } | 537 | } |
558 | 538 | ||
539 | // map Power Button short/long press to F34/F35 | ||
540 | case Key_SysReq: { | ||
541 | if ( isPress ) { | ||
542 | if ( m_power_timer ) | ||
543 | killTimer ( m_power_timer ); | ||
544 | m_power_timer = startTimer ( 500 ); | ||
545 | } | ||
546 | else if ( m_power_timer ) { | ||
547 | killTimer ( m_power_timer ); | ||
548 | m_power_timer = 0; | ||
549 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | ||
550 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | ||
551 | } | ||
552 | newkeycode = Key_unknown; | ||
553 | break; | ||
554 | } | ||
555 | } | ||
556 | |||
559 | if ( newkeycode != keycode ) { | 557 | if ( newkeycode != keycode ) { |
560 | if ( newkeycode != Key_unknown ) | 558 | if ( newkeycode != Key_unknown ) |
561 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 559 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
562 | return true; | 560 | return true; |
563 | } | 561 | } |
564 | else | 562 | else |
565 | return false; | 563 | return false; |
566 | } | 564 | } |
567 | 565 | ||
568 | void iPAQ::timerEvent ( QTimerEvent * ) | 566 | void iPAQ::timerEvent ( QTimerEvent * ) |
569 | { | 567 | { |
570 | killTimer ( m_power_timer ); | 568 | killTimer ( m_power_timer ); |
571 | m_power_timer = 0; | 569 | m_power_timer = 0; |
572 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 570 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
573 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 571 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
574 | } | 572 | } |
575 | 573 | ||
576 | 574 | ||
577 | void iPAQ::alarmSound ( ) | 575 | void iPAQ::alarmSound ( ) |
578 | { | 576 | { |
579 | #ifndef QT_NO_SOUND | 577 | #ifndef QT_NO_SOUND |
580 | static Sound snd ( "alarm" ); | 578 | static Sound snd ( "alarm" ); |
581 | int fd; | 579 | int fd; |
582 | int vol; | 580 | int vol; |
583 | bool vol_reset = false; | 581 | bool vol_reset = false; |
584 | 582 | ||
585 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 583 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
586 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 584 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
587 | Config cfg ( "qpe" ); | 585 | Config cfg ( "qpe" ); |
588 | cfg. setGroup ( "Volume" ); | 586 | cfg. setGroup ( "Volume" ); |
589 | 587 | ||
590 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 588 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
591 | if ( volalarm < 0 ) | 589 | if ( volalarm < 0 ) |
592 | volalarm = 0; | 590 | volalarm = 0; |
593 | else if ( volalarm > 100 ) | 591 | else if ( volalarm > 100 ) |
594 | volalarm = 100; | 592 | volalarm = 100; |
595 | volalarm |= ( volalarm << 8 ); | 593 | volalarm |= ( volalarm << 8 ); |
596 | 594 | ||
597 | if (( volalarm & 0xff ) > ( vol & 0xff )) { | 595 | if (( volalarm & 0xff ) > ( vol & 0xff )) { |
598 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 596 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
599 | vol_reset = true; | 597 | vol_reset = true; |
600 | } | 598 | } |
601 | } | 599 | } |
602 | } | 600 | } |
603 | 601 | ||
604 | snd. play ( ); | 602 | snd. play ( ); |
605 | while ( !snd. isFinished ( )) | 603 | while ( !snd. isFinished ( )) |
606 | qApp-> processEvents ( ); | 604 | qApp-> processEvents ( ); |
607 | 605 | ||
608 | if ( fd >= 0 ) { | 606 | if ( fd >= 0 ) { |
609 | if ( vol_reset ) | 607 | if ( vol_reset ) |
610 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 608 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
611 | ::close ( fd ); | 609 | ::close ( fd ); |
612 | } | 610 | } |
613 | #endif | 611 | #endif |
614 | } | 612 | } |
615 | 613 | ||
616 | 614 | ||
617 | bool iPAQ::setSoftSuspend ( bool soft ) | 615 | bool iPAQ::setSoftSuspend ( bool soft ) |
618 | { | 616 | { |
619 | bool res = false; | 617 | bool res = false; |
620 | int fd; | 618 | int fd; |
621 | 619 | ||
622 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 620 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
623 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 621 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
624 | res = true; | 622 | res = true; |
625 | else | 623 | else |
626 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 624 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
627 | 625 | ||
628 | ::close ( fd ); | 626 | ::close ( fd ); |
629 | } | 627 | } |
630 | else | 628 | else |
631 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 629 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
632 | 630 | ||
633 | return res; | 631 | return res; |
634 | } | 632 | } |
635 | 633 | ||
636 | 634 | ||
637 | bool iPAQ::setDisplayBrightness ( int bright ) | 635 | bool iPAQ::setDisplayBrightness ( int bright ) |
638 | { | 636 | { |
639 | bool res = false; | 637 | bool res = false; |
640 | int fd; | 638 | int fd; |
641 | 639 | ||
642 | if ( bright > 255 ) | 640 | if ( bright > 255 ) |
643 | bright = 255; | 641 | bright = 255; |
644 | if ( bright < 0 ) | 642 | if ( bright < 0 ) |
645 | bright = 0; | 643 | bright = 0; |
646 | 644 | ||
647 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 645 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
648 | FLITE_IN bl; | 646 | FLITE_IN bl; |
649 | bl. mode = 1; | 647 | bl. mode = 1; |
650 | bl. pwr = bright ? 1 : 0; | 648 | bl. pwr = bright ? 1 : 0; |
651 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 649 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
652 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 650 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
653 | ::close ( fd ); | 651 | ::close ( fd ); |
654 | } | 652 | } |
655 | return res; | 653 | return res; |
656 | } | 654 | } |
657 | 655 | ||
658 | int iPAQ::displayBrightnessResolution ( ) const | 656 | int iPAQ::displayBrightnessResolution ( ) const |
659 | { | 657 | { |
660 | switch ( model ( )) { | 658 | switch ( model ( )) { |
661 | case Model_iPAQ_H31xx: | 659 | case Model_iPAQ_H31xx: |
662 | case Model_iPAQ_H36xx: | 660 | case Model_iPAQ_H36xx: |
663 | case Model_iPAQ_H37xx: | 661 | case Model_iPAQ_H37xx: |
664 | return 128; // really 256, but >128 could damage the LCD | 662 | return 128; // really 256, but >128 could damage the LCD |
665 | 663 | ||
666 | case Model_iPAQ_H38xx: | 664 | case Model_iPAQ_H38xx: |
667 | case Model_iPAQ_H39xx: | 665 | case Model_iPAQ_H39xx: |
668 | return 64; | 666 | return 64; |
669 | 667 | ||
670 | default: | 668 | default: |
671 | return 2; | 669 | return 2; |
672 | } | 670 | } |
673 | } | 671 | } |
674 | 672 | ||
675 | 673 | ||
676 | bool iPAQ::hasLightSensor ( ) const | 674 | bool iPAQ::hasLightSensor ( ) const |
677 | { | 675 | { |
678 | return true; | 676 | return true; |
679 | } | 677 | } |
680 | 678 | ||
681 | int iPAQ::readLightSensor ( ) | 679 | int iPAQ::readLightSensor ( ) |
682 | { | 680 | { |
683 | int fd; | 681 | int fd; |
684 | int val = -1; | 682 | int val = -1; |
685 | 683 | ||
686 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 684 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
687 | char buffer [8]; | 685 | char buffer [8]; |
688 | 686 | ||
689 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 687 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
690 | char *endptr; | 688 | char *endptr; |
691 | 689 | ||
692 | buffer [4] = 0; | 690 | buffer [4] = 0; |
693 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 691 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
694 | 692 | ||
695 | if ( *endptr != 0 ) | 693 | if ( *endptr != 0 ) |
696 | val = -1; | 694 | val = -1; |
697 | } | 695 | } |
698 | ::close ( fd ); | 696 | ::close ( fd ); |
699 | } | 697 | } |
700 | 698 | ||
701 | return val; | 699 | return val; |
702 | } | 700 | } |
703 | 701 | ||
704 | int iPAQ::lightSensorResolution ( ) const | 702 | int iPAQ::lightSensorResolution ( ) const |
705 | { | 703 | { |
706 | return 256; | 704 | return 256; |
707 | } | 705 | } |
708 | 706 | ||
709 | /************************************************** | 707 | /************************************************** |
710 | * | 708 | * |
711 | * Zaurus | 709 | * Zaurus |
712 | * | 710 | * |
713 | **************************************************/ | 711 | **************************************************/ |
714 | 712 | ||
715 | 713 | ||
716 | 714 | ||
717 | void Zaurus::init ( ) | 715 | void Zaurus::init ( ) |
718 | { | 716 | { |
719 | d-> m_modelstr = "Zaurus SL5000"; | 717 | d-> m_modelstr = "Zaurus SL5000"; |
720 | d-> m_model = Model_Zaurus_SL5000; | 718 | d-> m_model = Model_Zaurus_SL5000; |
721 | d-> m_vendorstr = "Sharp"; | 719 | d-> m_vendorstr = "Sharp"; |
722 | d-> m_vendor = Vendor_Sharp; | 720 | d-> m_vendor = Vendor_Sharp; |
723 | 721 | ||
724 | QFile f ( "/proc/filesystems" ); | 722 | QFile f ( "/proc/filesystems" ); |
725 | 723 | ||
726 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 724 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
727 | d-> m_systemstr = "OpenZaurus"; | 725 | d-> m_systemstr = "OpenZaurus"; |
728 | d-> m_system = System_OpenZaurus; | 726 | d-> m_system = System_OpenZaurus; |
729 | 727 | ||
730 | f. close ( ); | 728 | f. close ( ); |
731 | 729 | ||
732 | f. setName ( "/etc/oz_version" ); | 730 | f. setName ( "/etc/oz_version" ); |
733 | if ( f. open ( IO_ReadOnly )) { | 731 | if ( f. open ( IO_ReadOnly )) { |
734 | QTextStream ts ( &f ); | 732 | QTextStream ts ( &f ); |
735 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 733 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
736 | f. close ( ); | 734 | f. close ( ); |
737 | } | 735 | } |
738 | } | 736 | } |
739 | else { | 737 | else { |
740 | d-> m_systemstr = "Zaurus"; | 738 | d-> m_systemstr = "Zaurus"; |
741 | d-> m_system = System_Zaurus; | 739 | d-> m_system = System_Zaurus; |
742 | } | 740 | } |
743 | 741 | ||
744 | 742 | ||
745 | m_leds [0] = Led_Off; | 743 | m_leds [0] = Led_Off; |
746 | } | 744 | } |
747 | 745 | ||
748 | #include <unistd.h> | 746 | #include <unistd.h> |
749 | #include <fcntl.h> | 747 | #include <fcntl.h> |
750 | #include <sys/ioctl.h> | 748 | #include <sys/ioctl.h> |