summaryrefslogtreecommitdiff
path: root/libopie2
authormickeyl <mickeyl>2005-01-23 21:35:29 (UTC)
committer mickeyl <mickeyl>2005-01-23 21:35:29 (UTC)
commitdd410f1eb69e68f04cf26b6d3e6bca88f0987f71 (patch) (side-by-side diff)
tree0f2b59bae4c326011783e9cdea0754e180ae0e27 /libopie2
parent78e658cecc7521cf3932f5eb44d3f551d73f3181 (diff)
downloadopie-dd410f1eb69e68f04cf26b6d3e6bca88f0987f71.zip
opie-dd410f1eb69e68f04cf26b6d3e6bca88f0987f71.tar.gz
opie-dd410f1eb69e68f04cf26b6d3e6bca88f0987f71.tar.bz2
remove setSoftSuspend() from ODevice. this is a left-over from the old days
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp5
-rw-r--r--libopie2/opiecore/device/odevice.h2
-rw-r--r--libopie2/opiecore/device/odevice_genuineintel.cpp6
-rw-r--r--libopie2/opiecore/device/odevice_genuineintel.h2
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp21
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.h2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp44
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.h2
8 files changed, 2 insertions, 82 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index a824392..3d69614 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -209,101 +209,96 @@ ODevice::ODevice()
break;
}
}
}
void ODevice::systemMessage( const QCString &msg, const QByteArray & )
{
if ( msg == "deviceButtonMappingChanged()" ) {
reloadButtonMapping();
}
}
void ODevice::init(const QString&)
{
}
/**
* This method initialises the button mapping
*/
void ODevice::initButtons()
{
if ( d->m_buttons )
return;
qDebug ( "init Buttons" );
d->m_buttons = new QValueList <ODeviceButton>;
for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
default_button *db = default_buttons + i;
ODeviceButton b;
b. setKeycode ( db->code );
b. setUserText ( QObject::tr ( "Button", db->utext ));
b. setPixmap ( Resource::loadPixmap ( db->pix ));
b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( db->fpressedservice ), db->fpressedaction ));
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( db->fheldservice ), db->fheldaction ));
d->m_buttons->append ( b );
}
reloadButtonMapping();
}
ODevice::~ODevice()
{
// we leak m_devicebuttons and m_cpu_frequency
// but it's a singleton and it is not so importantant
// -zecke
delete d;
}
-bool ODevice::setSoftSuspend ( bool /*soft*/ )
-{
- return false;
-}
-
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
/**
* This method will try to suspend the device
* It only works if the user is the QWS Server and the apm application
* is installed.
* It tries to suspend and then waits some time cause some distributions
* do have asynchronus apm implementations.
* This method will either fail and return false or it'll suspend the
* device and return once the device got woken up
*
* @return if the device got suspended
*/
bool ODevice::suspend()
{
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
ODevice::sendSuspendmsg();
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync(); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
// This is needed because the iPAQ apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
// This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
if ( res ) {
do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
}
return res;
}
//#include <linux/fb.h> better not rely on kernel headers in userspace ...
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index bbc32fa..96a41fc 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -210,98 +210,96 @@ struct default_button {
* like the Hardware used, LEDs, the Base Distribution and
* hardware key mappings.
*
* @short A small class for device specefic options
* @see QObject
* @author Robert Griebl
* @version 1.0
*/
class ODevice : public QObject
{
Q_OBJECT
private:
/* disable copy */
ODevice ( const ODevice & );
protected:
ODevice();
virtual void init(const QString&);
virtual void initButtons();
static void sendSuspendmsg();
ODeviceData *d;
public:
// sandman do we want to allow destructions? -zecke?
virtual ~ODevice();
static ODevice *inst();
// information
QString modelString() const;
OModel model() const;
inline OModel series() const { return (OModel) ( model() & Model_Series_Mask ); }
QString vendorString() const;
OVendor vendor() const;
QString systemString() const;
OSystem system() const;
QString systemVersionString() const;
virtual Transformation rotation() const;
virtual ODirection direction() const;
// system
-
- virtual bool setSoftSuspend ( bool on );
virtual bool suspend();
virtual bool setDisplayStatus ( bool on );
virtual bool setDisplayBrightness ( int brightness );
virtual int displayBrightnessResolution() const;
virtual bool setDisplayContrast ( int contrast );
virtual int displayContrastResolution() const;
// don't add new virtual methods, use this:
// /*virtual */ void boo(int i ) { return virtual_hook(1,&i); };
// and in your subclass do overwrite
// protected virtual int virtual_hook(int, void *)
// which is defined below
// input / output
virtual void playAlarmSound();
virtual void playKeySound();
virtual void playTouchSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState ( OLed led ) const;
virtual bool setLedState ( OLed led, OLedState st );
virtual bool hasLightSensor() const;
virtual int readLightSensor();
virtual int lightSensorResolution() const;
virtual bool hasHingeSensor() const;
virtual OHingeStatus readHingeSensor();
const QStrList &allowedCpuFrequencies() const;
bool setCurrentCpuFrequency(uint index);
/**
* Returns the available buttons on this device. The number and location
* of buttons will vary depending on the device. Button numbers will be assigned
* by the device manufacturer and will be from most preferred button to least preffered
* button. Note that this list only contains "user mappable" buttons.
*
* @todo Make method const and take care of calling initButtons or make that const too
*
*/
const QValueList<ODeviceButton> &buttons();
/**
* Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
* returns 0L
diff --git a/libopie2/opiecore/device/odevice_genuineintel.cpp b/libopie2/opiecore/device/odevice_genuineintel.cpp
index 61ba052..1584249 100644
--- a/libopie2/opiecore/device/odevice_genuineintel.cpp
+++ b/libopie2/opiecore/device/odevice_genuineintel.cpp
@@ -115,79 +115,73 @@ void GenuineIntel::initButtons()
b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib->fheldservice ), ib->fheldaction ));
d->m_buttons->append ( b );
}
reloadButtonMapping();
}
QValueList <OLed> GenuineIntel::ledList() const
{
QValueList <OLed> vl;
return vl; //none
}
QValueList <OLedState> GenuineIntel::ledStateList ( OLed ) const
{
QValueList <OLedState> vl;
return vl; // none
}
OLedState GenuineIntel::ledState ( OLed ) const
{
return Led_Off;
}
bool GenuineIntel::setLedState ( OLed , OLedState )
{
return false;
}
bool GenuineIntel::filter ( int /*unicode*/, int , int , bool , bool )
{
return false;
}
void GenuineIntel::playAlarmSound()
{
#ifndef QT_NO_SOUND
static Sound snd ( "alarm" );
if(!snd.isFinished())
return;
changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
snd. play();
#endif
}
-bool GenuineIntel::setSoftSuspend ( bool )
-{
- return false;
-}
-
-
bool GenuineIntel::setDisplayBrightness ( int )
{
return false;
}
int GenuineIntel::displayBrightnessResolution() const
{
return 1; // perhaps to avoid division by zero
}
bool GenuineIntel::hasLightSensor() const
{
return false;
}
int GenuineIntel::readLightSensor()
{
return 0;
}
int GenuineIntel::lightSensorResolution() const
{
return 1; // see above
}
diff --git a/libopie2/opiecore/device/odevice_genuineintel.h b/libopie2/opiecore/device/odevice_genuineintel.h
index 52c5fc6..69316af 100644
--- a/libopie2/opiecore/device/odevice_genuineintel.h
+++ b/libopie2/opiecore/device/odevice_genuineintel.h
@@ -2,83 +2,81 @@
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_GENUINEINTEL
#define ODEVICE_GENUINEINTEL
#include "odevice.h"
/* QT */
#include <qwindowsystem_qws.h>
namespace Opie {
namespace Core {
namespace Internal {
class GenuineIntel : public ODevice, public QWSServer::KeyboardFilter
{
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
- virtual bool setSoftSuspend( bool soft );
-
virtual bool setDisplayBrightness( int b );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
virtual bool hasLightSensor() const;
virtual int readLightSensor();
virtual int lightSensorResolution() const;
protected:
virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
};
struct gi_button {
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
}
}
}
#endif
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 9e01a0c..2ce38a9 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.cpp
@@ -291,117 +291,96 @@ 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::setSoftSuspend ( bool soft )
-{
- bool res = false;
- int fd;
-
- if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
- if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
- res = true;
- else
- ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
-
- ::close ( fd );
- }
- else
- ::perror ( "/proc/sys/ts/suspend_button_mode" );
-
- return res;
-}
-
-
bool iPAQ::setDisplayBrightness ( int bright )
{
bool res = false;
int fd;
if ( bright > 255 )
bright = 255;
if ( bright < 0 )
bright = 0;
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;
default:
return 2;
}
}
bool iPAQ::hasLightSensor() const
{
return true;
}
int iPAQ::readLightSensor()
{
diff --git a/libopie2/opiecore/device/odevice_ipaq.h b/libopie2/opiecore/device/odevice_ipaq.h
index cc0b8ac..b1dac74 100644
--- a/libopie2/opiecore/device/odevice_ipaq.h
+++ b/libopie2/opiecore/device/odevice_ipaq.h
@@ -2,89 +2,87 @@
                This file is part of the Opie Project
              Copyright (C) The Opie Team <opie-devel@handhelds.org>
=.
.=l.
           .>+-=
 _;:,     .>    :=|. This program is free software; you can
.> <`_,   >  .   <= redistribute it and/or modify it under
:`=1 )Y*s>-.--   : the terms of the GNU Library General Public
.="- .-=="i,     .._ License as published by the Free Software
 - .   .-<_>     .<> Foundation; either version 2 of the License,
     ._= =}       : or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s. This program is distributed in the hope that
     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY;
    : ..    .:,     . . . without even the implied warranty of
    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A
  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU
..}^=.=       =       ; Library General Public License for more
++=   -.     .`     .: details.
 :     =  ...= . :.=-
 -.   .:....=;==+<; You should have received a copy of the GNU
  -_. . .   )=.  = Library General Public License along with
    --        :-=` this library; see the file COPYING.LIB.
If not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330,
Boston, MA 02111-1307, USA.
*/
#ifndef ODEVICE_IPAQ
#define ODEVICE_IPAQ
#include "odevice.h"
/* QT */
#include <qwindowsystem_qws.h>
namespace Opie {
namespace Core {
namespace Internal {
class iPAQ : public ODevice, public QWSServer::KeyboardFilter
{
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
- virtual bool setSoftSuspend( bool soft );
-
virtual bool setDisplayBrightness( int b );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
virtual bool hasLightSensor() const;
virtual int readLightSensor();
virtual int lightSensorResolution() const;
protected:
virtual bool filter( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
virtual void timerEvent( QTimerEvent *te );
int m_power_timer;
OLedState m_leds [2];
};
struct i_button {
uint model;
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
}
}
}
#endif
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index b22ee70..cbc7a24 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -335,133 +335,96 @@ QValueList <OLedState> Zaurus::ledStateList( OLed l ) const
if ( l == Led_Mail )
vl << Led_Off << Led_On << Led_BlinkSlow;
return vl;
}
OLedState Zaurus::ledState( OLed which ) const
{
if ( which == Led_Mail )
return m_leds [0];
else
return Led_Off;
}
bool Zaurus::setLedState( OLed which, OLedState st )
{
// Currently not supported on non_embedix kernels
if (!m_embedix)
{
qDebug( "Zaurus::setLedState: ODevice handling for non-embedix kernels not yet implemented" );
return false;
}
static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
if ( which == Led_Mail ) {
if ( fd >= 0 ) {
struct sharp_led_status leds;
::memset ( &leds, 0, sizeof( leds ));
leds. which = SHARP_LED_MAIL_EXISTS;
bool ok = true;
switch ( st ) {
case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
default : ok = false;
}
if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
m_leds [0] = st;
return true;
}
}
}
return false;
}
-bool Zaurus::setSoftSuspend ( bool soft )
-{
- if (!m_embedix) {
- /* non-Embedix kernels dont have kernel autosuspend */
- return ODevice::setSoftSuspend( soft );
- }
-
- bool res = false;
- int fd;
-
- if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
- (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
-
- int sources = ::ioctl( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
-
- if ( sources >= 0 ) {
- if ( soft )
- sources &= ~APM_EVT_POWER_BUTTON;
- else
- sources |= APM_EVT_POWER_BUTTON;
-
- if ( ::ioctl( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
- res = true;
- else
- perror ( "APM_IOCGEVTSRC" );
- }
- else
- perror ( "APM_IOCGEVTSRC" );
-
- ::close( fd );
- }
- else
- perror( "/dev/apm_bios or /dev/misc/apm_bios" );
-
- return res;
-}
-
int Zaurus::displayBrightnessResolution() const
{
int res = 1;
if (m_embedix)
{
int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_RDWR|O_NONBLOCK );
if ( fd )
{
int value = ::ioctl( fd, SHARP_FL_IOCTL_GET_STEP, 0 );
::close( fd );
return value ? value : res;
}
}
else
{
int fd = ::open( "/sys/class/backlight/corgi-bl/max_brightness", O_RDONLY|O_NONBLOCK );
if ( fd )
{
char buf[100];
if ( ::read( fd, &buf[0], sizeof buf ) ) ::sscanf( &buf[0], "%d", &res );
::close( fd );
}
}
return res;
}
bool Zaurus::setDisplayBrightness( int bright )
{
//qDebug( "Zaurus::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;
if ( m_embedix )
{
int fd = ::open( SHARP_FL_IOCTL_DEVICE, O_WRONLY|O_NONBLOCK );
if ( fd )
{
res = ( ::ioctl( fd, SHARP_FL_IOCTL_STEP_CONTRAST, val ) == 0 );
::close( fd );
}
}
else
{
@@ -495,124 +458,121 @@ bool Zaurus::setDisplayStatus( bool on )
int fd = ::open( "/sys/class/backlight/corgi-bl/power", O_WRONLY|O_NONBLOCK );
if ( fd )
{
char buf[10];
buf[0] = on ? '1' : '0';
buf[1] = '\0';
res = ( ::write( fd, &buf[0], 2 ) == 0 );
::close( fd );
}
}
return res;
}
bool Zaurus::suspend()
{
qDebug("ODevice::suspend");
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
return false;
bool res = false;
ODevice::sendSuspendmsg();
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync(); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );
// This is needed because the apm implementation is asynchronous and we
// can not be sure when exactly the device is really suspended
if ( res ) {
do { // Yes, wait 15 seconds. This APM sucks big time.
::usleep ( 200 * 1000 );
::gettimeofday ( &tvn, 0 );
} while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
}
QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
return res;
}
Transformation Zaurus::rotation() const
{
Transformation rot;
- int handle = 0;
- int retval = 0;
-
+
switch ( d->m_model ) {
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC7x0:
OHingeStatus hs = readHingeSensor();
if ( hs == CASE_PORTRAIT ) rot = Rot0;
else if ( hs == CASE_UNKNOWN ) rot = Rot0;
else rot = Rot270;
break;
case Model_Zaurus_SL6000:
case Model_Zaurus_SLB600:
case Model_Zaurus_SLA300:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default:
rot = d->m_rotation;
break;
}
return rot;
}
ODirection Zaurus::direction() const
{
ODirection dir;
- int handle = 0;
- int retval = 0;
+
switch ( d->m_model ) {
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC7x0:
OHingeStatus hs = readHingeSensor();
if ( hs == CASE_PORTRAIT ) dir = CCW;
else if ( hs == CASE_UNKNOWN ) dir = CCW;
else dir = CW;
break;
case Model_Zaurus_SL6000:
case Model_Zaurus_SLA300:
case Model_Zaurus_SLB600:
case Model_Zaurus_SL5500:
case Model_Zaurus_SL5000:
default: dir = d->m_direction;
break;
}
return dir;
}
bool Zaurus::hasHingeSensor() const
{
return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
}
OHingeStatus Zaurus::readHingeSensor() const
{
if (m_embedix)
{
int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
if (handle == -1)
{
qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
return CASE_UNKNOWN;
}
else
{
int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
::close (handle);
if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
{
qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
return static_cast<OHingeStatus>( retval );
}
else
{
qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
return CASE_UNKNOWN;
diff --git a/libopie2/opiecore/device/odevice_zaurus.h b/libopie2/opiecore/device/odevice_zaurus.h
index c763798..04e73c4 100644
--- a/libopie2/opiecore/device/odevice_zaurus.h
+++ b/libopie2/opiecore/device/odevice_zaurus.h
@@ -49,90 +49,88 @@
#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
#define SHARP_BUZ_KEYSOUND 2 /* key sound */
#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
// LED
#define SHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
// Rotation and Power Management
#define SHARP_IOCTL_GET_ROTATION 0x413c
#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
#define APM_EVT_POWER_BUTTON (1 << 0)
// Brightness
#define SHARP_FL_IOCTL_DEVICE "/dev/sharp_fl"
#define SHARP_FL_IOCTL_ON 1
#define SHARP_FL_IOCTL_OFF 2
#define SHARP_FL_IOCTL_STEP_CONTRAST 100
#define SHARP_FL_IOCTL_GET_STEP_CONTRAST 101
#define SHARP_FL_IOCTL_GET_STEP 102
namespace Opie {
namespace Core {
namespace Internal {
class Zaurus : public ODevice
{
protected:
virtual void init(const QString&);
virtual void initButtons();
public:
- virtual bool setSoftSuspend( bool soft );
-
virtual bool setDisplayBrightness( int b );
virtual bool setDisplayStatus( bool on );
virtual int displayBrightnessResolution() const;
virtual void playAlarmSound();
virtual void playKeySound();
virtual void playTouchSound();
virtual QValueList <OLed> ledList() const;
virtual QValueList <OLedState> ledStateList ( OLed led ) const;
virtual OLedState ledState( OLed led ) const;
virtual bool setLedState( OLed led, OLedState st );
virtual bool hasHingeSensor() const;
virtual OHingeStatus readHingeSensor() const;
virtual bool suspend();
virtual Transformation rotation() const;
virtual ODirection direction() const;
protected:
virtual void buzzer( int snd );
OLedState m_leds[1];
bool m_embedix;
};
struct z_button {
Qt::Key code;
char *utext;
char *pix;
char *fpressedservice;
char *fpressedaction;
char *fheldservice;
char *fheldaction;
};
}
}
}
#endif