summaryrefslogtreecommitdiff
Side-by-side diff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro4
-rw-r--r--libopie/odevice.cpp246
-rw-r--r--libopie/odevice.h48
-rw-r--r--libopie/odevicebutton.cpp234
-rw-r--r--libopie/odevicebutton.h97
5 files changed, 609 insertions, 20 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index c829083..58a7489 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -1,76 +1,76 @@
TEMPLATE = lib
CONFIG += qte warn_on release
HEADERS = ofontmenu.h \
ocolorbutton.h \
ofiledialog.h ofileselector.h tododb.h \
ocheckitem.h todoevent.h todoresource.h \
todovcalresource.h xmltree.h \
colordialog.h colorpopupmenu.h \
oclickablelabel.h oprocctrl.h \
- oprocess.h odevice.h \
+ oprocess.h odevice.h odevicebutton.h \
otimepicker.h otabwidget.h \
otabbar.h otabinfo.h \
ofontselector.h \
pim/opimrecord.h \
pim/otodo.h \
pim/orecordlist.h \
pim/opimaccesstemplate.h \
pim/opimaccessbackend.h \
pim/otodoaccess.h \
pim/otodoaccessbackend.h \
pim/ocontact.h \
pim/ocontactaccess.h \
pim/ocontactaccessbackend.h \
pim/ocontactaccessbackend_xml.h \
pim/ocontactaccessbackend_vcard.h \
pim/obackendfactory.h \
pim/opimcache.h \
pim/otodoaccessvcal.h \
pim/orecur.h \
pim/opimstate.h \
pim/opimxrefpartner.h \
pim/opimxref.h \
pim/opimxrefmanager.h \
pim/opimmaintainer.h \
pim/opimnotify.h \
pim/opimnotifymanager.h \
pim/opimmainwindow.h \
pim/opimresolver.h \
orecurrancewidget.h \
oticker.h
# pim/otodoaccesssql.h \
SOURCES = ofontmenu.cc \
ocolorbutton.cpp \
sharp_compat.cpp \
xmltree.cc \
ofiledialog.cc ofileselector.cc \
ocheckitem.cpp tododb.cpp todoevent.cpp \
todovcalresource.cpp colordialog.cpp \
colorpopupmenu.cpp oclickablelabel.cpp \
oprocctrl.cpp oprocess.cpp \
- odevice.cpp otimepicker.cpp \
+ odevice.cpp odevicebutton.cpp otimepicker.cpp \
otabwidget.cpp otabbar.cpp \
ofontselector.cpp \
pim/otodo.cpp \
pim/opimrecord.cpp \
pim/otodoaccess.cpp \
pim/otodoaccessbackend.cpp \
pim/otodoaccessxml.cpp \
pim/ocontact.cpp \
pim/ocontactaccess.cpp \
pim/ocontactaccessbackend_vcard.cpp \
pim/otodoaccessvcal.cpp \
pim/orecur.cpp \
pim/opimstate.cpp \
pim/opimxrefpartner.cpp \
pim/opimxref.cpp \
pim/opimxrefmanager.cpp \
pim/opimmaintainer.cpp \
pim/opimnotify.cpp \
pim/opimnotifymanager.cpp \
pim/opimmainwindow.cpp \
pim/opimresolver.cpp \
orecurrancewidget.cpp \
oticker.cpp
# pim/otodoaccesssql.cpp \
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c947630..f93d1ed 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -12,189 +12,297 @@
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.
*/
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <signal.h>
#include <sys/time.h>
#include <linux/soundcard.h>
#include <math.h>
#include <qapplication.h>
#include <qfile.h>
#include <qtextstream.h>
#include <qpe/sound.h>
#include <qpe/resource.h>
#include <qpe/config.h>
+#include <qpe/qcopenvelope_qws.h>
#include "odevice.h"
#include <qwindowsystem_qws.h>
// _IO and friends are only defined in kernel headers ...
#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
#define OD_IO(type,number) OD_IOC(0,type,number,0)
#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
using namespace Opie;
class ODeviceData {
public:
bool m_qwsserver;
QString m_vendorstr;
OVendor m_vendor;
QString m_modelstr;
OModel m_model;
QString m_systemstr;
OSystem m_system;
QString m_sysverstr;
+
+ QValueList <ODeviceButton> m_buttons;
+ uint m_holdtime;
};
-class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter {
+class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
protected:
virtual void init ( );
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution ( ) const;
virtual void alarmSound ( );
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 QValueList <int> keyList ( ) 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];
};
class Zaurus : public ODevice {
protected:
virtual void init ( );
public:
virtual bool setSoftSuspend ( bool soft );
virtual bool setDisplayBrightness ( int b );
virtual int displayBrightnessResolution ( ) const;
virtual void alarmSound ( );
virtual void keySound ( );
virtual void touchSound ( );
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 QValueList <int> keyList ( ) const;
-
protected:
virtual void buzzer ( int snd );
OLedState m_leds [1];
};
+struct i_button {
+ uint model;
+ Qt::Key code;
+ char *utext;
+ char *pix;
+ char *fpressedservice;
+ char *fpressedaction;
+ char *fheldservice;
+ char *fheldaction;
+} ipaq_buttons [] = {
+ { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
+ Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
+ "devicebuttons/ipaq_calendar",
+ "datebook", "nextView()",
+ "today", "raise()" },
+ { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
+ Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
+ "devicebuttons/ipaq_contact",
+ "addressbook", "raise()",
+ "addressbook", "beamBusinessCard()" },
+ { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
+ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
+ "devicebuttons/ipaq_menu",
+ "QPE/TaskBar", "toggleMenu()",
+ "QPE/TaskBar", "toggleStartMenu()" },
+ { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
+ Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"),
+ "devicebuttons/ipaq_mail",
+ "mail", "raise()",
+ "mail", "newMail()" },
+ { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
+ Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
+ "devicebuttons/ipaq_home",
+ "QPE/Launcher", "home()",
+ "buttonsettings", "raise()" },
+ { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
+ Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
+ "devicebuttons/ipaq_record",
+ "QPE/VMemo", "toggleRecord()",
+ "sound", "raise()" },
+};
+
+struct z_button {
+ Qt::Key code;
+ char *utext;
+ char *pix;
+ char *fpressedservice;
+ char *fpressedaction;
+ char *fheldservice;
+ char *fheldaction;
+} z_buttons [] = {
+ { 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",
+ "mail", "raise()",
+ "mail", "newMail()" },
+};
+static QCString makeChannel ( const char *str )
+{
+ if ( str && !::strchr ( str, '/' ))
+ return QCString ( "QPE/Application/" ) + str;
+ else
+ return str;
+}
ODevice *ODevice::inst ( )
{
static ODevice *dev = 0;
if ( !dev ) {
if ( QFile::exists ( "/proc/hal/model" ))
dev = new iPAQ ( );
else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
dev = new Zaurus ( );
else
dev = new ODevice ( );
dev-> init ( );
}
return dev;
}
/**************************************************
*
* common
*
**************************************************/
ODevice::ODevice ( )
{
d = new ODeviceData;
d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
d-> m_modelstr = "Unknown";
d-> m_model = Model_Unknown;
d-> m_vendorstr = "Unkown";
d-> m_vendor = Vendor_Unknown;
d-> m_systemstr = "Unkown";
d-> m_system = System_Unknown;
d-> m_sysverstr = "0.0";
+
+ d-> m_holdtime = 1000; // 1000ms
+
+ QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
+ connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
+}
+
+void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
+{
+ if ( msg == "deviceButtonMappingChanged()" ) {
+ reloadButtonMapping ( );
+ }
}
void ODevice::init ( )
{
+ // Simulation uses iPAQ 3660 device buttons
+
+ for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
+ i_button *ib = ipaq_buttons + i;
+ ODeviceButton b;
+
+ if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
+ b. setKeycode ( ib-> code );
+ b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
+ b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
+ b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
+ b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
+
+ d-> m_buttons. append ( b );
+ }
+ }
+ reloadButtonMapping ( );
}
ODevice::~ODevice ( )
{
delete d;
}
bool ODevice::setSoftSuspend ( bool /*soft*/ )
{
return false;
}
//#include <linux/apm_bios.h>
#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
bool ODevice::suspend ( )
{
if ( !d-> m_qwsserver ) // 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;
@@ -338,52 +446,131 @@ OLedState ODevice::ledState ( OLed /*which*/ ) const
{
return Led_Off;
}
bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
{
return false;
}
bool ODevice::hasLightSensor ( ) const
{
return false;
}
int ODevice::readLightSensor ( )
{
return -1;
}
int ODevice::lightSensorResolution ( ) const
{
return 0;
}
-//QValueList <int> ODevice::keyList ( ) const
-//{
-// return QValueList <int> ( );
-//}
+const QValueList <ODeviceButton> &ODevice::buttons ( ) const
+{
+ return d-> m_buttons;
+}
+
+uint ODevice::buttonHoldTime ( ) const
+{
+ return d-> m_holdtime;
+}
+
+const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
+{
+ for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) {
+ if ( (*it). keycode ( ) == code )
+ return &(*it);
+ }
+ return 0;
+}
+
+void ODevice::reloadButtonMapping ( )
+{
+ Config cfg ( "ButtonSettings" );
+
+ for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) {
+ ODeviceButton &b = d-> m_buttons [i];
+ QString group = "Button" + QString::number ( i );
+
+ QCString pch, hch;
+ QCString pm, hm;
+ QByteArray pdata, hdata;
+
+ if ( cfg. hasGroup ( group )) {
+ cfg. setGroup ( group );
+ pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
+ pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
+ // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
+
+ hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
+ hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
+ // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
+ }
+
+ b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
+ b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
+ }
+}
+
+void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
+{
+ if ( button >= (int) d-> m_buttons. count ( ))
+ return;
+
+ ODeviceButton &b = d-> m_buttons [button];
+ b. setPressedAction ( action );
+
+ Config buttonFile ( "ButtonSettings" );
+ buttonFile. setGroup ( "Button" + QString::number ( button ));
+ buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( ));
+ buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
+
+// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
+
+ QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
+}
+
+void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
+{
+ if ( button >= (int) d-> m_buttons. count ( ))
+ return;
+
+ ODeviceButton &b = d-> m_buttons [button];
+ b. setHeldAction ( action );
+
+ Config buttonFile ( "ButtonSettings" );
+ buttonFile. setGroup ( "Button" + QString::number ( button ));
+ buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
+ buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
+
+// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
+
+ QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
+}
+
/**************************************************
*
* iPAQ
*
**************************************************/
void iPAQ::init ( )
{
d-> m_vendorstr = "HP";
d-> m_vendor = Vendor_HP;
QFile f ( "/proc/hal/model" );
if ( f. open ( IO_ReadOnly )) {
QTextStream ts ( &f );
d-> m_modelstr = "H" + ts. readLine ( );
if ( d-> m_modelstr == "H3100" )
d-> m_model = Model_iPAQ_H31xx;
else if ( d-> m_modelstr == "H3600" )
@@ -394,48 +581,68 @@ void iPAQ::init ( )
d-> m_model = Model_iPAQ_H38xx;
else if ( d-> m_modelstr == "H3900" )
d-> m_model = Model_iPAQ_H39xx;
else
d-> m_model = Model_Unknown;
f. close ( );
}
f. setName ( "/etc/familiar-version" );
if ( f. open ( IO_ReadOnly )) {
d-> m_systemstr = "Familiar";
d-> m_system = System_Familiar;
QTextStream ts ( &f );
d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
f. close ( );
}
m_leds [0] = m_leds [1] = Led_Off;
m_power_timer = 0;
+ for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
+ i_button *ib = ipaq_buttons + i;
+ ODeviceButton b;
+
+ qDebug ( "%d: %d", i, ib-> model );
+
+ if (( ib-> model & d-> m_model ) == d-> m_model ) {
+ b. setKeycode ( ib-> code );
+ b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
+ b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
+ b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
+ b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
+
+ d-> m_buttons. append ( b );
+
+ qDebug ( "code: %d", ib-> code );
+ }
+ }
+ reloadButtonMapping ( );
+
if ( d-> m_qwsserver )
QWSServer::setKeyboardFilter ( this );
}
//#include <linux/h3600_ts.h> // including kernel headers is evil ...
typedef struct {
unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
unsigned char TotalTime; /* Units of 5 seconds */
unsigned char OnTime; /* units of 100m/s */
unsigned char OffTime; /* units of 100m/s */
} LED_IN;
typedef struct {
unsigned char mode;
unsigned char pwr;
unsigned char brightness;
} FLITE_IN;
#define LED_ON OD_IOW( 'f', 5, LED_IN )
#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
@@ -482,55 +689,48 @@ bool iPAQ::setLedState ( OLed l, OLedState st )
LED_IN leds;
::memset ( &leds, 0, sizeof( leds ));
leds. TotalTime = 0;
leds. OnTime = 0;
leds. OffTime = 1;
leds. OffOnBlink = 2;
switch ( st ) {
case Led_Off : leds. OffOnBlink = 0; break;
case Led_On : leds. OffOnBlink = 1; break;
case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
}
if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
m_leds [0] = st;
return true;
}
}
}
return false;
}
-//QValueList <int> iPAQ::keyList ( ) const
-//{
-// QValueList <int> vl;
-// vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight;
-// return vl;
-//}
-
bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
{
int newkeycode = keycode;
switch ( keycode ) {
// H38xx/H39xx have no "Q" key anymore - this is now the Mail key
case HardKey_Menu: {
if (( d-> m_model == Model_iPAQ_H38xx ) ||
( d-> m_model == Model_iPAQ_H39xx )) {
newkeycode = HardKey_Mail;
}
break;
}
// Rotate cursor keys 180°
case Key_Left :
case Key_Right:
case Key_Up :
case Key_Down : {
if (( d-> m_model == Model_iPAQ_H31xx ) ||
( d-> m_model == Model_iPAQ_H38xx )) {
newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
}
break;
@@ -733,48 +933,62 @@ void Zaurus::init ( )
}
else {
d-> m_systemstr = "Zaurus";
d-> m_system = System_Zaurus;
}
f. setName ( "/proc/deviceinfo/product" );
if ( f. open ( IO_ReadOnly ) ) {
QTextStream ts ( &f );
QString model = ts. readLine ( );
f. close ( );
if ( model == "SL-5000D" ) {
d-> m_model = Model_Zaurus_SL5000;
d-> m_modelstr = "Zaurus SL-5000D";
} else if ( model == "SL-5500" ) {
d-> m_model = Model_Zaurus_SL5500;
d-> m_modelstr = "Zaurus SL-5500";
}
}
else {
d-> m_model = Model_Zaurus_SL5000;
d-> m_modelstr = "Zaurus SL-5000D (unverified)";
}
+ for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
+ z_button *zb = z_buttons + i;
+ ODeviceButton b;
+
+ b. setKeycode ( zb-> code );
+ b. setUserText ( qApp-> translate ( "Button", zb-> utext ));
+ b. setPixmap ( Resource::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 ( );
+
m_leds [0] = Led_Off;
}
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
//#include <asm/sharp_char.h> // including kernel headers is evil ...
#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
#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 */
/* --- for SHARP_BUZZER device --- */
//#define SHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 86491d4..ce62f1a 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,49 +1,52 @@
/* This file is part of the OPIE libraries
Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library 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 _LIBOPIE_ODEVICE_H_
#define _LIBOPIE_ODEVICE_H_
+#include <qobject.h>
#include <qstring.h>
#include <qnamespace.h>
+#include <opie/odevicebutton.h>
+
class ODeviceData;
namespace Opie {
enum OModel {
Model_Unknown,
Model_Series_Mask = 0xff000000,
Model_iPAQ = ( 1 << 24 ),
Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
Model_Zaurus = ( 2 << 24 ),
Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
};
@@ -66,50 +69,51 @@ enum OLedState {
Led_Off,
Led_On,
Led_BlinkSlow,
Led_BlinkFast
};
enum OLed {
Led_Mail,
Led_Power,
Led_BlueTooth
};
enum OHardKey {
HardKey_Datebook = Qt::Key_F9,
HardKey_Contacts = Qt::Key_F10,
HardKey_Menu = Qt::Key_F11,
HardKey_Home = Qt::Key_F12,
HardKey_Mail = Qt::Key_F14,
HardKey_Record = Qt::Key_F24,
HardKey_Suspend = Qt::Key_F34,
HardKey_Backlight = Qt::Key_F35,
};
-class ODevice
-{
+class ODevice : public QObject {
+ Q_OBJECT
+
private:
ODevice ( const ODevice & );
protected:
ODevice ( );
virtual void init ( );
ODeviceData *d;
public:
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;
@@ -121,30 +125,70 @@ public:
// system
virtual bool setSoftSuspend ( bool on );
virtual bool suspend ( );
virtual bool setDisplayStatus ( bool on );
virtual bool setDisplayBrightness ( int brightness );
virtual int displayBrightnessResolution ( ) const;
// input / output
virtual void alarmSound ( );
virtual void keySound ( );
virtual void touchSound ( );
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;
+
+ /**
+ * 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.
+ */
+ const QValueList<ODeviceButton> &buttons ( ) const;
+
+ /**
+ * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
+ * returns 0L
+ */
+ const ODeviceButton *buttonForKeycode ( ushort keyCode );
+
+ /**
+ * Reassigns the pressed action for \a button. To return to the factory
+ * default pass an empty string as \a qcopMessage.
+ */
+ void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
+
+ /**
+ * Reassigns the held action for \a button. To return to the factory
+ * default pass an empty string as \a qcopMessage.
+ */
+ void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
+
+ /**
+ * How long (in ms) you have to press a button for a "hold" action
+ */
+ uint buttonHoldTime ( ) const;
+
+signals:
+ void buttonMappingChanged ( );
+
+private slots:
+ void systemMessage ( const QCString &, const QByteArray & );
+
+protected:
+ void reloadButtonMapping ( );
};
}
#endif
diff --git a/libopie/odevicebutton.cpp b/libopie/odevicebutton.cpp
new file mode 100644
index 0000000..2270343
--- a/dev/null
+++ b/libopie/odevicebutton.cpp
@@ -0,0 +1,234 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+
+#include <qpixmap.h>
+#include <qstring.h>
+
+#include <qpe/qcopenvelope_qws.h>
+#include <opie/odevicebutton.h>
+
+using namespace Opie;
+
+
+class OQCopMessageData {
+public:
+ QCString m_channel;
+ QCString m_message;
+ QByteArray m_data;
+};
+
+
+OQCopMessage::OQCopMessage ( )
+ : d ( 0 )
+{
+ init ( QCString ( ), QCString ( ), QByteArray ( ));
+}
+
+OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
+ : d ( 0 )
+{
+ init ( copy. channel ( ), copy. message ( ), copy. data ( ));
+}
+
+OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
+{
+ init ( assign. channel ( ), assign. message ( ), assign. data ( ));
+ return *this;
+}
+
+OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
+ : d ( 0 )
+{
+ init ( ch, m, arg );
+}
+
+void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
+{
+ if ( !d )
+ d = new OQCopMessageData ( );
+ d-> m_channel = ch;
+ d-> m_message = m;
+ d-> m_data = arg;
+}
+
+bool OQCopMessage::send ( )
+{
+ if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ))
+ return false;
+
+ QCopEnvelope e ( d-> m_channel, d-> m_message );
+
+ if ( d-> m_data. size ( ))
+ e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
+
+ return true;
+}
+
+QCString OQCopMessage::channel ( ) const
+{
+ return d-> m_channel;
+}
+
+QCString OQCopMessage::message ( ) const
+{
+ return d-> m_message;
+}
+
+QByteArray OQCopMessage::data ( ) const
+{
+ return d-> m_data;
+}
+
+void OQCopMessage::setChannel ( const QCString &ch )
+{
+ d-> m_channel = ch;
+}
+
+void OQCopMessage::setMessage ( const QCString &m )
+{
+ d-> m_message = m;
+}
+
+void OQCopMessage::setData ( const QByteArray &data )
+{
+ d-> m_data = data;
+}
+
+/*! \class ODeviceButton
+ \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device.
+
+ This class represents a physical button on a Qtopia device. A
+ device may have "user programmable" buttons.
+ The location and number of buttons will vary from device to
+ device. userText() and pixmap() may be used to describe this button
+ to the user in help documentation.
+
+ \ingroup qtopiaemb
+ \internal
+*/
+
+ODeviceButton::ODeviceButton()
+{
+}
+
+ODeviceButton::~ODeviceButton()
+{
+}
+
+/*!
+ Returns the button's keycode.
+ */
+ushort ODeviceButton::keycode() const
+{
+ return m_Keycode;
+}
+
+
+/*!
+ This function returns a human readable, translated description of the button.
+ */
+QString ODeviceButton::userText() const
+{
+ return m_UserText;
+}
+
+/*!
+ This function returns the pixmap for this button. If there isn't one
+ it will return an empty (null) pixmap.
+ */
+QPixmap ODeviceButton::pixmap() const
+{
+ return m_Pixmap;
+}
+
+/*!
+ This function returns the factory preset (default) action for when this button
+ is pressed. The return value is a legal QCop message.
+ */
+OQCopMessage ODeviceButton::factoryPresetPressedAction() const
+{
+ return m_FactoryPresetPressedAction;
+}
+
+/*!
+ This function returns the user assigned action for when this button is pressed.
+ If no action is assigned, factoryPresetAction() is returned.
+ */
+OQCopMessage ODeviceButton::pressedAction() const
+{
+ if (m_PressedAction.channel().isEmpty())
+ return factoryPresetPressedAction();
+ return m_PressedAction;
+}
+
+/*!
+ This function returns the factory preset (default) action for when this button
+ is pressed and held. The return value is a legal QCop message.
+ */
+OQCopMessage ODeviceButton::factoryPresetHeldAction() const
+{
+ return m_FactoryPresetHeldAction;
+}
+
+/*!
+ This function returns the user assigned action for when this button is pressed
+ and held. If no action is assigned, factoryPresetAction() is returned.
+ */
+OQCopMessage ODeviceButton::heldAction() const
+{
+ if (m_HeldAction.channel().isEmpty())
+ return factoryPresetHeldAction();
+ return m_HeldAction;
+}
+
+void ODeviceButton::setKeycode(ushort keycode)
+{
+ m_Keycode = keycode;
+}
+
+void ODeviceButton::setUserText(const QString& text)
+{
+ m_UserText = text;
+}
+
+void ODeviceButton::setPixmap(const QPixmap& picture)
+{
+ m_Pixmap = picture;
+}
+
+void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
+{
+ m_FactoryPresetPressedAction = action;
+}
+
+void ODeviceButton::setPressedAction(const OQCopMessage& action)
+{
+ m_PressedAction = action;
+}
+
+void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
+{
+ m_FactoryPresetHeldAction = action;
+}
+
+void ODeviceButton::setHeldAction(const OQCopMessage& action)
+{
+ m_HeldAction = action;
+}
diff --git a/libopie/odevicebutton.h b/libopie/odevicebutton.h
new file mode 100644
index 0000000..5281ab2
--- a/dev/null
+++ b/libopie/odevicebutton.h
@@ -0,0 +1,97 @@
+/**********************************************************************
+** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
+**
+** This file is part of the Qtopia Environment.
+**
+** This file may be distributed and/or modified under the terms of the
+** GNU General Public License version 2 as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL included in the
+** packaging of this file.
+**
+** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
+** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+**
+** See http://www.trolltech.com/gpl/ for GPL licensing information.
+**
+** Contact info@trolltech.com if any conditions of this licensing are
+** not clear to you.
+**
+**********************************************************************/
+#ifndef DEVICE_BUTTON_H
+#define DEVICE_BUTTON_H
+
+#include <qpixmap.h>
+#include <qstring.h>
+
+class OQCopMessageData;
+
+namespace Opie
+{
+
+class OQCopMessage {
+public:
+ OQCopMessage ( );
+ OQCopMessage ( const OQCopMessage &copy );
+ OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( ));
+
+ OQCopMessage &operator = ( const OQCopMessage &assign );
+
+ void setChannel ( const QCString &channel );
+ void setMessage ( const QCString &message );
+ void setData ( const QByteArray &ba );
+
+ QCString channel ( ) const;
+ QCString message ( ) const;
+ QByteArray data ( ) const;
+
+ bool send ( );
+
+private:
+ void init ( const QCString &m_channel, const QCString &message, const QByteArray &args );
+
+ OQCopMessageData *d;
+};
+
+
+/**
+ * This class represents a physical button on a Qtopia device. A device may
+ * have n "user programmable" buttons, which are number 1..n. The location
+ * and number of buttons will vary from device to device. userText() and pixmap()
+ * may be used to describe this button to the user in help documentation.
+ */
+
+class ODeviceButton
+{
+public:
+ ODeviceButton();
+ virtual ~ODeviceButton();
+
+ ushort keycode ( ) const;
+ QString userText ( ) const;
+ QPixmap pixmap ( ) const;
+ OQCopMessage factoryPresetPressedAction ( ) const;
+ OQCopMessage pressedAction ( ) const;
+ OQCopMessage factoryPresetHeldAction ( ) const;
+ OQCopMessage heldAction ( ) const;
+
+ void setKeycode ( ushort keycode );
+ void setUserText ( const QString& text );
+ void setPixmap ( const QPixmap& picture );
+ void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
+ void setPressedAction ( const OQCopMessage& qcopMessage );
+ void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
+ void setHeldAction ( const OQCopMessage& qcopMessage );
+
+private:
+ ushort m_Keycode;
+ QString m_UserText;
+ QPixmap m_Pixmap;
+ OQCopMessage m_FactoryPresetPressedAction;
+ OQCopMessage m_PressedAction;
+ OQCopMessage m_FactoryPresetHeldAction;
+ OQCopMessage m_HeldAction;
+};
+
+}
+
+#endif