summaryrefslogtreecommitdiff
path: root/libopie
authorsandman <sandman>2002-12-22 23:54:50 (UTC)
committer sandman <sandman>2002-12-22 23:54:50 (UTC)
commit5c7694a7baadec8afe128ad2541e0a8acfc23737 (patch) (unidiff)
treec3dc0189dd9933e43565d85183474adfdc0de7aa /libopie
parent3ef4b1549eca77c3d1c3ef710eb6abbd3de336be (diff)
downloadopie-5c7694a7baadec8afe128ad2541e0a8acfc23737.zip
opie-5c7694a7baadec8afe128ad2541e0a8acfc23737.tar.gz
opie-5c7694a7baadec8afe128ad2541e0a8acfc23737.tar.bz2
- added the device button stuff to ODevice
- ODevice is now derived from QObject (don't ask me why I didn't make this from the beginning)
Diffstat (limited to 'libopie') (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,104 +1,104 @@
1TEMPLATE = lib 1TEMPLATE = lib
2CONFIG += qte warn_on release 2CONFIG += qte warn_on release
3HEADERS = ofontmenu.h \ 3HEADERS = ofontmenu.h \
4 ocolorbutton.h \ 4 ocolorbutton.h \
5 ofiledialog.h ofileselector.h tododb.h \ 5 ofiledialog.h ofileselector.h tododb.h \
6 ocheckitem.h todoevent.h todoresource.h \ 6 ocheckitem.h todoevent.h todoresource.h \
7 todovcalresource.h xmltree.h \ 7 todovcalresource.h xmltree.h \
8 colordialog.h colorpopupmenu.h \ 8 colordialog.h colorpopupmenu.h \
9 oclickablelabel.h oprocctrl.h \ 9 oclickablelabel.h oprocctrl.h \
10 oprocess.h odevice.h \ 10 oprocess.h odevice.h odevicebutton.h \
11 otimepicker.h otabwidget.h \ 11 otimepicker.h otabwidget.h \
12 otabbar.h otabinfo.h \ 12 otabbar.h otabinfo.h \
13 ofontselector.h \ 13 ofontselector.h \
14 pim/opimrecord.h \ 14 pim/opimrecord.h \
15 pim/otodo.h \ 15 pim/otodo.h \
16 pim/orecordlist.h \ 16 pim/orecordlist.h \
17 pim/opimaccesstemplate.h \ 17 pim/opimaccesstemplate.h \
18 pim/opimaccessbackend.h \ 18 pim/opimaccessbackend.h \
19 pim/otodoaccess.h \ 19 pim/otodoaccess.h \
20 pim/otodoaccessbackend.h \ 20 pim/otodoaccessbackend.h \
21 pim/ocontact.h \ 21 pim/ocontact.h \
22 pim/ocontactaccess.h \ 22 pim/ocontactaccess.h \
23 pim/ocontactaccessbackend.h \ 23 pim/ocontactaccessbackend.h \
24 pim/ocontactaccessbackend_xml.h \ 24 pim/ocontactaccessbackend_xml.h \
25 pim/ocontactaccessbackend_vcard.h \ 25 pim/ocontactaccessbackend_vcard.h \
26 pim/obackendfactory.h \ 26 pim/obackendfactory.h \
27 pim/opimcache.h \ 27 pim/opimcache.h \
28 pim/otodoaccessvcal.h \ 28 pim/otodoaccessvcal.h \
29 pim/orecur.h \ 29 pim/orecur.h \
30 pim/opimstate.h \ 30 pim/opimstate.h \
31 pim/opimxrefpartner.h \ 31 pim/opimxrefpartner.h \
32 pim/opimxref.h \ 32 pim/opimxref.h \
33 pim/opimxrefmanager.h \ 33 pim/opimxrefmanager.h \
34 pim/opimmaintainer.h \ 34 pim/opimmaintainer.h \
35 pim/opimnotify.h \ 35 pim/opimnotify.h \
36 pim/opimnotifymanager.h \ 36 pim/opimnotifymanager.h \
37 pim/opimmainwindow.h \ 37 pim/opimmainwindow.h \
38 pim/opimresolver.h \ 38 pim/opimresolver.h \
39 orecurrancewidget.h \ 39 orecurrancewidget.h \
40 oticker.h 40 oticker.h
41# pim/otodoaccesssql.h \ 41# pim/otodoaccesssql.h \
42 42
43SOURCES = ofontmenu.cc \ 43SOURCES = ofontmenu.cc \
44 ocolorbutton.cpp \ 44 ocolorbutton.cpp \
45 sharp_compat.cpp \ 45 sharp_compat.cpp \
46 xmltree.cc \ 46 xmltree.cc \
47 ofiledialog.cc ofileselector.cc \ 47 ofiledialog.cc ofileselector.cc \
48 ocheckitem.cpp tododb.cpp todoevent.cpp \ 48 ocheckitem.cpp tododb.cpp todoevent.cpp \
49 todovcalresource.cpp colordialog.cpp \ 49 todovcalresource.cpp colordialog.cpp \
50 colorpopupmenu.cpp oclickablelabel.cpp \ 50 colorpopupmenu.cpp oclickablelabel.cpp \
51 oprocctrl.cpp oprocess.cpp \ 51 oprocctrl.cpp oprocess.cpp \
52 odevice.cpp otimepicker.cpp \ 52 odevice.cpp odevicebutton.cpp otimepicker.cpp \
53 otabwidget.cpp otabbar.cpp \ 53 otabwidget.cpp otabbar.cpp \
54 ofontselector.cpp \ 54 ofontselector.cpp \
55 pim/otodo.cpp \ 55 pim/otodo.cpp \
56 pim/opimrecord.cpp \ 56 pim/opimrecord.cpp \
57 pim/otodoaccess.cpp \ 57 pim/otodoaccess.cpp \
58 pim/otodoaccessbackend.cpp \ 58 pim/otodoaccessbackend.cpp \
59 pim/otodoaccessxml.cpp \ 59 pim/otodoaccessxml.cpp \
60 pim/ocontact.cpp \ 60 pim/ocontact.cpp \
61 pim/ocontactaccess.cpp \ 61 pim/ocontactaccess.cpp \
62 pim/ocontactaccessbackend_vcard.cpp \ 62 pim/ocontactaccessbackend_vcard.cpp \
63 pim/otodoaccessvcal.cpp \ 63 pim/otodoaccessvcal.cpp \
64 pim/orecur.cpp \ 64 pim/orecur.cpp \
65 pim/opimstate.cpp \ 65 pim/opimstate.cpp \
66 pim/opimxrefpartner.cpp \ 66 pim/opimxrefpartner.cpp \
67 pim/opimxref.cpp \ 67 pim/opimxref.cpp \
68 pim/opimxrefmanager.cpp \ 68 pim/opimxrefmanager.cpp \
69 pim/opimmaintainer.cpp \ 69 pim/opimmaintainer.cpp \
70 pim/opimnotify.cpp \ 70 pim/opimnotify.cpp \
71 pim/opimnotifymanager.cpp \ 71 pim/opimnotifymanager.cpp \
72 pim/opimmainwindow.cpp \ 72 pim/opimmainwindow.cpp \
73 pim/opimresolver.cpp \ 73 pim/opimresolver.cpp \
74 orecurrancewidget.cpp \ 74 orecurrancewidget.cpp \
75 oticker.cpp 75 oticker.cpp
76# pim/otodoaccesssql.cpp \ 76# pim/otodoaccesssql.cpp \
77 77
78TARGET = opie 78TARGET = opie
79INCLUDEPATH += $(OPIEDIR)/include 79INCLUDEPATH += $(OPIEDIR)/include
80DESTDIR = $(QTDIR)/lib$(PROJMAK) 80DESTDIR = $(QTDIR)/lib$(PROJMAK)
81#VERSION = 1.0.0 81#VERSION = 1.0.0
82 82
83LIBS += -lqpe 83LIBS += -lqpe
84 84
85# LIBS += -lopiesql 85# LIBS += -lopiesql
86 86
87INTERFACES = otimepickerbase.ui orecurrancebase.ui 87INTERFACES = otimepickerbase.ui orecurrancebase.ui
88 88
89TRANSLATIONS = ../i18n/de/libopie.ts \ 89TRANSLATIONS = ../i18n/de/libopie.ts \
90 ../i18n/xx/libopie.ts \ 90 ../i18n/xx/libopie.ts \
91 ../i18n/en/libopie.ts \ 91 ../i18n/en/libopie.ts \
92 ../i18n/es/libopie.ts \ 92 ../i18n/es/libopie.ts \
93 ../i18n/fr/libopie.ts \ 93 ../i18n/fr/libopie.ts \
94 ../i18n/hu/libopie.ts \ 94 ../i18n/hu/libopie.ts \
95 ../i18n/ja/libopie.ts \ 95 ../i18n/ja/libopie.ts \
96 ../i18n/ko/libopie.ts \ 96 ../i18n/ko/libopie.ts \
97 ../i18n/no/libopie.ts \ 97 ../i18n/no/libopie.ts \
98 ../i18n/pl/libopie.ts \ 98 ../i18n/pl/libopie.ts \
99 ../i18n/pt/libopie.ts \ 99 ../i18n/pt/libopie.ts \
100 ../i18n/pt_BR/libopie.ts \ 100 ../i18n/pt_BR/libopie.ts \
101 ../i18n/sl/libopie.ts \ 101 ../i18n/sl/libopie.ts \
102 ../i18n/zh_CN/libopie.ts \ 102 ../i18n/zh_CN/libopie.ts \
103 ../i18n/zh_TW/libopie.ts \ 103 ../i18n/zh_TW/libopie.ts \
104 ../i18n/da/libopie.ts 104 ../i18n/da/libopie.ts
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index c947630..f93d1ed 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,962 +1,1176 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#include <linux/soundcard.h> 26#include <linux/soundcard.h>
27#include <math.h> 27#include <math.h>
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h>
36 37
37#include "odevice.h" 38#include "odevice.h"
38 39
39#include <qwindowsystem_qws.h> 40#include <qwindowsystem_qws.h>
40 41
41 42
42// _IO and friends are only defined in kernel headers ... 43// _IO and friends are only defined in kernel headers ...
43 44
44#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 45#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
45 46
46#define OD_IO(type,number) OD_IOC(0,type,number,0) 47#define OD_IO(type,number) OD_IOC(0,type,number,0)
47#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 48#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
48#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 49#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
49#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
50 51
51using namespace Opie; 52using namespace Opie;
52 53
53class ODeviceData { 54class ODeviceData {
54public: 55public:
55 bool m_qwsserver; 56 bool m_qwsserver;
56 57
57 QString m_vendorstr; 58 QString m_vendorstr;
58 OVendor m_vendor; 59 OVendor m_vendor;
59 60
60 QString m_modelstr; 61 QString m_modelstr;
61 OModel m_model; 62 OModel m_model;
62 63
63 QString m_systemstr; 64 QString m_systemstr;
64 OSystem m_system; 65 OSystem m_system;
65 66
66 QString m_sysverstr; 67 QString m_sysverstr;
68
69 QValueList <ODeviceButton> m_buttons;
70 uint m_holdtime;
67}; 71};
68 72
69 73
70class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { 74class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
71protected: 75protected:
72 virtual void init ( ); 76 virtual void init ( );
73 77
74public: 78public:
75 virtual bool setSoftSuspend ( bool soft ); 79 virtual bool setSoftSuspend ( bool soft );
76 80
77 virtual bool setDisplayBrightness ( int b ); 81 virtual bool setDisplayBrightness ( int b );
78 virtual int displayBrightnessResolution ( ) const; 82 virtual int displayBrightnessResolution ( ) const;
79 83
80 virtual void alarmSound ( ); 84 virtual void alarmSound ( );
81 85
82 virtual QValueList <OLed> ledList ( ) const; 86 virtual QValueList <OLed> ledList ( ) const;
83 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 87 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
84 virtual OLedState ledState ( OLed led ) const; 88 virtual OLedState ledState ( OLed led ) const;
85 virtual bool setLedState ( OLed led, OLedState st ); 89 virtual bool setLedState ( OLed led, OLedState st );
86 90
87 virtual bool hasLightSensor ( ) const; 91 virtual bool hasLightSensor ( ) const;
88 virtual int readLightSensor ( ); 92 virtual int readLightSensor ( );
89 virtual int lightSensorResolution ( ) const; 93 virtual int lightSensorResolution ( ) const;
90 94
91 //virtual QValueList <int> keyList ( ) const;
92
93protected: 95protected:
94 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 96 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
95 virtual void timerEvent ( QTimerEvent *te ); 97 virtual void timerEvent ( QTimerEvent *te );
96 98
97 int m_power_timer; 99 int m_power_timer;
98 100
99 OLedState m_leds [2]; 101 OLedState m_leds [2];
100}; 102};
101 103
102class Zaurus : public ODevice { 104class Zaurus : public ODevice {
103protected: 105protected:
104 virtual void init ( ); 106 virtual void init ( );
105 107
106 public: 108 public:
107 virtual bool setSoftSuspend ( bool soft ); 109 virtual bool setSoftSuspend ( bool soft );
108 110
109 virtual bool setDisplayBrightness ( int b ); 111 virtual bool setDisplayBrightness ( int b );
110 virtual int displayBrightnessResolution ( ) const; 112 virtual int displayBrightnessResolution ( ) const;
111 113
112 virtual void alarmSound ( ); 114 virtual void alarmSound ( );
113 virtual void keySound ( ); 115 virtual void keySound ( );
114 virtual void touchSound ( ); 116 virtual void touchSound ( );
115 117
116 virtual QValueList <OLed> ledList ( ) const; 118 virtual QValueList <OLed> ledList ( ) const;
117 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 119 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
118 virtual OLedState ledState ( OLed led ) const; 120 virtual OLedState ledState ( OLed led ) const;
119 virtual bool setLedState ( OLed led, OLedState st ); 121 virtual bool setLedState ( OLed led, OLedState st );
120 122
121 //virtual QValueList <int> keyList ( ) const;
122
123protected: 123protected:
124 virtual void buzzer ( int snd ); 124 virtual void buzzer ( int snd );
125 125
126 OLedState m_leds [1]; 126 OLedState m_leds [1];
127}; 127};
128 128
129 129
130struct i_button {
131 uint model;
132 Qt::Key code;
133 char *utext;
134 char *pix;
135 char *fpressedservice;
136 char *fpressedaction;
137 char *fheldservice;
138 char *fheldaction;
139} ipaq_buttons [] = {
140 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
141 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
142 "devicebuttons/ipaq_calendar",
143 "datebook", "nextView()",
144 "today", "raise()" },
145 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
146 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
147 "devicebuttons/ipaq_contact",
148 "addressbook", "raise()",
149 "addressbook", "beamBusinessCard()" },
150 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
151 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
152 "devicebuttons/ipaq_menu",
153 "QPE/TaskBar", "toggleMenu()",
154 "QPE/TaskBar", "toggleStartMenu()" },
155 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
156 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Mail Button"),
157 "devicebuttons/ipaq_mail",
158 "mail", "raise()",
159 "mail", "newMail()" },
160 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
161 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
162 "devicebuttons/ipaq_home",
163 "QPE/Launcher", "home()",
164 "buttonsettings", "raise()" },
165 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
166 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
167 "devicebuttons/ipaq_record",
168 "QPE/VMemo", "toggleRecord()",
169 "sound", "raise()" },
170};
171
172struct z_button {
173 Qt::Key code;
174 char *utext;
175 char *pix;
176 char *fpressedservice;
177 char *fpressedaction;
178 char *fheldservice;
179 char *fheldaction;
180} z_buttons [] = {
181 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
182 "devicebuttons/z_calendar",
183 "datebook", "nextView()",
184 "today", "raise()" },
185 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
186 "devicebuttons/z_contact",
187 "addressbook", "raise()",
188 "addressbook", "beamBusinessCard()" },
189 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
190 "devicebuttons/z_home",
191 "QPE/Launcher", "home()",
192 "buttonsettings", "raise()" },
193 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
194 "devicebuttons/z_menu",
195 "QPE/TaskBar", "toggleMenu()",
196 "QPE/TaskBar", "toggleStartMenu()" },
197 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
198 "devicebuttons/z_mail",
199 "mail", "raise()",
200 "mail", "newMail()" },
201};
130 202
203static QCString makeChannel ( const char *str )
204{
205 if ( str && !::strchr ( str, '/' ))
206 return QCString ( "QPE/Application/" ) + str;
207 else
208 return str;
209}
131 210
132 211
133 212
134 213
135ODevice *ODevice::inst ( ) 214ODevice *ODevice::inst ( )
136{ 215{
137 static ODevice *dev = 0; 216 static ODevice *dev = 0;
138 217
139 if ( !dev ) { 218 if ( !dev ) {
140 if ( QFile::exists ( "/proc/hal/model" )) 219 if ( QFile::exists ( "/proc/hal/model" ))
141 dev = new iPAQ ( ); 220 dev = new iPAQ ( );
142 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 221 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
143 dev = new Zaurus ( ); 222 dev = new Zaurus ( );
144 else 223 else
145 dev = new ODevice ( ); 224 dev = new ODevice ( );
146 225
147 dev-> init ( ); 226 dev-> init ( );
148 } 227 }
149 return dev; 228 return dev;
150} 229}
151 230
152 231
153/************************************************** 232/**************************************************
154 * 233 *
155 * common 234 * common
156 * 235 *
157 **************************************************/ 236 **************************************************/
158 237
159 238
160ODevice::ODevice ( ) 239ODevice::ODevice ( )
161{ 240{
162 d = new ODeviceData; 241 d = new ODeviceData;
163 242
164 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 243 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
165 244
166 d-> m_modelstr = "Unknown"; 245 d-> m_modelstr = "Unknown";
167 d-> m_model = Model_Unknown; 246 d-> m_model = Model_Unknown;
168 d-> m_vendorstr = "Unkown"; 247 d-> m_vendorstr = "Unkown";
169 d-> m_vendor = Vendor_Unknown; 248 d-> m_vendor = Vendor_Unknown;
170 d-> m_systemstr = "Unkown"; 249 d-> m_systemstr = "Unkown";
171 d-> m_system = System_Unknown; 250 d-> m_system = System_Unknown;
172 d-> m_sysverstr = "0.0"; 251 d-> m_sysverstr = "0.0";
252
253 d-> m_holdtime = 1000; // 1000ms
254
255 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
256 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
257}
258
259void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
260{
261 if ( msg == "deviceButtonMappingChanged()" ) {
262 reloadButtonMapping ( );
263 }
173} 264}
174 265
175void ODevice::init ( ) 266void ODevice::init ( )
176{ 267{
268 // Simulation uses iPAQ 3660 device buttons
269
270 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
271 i_button *ib = ipaq_buttons + i;
272 ODeviceButton b;
273
274 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
275 b. setKeycode ( ib-> code );
276 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
277 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
278 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
279 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
280
281 d-> m_buttons. append ( b );
282 }
283 }
284 reloadButtonMapping ( );
177} 285}
178 286
179ODevice::~ODevice ( ) 287ODevice::~ODevice ( )
180{ 288{
181 delete d; 289 delete d;
182} 290}
183 291
184bool ODevice::setSoftSuspend ( bool /*soft*/ ) 292bool ODevice::setSoftSuspend ( bool /*soft*/ )
185{ 293{
186 return false; 294 return false;
187} 295}
188 296
189//#include <linux/apm_bios.h> 297//#include <linux/apm_bios.h>
190 298
191#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 299#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
192 300
193 301
194bool ODevice::suspend ( ) 302bool ODevice::suspend ( )
195{ 303{
196 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 304 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
197 return false; 305 return false;
198 306
199 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 307 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
200 return false; 308 return false;
201 309
202 bool res = false; 310 bool res = false;
203 311
204 struct timeval tvs, tvn; 312 struct timeval tvs, tvn;
205 ::gettimeofday ( &tvs, 0 ); 313 ::gettimeofday ( &tvs, 0 );
206 314
207 ::sync ( ); // flush fs caches 315 ::sync ( ); // flush fs caches
208 res = ( ::system ( "apm --suspend" ) == 0 ); 316 res = ( ::system ( "apm --suspend" ) == 0 );
209 317
210 // This is needed because the iPAQ apm implementation is asynchronous and we 318 // This is needed because the iPAQ apm implementation is asynchronous and we
211 // can not be sure when exactly the device is really suspended 319 // can not be sure when exactly the device is really suspended
212 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 320 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
213 321
214 if ( res ) { 322 if ( res ) {
215 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 323 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
216 ::usleep ( 200 * 1000 ); 324 ::usleep ( 200 * 1000 );
217 ::gettimeofday ( &tvn, 0 ); 325 ::gettimeofday ( &tvn, 0 );
218 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 326 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
219 } 327 }
220 328
221 return res; 329 return res;
222} 330}
223 331
224//#include <linux/fb.h> better not rely on kernel headers in userspace ... 332//#include <linux/fb.h> better not rely on kernel headers in userspace ...
225 333
226#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 334#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
227 335
228/* VESA Blanking Levels */ 336/* VESA Blanking Levels */
229#define VESA_NO_BLANKING 0 337#define VESA_NO_BLANKING 0
230#define VESA_VSYNC_SUSPEND 1 338#define VESA_VSYNC_SUSPEND 1
231#define VESA_HSYNC_SUSPEND 2 339#define VESA_HSYNC_SUSPEND 2
232#define VESA_POWERDOWN 3 340#define VESA_POWERDOWN 3
233 341
234 342
235bool ODevice::setDisplayStatus ( bool on ) 343bool ODevice::setDisplayStatus ( bool on )
236{ 344{
237 if ( d-> m_model == Model_Unknown ) 345 if ( d-> m_model == Model_Unknown )
238 return false; 346 return false;
239 347
240 bool res = false; 348 bool res = false;
241 int fd; 349 int fd;
242 350
243 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 351 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
244 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 352 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
245 ::close ( fd ); 353 ::close ( fd );
246 } 354 }
247 return res; 355 return res;
248} 356}
249 357
250bool ODevice::setDisplayBrightness ( int ) 358bool ODevice::setDisplayBrightness ( int )
251{ 359{
252 return false; 360 return false;
253} 361}
254 362
255int ODevice::displayBrightnessResolution ( ) const 363int ODevice::displayBrightnessResolution ( ) const
256{ 364{
257 return 16; 365 return 16;
258} 366}
259 367
260QString ODevice::vendorString ( ) const 368QString ODevice::vendorString ( ) const
261{ 369{
262 return d-> m_vendorstr; 370 return d-> m_vendorstr;
263} 371}
264 372
265OVendor ODevice::vendor ( ) const 373OVendor ODevice::vendor ( ) const
266{ 374{
267 return d-> m_vendor; 375 return d-> m_vendor;
268} 376}
269 377
270QString ODevice::modelString ( ) const 378QString ODevice::modelString ( ) const
271{ 379{
272 return d-> m_modelstr; 380 return d-> m_modelstr;
273} 381}
274 382
275OModel ODevice::model ( ) const 383OModel ODevice::model ( ) const
276{ 384{
277 return d-> m_model; 385 return d-> m_model;
278} 386}
279 387
280QString ODevice::systemString ( ) const 388QString ODevice::systemString ( ) const
281{ 389{
282 return d-> m_systemstr; 390 return d-> m_systemstr;
283} 391}
284 392
285OSystem ODevice::system ( ) const 393OSystem ODevice::system ( ) const
286{ 394{
287 return d-> m_system; 395 return d-> m_system;
288} 396}
289 397
290QString ODevice::systemVersionString ( ) const 398QString ODevice::systemVersionString ( ) const
291{ 399{
292 return d-> m_sysverstr; 400 return d-> m_sysverstr;
293} 401}
294 402
295void ODevice::alarmSound ( ) 403void ODevice::alarmSound ( )
296{ 404{
297#ifndef QT_NO_SOUND 405#ifndef QT_NO_SOUND
298 static Sound snd ( "alarm" ); 406 static Sound snd ( "alarm" );
299 407
300 if ( snd. isFinished ( )) 408 if ( snd. isFinished ( ))
301 snd. play ( ); 409 snd. play ( );
302#endif 410#endif
303} 411}
304 412
305void ODevice::keySound ( ) 413void ODevice::keySound ( )
306{ 414{
307#ifndef QT_NO_SOUND 415#ifndef QT_NO_SOUND
308 static Sound snd ( "keysound" ); 416 static Sound snd ( "keysound" );
309 417
310 if ( snd. isFinished ( )) 418 if ( snd. isFinished ( ))
311 snd. play ( ); 419 snd. play ( );
312#endif 420#endif
313} 421}
314 422
315void ODevice::touchSound ( ) 423void ODevice::touchSound ( )
316{ 424{
317 425
318#ifndef QT_NO_SOUND 426#ifndef QT_NO_SOUND
319 static Sound snd ( "touchsound" ); 427 static Sound snd ( "touchsound" );
320 428
321 if ( snd. isFinished ( )) 429 if ( snd. isFinished ( ))
322 snd. play ( ); 430 snd. play ( );
323#endif 431#endif
324} 432}
325 433
326 434
327QValueList <OLed> ODevice::ledList ( ) const 435QValueList <OLed> ODevice::ledList ( ) const
328{ 436{
329 return QValueList <OLed> ( ); 437 return QValueList <OLed> ( );
330} 438}
331 439
332QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 440QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
333{ 441{
334 return QValueList <OLedState> ( ); 442 return QValueList <OLedState> ( );
335} 443}
336 444
337OLedState ODevice::ledState ( OLed /*which*/ ) const 445OLedState ODevice::ledState ( OLed /*which*/ ) const
338{ 446{
339 return Led_Off; 447 return Led_Off;
340} 448}
341 449
342bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 450bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
343{ 451{
344 return false; 452 return false;
345} 453}
346 454
347bool ODevice::hasLightSensor ( ) const 455bool ODevice::hasLightSensor ( ) const
348{ 456{
349 return false; 457 return false;
350} 458}
351 459
352int ODevice::readLightSensor ( ) 460int ODevice::readLightSensor ( )
353{ 461{
354 return -1; 462 return -1;
355} 463}
356 464
357int ODevice::lightSensorResolution ( ) const 465int ODevice::lightSensorResolution ( ) const
358{ 466{
359 return 0; 467 return 0;
360} 468}
361 469
362//QValueList <int> ODevice::keyList ( ) const 470const QValueList <ODeviceButton> &ODevice::buttons ( ) const
363//{ 471{
364 //return QValueList <int> ( ); 472 return d-> m_buttons;
365//} 473}
474
475uint ODevice::buttonHoldTime ( ) const
476{
477 return d-> m_holdtime;
478}
479
480const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
481{
482 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons. begin ( ); it != d-> m_buttons. end ( ); ++it ) {
483 if ( (*it). keycode ( ) == code )
484 return &(*it);
485 }
486 return 0;
487}
488
489void ODevice::reloadButtonMapping ( )
490{
491 Config cfg ( "ButtonSettings" );
492
493 for ( uint i = 0; i < d-> m_buttons. count ( ); i++ ) {
494 ODeviceButton &b = d-> m_buttons [i];
495 QString group = "Button" + QString::number ( i );
496
497 QCString pch, hch;
498 QCString pm, hm;
499 QByteArray pdata, hdata;
500
501 if ( cfg. hasGroup ( group )) {
502 cfg. setGroup ( group );
503 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
504 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
505 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
506
507 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
508 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
509 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
510 }
511
512 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
513 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
514 }
515}
516
517void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
518{
519 if ( button >= (int) d-> m_buttons. count ( ))
520 return;
521
522 ODeviceButton &b = d-> m_buttons [button];
523 b. setPressedAction ( action );
524
525 Config buttonFile ( "ButtonSettings" );
526 buttonFile. setGroup ( "Button" + QString::number ( button ));
527 buttonFile. writeEntry ( "PressedActionChannel", (const char*) b. pressedAction ( ). channel ( ));
528 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
529
530 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
531
532 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
533}
534
535void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
536{
537 if ( button >= (int) d-> m_buttons. count ( ))
538 return;
539
540 ODeviceButton &b = d-> m_buttons [button];
541 b. setHeldAction ( action );
542
543 Config buttonFile ( "ButtonSettings" );
544 buttonFile. setGroup ( "Button" + QString::number ( button ));
545 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
546 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
547
548 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
549
550 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
551}
552
366 553
367 554
368 555
369/************************************************** 556/**************************************************
370 * 557 *
371 * iPAQ 558 * iPAQ
372 * 559 *
373 **************************************************/ 560 **************************************************/
374 561
375void iPAQ::init ( ) 562void iPAQ::init ( )
376{ 563{
377 d-> m_vendorstr = "HP"; 564 d-> m_vendorstr = "HP";
378 d-> m_vendor = Vendor_HP; 565 d-> m_vendor = Vendor_HP;
379 566
380 QFile f ( "/proc/hal/model" ); 567 QFile f ( "/proc/hal/model" );
381 568
382 if ( f. open ( IO_ReadOnly )) { 569 if ( f. open ( IO_ReadOnly )) {
383 QTextStream ts ( &f ); 570 QTextStream ts ( &f );
384 571
385 d-> m_modelstr = "H" + ts. readLine ( ); 572 d-> m_modelstr = "H" + ts. readLine ( );
386 573
387 if ( d-> m_modelstr == "H3100" ) 574 if ( d-> m_modelstr == "H3100" )
388 d-> m_model = Model_iPAQ_H31xx; 575 d-> m_model = Model_iPAQ_H31xx;
389 else if ( d-> m_modelstr == "H3600" ) 576 else if ( d-> m_modelstr == "H3600" )
390 d-> m_model = Model_iPAQ_H36xx; 577 d-> m_model = Model_iPAQ_H36xx;
391 else if ( d-> m_modelstr == "H3700" ) 578 else if ( d-> m_modelstr == "H3700" )
392 d-> m_model = Model_iPAQ_H37xx; 579 d-> m_model = Model_iPAQ_H37xx;
393 else if ( d-> m_modelstr == "H3800" ) 580 else if ( d-> m_modelstr == "H3800" )
394 d-> m_model = Model_iPAQ_H38xx; 581 d-> m_model = Model_iPAQ_H38xx;
395 else if ( d-> m_modelstr == "H3900" ) 582 else if ( d-> m_modelstr == "H3900" )
396 d-> m_model = Model_iPAQ_H39xx; 583 d-> m_model = Model_iPAQ_H39xx;
397 else 584 else
398 d-> m_model = Model_Unknown; 585 d-> m_model = Model_Unknown;
399 586
400 f. close ( ); 587 f. close ( );
401 } 588 }
402 589
403 f. setName ( "/etc/familiar-version" ); 590 f. setName ( "/etc/familiar-version" );
404 if ( f. open ( IO_ReadOnly )) { 591 if ( f. open ( IO_ReadOnly )) {
405 d-> m_systemstr = "Familiar"; 592 d-> m_systemstr = "Familiar";
406 d-> m_system = System_Familiar; 593 d-> m_system = System_Familiar;
407 594
408 QTextStream ts ( &f ); 595 QTextStream ts ( &f );
409 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 596 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
410 597
411 f. close ( ); 598 f. close ( );
412 } 599 }
413 600
414 m_leds [0] = m_leds [1] = Led_Off; 601 m_leds [0] = m_leds [1] = Led_Off;
415 602
416 m_power_timer = 0; 603 m_power_timer = 0;
417 604
605 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
606 i_button *ib = ipaq_buttons + i;
607 ODeviceButton b;
608
609 qDebug ( "%d: %d", i, ib-> model );
610
611 if (( ib-> model & d-> m_model ) == d-> m_model ) {
612 b. setKeycode ( ib-> code );
613 b. setUserText ( qApp-> translate ( "Button", ib-> utext ));
614 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
615 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
616 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
617
618 d-> m_buttons. append ( b );
619
620 qDebug ( "code: %d", ib-> code );
621 }
622 }
623 reloadButtonMapping ( );
624
418 if ( d-> m_qwsserver ) 625 if ( d-> m_qwsserver )
419 QWSServer::setKeyboardFilter ( this ); 626 QWSServer::setKeyboardFilter ( this );
420} 627}
421 628
422//#include <linux/h3600_ts.h> // including kernel headers is evil ... 629//#include <linux/h3600_ts.h> // including kernel headers is evil ...
423 630
424typedef struct { 631typedef struct {
425 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 632 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
426 unsigned char TotalTime; /* Units of 5 seconds */ 633 unsigned char TotalTime; /* Units of 5 seconds */
427 unsigned char OnTime; /* units of 100m/s */ 634 unsigned char OnTime; /* units of 100m/s */
428 unsigned char OffTime; /* units of 100m/s */ 635 unsigned char OffTime; /* units of 100m/s */
429} LED_IN; 636} LED_IN;
430 637
431typedef struct { 638typedef struct {
432 unsigned char mode; 639 unsigned char mode;
433 unsigned char pwr; 640 unsigned char pwr;
434 unsigned char brightness; 641 unsigned char brightness;
435} FLITE_IN; 642} FLITE_IN;
436 643
437#define LED_ON OD_IOW( 'f', 5, LED_IN ) 644#define LED_ON OD_IOW( 'f', 5, LED_IN )
438#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 645#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
439 646
440 647
441 648
442QValueList <OLed> iPAQ::ledList ( ) const 649QValueList <OLed> iPAQ::ledList ( ) const
443{ 650{
444 QValueList <OLed> vl; 651 QValueList <OLed> vl;
445 vl << Led_Power; 652 vl << Led_Power;
446 653
447 if ( d-> m_model == Model_iPAQ_H38xx ) 654 if ( d-> m_model == Model_iPAQ_H38xx )
448 vl << Led_BlueTooth; 655 vl << Led_BlueTooth;
449 return vl; 656 return vl;
450} 657}
451 658
452QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 659QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
453{ 660{
454 QValueList <OLedState> vl; 661 QValueList <OLedState> vl;
455 662
456 if ( l == Led_Power ) 663 if ( l == Led_Power )
457 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 664 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
458 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 665 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
459 vl << Led_Off; // << Led_On << ??? 666 vl << Led_Off; // << Led_On << ???
460 667
461 return vl; 668 return vl;
462} 669}
463 670
464OLedState iPAQ::ledState ( OLed l ) const 671OLedState iPAQ::ledState ( OLed l ) const
465 { 672 {
466 switch ( l ) { 673 switch ( l ) {
467 case Led_Power: 674 case Led_Power:
468 return m_leds [0]; 675 return m_leds [0];
469 case Led_BlueTooth: 676 case Led_BlueTooth:
470 return m_leds [1]; 677 return m_leds [1];
471 default: 678 default:
472 return Led_Off; 679 return Led_Off;
473 } 680 }
474} 681}
475 682
476bool iPAQ::setLedState ( OLed l, OLedState st ) 683bool iPAQ::setLedState ( OLed l, OLedState st )
477{ 684{
478 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 685 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
479 686
480 if ( l == Led_Power ) { 687 if ( l == Led_Power ) {
481 if ( fd >= 0 ) { 688 if ( fd >= 0 ) {
482 LED_IN leds; 689 LED_IN leds;
483 ::memset ( &leds, 0, sizeof( leds )); 690 ::memset ( &leds, 0, sizeof( leds ));
484 leds. TotalTime = 0; 691 leds. TotalTime = 0;
485 leds. OnTime = 0; 692 leds. OnTime = 0;
486 leds. OffTime = 1; 693 leds. OffTime = 1;
487 leds. OffOnBlink = 2; 694 leds. OffOnBlink = 2;
488 695
489 switch ( st ) { 696 switch ( st ) {
490 case Led_Off : leds. OffOnBlink = 0; break; 697 case Led_Off : leds. OffOnBlink = 0; break;
491 case Led_On : leds. OffOnBlink = 1; break; 698 case Led_On : leds. OffOnBlink = 1; break;
492 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 699 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
493 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 700 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
494 } 701 }
495 702
496 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 703 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
497 m_leds [0] = st; 704 m_leds [0] = st;
498 return true; 705 return true;
499 } 706 }
500 } 707 }
501 } 708 }
502 return false; 709 return false;
503} 710}
504 711
505 712
506//QValueList <int> iPAQ::keyList ( ) const
507//{
508 //QValueList <int> vl;
509 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight;
510 //return vl;
511//}
512
513bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 713bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
514{ 714{
515 int newkeycode = keycode; 715 int newkeycode = keycode;
516 716
517 switch ( keycode ) { 717 switch ( keycode ) {
518 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 718 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
519 case HardKey_Menu: { 719 case HardKey_Menu: {
520 if (( d-> m_model == Model_iPAQ_H38xx ) || 720 if (( d-> m_model == Model_iPAQ_H38xx ) ||
521 ( d-> m_model == Model_iPAQ_H39xx )) { 721 ( d-> m_model == Model_iPAQ_H39xx )) {
522 newkeycode = HardKey_Mail; 722 newkeycode = HardKey_Mail;
523 } 723 }
524 break; 724 break;
525 } 725 }
526 726
527 // Rotate cursor keys 180° 727 // Rotate cursor keys 180°
528 case Key_Left : 728 case Key_Left :
529 case Key_Right: 729 case Key_Right:
530 case Key_Up : 730 case Key_Up :
531 case Key_Down : { 731 case Key_Down : {
532 if (( d-> m_model == Model_iPAQ_H31xx ) || 732 if (( d-> m_model == Model_iPAQ_H31xx ) ||
533 ( d-> m_model == Model_iPAQ_H38xx )) { 733 ( d-> m_model == Model_iPAQ_H38xx )) {
534 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 734 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
535 } 735 }
536 break; 736 break;
537 } 737 }
538 738
539 // map Power Button short/long press to F34/F35 739 // map Power Button short/long press to F34/F35
540 case Key_SysReq: { 740 case Key_SysReq: {
541 if ( isPress ) { 741 if ( isPress ) {
542 if ( m_power_timer ) 742 if ( m_power_timer )
543 killTimer ( m_power_timer ); 743 killTimer ( m_power_timer );
544 m_power_timer = startTimer ( 500 ); 744 m_power_timer = startTimer ( 500 );
545 } 745 }
546 else if ( m_power_timer ) { 746 else if ( m_power_timer ) {
547 killTimer ( m_power_timer ); 747 killTimer ( m_power_timer );
548 m_power_timer = 0; 748 m_power_timer = 0;
549 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 749 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
550 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 750 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
551 } 751 }
552 newkeycode = Key_unknown; 752 newkeycode = Key_unknown;
553 break; 753 break;
554 } 754 }
555 } 755 }
556 756
557 if ( newkeycode != keycode ) { 757 if ( newkeycode != keycode ) {
558 if ( newkeycode != Key_unknown ) 758 if ( newkeycode != Key_unknown )
559 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 759 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
560 return true; 760 return true;
561 } 761 }
562 else 762 else
563 return false; 763 return false;
564} 764}
565 765
566void iPAQ::timerEvent ( QTimerEvent * ) 766void iPAQ::timerEvent ( QTimerEvent * )
567{ 767{
568 killTimer ( m_power_timer ); 768 killTimer ( m_power_timer );
569 m_power_timer = 0; 769 m_power_timer = 0;
570 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 770 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
571 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 771 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
572} 772}
573 773
574 774
575void iPAQ::alarmSound ( ) 775void iPAQ::alarmSound ( )
576{ 776{
577#ifndef QT_NO_SOUND 777#ifndef QT_NO_SOUND
578 static Sound snd ( "alarm" ); 778 static Sound snd ( "alarm" );
579 int fd; 779 int fd;
580 int vol; 780 int vol;
581 bool vol_reset = false; 781 bool vol_reset = false;
582 782
583 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 783 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
584 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 784 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
585 Config cfg ( "qpe" ); 785 Config cfg ( "qpe" );
586 cfg. setGroup ( "Volume" ); 786 cfg. setGroup ( "Volume" );
587 787
588 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 788 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
589 if ( volalarm < 0 ) 789 if ( volalarm < 0 )
590 volalarm = 0; 790 volalarm = 0;
591 else if ( volalarm > 100 ) 791 else if ( volalarm > 100 )
592 volalarm = 100; 792 volalarm = 100;
593 volalarm |= ( volalarm << 8 ); 793 volalarm |= ( volalarm << 8 );
594 794
595 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 795 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
596 vol_reset = true; 796 vol_reset = true;
597 } 797 }
598 } 798 }
599 799
600 snd. play ( ); 800 snd. play ( );
601 while ( !snd. isFinished ( )) 801 while ( !snd. isFinished ( ))
602 qApp-> processEvents ( ); 802 qApp-> processEvents ( );
603 803
604 if ( fd >= 0 ) { 804 if ( fd >= 0 ) {
605 if ( vol_reset ) 805 if ( vol_reset )
606 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 806 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
607 ::close ( fd ); 807 ::close ( fd );
608 } 808 }
609#endif 809#endif
610} 810}
611 811
612 812
613bool iPAQ::setSoftSuspend ( bool soft ) 813bool iPAQ::setSoftSuspend ( bool soft )
614{ 814{
615 bool res = false; 815 bool res = false;
616 int fd; 816 int fd;
617 817
618 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 818 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
619 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 819 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
620 res = true; 820 res = true;
621 else 821 else
622 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 822 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
623 823
624 ::close ( fd ); 824 ::close ( fd );
625 } 825 }
626 else 826 else
627 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 827 ::perror ( "/proc/sys/ts/suspend_button_mode" );
628 828
629 return res; 829 return res;
630} 830}
631 831
632 832
633bool iPAQ::setDisplayBrightness ( int bright ) 833bool iPAQ::setDisplayBrightness ( int bright )
634{ 834{
635 bool res = false; 835 bool res = false;
636 int fd; 836 int fd;
637 837
638 if ( bright > 255 ) 838 if ( bright > 255 )
639 bright = 255; 839 bright = 255;
640 if ( bright < 0 ) 840 if ( bright < 0 )
641 bright = 0; 841 bright = 0;
642 842
643 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 843 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
644 FLITE_IN bl; 844 FLITE_IN bl;
645 bl. mode = 1; 845 bl. mode = 1;
646 bl. pwr = bright ? 1 : 0; 846 bl. pwr = bright ? 1 : 0;
647 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 847 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
648 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 848 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
649 ::close ( fd ); 849 ::close ( fd );
650 } 850 }
651 return res; 851 return res;
652} 852}
653 853
654int iPAQ::displayBrightnessResolution ( ) const 854int iPAQ::displayBrightnessResolution ( ) const
655{ 855{
656 switch ( model ( )) { 856 switch ( model ( )) {
657 case Model_iPAQ_H31xx: 857 case Model_iPAQ_H31xx:
658 case Model_iPAQ_H36xx: 858 case Model_iPAQ_H36xx:
659 case Model_iPAQ_H37xx: 859 case Model_iPAQ_H37xx:
660 return 128; // really 256, but >128 could damage the LCD 860 return 128; // really 256, but >128 could damage the LCD
661 861
662 case Model_iPAQ_H38xx: 862 case Model_iPAQ_H38xx:
663 case Model_iPAQ_H39xx: 863 case Model_iPAQ_H39xx:
664 return 64; 864 return 64;
665 865
666 default: 866 default:
667 return 2; 867 return 2;
668 } 868 }
669} 869}
670 870
671 871
672bool iPAQ::hasLightSensor ( ) const 872bool iPAQ::hasLightSensor ( ) const
673{ 873{
674 return true; 874 return true;
675} 875}
676 876
677int iPAQ::readLightSensor ( ) 877int iPAQ::readLightSensor ( )
678{ 878{
679 int fd; 879 int fd;
680 int val = -1; 880 int val = -1;
681 881
682 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 882 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
683 char buffer [8]; 883 char buffer [8];
684 884
685 if ( ::read ( fd, buffer, 5 ) == 5 ) { 885 if ( ::read ( fd, buffer, 5 ) == 5 ) {
686 char *endptr; 886 char *endptr;
687 887
688 buffer [4] = 0; 888 buffer [4] = 0;
689 val = ::strtol ( buffer + 2, &endptr, 16 ); 889 val = ::strtol ( buffer + 2, &endptr, 16 );
690 890
691 if ( *endptr != 0 ) 891 if ( *endptr != 0 )
692 val = -1; 892 val = -1;
693 } 893 }
694 ::close ( fd ); 894 ::close ( fd );
695 } 895 }
696 896
697 return val; 897 return val;
698} 898}
699 899
700int iPAQ::lightSensorResolution ( ) const 900int iPAQ::lightSensorResolution ( ) const
701{ 901{
702 return 256; 902 return 256;
703} 903}
704 904
705/************************************************** 905/**************************************************
706 * 906 *
707 * Zaurus 907 * Zaurus
708 * 908 *
709 **************************************************/ 909 **************************************************/
710 910
711 911
712 912
713void Zaurus::init ( ) 913void Zaurus::init ( )
714{ 914{
715 d-> m_vendorstr = "Sharp"; 915 d-> m_vendorstr = "Sharp";
716 d-> m_vendor = Vendor_Sharp; 916 d-> m_vendor = Vendor_Sharp;
717 917
718 QFile f ( "/proc/filesystems" ); 918 QFile f ( "/proc/filesystems" );
719 919
720 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 920 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
721 d-> m_vendorstr = "OpenZaurus Team"; 921 d-> m_vendorstr = "OpenZaurus Team";
722 d-> m_systemstr = "OpenZaurus"; 922 d-> m_systemstr = "OpenZaurus";
723 d-> m_system = System_OpenZaurus; 923 d-> m_system = System_OpenZaurus;
724 924
725 f. close ( ); 925 f. close ( );
726 926
727 f. setName ( "/etc/oz_version" ); 927 f. setName ( "/etc/oz_version" );
728 if ( f. open ( IO_ReadOnly )) { 928 if ( f. open ( IO_ReadOnly )) {
729 QTextStream ts ( &f ); 929 QTextStream ts ( &f );
730 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 930 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
731 f. close ( ); 931 f. close ( );
732 } 932 }
733 } 933 }
734 else { 934 else {
735 d-> m_systemstr = "Zaurus"; 935 d-> m_systemstr = "Zaurus";
736 d-> m_system = System_Zaurus; 936 d-> m_system = System_Zaurus;
737 } 937 }
738 938
739 f. setName ( "/proc/deviceinfo/product" ); 939 f. setName ( "/proc/deviceinfo/product" );
740 if ( f. open ( IO_ReadOnly ) ) { 940 if ( f. open ( IO_ReadOnly ) ) {
741 QTextStream ts ( &f ); 941 QTextStream ts ( &f );
742 QString model = ts. readLine ( ); 942 QString model = ts. readLine ( );
743 f. close ( ); 943 f. close ( );
744 if ( model == "SL-5000D" ) { 944 if ( model == "SL-5000D" ) {
745 d-> m_model = Model_Zaurus_SL5000; 945 d-> m_model = Model_Zaurus_SL5000;
746 d-> m_modelstr = "Zaurus SL-5000D"; 946 d-> m_modelstr = "Zaurus SL-5000D";
747 } else if ( model == "SL-5500" ) { 947 } else if ( model == "SL-5500" ) {
748 d-> m_model = Model_Zaurus_SL5500; 948 d-> m_model = Model_Zaurus_SL5500;
749 d-> m_modelstr = "Zaurus SL-5500"; 949 d-> m_modelstr = "Zaurus SL-5500";
750 } 950 }
751 } 951 }
752 else { 952 else {
753 d-> m_model = Model_Zaurus_SL5000; 953 d-> m_model = Model_Zaurus_SL5000;
754 d-> m_modelstr = "Zaurus SL-5000D (unverified)"; 954 d-> m_modelstr = "Zaurus SL-5000D (unverified)";
755 } 955 }
756 956
957 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
958 z_button *zb = z_buttons + i;
959 ODeviceButton b;
960
961 b. setKeycode ( zb-> code );
962 b. setUserText ( qApp-> translate ( "Button", zb-> utext ));
963 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
964 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
965 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
966
967 d-> m_buttons. append ( b );
968 }
969 reloadButtonMapping ( );
970
757 m_leds [0] = Led_Off; 971 m_leds [0] = Led_Off;
758} 972}
759 973
760#include <unistd.h> 974#include <unistd.h>
761#include <fcntl.h> 975#include <fcntl.h>
762#include <sys/ioctl.h> 976#include <sys/ioctl.h>
763 977
764//#include <asm/sharp_char.h> // including kernel headers is evil ... 978//#include <asm/sharp_char.h> // including kernel headers is evil ...
765 979
766#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 980#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
767 981
768 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 982 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
769#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 983#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
770 984
771#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 985#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
772#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 986#define SHARP_BUZ_KEYSOUND 2 /* key sound */
773#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 987#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
774 988
775/* --- for SHARP_BUZZER device --- */ 989/* --- for SHARP_BUZZER device --- */
776 990
777 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 991 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
778//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 992//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
779 993
780#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 994#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
781#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 995#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
782#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 996#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
783#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 997#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
784#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 998#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
785 999
786//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1000//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
787//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1001//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
788 1002
789//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1003//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
790//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1004//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
791//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1005//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
792//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1006//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
793//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1007//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
794//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1008//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
795//#define SHARP_PDA_APPSTART 9 /* application start */ 1009//#define SHARP_PDA_APPSTART 9 /* application start */
796//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1010//#define SHARP_PDA_APPQUIT 10 /* application ends */
797 1011
798//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1012//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
799//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1013//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
800//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1014//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
801//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1015//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
802// 1016//
803 1017
804 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1018 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
805#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1019#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
806 1020
807typedef struct sharp_led_status { 1021typedef struct sharp_led_status {
808 int which; /* select which LED status is wanted. */ 1022 int which; /* select which LED status is wanted. */
809 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1023 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
810} sharp_led_status; 1024} sharp_led_status;
811 1025
812#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1026#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
813 1027
814#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1028#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
815#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1029#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
816#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1030#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
817 1031
818// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1032// #include <asm/sharp_apm.h> // including kernel headers is evil ...
819 1033
820#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1034#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
821#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1035#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
822#define APM_EVT_POWER_BUTTON (1 << 0) 1036#define APM_EVT_POWER_BUTTON (1 << 0)
823 1037
824#define FL_IOCTL_STEP_CONTRAST 100 1038#define FL_IOCTL_STEP_CONTRAST 100
825 1039
826 1040
827void Zaurus::buzzer ( int sound ) 1041void Zaurus::buzzer ( int sound )
828{ 1042{
829 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 1043 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
830 1044
831 if ( fd >= 0 ) 1045 if ( fd >= 0 )
832 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1046 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
833} 1047}
834 1048
835 1049
836void Zaurus::alarmSound ( ) 1050void Zaurus::alarmSound ( )
837{ 1051{
838 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1052 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
839} 1053}
840 1054
841void Zaurus::touchSound ( ) 1055void Zaurus::touchSound ( )
842{ 1056{
843 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1057 buzzer ( SHARP_BUZ_TOUCHSOUND );
844} 1058}
845 1059
846void Zaurus::keySound ( ) 1060void Zaurus::keySound ( )
847{ 1061{
848 buzzer ( SHARP_BUZ_KEYSOUND ); 1062 buzzer ( SHARP_BUZ_KEYSOUND );
849} 1063}
850 1064
851 1065
852QValueList <OLed> Zaurus::ledList ( ) const 1066QValueList <OLed> Zaurus::ledList ( ) const
853{ 1067{
854 QValueList <OLed> vl; 1068 QValueList <OLed> vl;
855 vl << Led_Mail; 1069 vl << Led_Mail;
856 return vl; 1070 return vl;
857} 1071}
858 1072
859QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1073QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
860{ 1074{
861 QValueList <OLedState> vl; 1075 QValueList <OLedState> vl;
862 1076
863 if ( l == Led_Mail ) 1077 if ( l == Led_Mail )
864 vl << Led_Off << Led_On << Led_BlinkSlow; 1078 vl << Led_Off << Led_On << Led_BlinkSlow;
865 return vl; 1079 return vl;
866} 1080}
867 1081
868OLedState Zaurus::ledState ( OLed which ) const 1082OLedState Zaurus::ledState ( OLed which ) const
869{ 1083{
870 if ( which == Led_Mail ) 1084 if ( which == Led_Mail )
871 return m_leds [0]; 1085 return m_leds [0];
872 else 1086 else
873 return Led_Off; 1087 return Led_Off;
874} 1088}
875 1089
876bool Zaurus::setLedState ( OLed which, OLedState st ) 1090bool Zaurus::setLedState ( OLed which, OLedState st )
877{ 1091{
878 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1092 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
879 1093
880 if ( which == Led_Mail ) { 1094 if ( which == Led_Mail ) {
881 if ( fd >= 0 ) { 1095 if ( fd >= 0 ) {
882 struct sharp_led_status leds; 1096 struct sharp_led_status leds;
883 ::memset ( &leds, 0, sizeof( leds )); 1097 ::memset ( &leds, 0, sizeof( leds ));
884 leds. which = SHARP_LED_MAIL_EXISTS; 1098 leds. which = SHARP_LED_MAIL_EXISTS;
885 bool ok = true; 1099 bool ok = true;
886 1100
887 switch ( st ) { 1101 switch ( st ) {
888 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1102 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
889 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1103 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
890 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1104 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
891 default : ok = false; 1105 default : ok = false;
892 } 1106 }
893 1107
894 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1108 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
895 m_leds [0] = st; 1109 m_leds [0] = st;
896 return true; 1110 return true;
897 } 1111 }
898 } 1112 }
899 } 1113 }
900 return false; 1114 return false;
901} 1115}
902 1116
903bool Zaurus::setSoftSuspend ( bool soft ) 1117bool Zaurus::setSoftSuspend ( bool soft )
904{ 1118{
905 bool res = false; 1119 bool res = false;
906 int fd; 1120 int fd;
907 1121
908 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1122 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
909 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1123 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
910 1124
911 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1125 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
912 1126
913 if ( sources >= 0 ) { 1127 if ( sources >= 0 ) {
914 if ( soft ) 1128 if ( soft )
915 sources &= ~APM_EVT_POWER_BUTTON; 1129 sources &= ~APM_EVT_POWER_BUTTON;
916 else 1130 else
917 sources |= APM_EVT_POWER_BUTTON; 1131 sources |= APM_EVT_POWER_BUTTON;
918 1132
919 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1133 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
920 res = true; 1134 res = true;
921 else 1135 else
922 perror ( "APM_IOCGEVTSRC" ); 1136 perror ( "APM_IOCGEVTSRC" );
923 } 1137 }
924 else 1138 else
925 perror ( "APM_IOCGEVTSRC" ); 1139 perror ( "APM_IOCGEVTSRC" );
926 1140
927 ::close ( fd ); 1141 ::close ( fd );
928 } 1142 }
929 else 1143 else
930 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1144 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
931 1145
932 return res; 1146 return res;
933} 1147}
934 1148
935 1149
936bool Zaurus::setDisplayBrightness ( int bright ) 1150bool Zaurus::setDisplayBrightness ( int bright )
937{ 1151{
938 bool res = false; 1152 bool res = false;
939 int fd; 1153 int fd;
940 1154
941 if ( bright > 255 ) 1155 if ( bright > 255 )
942 bright = 255; 1156 bright = 255;
943 if ( bright < 0 ) 1157 if ( bright < 0 )
944 bright = 0; 1158 bright = 0;
945 1159
946 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1160 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
947 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1161 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
948 if ( bright && !bl ) 1162 if ( bright && !bl )
949 bl = 1; 1163 bl = 1;
950 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1164 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
951 ::close ( fd ); 1165 ::close ( fd );
952 } 1166 }
953 return res; 1167 return res;
954} 1168}
955 1169
956 1170
957int Zaurus::displayBrightnessResolution ( ) const 1171int Zaurus::displayBrightnessResolution ( ) const
958{ 1172{
959 return 5; 1173 return 5;
960} 1174}
961 1175
962 1176
diff --git a/libopie/odevice.h b/libopie/odevice.h
index 86491d4..ce62f1a 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,150 +1,194 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#ifndef _LIBOPIE_ODEVICE_H_ 20#ifndef _LIBOPIE_ODEVICE_H_
21#define _LIBOPIE_ODEVICE_H_ 21#define _LIBOPIE_ODEVICE_H_
22 22
23#include <qobject.h>
23#include <qstring.h> 24#include <qstring.h>
24#include <qnamespace.h> 25#include <qnamespace.h>
25 26
27#include <opie/odevicebutton.h>
28
26class ODeviceData; 29class ODeviceData;
27 30
28namespace Opie { 31namespace Opie {
29 32
30enum OModel { 33enum OModel {
31 Model_Unknown, 34 Model_Unknown,
32 35
33 Model_Series_Mask = 0xff000000, 36 Model_Series_Mask = 0xff000000,
34 37
35 Model_iPAQ = ( 1 << 24 ), 38 Model_iPAQ = ( 1 << 24 ),
36 39
37 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 40 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
38 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 41 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
39 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 42 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
40 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 43 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
41 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 44 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
42 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 45 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
43 46
44 Model_Zaurus = ( 2 << 24 ), 47 Model_Zaurus = ( 2 << 24 ),
45 48
46 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 49 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
47 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 50 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
48}; 51};
49 52
50 enum OVendor { 53 enum OVendor {
51 Vendor_Unknown, 54 Vendor_Unknown,
52 55
53 Vendor_HP, 56 Vendor_HP,
54 Vendor_Sharp 57 Vendor_Sharp
55 }; 58 };
56 59
57enum OSystem { 60enum OSystem {
58 System_Unknown, 61 System_Unknown,
59 62
60 System_Familiar, 63 System_Familiar,
61 System_Zaurus, 64 System_Zaurus,
62 System_OpenZaurus 65 System_OpenZaurus
63}; 66};
64 67
65enum OLedState { 68enum OLedState {
66 Led_Off, 69 Led_Off,
67 Led_On, 70 Led_On,
68 Led_BlinkSlow, 71 Led_BlinkSlow,
69 Led_BlinkFast 72 Led_BlinkFast
70}; 73};
71 74
72enum OLed { 75enum OLed {
73 Led_Mail, 76 Led_Mail,
74 Led_Power, 77 Led_Power,
75 Led_BlueTooth 78 Led_BlueTooth
76}; 79};
77 80
78enum OHardKey { 81enum OHardKey {
79 HardKey_Datebook = Qt::Key_F9, 82 HardKey_Datebook = Qt::Key_F9,
80 HardKey_Contacts = Qt::Key_F10, 83 HardKey_Contacts = Qt::Key_F10,
81 HardKey_Menu = Qt::Key_F11, 84 HardKey_Menu = Qt::Key_F11,
82 HardKey_Home = Qt::Key_F12, 85 HardKey_Home = Qt::Key_F12,
83 HardKey_Mail = Qt::Key_F14, 86 HardKey_Mail = Qt::Key_F14,
84 HardKey_Record = Qt::Key_F24, 87 HardKey_Record = Qt::Key_F24,
85 HardKey_Suspend = Qt::Key_F34, 88 HardKey_Suspend = Qt::Key_F34,
86 HardKey_Backlight = Qt::Key_F35, 89 HardKey_Backlight = Qt::Key_F35,
87}; 90};
88 91
89 92
90class ODevice 93class ODevice : public QObject {
91{ 94 Q_OBJECT
95
92private: 96private:
93 ODevice ( const ODevice & ); 97 ODevice ( const ODevice & );
94 98
95protected: 99protected:
96 ODevice ( ); 100 ODevice ( );
97 virtual void init ( ); 101 virtual void init ( );
98 102
99 ODeviceData *d; 103 ODeviceData *d;
100 104
101public: 105public:
102 virtual ~ODevice ( ); 106 virtual ~ODevice ( );
103 107
104 static ODevice *inst ( ); 108 static ODevice *inst ( );
105 109
106 110
107 111
108// information 112// information
109 113
110 QString modelString ( ) const; 114 QString modelString ( ) const;
111 OModel model ( ) const; 115 OModel model ( ) const;
112 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); } 116 inline OModel series ( ) const { return (OModel) ( model ( ) & Model_Series_Mask ); }
113 117
114 QString vendorString ( ) const; 118 QString vendorString ( ) const;
115 OVendor vendor ( ) const; 119 OVendor vendor ( ) const;
116 120
117 QString systemString ( ) const; 121 QString systemString ( ) const;
118 OSystem system ( ) const; 122 OSystem system ( ) const;
119 123
120 QString systemVersionString ( ) const; 124 QString systemVersionString ( ) const;
121 125
122 // system 126 // system
123 127
124 virtual bool setSoftSuspend ( bool on ); 128 virtual bool setSoftSuspend ( bool on );
125 virtual bool suspend ( ); 129 virtual bool suspend ( );
126 130
127 virtual bool setDisplayStatus ( bool on ); 131 virtual bool setDisplayStatus ( bool on );
128 virtual bool setDisplayBrightness ( int brightness ); 132 virtual bool setDisplayBrightness ( int brightness );
129 virtual int displayBrightnessResolution ( ) const; 133 virtual int displayBrightnessResolution ( ) const;
130 134
131// input / output 135// input / output
132 136
133 virtual void alarmSound ( ); 137 virtual void alarmSound ( );
134 virtual void keySound ( ); 138 virtual void keySound ( );
135 virtual void touchSound ( ); 139 virtual void touchSound ( );
136 140
137 virtual QValueList <OLed> ledList ( ) const; 141 virtual QValueList <OLed> ledList ( ) const;
138 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 142 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
139 virtual OLedState ledState ( OLed led ) const; 143 virtual OLedState ledState ( OLed led ) const;
140 virtual bool setLedState ( OLed led, OLedState st ); 144 virtual bool setLedState ( OLed led, OLedState st );
141 145
142 virtual bool hasLightSensor ( ) const; 146 virtual bool hasLightSensor ( ) const;
143 virtual int readLightSensor ( ); 147 virtual int readLightSensor ( );
144 virtual int lightSensorResolution ( ) const; 148 virtual int lightSensorResolution ( ) const;
149
150 /**
151 * Returns the available buttons on this device. The number and location
152 * of buttons will vary depending on the device. Button numbers will be assigned
153 * by the device manufacturer and will be from most preferred button to least preffered
154 * button. Note that this list only contains "user mappable" buttons.
155 */
156 const QValueList<ODeviceButton> &buttons ( ) const;
157
158 /**
159 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
160 * returns 0L
161 */
162 const ODeviceButton *buttonForKeycode ( ushort keyCode );
163
164 /**
165 * Reassigns the pressed action for \a button. To return to the factory
166 * default pass an empty string as \a qcopMessage.
167 */
168 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
169
170 /**
171 * Reassigns the held action for \a button. To return to the factory
172 * default pass an empty string as \a qcopMessage.
173 */
174 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
175
176 /**
177 * How long (in ms) you have to press a button for a "hold" action
178 */
179 uint buttonHoldTime ( ) const;
180
181 signals:
182 void buttonMappingChanged ( );
183
184 private slots:
185 void systemMessage ( const QCString &, const QByteArray & );
186
187protected:
188 void reloadButtonMapping ( );
145}; 189};
146 190
147} 191}
148 192
149#endif 193#endif
150 194
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 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20
21#include <qpixmap.h>
22#include <qstring.h>
23
24#include <qpe/qcopenvelope_qws.h>
25#include <opie/odevicebutton.h>
26
27using namespace Opie;
28
29
30class OQCopMessageData {
31 public:
32 QCString m_channel;
33 QCString m_message;
34 QByteArray m_data;
35};
36
37
38OQCopMessage::OQCopMessage ( )
39 : d ( 0 )
40{
41 init ( QCString ( ), QCString ( ), QByteArray ( ));
42}
43
44OQCopMessage::OQCopMessage ( const OQCopMessage &copy )
45 : d ( 0 )
46{
47 init ( copy. channel ( ), copy. message ( ), copy. data ( ));
48}
49
50OQCopMessage &OQCopMessage::operator = ( const OQCopMessage &assign )
51{
52 init ( assign. channel ( ), assign. message ( ), assign. data ( ));
53 return *this;
54}
55
56OQCopMessage::OQCopMessage ( const QCString &ch, const QCString &m, const QByteArray &arg )
57 : d ( 0 )
58{
59 init ( ch, m, arg );
60}
61
62void OQCopMessage::init ( const QCString &ch, const QCString &m, const QByteArray &arg )
63{
64 if ( !d )
65 d = new OQCopMessageData ( );
66 d-> m_channel = ch;
67 d-> m_message = m;
68 d-> m_data = arg;
69}
70
71bool OQCopMessage::send ( )
72{
73 if ( d-> m_channel. isEmpty ( ) || d-> m_message. isEmpty ( ))
74 return false;
75
76 QCopEnvelope e ( d-> m_channel, d-> m_message );
77
78 if ( d-> m_data. size ( ))
79 e. writeRawBytes ( d-> m_data. data ( ), d-> m_data. size ( ));
80
81 return true;
82}
83
84QCString OQCopMessage::channel ( ) const
85{
86 return d-> m_channel;
87}
88
89QCString OQCopMessage::message ( ) const
90{
91 return d-> m_message;
92}
93
94QByteArray OQCopMessage::data ( ) const
95{
96 return d-> m_data;
97}
98
99void OQCopMessage::setChannel ( const QCString &ch )
100{
101 d-> m_channel = ch;
102}
103
104void OQCopMessage::setMessage ( const QCString &m )
105{
106 d-> m_message = m;
107}
108
109void OQCopMessage::setData ( const QByteArray &data )
110{
111 d-> m_data = data;
112}
113
114/*! \class ODeviceButton
115 \brief The ODeviceButton class represents a physical user mappable button on a Qtopia device.
116
117 This class represents a physical button on a Qtopia device. A
118 device may have "user programmable" buttons.
119 The location and number of buttons will vary from device to
120 device. userText() and pixmap() may be used to describe this button
121 to the user in help documentation.
122
123 \ingroup qtopiaemb
124 \internal
125*/
126
127ODeviceButton::ODeviceButton()
128{
129}
130
131ODeviceButton::~ODeviceButton()
132{
133}
134
135/*!
136 Returns the button's keycode.
137 */
138ushort ODeviceButton::keycode() const
139{
140 return m_Keycode;
141}
142
143
144/*!
145 This function returns a human readable, translated description of the button.
146 */
147QString ODeviceButton::userText() const
148{
149 return m_UserText;
150}
151
152/*!
153 This function returns the pixmap for this button. If there isn't one
154 it will return an empty (null) pixmap.
155 */
156QPixmap ODeviceButton::pixmap() const
157{
158 return m_Pixmap;
159}
160
161/*!
162 This function returns the factory preset (default) action for when this button
163 is pressed. The return value is a legal QCop message.
164 */
165OQCopMessage ODeviceButton::factoryPresetPressedAction() const
166{
167 return m_FactoryPresetPressedAction;
168}
169
170/*!
171 This function returns the user assigned action for when this button is pressed.
172 If no action is assigned, factoryPresetAction() is returned.
173 */
174OQCopMessage ODeviceButton::pressedAction() const
175{
176 if (m_PressedAction.channel().isEmpty())
177 return factoryPresetPressedAction();
178 return m_PressedAction;
179}
180
181/*!
182 This function returns the factory preset (default) action for when this button
183 is pressed and held. The return value is a legal QCop message.
184 */
185OQCopMessage ODeviceButton::factoryPresetHeldAction() const
186{
187 return m_FactoryPresetHeldAction;
188}
189
190/*!
191 This function returns the user assigned action for when this button is pressed
192 and held. If no action is assigned, factoryPresetAction() is returned.
193 */
194OQCopMessage ODeviceButton::heldAction() const
195{
196 if (m_HeldAction.channel().isEmpty())
197 return factoryPresetHeldAction();
198 return m_HeldAction;
199}
200
201void ODeviceButton::setKeycode(ushort keycode)
202{
203 m_Keycode = keycode;
204}
205
206void ODeviceButton::setUserText(const QString& text)
207{
208 m_UserText = text;
209}
210
211void ODeviceButton::setPixmap(const QPixmap& picture)
212{
213 m_Pixmap = picture;
214}
215
216void ODeviceButton::setFactoryPresetPressedAction(const OQCopMessage& action)
217{
218 m_FactoryPresetPressedAction = action;
219}
220
221void ODeviceButton::setPressedAction(const OQCopMessage& action)
222{
223 m_PressedAction = action;
224}
225
226void ODeviceButton::setFactoryPresetHeldAction(const OQCopMessage& action)
227{
228 m_FactoryPresetHeldAction = action;
229}
230
231void ODeviceButton::setHeldAction(const OQCopMessage& action)
232{
233 m_HeldAction = action;
234}
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 @@
1/**********************************************************************
2** Copyright (C) 2000-2002 Trolltech AS. All rights reserved.
3**
4** This file is part of the Qtopia Environment.
5**
6** This file may be distributed and/or modified under the terms of the
7** GNU General Public License version 2 as published by the Free Software
8** Foundation and appearing in the file LICENSE.GPL included in the
9** packaging of this file.
10**
11** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
12** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
13**
14** See http://www.trolltech.com/gpl/ for GPL licensing information.
15**
16** Contact info@trolltech.com if any conditions of this licensing are
17** not clear to you.
18**
19**********************************************************************/
20#ifndef DEVICE_BUTTON_H
21#define DEVICE_BUTTON_H
22
23#include <qpixmap.h>
24#include <qstring.h>
25
26class OQCopMessageData;
27
28namespace Opie
29{
30
31class OQCopMessage {
32public:
33 OQCopMessage ( );
34 OQCopMessage ( const OQCopMessage &copy );
35 OQCopMessage ( const QCString &m_channel, const QCString &message, const QByteArray &args = QByteArray ( ));
36
37 OQCopMessage &operator = ( const OQCopMessage &assign );
38
39 void setChannel ( const QCString &channel );
40 void setMessage ( const QCString &message );
41 void setData ( const QByteArray &ba );
42
43 QCString channel ( ) const;
44 QCString message ( ) const;
45 QByteArray data ( ) const;
46
47 bool send ( );
48
49private:
50 void init ( const QCString &m_channel, const QCString &message, const QByteArray &args );
51
52 OQCopMessageData *d;
53};
54
55
56/**
57 * This class represents a physical button on a Qtopia device. A device may
58 * have n "user programmable" buttons, which are number 1..n. The location
59 * and number of buttons will vary from device to device. userText() and pixmap()
60 * may be used to describe this button to the user in help documentation.
61 */
62
63class ODeviceButton
64{
65public:
66 ODeviceButton();
67 virtual ~ODeviceButton();
68
69 ushort keycode ( ) const;
70 QString userText ( ) const;
71 QPixmap pixmap ( ) const;
72 OQCopMessage factoryPresetPressedAction ( ) const;
73 OQCopMessage pressedAction ( ) const;
74 OQCopMessage factoryPresetHeldAction ( ) const;
75 OQCopMessage heldAction ( ) const;
76
77 void setKeycode ( ushort keycode );
78 void setUserText ( const QString& text );
79 void setPixmap ( const QPixmap& picture );
80 void setFactoryPresetPressedAction ( const OQCopMessage& qcopMessage );
81 void setPressedAction ( const OQCopMessage& qcopMessage );
82 void setFactoryPresetHeldAction ( const OQCopMessage& qcopMessage );
83 void setHeldAction ( const OQCopMessage& qcopMessage );
84
85private:
86 ushort m_Keycode;
87 QString m_UserText;
88 QPixmap m_Pixmap;
89 OQCopMessage m_FactoryPresetPressedAction;
90 OQCopMessage m_PressedAction;
91 OQCopMessage m_FactoryPresetHeldAction;
92 OQCopMessage m_HeldAction;
93};
94
95}
96
97#endif