summaryrefslogtreecommitdiff
path: root/libopie2/opiecore
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_mypal.cpp6
2 files changed, 4 insertions, 4 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 2d734a4..5272a3c 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -312,153 +312,153 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b
// map Power Button short/long press to F34/F35
case Key_SysReq: {
if ( isPress ) {
if ( m_power_timer )
killTimer ( m_power_timer );
m_power_timer = startTimer ( 500 );
}
else if ( m_power_timer ) {
killTimer ( m_power_timer );
m_power_timer = 0;
QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
}
newkeycode = Key_unknown;
break;
}
}
if ( newkeycode != keycode ) {
if ( newkeycode != Key_unknown )
QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
return true;
}
else
return false;
}
void iPAQ::timerEvent ( QTimerEvent * )
{
killTimer ( m_power_timer );
m_power_timer = 0;
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
}
void iPAQ::playAlarmSound()
{
#ifndef QT_NO_SOUND
static Sound snd ( "alarm" );
if(!snd.isFinished())
return;
changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
snd. play();
#endif
}
bool iPAQ::setDisplayBrightness ( int bright )
{
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 0 )
bright = 0;
QString cmdline;
switch ( model()) {
case Model_iPAQ_H191x:
if ( !bright )
cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power");
else
cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright );
// No Global::shellQuote as we gurantee it to be sane
res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
break;
default:
if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
FLITE_IN bl;
bl. mode = 1;
bl. pwr = bright ? 1 : 0;
bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
::close ( fd );
}
}
return res;
}
int iPAQ::displayBrightnessResolution() const
{
switch ( model()) {
case Model_iPAQ_H31xx:
case Model_iPAQ_H36xx:
case Model_iPAQ_H37xx:
return 128; // really 256, but >128 could damage the LCD
case Model_iPAQ_H38xx:
case Model_iPAQ_H39xx:
return 64;
case Model_iPAQ_H5xxx:
return 255;
case Model_iPAQ_H191x:
- return 183;
+ return 7;
case Model_iPAQ_H1940:
return 44;
default:
return 2;
}
}
bool iPAQ::setDisplayStatus ( bool on )
{
bool res = false;
QString cmdline;
if ( model() == Model_iPAQ_H191x ) {
cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
} else {
return OAbstractMobileDevice::setDisplayStatus(on);
}
res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
return res;
}
bool iPAQ::hasLightSensor() const
{
return true;
}
int iPAQ::readLightSensor()
{
int fd;
int val = -1;
if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
char buffer [8];
if ( ::read ( fd, buffer, 5 ) == 5 ) {
char *endptr;
buffer [4] = 0;
val = ::strtol ( buffer + 2, &endptr, 16 );
if ( *endptr != 0 )
val = -1;
}
::close ( fd );
}
return val;
}
int iPAQ::lightSensorResolution() const
{
return 256;
}
diff --git a/libopie2/opiecore/device/odevice_mypal.cpp b/libopie2/opiecore/device/odevice_mypal.cpp
index 45c70ae..da0272e 100644
--- a/libopie2/opiecore/device/odevice_mypal.cpp
+++ b/libopie2/opiecore/device/odevice_mypal.cpp
@@ -108,145 +108,145 @@ void MyPal::initButtons()
if ( d->m_buttons )
return;
if ( isQWS( ) ) {
addPreHandler(this);
}
d->m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( mypal_buttons ) / sizeof( m_button )); i++ ) {
m_button *mb = mypal_buttons + i;
ODeviceButton b;
if (( mb->model & d->m_model ) == d->m_model ) {
b. setKeycode ( mb->code );
b. setUserText ( QObject::tr ( "Button", mb->utext ));
b. setPixmap ( OResource::loadPixmap ( mb->pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( mb->fpressedservice ), mb->fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( mb->fheldservice ), mb->fheldaction ));
d->m_buttons->append ( b );
}
}
reloadButtonMapping();
}
bool MyPal::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
{
int newkeycode = keycode;
switch ( keycode ) {
case Key_Left :
case Key_Right:
case Key_Up :
case Key_Down : {
// Rotate the cursor keys by 270
// keycode - Key_Left = position of the button starting from left clockwise
// add the rotation to it and modolo. No we've the original offset
// add the offset to the Key_Left key
if ( d->m_model == Model_MyPal_716 )
newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
break;
}
// map Power Button short/long press to F34/F35
case Key_SysReq: {
if ( isPress ) {
if ( m_power_timer )
killTimer ( m_power_timer );
m_power_timer = startTimer ( 500 );
}
else if ( m_power_timer ) {
killTimer ( m_power_timer );
m_power_timer = 0;
QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
}
newkeycode = Key_unknown;
break;
}
}
if ( newkeycode != keycode ) {
if ( newkeycode != Key_unknown )
QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
return true;
}
else
return false;
}
void MyPal::timerEvent ( QTimerEvent * )
{
killTimer ( m_power_timer );
m_power_timer = 0;
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
}
void MyPal::playAlarmSound()
{
#ifndef QT_NO_SOUND
static Sound snd ( "alarm" );
if(!snd.isFinished())
return;
changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
snd. play();
#endif
}
bool MyPal::setDisplayBrightness ( int bright )
{
bool res = false;
- if ( bright > 220 )
- bright = 220;
+ if ( bright > 255 )
+ bright = 255;
if ( bright < 0 )
bright = 0;
QString cmdline;
switch ( model()) {
case Model_MyPal_716:
if ( !bright )
cmdline = QString::fromLatin1( "echo 4 > /sys/class/backlight/pxafb/power");
else
cmdline = QString::fromLatin1( "echo 0 > /sys/class/backlight/pxafb/power; echo %1 > /sys/class/backlight/pxafb/brightness" ).arg( bright );
// No Global::shellQuote as we gurantee it to be sane
res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
break;
default:
res = OAbstractMobileDevice::setDisplayBrightness(bright);
}
return res;
}
int MyPal::displayBrightnessResolution() const
{
switch ( model()) {
case Model_MyPal_716:
- return 220;
+ return 7;
default:
return OAbstractMobileDevice::displayBrightnessResolution();
}
}
bool MyPal::setDisplayStatus ( bool on )
{
bool res = false;
QString cmdline;
if ( model() == Model_MyPal_716 ) {
cmdline = QString::fromLatin1( "echo %1 > /sys/class/lcd/pxafb/power; echo %2 > /sys/class/backlight/pxafb/power").arg( on ? "0" : "4" ).arg( on ? "0" : "4" );
} else {
return OAbstractMobileDevice::setDisplayStatus(on);
}
res = ( ::system( QFile::encodeName(cmdline) ) == 0 );
return res;
}