summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device/odevice_zaurus.cpp
Side-by-side diff
Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index a75f566..8a7e252 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -112,96 +112,97 @@ struct z_button z_buttons_c700 [] = {
"devicebuttons/z_hinge2",
"QPE/Rotation", "rotateDefault()",0},
{ Qt::Key_F17, QT_TRANSLATE_NOOP("Button", "Hinge3"),
"devicebuttons/z_hinge3",
"QPE/Rotation", "rotateDefault()",0},
};
struct z_button z_buttons_6000 [] = {
{ Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
"devicebuttons/z_calendar",
"datebook", "nextView()",
"today", "raise()" },
{ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
"devicebuttons/z_contact",
"addressbook", "raise()",
"addressbook", "beamBusinessCard()" },
{ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
"devicebuttons/z_home",
"QPE/Launcher", "home()",
"buttonsettings", "raise()" },
{ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
"devicebuttons/z_menu",
"QPE/TaskBar", "toggleMenu()",
"QPE/TaskBar", "toggleStartMenu()" },
{ Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
"devicebuttons/z_mail",
"opiemail", "raise()",
"opiemail", "newMail()" },
{ Qt::Key_F15, QT_TRANSLATE_NOOP("Button", "Rotate Button"),
"devicebuttons/z_rotate",
0,
"QPE/Rotation", "rotateDefault()" },
{ Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
"devicebuttons/z_hinge3",
"QPE/VMemo", "toggleRecord()",
"sound", "raise()" },
};
// FIXME This gets unnecessary complicated. We should think about splitting the Zaurus
// class up into individual classes. We would need three classes
//
// Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000)
// Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600)
// Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, C860, C3000, C1000, C3100)
// Zaurus-Tosa (PXA-model w/ 480x640 lcd, for SL6000)
void Zaurus::init(const QString& cpu_info)
{
+ qDebug( "Zaurus::init()" );
// Set the time to wait until the system is really suspended
// the delta between apm --suspend and sleeping
setAPMTimeOut( 15000 );
// generic distribution code already scanned /etc/issue at that point -
// embedix releases contain "Embedix <version> | Linux for Embedded Devices"
if ( d->m_sysverstr.contains( "embedix", false ) )
{
d->m_vendorstr = "Sharp";
d->m_vendor = Vendor_Sharp;
d->m_systemstr = "Zaurus";
d->m_system = System_Zaurus;
m_embedix = true;
}
else
{
d->m_vendorstr = "OpenZaurus Team";
d->m_systemstr = "OpenZaurus";
d->m_system = System_OpenZaurus;
// sysver already gathered
// OpenZaurus sometimes uses the 2.4 (embedix) kernel, check if this is one
FILE *uname = popen("uname -r", "r");
QFile f;
QString line;
if ( f.open(IO_ReadOnly, uname) ) {
QTextStream ts ( &f );
line = ts.readLine();
m_embedix = line.startsWith( "2.4." );
f.close();
}
pclose(uname);
}
// check the Zaurus model
QString model;
int loc = cpu_info.find( ":" );
if ( loc != -1 )
model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
else
model = cpu_info;
if ( model == "SHARP Corgi" ) {
d->m_model = Model_Zaurus_SLC7x0;
d->m_modelstr = "Zaurus SL-C700";
} else if ( model == "SHARP Shepherd" ) {
d->m_model = Model_Zaurus_SLC7x0;
d->m_modelstr = "Zaurus SL-C750";
@@ -214,147 +215,148 @@ void Zaurus::init(const QString& cpu_info)
} else if ( model == "SHARP Poodle" ) {
d->m_model = Model_Zaurus_SLB600;
d->m_modelstr = "Zaurus SL-B500 or SL-5600";
} else if ( model == "Sharp-Collie" || model == "Collie" ) {
d->m_model = Model_Zaurus_SL5500;
d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
} else if ( model == "SHARP Tosa" ) {
d->m_model = Model_Zaurus_SL6000;
d->m_modelstr = "Zaurus SL-6000";
} else if ( model == "SHARP Spitz" ) {
d->m_model = Model_Zaurus_SLC3000;
d->m_modelstr = "Zaurus SL-C3000";
} else if ( model == "SHARP Akita" ) {
d->m_model = Model_Zaurus_SLC1000;
d->m_modelstr = "Zaurus SL-C1000";
} else if ( model == "SHARP Borzoi" ) {
d->m_model = Model_Zaurus_SLC3100;
d->m_modelstr = "Zaurus SL-C3100";
} else {
d->m_model = Model_Zaurus_SL5500;
d->m_modelstr = "Unknown Zaurus";
}
// set path to backlight device in kernel 2.6
switch ( d->m_model )
{
case Model_Zaurus_SLB600: // fallthrough
case Model_Zaurus_SL5500:
m_backlightdev = "/sys/class/backlight/locomo-backlight/";
break;
case Model_Zaurus_SL6000:
m_backlightdev = "/sys/class/backlight/tosa-bl/";
break;
default:
m_backlightdev = "/sys/class/backlight/corgi-bl/";
}
// set initial rotation
switch( d->m_model )
{
case Model_Zaurus_SL6000: // fallthrough
case Model_Zaurus_SLA300:
d->m_rotation = Rot0;
break;
case Model_Zaurus_SLC3100: // fallthrough
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC1000: // fallthrough
case Model_Zaurus_SLC7x0:
+ initHingeSensor();
d->m_rotation = rotation();
d->m_direction = direction();
break;
case Model_Zaurus_SLB600: // fallthrough
case Model_Zaurus_SL5000: // fallthrough
case Model_Zaurus_SL5500: // fallthrough
default:
d->m_rotation = Rot270;
}
// set default qte driver
switch( d->m_model )
{
case Model_Zaurus_SLC7x0:
d->m_qteDriver = "W100";
break;
default:
d->m_qteDriver = "Transformed";
}
m_leds[0] = Led_Off;
if ( m_embedix )
qDebug( "Zaurus::init() - Using the 2.4 Embedix HAL on a %s", (const char*) d->m_modelstr );
else
qDebug( "Zaurus::init() - Using the 2.6 OpenZaurus HAL on a %s", (const char*) d->m_modelstr );
}
void Zaurus::initButtons()
{
+ qDebug( "Zaurus::initButtons()" );
if ( d->m_buttons )
return;
d->m_buttons = new QValueList <ODeviceButton>;
struct z_button * pz_buttons;
int buttoncount;
switch ( d->m_model )
{
case Model_Zaurus_SL6000:
pz_buttons = z_buttons_6000;
buttoncount = ARRAY_SIZE(z_buttons_6000);
break;
case Model_Zaurus_SLC3100: // fallthrough
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC1000: // fallthrough
case Model_Zaurus_SLC7x0:
if ( isQWS( ) )
- { // setup hinge sensor stuff
+ {
addPreHandler(this);
- initHingeSensor();
}
pz_buttons = z_buttons_c700;
buttoncount = ARRAY_SIZE(z_buttons_c700);
break;
default:
pz_buttons = z_buttons;
buttoncount = ARRAY_SIZE(z_buttons);
break;
}
for ( int i = 0; i < buttoncount; i++ ) {
struct z_button *zb = pz_buttons + i;
ODeviceButton b;
b.setKeycode( zb->code );
b.setUserText( QObject::tr( "Button", zb->utext ));
b.setPixmap( OResource::loadPixmap( zb->pix ));
b.setFactoryPresetPressedAction( OQCopMessage( makeChannel ( zb->fpressedservice ), zb->fpressedaction ));
b.setFactoryPresetHeldAction( OQCopMessage( makeChannel ( zb->fheldservice ), zb->fheldaction ));
d->m_buttons->append( b );
}
reloadButtonMapping();
}
typedef struct sharp_led_status {
int which; /* select which LED status is wanted. */
int status; /* set new led status if you call SHARP_LED_SETSTATUS */
} sharp_led_status;
void Zaurus::buzzer( int sound )
{
#ifndef QT_NO_SOUND
Sound *snd = 0;
// All devices except SL5500 have a DSP device
if ( d->m_model != Model_Zaurus_SL5000
&& d->m_model != Model_Zaurus_SL5500 ) {
switch ( sound ){
case SHARP_BUZ_TOUCHSOUND: {
static Sound touch_sound("touchsound");
snd = &touch_sound;
}
break;
case SHARP_BUZ_KEYSOUND: {
@@ -556,96 +558,97 @@ Transformation Zaurus::rotation() const
{
qDebug( "Zaurus::rotation()" );
Transformation rot;
switch ( d->m_model ) {
case Model_Zaurus_SLC3100: // fallthrough
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC1000:
{
OHingeStatus hs = readHingeSensor();
qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
if ( hs == CASE_PORTRAIT ) rot = Rot0;
else if ( hs == CASE_UNKNOWN ) rot = Rot270;
else rot = Rot270;
}
break;
// SLC7x0 needs a special case here, because we were able to set the W100
// hardware default rotation on kernel 2.6 to Rot0
case Model_Zaurus_SLC7x0:
{
OHingeStatus hs = readHingeSensor();
qDebug( "Zaurus::rotation() - hinge sensor = %d", (int) hs );
if ( m_embedix )
{
if ( hs == CASE_PORTRAIT ) rot = Rot0;
else if ( hs == CASE_UNKNOWN ) rot = Rot270;
else rot = Rot270;
}
else
{
if ( hs == CASE_PORTRAIT ) rot = Rot90;
else if ( hs == CASE_UNKNOWN ) rot = Rot0;
else rot = Rot0;
}
}
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;
}
+ qDebug( "Zaurus::rotation() - returning '%d'", rot );
return rot;
}
ODirection Zaurus::direction() const
{
ODirection dir;
switch ( d->m_model ) {
case Model_Zaurus_SLC3100: // fallthrough
case Model_Zaurus_SLC3000: // fallthrough
case Model_Zaurus_SLC1000: // 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_SLC3100 ||
d->m_model == Model_Zaurus_SLC3000 ||
d->m_model == Model_Zaurus_SLC1000;
}
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
@@ -660,120 +663,129 @@ OHingeStatus Zaurus::readHingeSensor() const
else
{
qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
return CASE_UNKNOWN;
}
}
}
else
{
/*
* The corgi keyboard is event source 0 in OZ kernel 2.6.
* Hinge status is reported via Input System Switchs 0 and 1 like that:
*
* -------------------------
* | SW0 | SW1 | CASE |
* |-----|-----|-----------|
* | 0 0 Landscape |
* | 0 1 Portrait |
* | 1 0 Unknown |
* | 1 1 Closed |
* -------------------------
*/
OInputDevice* keyboard = OInputSystem::instance()->device( "event0" );
bool switch0 = true;
bool switch1 = false;
if ( keyboard )
{
switch0 = keyboard->isHeld( OInputDevice::Switch0 );
switch1 = keyboard->isHeld( OInputDevice::Switch1 );
}
if ( switch0 )
{
return switch1 ? CASE_CLOSED : CASE_UNKNOWN;
}
else
{
return switch1 ? CASE_PORTRAIT : CASE_LANDSCAPE;
}
}
}
void Zaurus::initHingeSensor()
{
if ( m_embedix ) return;
m_hinge.setName( "/dev/input/event0" );
if ( !m_hinge.open( IO_ReadOnly ) )
{
- qDebug( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) );
+ qWarning( "Zaurus::init() - Couldn't open /dev/input/event0 for read (%s)", strerror( errno ) );
return;
}
QSocketNotifier* sn = new QSocketNotifier( m_hinge.handle(), QSocketNotifier::Read, this );
QObject::connect( sn, SIGNAL(activated(int)), this, SLOT(hingeSensorTriggered()) );
+
+ qDebug( "Zaurus::init() - Hinge Sensor Initialization successfully completed" );
}
void Zaurus::hingeSensorTriggered()
{
qDebug( "Zaurus::hingeSensorTriggered() - got event" );
struct input_event e;
if ( ::read( m_hinge.handle(), &e, sizeof e ) > 0 )
{
qDebug( "Zaurus::hingeSensorTriggered() - event has type %d, code %d, value %d", e.type, e.code, e.value );
if ( e.type != EV_SW ) return;
if ( readHingeSensor() != CASE_UNKNOWN )
{
qDebug( "Zaurus::hingeSensorTriggered() - got valid switch event, calling rotateDefault()" );
QCopChannel::send( "QPE/Rotation", "rotateDefault()" );
}
}
}
+void Zaurus::systemMessage( const QCString &msg, const QByteArray & )
+{
+ if ( msg == "deviceButtonMappingChanged()" ) {
+ reloadButtonMapping();
+ }
+}
+
/*
* Take code from iPAQ device.
* That way we switch the cursor directions depending on status of hinge sensor, eg. hardware direction.
* I hope that is ok - Alwin
*/
bool Zaurus::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
{
int newkeycode = keycode;
if ( !hasHingeSensor() ) return false;
/* map cursor keys depending on the hinge status */
switch ( keycode ) {
// Rotate cursor keys
case Key_Left :
case Key_Right:
case Key_Up :
case Key_Down :
{
if (rotation()==Rot90) {
newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
}
}
break;
}
if (newkeycode!=keycode) {
if ( newkeycode != Key_unknown ) {
QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
}
return true;
}
return false;
}
bool Zaurus::suspend() {
if ( !isQWS( ) ) // only qwsserver is allowed to suspend
return false;
bool res = false;
QCopChannel::send( "QPE/System", "aboutToSuspend()" );
struct timeval tvs, tvn;
::gettimeofday ( &tvs, 0 );
::sync(); // flush fs caches
res = ( ::system ( "apm --suspend" ) == 0 );