summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp8
1 files changed, 3 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 8f4e296..7d8cdbf 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -648,36 +648,34 @@ bool iPAQ::setSoftSuspend ( bool soft )
648 else 648 else
649 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 649 ::perror ( "/proc/sys/ts/suspend_button_mode" );
650 650
651 return res; 651 return res;
652} 652}
653 653
654 654
655bool iPAQ::setDisplayBrightness ( int bright ) 655bool iPAQ::setDisplayBrightness ( int bright )
656{ 656{
657 bool res = false; 657 bool res = false;
658 int fd; 658 int fd;
659 659
660 int maxbright = displayBrightnessResolution ( ); 660 if ( bright > 255 )
661 661 bright = 255;
662 if ( bright > maxbright )
663 bright = maxbright;
664 if ( bright < 0 ) 662 if ( bright < 0 )
665 bright = 0; 663 bright = 0;
666 664
667 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 665 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
668 FLITE_IN bl; 666 FLITE_IN bl;
669 bl. mode = 1; 667 bl. mode = 1;
670 bl. pwr = bright ? 1 : 0; 668 bl. pwr = bright ? 1 : 0;
671 bl. brightness = bright; 669 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
672 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 670 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
673 ::close ( fd ); 671 ::close ( fd );
674 } 672 }
675 return res; 673 return res;
676} 674}
677 675
678int iPAQ::displayBrightnessResolution ( ) const 676int iPAQ::displayBrightnessResolution ( ) const
679{ 677{
680 switch ( model ( )) { 678 switch ( model ( )) {
681 case Model_iPAQ_H31xx: 679 case Model_iPAQ_H31xx:
682 case Model_iPAQ_H36xx: 680 case Model_iPAQ_H36xx:
683 case Model_iPAQ_H37xx: 681 case Model_iPAQ_H37xx: