-rw-r--r-- | libopie/odevice.cpp | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 29c8ad2..713cc90 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -381,1014 +381,1026 @@ bool ODevice::setDisplayStatus ( bool on ) | |||
381 | 381 | ||
382 | bool res = false; | 382 | bool res = false; |
383 | int fd; | 383 | int fd; |
384 | 384 | ||
385 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 385 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
386 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 386 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
387 | ::close ( fd ); | 387 | ::close ( fd ); |
388 | } | 388 | } |
389 | return res; | 389 | return res; |
390 | } | 390 | } |
391 | 391 | ||
392 | /** | 392 | /** |
393 | * This sets the display brightness | 393 | * This sets the display brightness |
394 | * @return success or failure | 394 | * @return success or failure |
395 | */ | 395 | */ |
396 | bool ODevice::setDisplayBrightness ( int p) | 396 | bool ODevice::setDisplayBrightness ( int p) |
397 | { | 397 | { |
398 | Q_UNUSED( p ) | 398 | Q_UNUSED( p ) |
399 | return false; | 399 | return false; |
400 | } | 400 | } |
401 | 401 | ||
402 | int ODevice::displayBrightnessResolution ( ) const | 402 | int ODevice::displayBrightnessResolution ( ) const |
403 | { | 403 | { |
404 | return 16; | 404 | return 16; |
405 | } | 405 | } |
406 | 406 | ||
407 | /** | 407 | /** |
408 | * This returns the vendor as string | 408 | * This returns the vendor as string |
409 | * @return Vendor as QString | 409 | * @return Vendor as QString |
410 | */ | 410 | */ |
411 | QString ODevice::vendorString ( ) const | 411 | QString ODevice::vendorString ( ) const |
412 | { | 412 | { |
413 | return d-> m_vendorstr; | 413 | return d-> m_vendorstr; |
414 | } | 414 | } |
415 | 415 | ||
416 | /** | 416 | /** |
417 | * This returns the vendor as one of the values of OVendor | 417 | * This returns the vendor as one of the values of OVendor |
418 | * @return OVendor | 418 | * @return OVendor |
419 | */ | 419 | */ |
420 | OVendor ODevice::vendor ( ) const | 420 | OVendor ODevice::vendor ( ) const |
421 | { | 421 | { |
422 | return d-> m_vendor; | 422 | return d-> m_vendor; |
423 | } | 423 | } |
424 | 424 | ||
425 | /** | 425 | /** |
426 | * This returns the model as a string | 426 | * This returns the model as a string |
427 | * @return A string representing the model | 427 | * @return A string representing the model |
428 | */ | 428 | */ |
429 | QString ODevice::modelString ( ) const | 429 | QString ODevice::modelString ( ) const |
430 | { | 430 | { |
431 | return d-> m_modelstr; | 431 | return d-> m_modelstr; |
432 | } | 432 | } |
433 | 433 | ||
434 | /** | 434 | /** |
435 | * This does return the OModel used | 435 | * This does return the OModel used |
436 | */ | 436 | */ |
437 | OModel ODevice::model ( ) const | 437 | OModel ODevice::model ( ) const |
438 | { | 438 | { |
439 | return d-> m_model; | 439 | return d-> m_model; |
440 | } | 440 | } |
441 | 441 | ||
442 | /** | 442 | /** |
443 | * This does return the systen name | 443 | * This does return the systen name |
444 | */ | 444 | */ |
445 | QString ODevice::systemString ( ) const | 445 | QString ODevice::systemString ( ) const |
446 | { | 446 | { |
447 | return d-> m_systemstr; | 447 | return d-> m_systemstr; |
448 | } | 448 | } |
449 | 449 | ||
450 | /** | 450 | /** |
451 | * Return System as OSystem value | 451 | * Return System as OSystem value |
452 | */ | 452 | */ |
453 | OSystem ODevice::system ( ) const | 453 | OSystem ODevice::system ( ) const |
454 | { | 454 | { |
455 | return d-> m_system; | 455 | return d-> m_system; |
456 | } | 456 | } |
457 | 457 | ||
458 | /** | 458 | /** |
459 | * @return the version string of the base system | 459 | * @return the version string of the base system |
460 | */ | 460 | */ |
461 | QString ODevice::systemVersionString ( ) const | 461 | QString ODevice::systemVersionString ( ) const |
462 | { | 462 | { |
463 | return d-> m_sysverstr; | 463 | return d-> m_sysverstr; |
464 | } | 464 | } |
465 | 465 | ||
466 | /** | 466 | /** |
467 | * @return the current Transformation | 467 | * @return the current Transformation |
468 | */ | 468 | */ |
469 | Transformation ODevice::rotation ( ) const | 469 | Transformation ODevice::rotation ( ) const |
470 | { | 470 | { |
471 | return d-> m_rotation; | 471 | return d-> m_rotation; |
472 | } | 472 | } |
473 | 473 | ||
474 | /** | 474 | /** |
475 | * @return the current rotation direction | 475 | * @return the current rotation direction |
476 | */ | 476 | */ |
477 | ODirection ODevice::direction ( ) const | 477 | ODirection ODevice::direction ( ) const |
478 | { | 478 | { |
479 | return d-> m_direction; | 479 | return d-> m_direction; |
480 | } | 480 | } |
481 | 481 | ||
482 | /** | 482 | /** |
483 | * This plays an alarmSound | 483 | * This plays an alarmSound |
484 | */ | 484 | */ |
485 | void ODevice::alarmSound ( ) | 485 | void ODevice::alarmSound ( ) |
486 | { | 486 | { |
487 | #ifndef QT_NO_SOUND | 487 | #ifndef QT_NO_SOUND |
488 | static Sound snd ( "alarm" ); | 488 | static Sound snd ( "alarm" ); |
489 | 489 | ||
490 | if ( snd. isFinished ( )) | 490 | if ( snd. isFinished ( )) |
491 | snd. play ( ); | 491 | snd. play ( ); |
492 | #endif | 492 | #endif |
493 | } | 493 | } |
494 | 494 | ||
495 | /** | 495 | /** |
496 | * This plays a key sound | 496 | * This plays a key sound |
497 | */ | 497 | */ |
498 | void ODevice::keySound ( ) | 498 | void ODevice::keySound ( ) |
499 | { | 499 | { |
500 | #ifndef QT_NO_SOUND | 500 | #ifndef QT_NO_SOUND |
501 | static Sound snd ( "keysound" ); | 501 | static Sound snd ( "keysound" ); |
502 | 502 | ||
503 | if ( snd. isFinished ( )) | 503 | if ( snd. isFinished ( )) |
504 | snd. play ( ); | 504 | snd. play ( ); |
505 | #endif | 505 | #endif |
506 | } | 506 | } |
507 | 507 | ||
508 | /** | 508 | /** |
509 | * This plays a touch sound | 509 | * This plays a touch sound |
510 | */ | 510 | */ |
511 | void ODevice::touchSound ( ) | 511 | void ODevice::touchSound ( ) |
512 | { | 512 | { |
513 | 513 | ||
514 | #ifndef QT_NO_SOUND | 514 | #ifndef QT_NO_SOUND |
515 | static Sound snd ( "touchsound" ); | 515 | static Sound snd ( "touchsound" ); |
516 | 516 | ||
517 | if ( snd. isFinished ( )) | 517 | if ( snd. isFinished ( )) |
518 | snd. play ( ); | 518 | snd. play ( ); |
519 | #endif | 519 | #endif |
520 | } | 520 | } |
521 | 521 | ||
522 | /** | 522 | /** |
523 | * This method will return a list of leds | 523 | * This method will return a list of leds |
524 | * available on this device | 524 | * available on this device |
525 | * @return a list of LEDs. | 525 | * @return a list of LEDs. |
526 | */ | 526 | */ |
527 | QValueList <OLed> ODevice::ledList ( ) const | 527 | QValueList <OLed> ODevice::ledList ( ) const |
528 | { | 528 | { |
529 | return QValueList <OLed> ( ); | 529 | return QValueList <OLed> ( ); |
530 | } | 530 | } |
531 | 531 | ||
532 | /** | 532 | /** |
533 | * This does return the state of the LEDs | 533 | * This does return the state of the LEDs |
534 | */ | 534 | */ |
535 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 535 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
536 | { | 536 | { |
537 | return QValueList <OLedState> ( ); | 537 | return QValueList <OLedState> ( ); |
538 | } | 538 | } |
539 | 539 | ||
540 | /** | 540 | /** |
541 | * @return the state for a given OLed | 541 | * @return the state for a given OLed |
542 | */ | 542 | */ |
543 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 543 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
544 | { | 544 | { |
545 | return Led_Off; | 545 | return Led_Off; |
546 | } | 546 | } |
547 | 547 | ||
548 | /** | 548 | /** |
549 | * Set the state for a LED | 549 | * Set the state for a LED |
550 | * @param which Which OLed to use | 550 | * @param which Which OLed to use |
551 | * @param st The state to set | 551 | * @param st The state to set |
552 | * @return success or failure | 552 | * @return success or failure |
553 | */ | 553 | */ |
554 | bool ODevice::setLedState ( OLed which, OLedState st ) | 554 | bool ODevice::setLedState ( OLed which, OLedState st ) |
555 | { | 555 | { |
556 | Q_UNUSED( which ) | 556 | Q_UNUSED( which ) |
557 | Q_UNUSED( st ) | 557 | Q_UNUSED( st ) |
558 | return false; | 558 | return false; |
559 | } | 559 | } |
560 | 560 | ||
561 | /** | 561 | /** |
562 | * @return if the device has a light sensor | 562 | * @return if the device has a light sensor |
563 | */ | 563 | */ |
564 | bool ODevice::hasLightSensor ( ) const | 564 | bool ODevice::hasLightSensor ( ) const |
565 | { | 565 | { |
566 | return false; | 566 | return false; |
567 | } | 567 | } |
568 | 568 | ||
569 | /** | 569 | /** |
570 | * @return a value from the light senso | 570 | * @return a value from the light senso |
571 | */ | 571 | */ |
572 | int ODevice::readLightSensor ( ) | 572 | int ODevice::readLightSensor ( ) |
573 | { | 573 | { |
574 | return -1; | 574 | return -1; |
575 | } | 575 | } |
576 | 576 | ||
577 | /** | 577 | /** |
578 | * @return the light sensor resolution whatever that is ;) | 578 | * @return the light sensor resolution whatever that is ;) |
579 | */ | 579 | */ |
580 | int ODevice::lightSensorResolution ( ) const | 580 | int ODevice::lightSensorResolution ( ) const |
581 | { | 581 | { |
582 | return 0; | 582 | return 0; |
583 | } | 583 | } |
584 | 584 | ||
585 | /** | 585 | /** |
586 | * @return a list of hardware buttons | 586 | * @return a list of hardware buttons |
587 | */ | 587 | */ |
588 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 588 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
589 | { | 589 | { |
590 | initButtons ( ); | 590 | initButtons ( ); |
591 | 591 | ||
592 | return *d-> m_buttons; | 592 | return *d-> m_buttons; |
593 | } | 593 | } |
594 | 594 | ||
595 | /** | 595 | /** |
596 | * @return The amount of time that would count as a hold | 596 | * @return The amount of time that would count as a hold |
597 | */ | 597 | */ |
598 | uint ODevice::buttonHoldTime ( ) const | 598 | uint ODevice::buttonHoldTime ( ) const |
599 | { | 599 | { |
600 | return d-> m_holdtime; | 600 | return d-> m_holdtime; |
601 | } | 601 | } |
602 | 602 | ||
603 | /** | 603 | /** |
604 | * This method return a ODeviceButton for a key code | 604 | * This method return a ODeviceButton for a key code |
605 | * or 0 if no special hardware button is available for the device | 605 | * or 0 if no special hardware button is available for the device |
606 | * | 606 | * |
607 | * @return The devicebutton or 0l | 607 | * @return The devicebutton or 0l |
608 | * @see ODeviceButton | 608 | * @see ODeviceButton |
609 | */ | 609 | */ |
610 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 610 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
611 | { | 611 | { |
612 | initButtons ( ); | 612 | initButtons ( ); |
613 | 613 | ||
614 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 614 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
615 | if ( (*it). keycode ( ) == code ) | 615 | if ( (*it). keycode ( ) == code ) |
616 | return &(*it); | 616 | return &(*it); |
617 | } | 617 | } |
618 | return 0; | 618 | return 0; |
619 | } | 619 | } |
620 | 620 | ||
621 | void ODevice::reloadButtonMapping ( ) | 621 | void ODevice::reloadButtonMapping ( ) |
622 | { | 622 | { |
623 | initButtons ( ); | 623 | initButtons ( ); |
624 | 624 | ||
625 | Config cfg ( "ButtonSettings" ); | 625 | Config cfg ( "ButtonSettings" ); |
626 | 626 | ||
627 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 627 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
628 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 628 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
629 | QString group = "Button" + QString::number ( i ); | 629 | QString group = "Button" + QString::number ( i ); |
630 | 630 | ||
631 | QCString pch, hch; | 631 | QCString pch, hch; |
632 | QCString pm, hm; | 632 | QCString pm, hm; |
633 | QByteArray pdata, hdata; | 633 | QByteArray pdata, hdata; |
634 | 634 | ||
635 | if ( cfg. hasGroup ( group )) { | 635 | if ( cfg. hasGroup ( group )) { |
636 | cfg. setGroup ( group ); | 636 | cfg. setGroup ( group ); |
637 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 637 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
638 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 638 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
639 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 639 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
640 | 640 | ||
641 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 641 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
642 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 642 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
643 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 643 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
644 | } | 644 | } |
645 | 645 | ||
646 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 646 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
647 | 647 | ||
648 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 648 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
649 | } | 649 | } |
650 | } | 650 | } |
651 | 651 | ||
652 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 652 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
653 | { | 653 | { |
654 | initButtons ( ); | 654 | initButtons ( ); |
655 | 655 | ||
656 | QString mb_chan; | 656 | QString mb_chan; |
657 | 657 | ||
658 | if ( button >= (int) d-> m_buttons-> count ( )) | 658 | if ( button >= (int) d-> m_buttons-> count ( )) |
659 | return; | 659 | return; |
660 | 660 | ||
661 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 661 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
662 | b. setPressedAction ( action ); | 662 | b. setPressedAction ( action ); |
663 | 663 | ||
664 | mb_chan=b. pressedAction ( ). channel ( ); | 664 | mb_chan=b. pressedAction ( ). channel ( ); |
665 | 665 | ||
666 | Config buttonFile ( "ButtonSettings" ); | 666 | Config buttonFile ( "ButtonSettings" ); |
667 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 667 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
668 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 668 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
669 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 669 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
670 | 670 | ||
671 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 671 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
672 | 672 | ||
673 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 673 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
674 | } | 674 | } |
675 | 675 | ||
676 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 676 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
677 | { | 677 | { |
678 | initButtons ( ); | 678 | initButtons ( ); |
679 | 679 | ||
680 | if ( button >= (int) d-> m_buttons-> count ( )) | 680 | if ( button >= (int) d-> m_buttons-> count ( )) |
681 | return; | 681 | return; |
682 | 682 | ||
683 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 683 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
684 | b. setHeldAction ( action ); | 684 | b. setHeldAction ( action ); |
685 | 685 | ||
686 | Config buttonFile ( "ButtonSettings" ); | 686 | Config buttonFile ( "ButtonSettings" ); |
687 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 687 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
688 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 688 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
689 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 689 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
690 | 690 | ||
691 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 691 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
692 | 692 | ||
693 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 693 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
694 | } | 694 | } |
695 | 695 | ||
696 | 696 | ||
697 | 697 | ||
698 | 698 | ||
699 | /************************************************** | 699 | /************************************************** |
700 | * | 700 | * |
701 | * iPAQ | 701 | * iPAQ |
702 | * | 702 | * |
703 | **************************************************/ | 703 | **************************************************/ |
704 | 704 | ||
705 | void iPAQ::init ( ) | 705 | void iPAQ::init ( ) |
706 | { | 706 | { |
707 | d-> m_vendorstr = "HP"; | 707 | d-> m_vendorstr = "HP"; |
708 | d-> m_vendor = Vendor_HP; | 708 | d-> m_vendor = Vendor_HP; |
709 | 709 | ||
710 | QFile f ( "/proc/hal/model" ); | 710 | QFile f ( "/proc/hal/model" ); |
711 | 711 | ||
712 | if ( f. open ( IO_ReadOnly )) { | 712 | if ( f. open ( IO_ReadOnly )) { |
713 | QTextStream ts ( &f ); | 713 | QTextStream ts ( &f ); |
714 | 714 | ||
715 | d-> m_modelstr = "H" + ts. readLine ( ); | 715 | d-> m_modelstr = "H" + ts. readLine ( ); |
716 | 716 | ||
717 | if ( d-> m_modelstr == "H3100" ) | 717 | if ( d-> m_modelstr == "H3100" ) |
718 | d-> m_model = Model_iPAQ_H31xx; | 718 | d-> m_model = Model_iPAQ_H31xx; |
719 | else if ( d-> m_modelstr == "H3600" ) | 719 | else if ( d-> m_modelstr == "H3600" ) |
720 | d-> m_model = Model_iPAQ_H36xx; | 720 | d-> m_model = Model_iPAQ_H36xx; |
721 | else if ( d-> m_modelstr == "H3700" ) | 721 | else if ( d-> m_modelstr == "H3700" ) |
722 | d-> m_model = Model_iPAQ_H37xx; | 722 | d-> m_model = Model_iPAQ_H37xx; |
723 | else if ( d-> m_modelstr == "H3800" ) | 723 | else if ( d-> m_modelstr == "H3800" ) |
724 | d-> m_model = Model_iPAQ_H38xx; | 724 | d-> m_model = Model_iPAQ_H38xx; |
725 | else if ( d-> m_modelstr == "H3900" ) | 725 | else if ( d-> m_modelstr == "H3900" ) |
726 | d-> m_model = Model_iPAQ_H39xx; | 726 | d-> m_model = Model_iPAQ_H39xx; |
727 | else | 727 | else |
728 | d-> m_model = Model_Unknown; | 728 | d-> m_model = Model_Unknown; |
729 | 729 | ||
730 | f. close ( ); | 730 | f. close ( ); |
731 | } | 731 | } |
732 | 732 | ||
733 | switch ( d-> m_model ) { | 733 | switch ( d-> m_model ) { |
734 | case Model_iPAQ_H31xx: | 734 | case Model_iPAQ_H31xx: |
735 | case Model_iPAQ_H38xx: | 735 | case Model_iPAQ_H38xx: |
736 | d-> m_rotation = Rot90; | 736 | d-> m_rotation = Rot90; |
737 | break; | 737 | break; |
738 | case Model_iPAQ_H36xx: | 738 | case Model_iPAQ_H36xx: |
739 | case Model_iPAQ_H37xx: | 739 | case Model_iPAQ_H37xx: |
740 | case Model_iPAQ_H39xx: | 740 | case Model_iPAQ_H39xx: |
741 | default: | 741 | default: |
742 | d-> m_rotation = Rot270; | 742 | d-> m_rotation = Rot270; |
743 | break; | 743 | break; |
744 | } | 744 | } |
745 | 745 | ||
746 | f. setName ( "/etc/familiar-version" ); | 746 | f. setName ( "/etc/familiar-version" ); |
747 | if ( f. open ( IO_ReadOnly )) { | 747 | if ( f. open ( IO_ReadOnly )) { |
748 | d-> m_systemstr = "Familiar"; | 748 | d-> m_systemstr = "Familiar"; |
749 | d-> m_system = System_Familiar; | 749 | d-> m_system = System_Familiar; |
750 | 750 | ||
751 | QTextStream ts ( &f ); | 751 | QTextStream ts ( &f ); |
752 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 752 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
753 | 753 | ||
754 | f. close ( ); | 754 | f. close ( ); |
755 | } else { | 755 | } else { |
756 | f. setName ( "/etc/oz_version" ); | 756 | f. setName ( "/etc/oz_version" ); |
757 | 757 | ||
758 | if ( f. open ( IO_ReadOnly )) { | 758 | if ( f. open ( IO_ReadOnly )) { |
759 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 759 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
760 | d-> m_system = System_Familiar; | 760 | d-> m_system = System_Familiar; |
761 | 761 | ||
762 | QTextStream ts ( &f ); | 762 | QTextStream ts ( &f ); |
763 | ts.setDevice ( &f ); | 763 | ts.setDevice ( &f ); |
764 | d-> m_sysverstr = ts. readLine ( ); | 764 | d-> m_sysverstr = ts. readLine ( ); |
765 | f. close ( ); | 765 | f. close ( ); |
766 | } | 766 | } |
767 | } | 767 | } |
768 | 768 | ||
769 | 769 | ||
770 | 770 | ||
771 | 771 | ||
772 | 772 | ||
773 | m_leds [0] = m_leds [1] = Led_Off; | 773 | m_leds [0] = m_leds [1] = Led_Off; |
774 | 774 | ||
775 | m_power_timer = 0; | 775 | m_power_timer = 0; |
776 | 776 | ||
777 | } | 777 | } |
778 | 778 | ||
779 | void iPAQ::initButtons ( ) | 779 | void iPAQ::initButtons ( ) |
780 | { | 780 | { |
781 | if ( d-> m_buttons ) | 781 | if ( d-> m_buttons ) |
782 | return; | 782 | return; |
783 | 783 | ||
784 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 784 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
785 | 785 | ||
786 | if ( d-> m_qwsserver ) | 786 | if ( d-> m_qwsserver ) |
787 | QWSServer::setKeyboardFilter ( this ); | 787 | QWSServer::setKeyboardFilter ( this ); |
788 | 788 | ||
789 | d-> m_buttons = new QValueList <ODeviceButton>; | 789 | d-> m_buttons = new QValueList <ODeviceButton>; |
790 | 790 | ||
791 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 791 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
792 | i_button *ib = ipaq_buttons + i; | 792 | i_button *ib = ipaq_buttons + i; |
793 | ODeviceButton b; | 793 | ODeviceButton b; |
794 | 794 | ||
795 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 795 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
796 | b. setKeycode ( ib-> code ); | 796 | b. setKeycode ( ib-> code ); |
797 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 797 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
798 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 798 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
799 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 799 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
800 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 800 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
801 | 801 | ||
802 | d-> m_buttons-> append ( b ); | 802 | d-> m_buttons-> append ( b ); |
803 | } | 803 | } |
804 | } | 804 | } |
805 | reloadButtonMapping ( ); | 805 | reloadButtonMapping ( ); |
806 | 806 | ||
807 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 807 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
808 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 808 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
809 | } | 809 | } |
810 | 810 | ||
811 | 811 | ||
812 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 812 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
813 | 813 | ||
814 | typedef struct { | 814 | typedef struct { |
815 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 815 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
816 | unsigned char TotalTime; /* Units of 5 seconds */ | 816 | unsigned char TotalTime; /* Units of 5 seconds */ |
817 | unsigned char OnTime; /* units of 100m/s */ | 817 | unsigned char OnTime; /* units of 100m/s */ |
818 | unsigned char OffTime; /* units of 100m/s */ | 818 | unsigned char OffTime; /* units of 100m/s */ |
819 | } LED_IN; | 819 | } LED_IN; |
820 | 820 | ||
821 | typedef struct { | 821 | typedef struct { |
822 | unsigned char mode; | 822 | unsigned char mode; |
823 | unsigned char pwr; | 823 | unsigned char pwr; |
824 | unsigned char brightness; | 824 | unsigned char brightness; |
825 | } FLITE_IN; | 825 | } FLITE_IN; |
826 | 826 | ||
827 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 827 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
828 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 828 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
829 | 829 | ||
830 | 830 | ||
831 | QValueList <OLed> iPAQ::ledList ( ) const | 831 | QValueList <OLed> iPAQ::ledList ( ) const |
832 | { | 832 | { |
833 | QValueList <OLed> vl; | 833 | QValueList <OLed> vl; |
834 | vl << Led_Power; | 834 | vl << Led_Power; |
835 | 835 | ||
836 | if ( d-> m_model == Model_iPAQ_H38xx ) | 836 | if ( d-> m_model == Model_iPAQ_H38xx ) |
837 | vl << Led_BlueTooth; | 837 | vl << Led_BlueTooth; |
838 | return vl; | 838 | return vl; |
839 | } | 839 | } |
840 | 840 | ||
841 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 841 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
842 | { | 842 | { |
843 | QValueList <OLedState> vl; | 843 | QValueList <OLedState> vl; |
844 | 844 | ||
845 | if ( l == Led_Power ) | 845 | if ( l == Led_Power ) |
846 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 846 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
847 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 847 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
848 | vl << Led_Off; // << Led_On << ??? | 848 | vl << Led_Off; // << Led_On << ??? |
849 | 849 | ||
850 | return vl; | 850 | return vl; |
851 | } | 851 | } |
852 | 852 | ||
853 | OLedState iPAQ::ledState ( OLed l ) const | 853 | OLedState iPAQ::ledState ( OLed l ) const |
854 | { | 854 | { |
855 | switch ( l ) { | 855 | switch ( l ) { |
856 | case Led_Power: | 856 | case Led_Power: |
857 | return m_leds [0]; | 857 | return m_leds [0]; |
858 | case Led_BlueTooth: | 858 | case Led_BlueTooth: |
859 | return m_leds [1]; | 859 | return m_leds [1]; |
860 | default: | 860 | default: |
861 | return Led_Off; | 861 | return Led_Off; |
862 | } | 862 | } |
863 | } | 863 | } |
864 | 864 | ||
865 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 865 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
866 | { | 866 | { |
867 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 867 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
868 | 868 | ||
869 | if ( l == Led_Power ) { | 869 | if ( l == Led_Power ) { |
870 | if ( fd >= 0 ) { | 870 | if ( fd >= 0 ) { |
871 | LED_IN leds; | 871 | LED_IN leds; |
872 | ::memset ( &leds, 0, sizeof( leds )); | 872 | ::memset ( &leds, 0, sizeof( leds )); |
873 | leds. TotalTime = 0; | 873 | leds. TotalTime = 0; |
874 | leds. OnTime = 0; | 874 | leds. OnTime = 0; |
875 | leds. OffTime = 1; | 875 | leds. OffTime = 1; |
876 | leds. OffOnBlink = 2; | 876 | leds. OffOnBlink = 2; |
877 | 877 | ||
878 | switch ( st ) { | 878 | switch ( st ) { |
879 | case Led_Off : leds. OffOnBlink = 0; break; | 879 | case Led_Off : leds. OffOnBlink = 0; break; |
880 | case Led_On : leds. OffOnBlink = 1; break; | 880 | case Led_On : leds. OffOnBlink = 1; break; |
881 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 881 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
882 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 882 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
883 | } | 883 | } |
884 | 884 | ||
885 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 885 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
886 | m_leds [0] = st; | 886 | m_leds [0] = st; |
887 | return true; | 887 | return true; |
888 | } | 888 | } |
889 | } | 889 | } |
890 | } | 890 | } |
891 | return false; | 891 | return false; |
892 | } | 892 | } |
893 | 893 | ||
894 | 894 | ||
895 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 895 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
896 | { | 896 | { |
897 | int newkeycode = keycode; | 897 | int newkeycode = keycode; |
898 | 898 | ||
899 | switch ( keycode ) { | 899 | switch ( keycode ) { |
900 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 900 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
901 | case HardKey_Menu: { | 901 | case HardKey_Menu: { |
902 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 902 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
903 | ( d-> m_model == Model_iPAQ_H39xx )) { | 903 | ( d-> m_model == Model_iPAQ_H39xx )) { |
904 | newkeycode = HardKey_Mail; | 904 | newkeycode = HardKey_Mail; |
905 | } | 905 | } |
906 | break; | 906 | break; |
907 | } | 907 | } |
908 | 908 | ||
909 | // Rotate cursor keys 180° | 909 | // Rotate cursor keys 180° |
910 | case Key_Left : | 910 | case Key_Left : |
911 | case Key_Right: | 911 | case Key_Right: |
912 | case Key_Up : | 912 | case Key_Up : |
913 | case Key_Down : { | 913 | case Key_Down : { |
914 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 914 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
915 | ( d-> m_model == Model_iPAQ_H38xx )) { | 915 | ( d-> m_model == Model_iPAQ_H38xx )) { |
916 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 916 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
917 | } | 917 | } |
918 | break; | 918 | break; |
919 | } | 919 | } |
920 | 920 | ||
921 | // map Power Button short/long press to F34/F35 | 921 | // map Power Button short/long press to F34/F35 |
922 | case Key_SysReq: { | 922 | case Key_SysReq: { |
923 | if ( isPress ) { | 923 | if ( isPress ) { |
924 | if ( m_power_timer ) | 924 | if ( m_power_timer ) |
925 | killTimer ( m_power_timer ); | 925 | killTimer ( m_power_timer ); |
926 | m_power_timer = startTimer ( 500 ); | 926 | m_power_timer = startTimer ( 500 ); |
927 | } | 927 | } |
928 | else if ( m_power_timer ) { | 928 | else if ( m_power_timer ) { |
929 | killTimer ( m_power_timer ); | 929 | killTimer ( m_power_timer ); |
930 | m_power_timer = 0; | 930 | m_power_timer = 0; |
931 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 931 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
932 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 932 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
933 | } | 933 | } |
934 | newkeycode = Key_unknown; | 934 | newkeycode = Key_unknown; |
935 | break; | 935 | break; |
936 | } | 936 | } |
937 | } | 937 | } |
938 | 938 | ||
939 | if ( newkeycode != keycode ) { | 939 | if ( newkeycode != keycode ) { |
940 | if ( newkeycode != Key_unknown ) | 940 | if ( newkeycode != Key_unknown ) |
941 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 941 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
942 | return true; | 942 | return true; |
943 | } | 943 | } |
944 | else | 944 | else |
945 | return false; | 945 | return false; |
946 | } | 946 | } |
947 | 947 | ||
948 | void iPAQ::timerEvent ( QTimerEvent * ) | 948 | void iPAQ::timerEvent ( QTimerEvent * ) |
949 | { | 949 | { |
950 | killTimer ( m_power_timer ); | 950 | killTimer ( m_power_timer ); |
951 | m_power_timer = 0; | 951 | m_power_timer = 0; |
952 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 952 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
953 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 953 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
954 | } | 954 | } |
955 | 955 | ||
956 | 956 | ||
957 | void iPAQ::alarmSound ( ) | 957 | void iPAQ::alarmSound ( ) |
958 | { | 958 | { |
959 | #ifndef QT_NO_SOUND | 959 | #ifndef QT_NO_SOUND |
960 | static Sound snd ( "alarm" ); | 960 | static Sound snd ( "alarm" ); |
961 | int fd; | 961 | int fd; |
962 | int vol; | 962 | int vol; |
963 | bool vol_reset = false; | 963 | bool vol_reset = false; |
964 | 964 | ||
965 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 965 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
966 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 966 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
967 | Config cfg ( "qpe" ); | 967 | Config cfg ( "qpe" ); |
968 | cfg. setGroup ( "Volume" ); | 968 | cfg. setGroup ( "Volume" ); |
969 | 969 | ||
970 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 970 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
971 | if ( volalarm < 0 ) | 971 | if ( volalarm < 0 ) |
972 | volalarm = 0; | 972 | volalarm = 0; |
973 | else if ( volalarm > 100 ) | 973 | else if ( volalarm > 100 ) |
974 | volalarm = 100; | 974 | volalarm = 100; |
975 | volalarm |= ( volalarm << 8 ); | 975 | volalarm |= ( volalarm << 8 ); |
976 | 976 | ||
977 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 977 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
978 | vol_reset = true; | 978 | vol_reset = true; |
979 | } | 979 | } |
980 | } | 980 | } |
981 | 981 | ||
982 | snd. play ( ); | 982 | snd. play ( ); |
983 | while ( !snd. isFinished ( )) | 983 | while ( !snd. isFinished ( )) |
984 | qApp-> processEvents ( ); | 984 | qApp-> processEvents ( ); |
985 | 985 | ||
986 | if ( fd >= 0 ) { | 986 | if ( fd >= 0 ) { |
987 | if ( vol_reset ) | 987 | if ( vol_reset ) |
988 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 988 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
989 | ::close ( fd ); | 989 | ::close ( fd ); |
990 | } | 990 | } |
991 | #endif | 991 | #endif |
992 | } | 992 | } |
993 | 993 | ||
994 | 994 | ||
995 | bool iPAQ::setSoftSuspend ( bool soft ) | 995 | bool iPAQ::setSoftSuspend ( bool soft ) |
996 | { | 996 | { |
997 | bool res = false; | 997 | bool res = false; |
998 | int fd; | 998 | int fd; |
999 | 999 | ||
1000 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1000 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1001 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1001 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1002 | res = true; | 1002 | res = true; |
1003 | else | 1003 | else |
1004 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1004 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1005 | 1005 | ||
1006 | ::close ( fd ); | 1006 | ::close ( fd ); |
1007 | } | 1007 | } |
1008 | else | 1008 | else |
1009 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1009 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1010 | 1010 | ||
1011 | return res; | 1011 | return res; |
1012 | } | 1012 | } |
1013 | 1013 | ||
1014 | 1014 | ||
1015 | bool iPAQ::setDisplayBrightness ( int bright ) | 1015 | bool iPAQ::setDisplayBrightness ( int bright ) |
1016 | { | 1016 | { |
1017 | bool res = false; | 1017 | bool res = false; |
1018 | int fd; | 1018 | int fd; |
1019 | 1019 | ||
1020 | if ( bright > 255 ) | 1020 | if ( bright > 255 ) |
1021 | bright = 255; | 1021 | bright = 255; |
1022 | if ( bright < 0 ) | 1022 | if ( bright < 0 ) |
1023 | bright = 0; | 1023 | bright = 0; |
1024 | 1024 | ||
1025 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1025 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1026 | FLITE_IN bl; | 1026 | FLITE_IN bl; |
1027 | bl. mode = 1; | 1027 | bl. mode = 1; |
1028 | bl. pwr = bright ? 1 : 0; | 1028 | bl. pwr = bright ? 1 : 0; |
1029 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1029 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1030 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1030 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1031 | ::close ( fd ); | 1031 | ::close ( fd ); |
1032 | } | 1032 | } |
1033 | return res; | 1033 | return res; |
1034 | } | 1034 | } |
1035 | 1035 | ||
1036 | int iPAQ::displayBrightnessResolution ( ) const | 1036 | int iPAQ::displayBrightnessResolution ( ) const |
1037 | { | 1037 | { |
1038 | switch ( model ( )) { | 1038 | switch ( model ( )) { |
1039 | case Model_iPAQ_H31xx: | 1039 | case Model_iPAQ_H31xx: |
1040 | case Model_iPAQ_H36xx: | 1040 | case Model_iPAQ_H36xx: |
1041 | case Model_iPAQ_H37xx: | 1041 | case Model_iPAQ_H37xx: |
1042 | return 128; // really 256, but >128 could damage the LCD | 1042 | return 128; // really 256, but >128 could damage the LCD |
1043 | 1043 | ||
1044 | case Model_iPAQ_H38xx: | 1044 | case Model_iPAQ_H38xx: |
1045 | case Model_iPAQ_H39xx: | 1045 | case Model_iPAQ_H39xx: |
1046 | return 64; | 1046 | return 64; |
1047 | 1047 | ||
1048 | default: | 1048 | default: |
1049 | return 2; | 1049 | return 2; |
1050 | } | 1050 | } |
1051 | } | 1051 | } |
1052 | 1052 | ||
1053 | 1053 | ||
1054 | bool iPAQ::hasLightSensor ( ) const | 1054 | bool iPAQ::hasLightSensor ( ) const |
1055 | { | 1055 | { |
1056 | return true; | 1056 | return true; |
1057 | } | 1057 | } |
1058 | 1058 | ||
1059 | int iPAQ::readLightSensor ( ) | 1059 | int iPAQ::readLightSensor ( ) |
1060 | { | 1060 | { |
1061 | int fd; | 1061 | int fd; |
1062 | int val = -1; | 1062 | int val = -1; |
1063 | 1063 | ||
1064 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1064 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1065 | char buffer [8]; | 1065 | char buffer [8]; |
1066 | 1066 | ||
1067 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1067 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1068 | char *endptr; | 1068 | char *endptr; |
1069 | 1069 | ||
1070 | buffer [4] = 0; | 1070 | buffer [4] = 0; |
1071 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1071 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1072 | 1072 | ||
1073 | if ( *endptr != 0 ) | 1073 | if ( *endptr != 0 ) |
1074 | val = -1; | 1074 | val = -1; |
1075 | } | 1075 | } |
1076 | ::close ( fd ); | 1076 | ::close ( fd ); |
1077 | } | 1077 | } |
1078 | 1078 | ||
1079 | return val; | 1079 | return val; |
1080 | } | 1080 | } |
1081 | 1081 | ||
1082 | int iPAQ::lightSensorResolution ( ) const | 1082 | int iPAQ::lightSensorResolution ( ) const |
1083 | { | 1083 | { |
1084 | return 256; | 1084 | return 256; |
1085 | } | 1085 | } |
1086 | 1086 | ||
1087 | /************************************************** | 1087 | /************************************************** |
1088 | * | 1088 | * |
1089 | * Zaurus | 1089 | * Zaurus |
1090 | * | 1090 | * |
1091 | **************************************************/ | 1091 | **************************************************/ |
1092 | 1092 | ||
1093 | 1093 | ||
1094 | 1094 | ||
1095 | void Zaurus::init ( ) | 1095 | void Zaurus::init ( ) |
1096 | { | 1096 | { |
1097 | d-> m_vendorstr = "Sharp"; | 1097 | d-> m_vendorstr = "Sharp"; |
1098 | d-> m_vendor = Vendor_Sharp; | 1098 | d-> m_vendor = Vendor_Sharp; |
1099 | 1099 | ||
1100 | QFile f ( "/proc/filesystems" ); | 1100 | QFile f ( "/proc/filesystems" ); |
1101 | 1101 | ||
1102 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1102 | if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1103 | d-> m_vendorstr = "OpenZaurus Team"; | 1103 | d-> m_vendorstr = "OpenZaurus Team"; |
1104 | d-> m_systemstr = "OpenZaurus"; | 1104 | d-> m_systemstr = "OpenZaurus"; |
1105 | d-> m_system = System_OpenZaurus; | 1105 | d-> m_system = System_OpenZaurus; |
1106 | 1106 | ||
1107 | f. close ( ); | 1107 | f. close ( ); |
1108 | 1108 | ||
1109 | f. setName ( "/etc/oz_version" ); | 1109 | f. setName ( "/etc/oz_version" ); |
1110 | if ( f. open ( IO_ReadOnly )) { | 1110 | if ( f. open ( IO_ReadOnly )) { |
1111 | QTextStream ts ( &f ); | 1111 | QTextStream ts ( &f ); |
1112 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1112 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1113 | f. close ( ); | 1113 | f. close ( ); |
1114 | } | 1114 | } |
1115 | } | 1115 | } |
1116 | else { | 1116 | else { |
1117 | d-> m_systemstr = "Zaurus"; | 1117 | d-> m_systemstr = "Zaurus"; |
1118 | d-> m_system = System_Zaurus; | 1118 | d-> m_system = System_Zaurus; |
1119 | } | 1119 | } |
1120 | 1120 | ||
1121 | f. setName ( "/proc/deviceinfo/product" ); | 1121 | f. setName ( "/proc/deviceinfo/product" ); |
1122 | if ( f. open ( IO_ReadOnly ) ) { | 1122 | if ( f. open ( IO_ReadOnly ) ) { |
1123 | QTextStream ts ( &f ); | 1123 | QTextStream ts ( &f ); |
1124 | QString model = ts. readLine ( ); | 1124 | QString model = ts. readLine ( ); |
1125 | f. close ( ); | 1125 | f. close ( ); |
1126 | 1126 | ||
1127 | d-> m_modelstr = QString("Zaurus ") + model; | 1127 | d-> m_modelstr = QString("Zaurus ") + model; |
1128 | if ( model == "SL-5500" ) | 1128 | if ( model == "SL-5500" ) |
1129 | d-> m_model = Model_Zaurus_SL5500; | 1129 | d-> m_model = Model_Zaurus_SL5500; |
1130 | else if ( model == "SL-C700" ) | 1130 | else if ( model == "SL-C700" ) |
1131 | d-> m_model = Model_Zaurus_SLC700; | 1131 | d-> m_model = Model_Zaurus_SLC700; |
1132 | else if ( model == "SL-A300" ) | 1132 | else if ( model == "SL-A300" ) |
1133 | d-> m_model = Model_Zaurus_SLA300; | 1133 | d-> m_model = Model_Zaurus_SLA300; |
1134 | else if ( model == "SL-B600" || model == "SL-5600" ) | 1134 | else if ( model == "SL-B600" || model == "SL-5600" ) |
1135 | d-> m_model = Model_Zaurus_SLB600; | 1135 | d-> m_model = Model_Zaurus_SLB600; |
1136 | else | 1136 | else |
1137 | d-> m_model = Model_Zaurus_SL5000; | 1137 | d-> m_model = Model_Zaurus_SL5000; |
1138 | } | 1138 | } |
1139 | else { | 1139 | else { |
1140 | d-> m_model = Model_Zaurus_SL5000; | 1140 | d-> m_model = Model_Zaurus_SL5000; |
1141 | d-> m_modelstr = "Zaurus (model unknown)"; | 1141 | d-> m_modelstr = "Zaurus (model unknown)"; |
1142 | } | 1142 | } |
1143 | 1143 | ||
1144 | switch ( d-> m_model ) { | 1144 | switch ( d-> m_model ) { |
1145 | case Model_Zaurus_SLA300: | 1145 | case Model_Zaurus_SLA300: |
1146 | d-> m_rotation = Rot0; | 1146 | d-> m_rotation = Rot0; |
1147 | break; | 1147 | break; |
1148 | case Model_Zaurus_SLC700: | 1148 | case Model_Zaurus_SLC700: |
1149 | /* note for C700, we must check the display rotation | 1149 | bool flipstate = false; |
1150 | * sensor to set an appropriate value | 1150 | // Note: need to 1) set flipstate based on physical screen orientation |
1151 | */ | 1151 | // and 2) check to see if the user overrode the rotation direction |
1152 | // using appearance, and if so, remove that item from the Config to | ||
1153 | // ensure the rotate applet flips us back to the previous state. | ||
1154 | if ( flipstate ) { | ||
1155 | // 480x640 | ||
1156 | d-> m_rotation = Rot0; | ||
1157 | d-> m_direction = CW; | ||
1158 | } else { | ||
1159 | // 640x480 | ||
1160 | d-> m_rotation = Rot270; | ||
1161 | d-> m_direction = CCW; | ||
1162 | } | ||
1163 | break; | ||
1152 | case Model_Zaurus_SLB600: | 1164 | case Model_Zaurus_SLB600: |
1153 | case Model_Zaurus_SL5500: | 1165 | case Model_Zaurus_SL5500: |
1154 | case Model_Zaurus_SL5000: | 1166 | case Model_Zaurus_SL5000: |
1155 | default: | 1167 | default: |
1156 | d-> m_rotation = Rot270; | 1168 | d-> m_rotation = Rot270; |
1157 | break; | 1169 | break; |
1158 | } | 1170 | } |
1159 | m_leds [0] = Led_Off; | 1171 | m_leds [0] = Led_Off; |
1160 | } | 1172 | } |
1161 | 1173 | ||
1162 | void Zaurus::initButtons ( ) | 1174 | void Zaurus::initButtons ( ) |
1163 | { | 1175 | { |
1164 | if ( d-> m_buttons ) | 1176 | if ( d-> m_buttons ) |
1165 | return; | 1177 | return; |
1166 | 1178 | ||
1167 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 1179 | d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
1168 | 1180 | ||
1169 | d-> m_buttons = new QValueList <ODeviceButton>; | 1181 | d-> m_buttons = new QValueList <ODeviceButton>; |
1170 | 1182 | ||
1171 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { | 1183 | for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { |
1172 | z_button *zb = z_buttons + i; | 1184 | z_button *zb = z_buttons + i; |
1173 | ODeviceButton b; | 1185 | ODeviceButton b; |
1174 | 1186 | ||
1175 | b. setKeycode ( zb-> code ); | 1187 | b. setKeycode ( zb-> code ); |
1176 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1188 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1177 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1189 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1178 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); | 1190 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); |
1179 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); | 1191 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); |
1180 | 1192 | ||
1181 | d-> m_buttons-> append ( b ); | 1193 | d-> m_buttons-> append ( b ); |
1182 | } | 1194 | } |
1183 | 1195 | ||
1184 | reloadButtonMapping ( ); | 1196 | reloadButtonMapping ( ); |
1185 | 1197 | ||
1186 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1198 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1187 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); | 1199 | connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); |
1188 | } | 1200 | } |
1189 | 1201 | ||
1190 | #include <unistd.h> | 1202 | #include <unistd.h> |
1191 | #include <fcntl.h> | 1203 | #include <fcntl.h> |
1192 | #include <sys/ioctl.h> | 1204 | #include <sys/ioctl.h> |
1193 | 1205 | ||
1194 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1206 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1195 | 1207 | ||
1196 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1208 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1197 | 1209 | ||
1198 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1210 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1199 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1211 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1200 | 1212 | ||
1201 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1213 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1202 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1214 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1203 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1215 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1204 | 1216 | ||
1205 | /* --- for SHARP_BUZZER device --- */ | 1217 | /* --- for SHARP_BUZZER device --- */ |
1206 | 1218 | ||
1207 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1219 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1208 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1220 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1209 | 1221 | ||
1210 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1222 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1211 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1223 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1212 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1224 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1213 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1225 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1214 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1226 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1215 | 1227 | ||
1216 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1228 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1217 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1229 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1218 | 1230 | ||
1219 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1231 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1220 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1232 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1221 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1233 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1222 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1234 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1223 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1235 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1224 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1236 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1225 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1237 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1226 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1238 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1227 | 1239 | ||
1228 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1240 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1229 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1241 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1230 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1242 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1231 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1243 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1232 | // | 1244 | // |
1233 | 1245 | ||
1234 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1246 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1235 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1247 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1236 | 1248 | ||
1237 | typedef struct sharp_led_status { | 1249 | typedef struct sharp_led_status { |
1238 | int which; /* select which LED status is wanted. */ | 1250 | int which; /* select which LED status is wanted. */ |
1239 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1251 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1240 | } sharp_led_status; | 1252 | } sharp_led_status; |
1241 | 1253 | ||
1242 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1254 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1243 | 1255 | ||
1244 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1256 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1245 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1257 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1246 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1258 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1247 | 1259 | ||
1248 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1260 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1249 | 1261 | ||
1250 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1262 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1251 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1263 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1252 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1264 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1253 | 1265 | ||
1254 | #define FL_IOCTL_STEP_CONTRAST 100 | 1266 | #define FL_IOCTL_STEP_CONTRAST 100 |
1255 | 1267 | ||
1256 | 1268 | ||
1257 | void Zaurus::buzzer ( int sound ) | 1269 | void Zaurus::buzzer ( int sound ) |
1258 | { | 1270 | { |
1259 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1271 | static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1260 | 1272 | ||
1261 | if ( fd >= 0 ) { | 1273 | if ( fd >= 0 ) { |
1262 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1274 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1263 | ::close ( fd ); | 1275 | ::close ( fd ); |
1264 | } | 1276 | } |
1265 | } | 1277 | } |
1266 | 1278 | ||
1267 | 1279 | ||
1268 | void Zaurus::alarmSound ( ) | 1280 | void Zaurus::alarmSound ( ) |
1269 | { | 1281 | { |
1270 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1282 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1271 | } | 1283 | } |
1272 | 1284 | ||
1273 | void Zaurus::touchSound ( ) | 1285 | void Zaurus::touchSound ( ) |
1274 | { | 1286 | { |
1275 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1287 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1276 | } | 1288 | } |
1277 | 1289 | ||
1278 | void Zaurus::keySound ( ) | 1290 | void Zaurus::keySound ( ) |
1279 | { | 1291 | { |
1280 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1292 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1281 | } | 1293 | } |
1282 | 1294 | ||
1283 | 1295 | ||
1284 | QValueList <OLed> Zaurus::ledList ( ) const | 1296 | QValueList <OLed> Zaurus::ledList ( ) const |
1285 | { | 1297 | { |
1286 | QValueList <OLed> vl; | 1298 | QValueList <OLed> vl; |
1287 | vl << Led_Mail; | 1299 | vl << Led_Mail; |
1288 | return vl; | 1300 | return vl; |
1289 | } | 1301 | } |
1290 | 1302 | ||
1291 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1303 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1292 | { | 1304 | { |
1293 | QValueList <OLedState> vl; | 1305 | QValueList <OLedState> vl; |
1294 | 1306 | ||
1295 | if ( l == Led_Mail ) | 1307 | if ( l == Led_Mail ) |
1296 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1308 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1297 | return vl; | 1309 | return vl; |
1298 | } | 1310 | } |
1299 | 1311 | ||
1300 | OLedState Zaurus::ledState ( OLed which ) const | 1312 | OLedState Zaurus::ledState ( OLed which ) const |
1301 | { | 1313 | { |
1302 | if ( which == Led_Mail ) | 1314 | if ( which == Led_Mail ) |
1303 | return m_leds [0]; | 1315 | return m_leds [0]; |
1304 | else | 1316 | else |
1305 | return Led_Off; | 1317 | return Led_Off; |
1306 | } | 1318 | } |
1307 | 1319 | ||
1308 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1320 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1309 | { | 1321 | { |
1310 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1322 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1311 | 1323 | ||
1312 | if ( which == Led_Mail ) { | 1324 | if ( which == Led_Mail ) { |
1313 | if ( fd >= 0 ) { | 1325 | if ( fd >= 0 ) { |
1314 | struct sharp_led_status leds; | 1326 | struct sharp_led_status leds; |
1315 | ::memset ( &leds, 0, sizeof( leds )); | 1327 | ::memset ( &leds, 0, sizeof( leds )); |
1316 | leds. which = SHARP_LED_MAIL_EXISTS; | 1328 | leds. which = SHARP_LED_MAIL_EXISTS; |
1317 | bool ok = true; | 1329 | bool ok = true; |
1318 | 1330 | ||
1319 | switch ( st ) { | 1331 | switch ( st ) { |
1320 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1332 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1321 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1333 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1322 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1334 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1323 | default : ok = false; | 1335 | default : ok = false; |
1324 | } | 1336 | } |
1325 | 1337 | ||
1326 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1338 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1327 | m_leds [0] = st; | 1339 | m_leds [0] = st; |
1328 | return true; | 1340 | return true; |
1329 | } | 1341 | } |
1330 | } | 1342 | } |
1331 | } | 1343 | } |
1332 | return false; | 1344 | return false; |
1333 | } | 1345 | } |
1334 | 1346 | ||
1335 | bool Zaurus::setSoftSuspend ( bool soft ) | 1347 | bool Zaurus::setSoftSuspend ( bool soft ) |
1336 | { | 1348 | { |
1337 | bool res = false; | 1349 | bool res = false; |
1338 | int fd; | 1350 | int fd; |
1339 | 1351 | ||
1340 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1352 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1341 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1353 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1342 | 1354 | ||
1343 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1355 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1344 | 1356 | ||
1345 | if ( sources >= 0 ) { | 1357 | if ( sources >= 0 ) { |
1346 | if ( soft ) | 1358 | if ( soft ) |
1347 | sources &= ~APM_EVT_POWER_BUTTON; | 1359 | sources &= ~APM_EVT_POWER_BUTTON; |
1348 | else | 1360 | else |
1349 | sources |= APM_EVT_POWER_BUTTON; | 1361 | sources |= APM_EVT_POWER_BUTTON; |
1350 | 1362 | ||
1351 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1363 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1352 | res = true; | 1364 | res = true; |
1353 | else | 1365 | else |
1354 | perror ( "APM_IOCGEVTSRC" ); | 1366 | perror ( "APM_IOCGEVTSRC" ); |
1355 | } | 1367 | } |
1356 | else | 1368 | else |
1357 | perror ( "APM_IOCGEVTSRC" ); | 1369 | perror ( "APM_IOCGEVTSRC" ); |
1358 | 1370 | ||
1359 | ::close ( fd ); | 1371 | ::close ( fd ); |
1360 | } | 1372 | } |
1361 | else | 1373 | else |
1362 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1374 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1363 | 1375 | ||
1364 | return res; | 1376 | return res; |
1365 | } | 1377 | } |
1366 | 1378 | ||
1367 | 1379 | ||
1368 | bool Zaurus::setDisplayBrightness ( int bright ) | 1380 | bool Zaurus::setDisplayBrightness ( int bright ) |
1369 | { | 1381 | { |
1370 | bool res = false; | 1382 | bool res = false; |
1371 | int fd; | 1383 | int fd; |
1372 | 1384 | ||
1373 | if ( bright > 255 ) | 1385 | if ( bright > 255 ) |
1374 | bright = 255; | 1386 | bright = 255; |
1375 | if ( bright < 0 ) | 1387 | if ( bright < 0 ) |
1376 | bright = 0; | 1388 | bright = 0; |
1377 | 1389 | ||
1378 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 1390 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
1379 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 1391 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
1380 | if ( bright && !bl ) | 1392 | if ( bright && !bl ) |
1381 | bl = 1; | 1393 | bl = 1; |
1382 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 1394 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
1383 | ::close ( fd ); | 1395 | ::close ( fd ); |
1384 | } | 1396 | } |
1385 | return res; | 1397 | return res; |
1386 | } | 1398 | } |
1387 | 1399 | ||
1388 | 1400 | ||
1389 | int Zaurus::displayBrightnessResolution ( ) const | 1401 | int Zaurus::displayBrightnessResolution ( ) const |
1390 | { | 1402 | { |
1391 | return 5; | 1403 | return 5; |
1392 | } | 1404 | } |
1393 | 1405 | ||
1394 | 1406 | ||