summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/device') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_htc.cpp3
1 files changed, 1 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_htc.cpp b/libopie2/opiecore/device/odevice_htc.cpp
index c21e10d..4e5200b 100644
--- a/libopie2/opiecore/device/odevice_htc.cpp
+++ b/libopie2/opiecore/device/odevice_htc.cpp
@@ -375,106 +375,105 @@ int HTC::displayBrightnessResolution() const
}
return res;
}
bool HTC::setDisplayBrightness( int bright )
{
//qDebug( "HTC::setDisplayBrightness( %d )", bright );
bool res = false;
if ( bright > 255 ) bright = 255;
if ( bright < 0 ) bright = 0;
int numberOfSteps = displayBrightnessResolution();
int val = ( bright == 1 ) ? 1 : ( bright * numberOfSteps ) / 255;
int fd = ::open( m_backlightdev + "brightness", O_WRONLY|O_NONBLOCK );
if ( fd )
{
char buf[100];
int len = ::snprintf( &buf[0], sizeof buf, "%d", val );
res = ( ::write( fd, &buf[0], len ) == 0 );
::close( fd );
}
return res;
}
bool HTC::setDisplayStatus( bool on )
{
bool res = false;
int fd = ::open( m_backlightdev + "power", O_WRONLY|O_NONBLOCK );
if ( fd )
{
char buf[10];
buf[0] = on ? FB_BLANK_UNBLANK : FB_BLANK_POWERDOWN;
buf[1] = '\0';
res = ( ::write( fd, &buf[0], 2 ) == 0 );
::close( fd );
}
return res;
}
Transformation HTC::rotation() const
{
qDebug( "HTC::rotation()" );
- Transformation rot;
+ Transformation rot = Rot270;
switch ( d->m_model ) {
case Model_HTC_Universal:
{
OHingeStatus hs = readHingeSensor();
qDebug( "HTC::rotation() - hinge sensor = %d", (int) hs );
if ( hs == CASE_PORTRAIT ) rot = Rot0;
else if ( hs == CASE_UNKNOWN ) rot = Rot270;
- else rot = Rot270;
}
break;
}
qDebug( "HTC::rotation() - returning '%d'", rot );
return rot;
}
ODirection HTC::direction() const
{
ODirection dir;
switch ( d->m_model ) {
case Model_HTC_Universal: {
OHingeStatus hs = readHingeSensor();
if ( hs == CASE_PORTRAIT ) dir = CCW;
else if ( hs == CASE_UNKNOWN ) dir = CCW;
else dir = CW;
}
break;
default: dir = d->m_direction;
break;
}
return dir;
}
bool HTC::hasHingeSensor() const
{
return d->m_model == Model_HTC_Universal;
}
OHingeStatus HTC::readHingeSensor() const
{
/*
* The HTC Universal keyboard is event source 1 in kernel 2.6.
* Hinge status is reported via Input System Switchs 0 and 1 like that:
*
* -------------------------
* | SW0 | SW1 | CASE |
* |-----|-----|-----------|
* | 0 0 Unknown |
* | 1 0 Portrait |
* | 0 1 Closed |
* | 1 1 Landscape |
* -------------------------
*/
OInputDevice* keyboard = OInputSystem::instance()->device( "event1" );
bool switch0 = true;