summaryrefslogtreecommitdiff
path: root/libopie
authoreilers <eilers>2003-11-03 16:52:18 (UTC)
committer eilers <eilers>2003-11-03 16:52:18 (UTC)
commitd34dc773591a2d467c68875a68a671d6a809f861 (patch) (unidiff)
treeb57e5ae15c51e3d87ca95d57aedfd1ca3db57bfe /libopie
parentce84f2d8bdd65c438821f0457cdad6bbbfa73380 (diff)
downloadopie-d34dc773591a2d467c68875a68a671d6a809f861.zip
opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.gz
opie-d34dc773591a2d467c68875a68a671d6a809f861.tar.bz2
Porting Opie to MacOS-X.
The base system and all platform independent applications and platforms should work. Please see $OPIEDIR/development/macosx for details
Diffstat (limited to 'libopie') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/libopie.pro4
-rw-r--r--libopie/odevice.cpp2
2 files changed, 2 insertions, 4 deletions
diff --git a/libopie/libopie.pro b/libopie/libopie.pro
index 0398775..bf6b78f 100644
--- a/libopie/libopie.pro
+++ b/libopie/libopie.pro
@@ -1,136 +1,132 @@
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 \ 5 ofiledialog.h ofileselector.h \
6 ofileselector_p.h \ 6 ofileselector_p.h \
7 ocheckitem.h \ 7 ocheckitem.h \
8 xmltree.h \ 8 xmltree.h \
9 colordialog.h colorpopupmenu.h \ 9 colordialog.h colorpopupmenu.h \
10 oclickablelabel.h oprocctrl.h \ 10 oclickablelabel.h oprocctrl.h \
11 oprocess.h odevice.h odevicebutton.h \ 11 oprocess.h odevice.h odevicebutton.h \
12 otimepicker.h otabwidget.h \ 12 otimepicker.h otabwidget.h \
13 otabbar.h otabinfo.h \ 13 otabbar.h otabinfo.h \
14 ofontselector.h \ 14 ofontselector.h \
15 pim/opimrecord.h \ 15 pim/opimrecord.h \
16 pim/otodo.h \ 16 pim/otodo.h \
17 pim/orecordlist.h \ 17 pim/orecordlist.h \
18 pim/opimaccesstemplate.h \ 18 pim/opimaccesstemplate.h \
19 pim/opimaccessbackend.h \ 19 pim/opimaccessbackend.h \
20 pim/otodoaccess.h \ 20 pim/otodoaccess.h \
21 pim/otodoaccessbackend.h \ 21 pim/otodoaccessbackend.h \
22 pim/oconversion.h \ 22 pim/oconversion.h \
23 pim/ocontact.h \ 23 pim/ocontact.h \
24 pim/ocontactfields.h \ 24 pim/ocontactfields.h \
25 pim/ocontactaccess.h \ 25 pim/ocontactaccess.h \
26 pim/ocontactaccessbackend.h \ 26 pim/ocontactaccessbackend.h \
27 pim/ocontactaccessbackend_xml.h \ 27 pim/ocontactaccessbackend_xml.h \
28 pim/ocontactaccessbackend_vcard.h \ 28 pim/ocontactaccessbackend_vcard.h \
29 pim/obackendfactory.h \ 29 pim/obackendfactory.h \
30 pim/opimcache.h \ 30 pim/opimcache.h \
31 pim/otodoaccessvcal.h \ 31 pim/otodoaccessvcal.h \
32 pim/orecur.h \ 32 pim/orecur.h \
33 pim/opimstate.h \ 33 pim/opimstate.h \
34 pim/opimxrefpartner.h \ 34 pim/opimxrefpartner.h \
35 pim/opimxref.h \ 35 pim/opimxref.h \
36 pim/opimxrefmanager.h \ 36 pim/opimxrefmanager.h \
37 pim/opimmaintainer.h \ 37 pim/opimmaintainer.h \
38 pim/opimnotify.h \ 38 pim/opimnotify.h \
39 pim/opimnotifymanager.h \ 39 pim/opimnotifymanager.h \
40 pim/opimmainwindow.h \ 40 pim/opimmainwindow.h \
41 pim/opimresolver.h \ 41 pim/opimresolver.h \
42 pim/oevent.h \ 42 pim/oevent.h \
43 pim/otimezone.h \ 43 pim/otimezone.h \
44 pim/odatebookaccess.h \ 44 pim/odatebookaccess.h \
45 pim/odatebookaccessbackend.h \ 45 pim/odatebookaccessbackend.h \
46 pim/odatebookaccessbackend_xml.h \ 46 pim/odatebookaccessbackend_xml.h \
47 orecurrancewidget.h \ 47 orecurrancewidget.h \
48 oticker.h owait.h 48 oticker.h owait.h
49 49
50SOURCES = ofontmenu.cc \ 50SOURCES = ofontmenu.cc \
51 ocolorbutton.cpp \ 51 ocolorbutton.cpp \
52 sharp_compat.cpp \ 52 sharp_compat.cpp \
53 xmltree.cc \ 53 xmltree.cc \
54 ofiledialog.cc ofileselector.cpp \ 54 ofiledialog.cc ofileselector.cpp \
55 ocheckitem.cpp \ 55 ocheckitem.cpp \
56 colordialog.cpp \ 56 colordialog.cpp \
57 colorpopupmenu.cpp oclickablelabel.cpp \ 57 colorpopupmenu.cpp oclickablelabel.cpp \
58 oprocctrl.cpp oprocess.cpp \ 58 oprocctrl.cpp oprocess.cpp \
59 odevice.cpp odevicebutton.cpp otimepicker.cpp \ 59 odevice.cpp odevicebutton.cpp otimepicker.cpp \
60 otabwidget.cpp otabbar.cpp \ 60 otabwidget.cpp otabbar.cpp \
61 ofontselector.cpp \ 61 ofontselector.cpp \
62 pim/otodo.cpp \ 62 pim/otodo.cpp \
63 pim/opimrecord.cpp \ 63 pim/opimrecord.cpp \
64 pim/otodoaccess.cpp \ 64 pim/otodoaccess.cpp \
65 pim/otodoaccessbackend.cpp \ 65 pim/otodoaccessbackend.cpp \
66 pim/otodoaccessxml.cpp \ 66 pim/otodoaccessxml.cpp \
67 pim/oconversion.cpp \ 67 pim/oconversion.cpp \
68 pim/ocontact.cpp \ 68 pim/ocontact.cpp \
69 pim/ocontactfields.cpp \ 69 pim/ocontactfields.cpp \
70 pim/ocontactaccess.cpp \ 70 pim/ocontactaccess.cpp \
71 pim/ocontactaccessbackend_vcard.cpp \ 71 pim/ocontactaccessbackend_vcard.cpp \
72 pim/ocontactaccessbackend_xml.cpp \ 72 pim/ocontactaccessbackend_xml.cpp \
73 pim/otodoaccessvcal.cpp \ 73 pim/otodoaccessvcal.cpp \
74 pim/orecur.cpp \ 74 pim/orecur.cpp \
75 pim/opimstate.cpp \ 75 pim/opimstate.cpp \
76 pim/opimxrefpartner.cpp \ 76 pim/opimxrefpartner.cpp \
77 pim/opimxref.cpp \ 77 pim/opimxref.cpp \
78 pim/opimxrefmanager.cpp \ 78 pim/opimxrefmanager.cpp \
79 pim/opimmaintainer.cpp \ 79 pim/opimmaintainer.cpp \
80 pim/opimnotify.cpp \ 80 pim/opimnotify.cpp \
81 pim/opimnotifymanager.cpp \ 81 pim/opimnotifymanager.cpp \
82 pim/opimmainwindow.cpp \ 82 pim/opimmainwindow.cpp \
83 pim/opimresolver.cpp \ 83 pim/opimresolver.cpp \
84 pim/oevent.cpp \ 84 pim/oevent.cpp \
85 pim/otimezone.cpp \ 85 pim/otimezone.cpp \
86 pim/odatebookaccess.cpp \ 86 pim/odatebookaccess.cpp \
87 pim/odatebookaccessbackend.cpp \ 87 pim/odatebookaccessbackend.cpp \
88 pim/odatebookaccessbackend_xml.cpp \ 88 pim/odatebookaccessbackend_xml.cpp \
89 orecurrancewidget.cpp \ 89 orecurrancewidget.cpp \
90 oticker.cpp owait.cpp 90 oticker.cpp owait.cpp
91 91
92TARGET = opie 92TARGET = opie
93INCLUDEPATH += $(OPIEDIR)/include 93INCLUDEPATH += $(OPIEDIR)/include
94DESTDIR = $(OPIEDIR)/lib$(PROJMAK) 94DESTDIR = $(OPIEDIR)/lib$(PROJMAK)
95 95
96# The following is just for my Notebook !
97# It should never be committed !! (eilers)
98# QMAKE_CXXFLAGS += -DQT_NO_SOUND
99
100LIBS += -lqpe 96LIBS += -lqpe
101 97
102# Add SQL-Support if selected by config (eilers) 98# Add SQL-Support if selected by config (eilers)
103CONFTEST = $$system( echo $CONFIG_SQL_PIM_BACKEND ) 99CONFTEST = $$system( echo $CONFIG_SQL_PIM_BACKEND )
104contains( CONFTEST, y ){ 100contains( CONFTEST, y ){
105 101
106DEFINES += __USE_SQL 102DEFINES += __USE_SQL
107LIBS += -lopiedb2 -lsqlite 103LIBS += -lopiedb2 -lsqlite
108HEADERS += pim/otodoaccesssql.h pim/ocontactaccessbackend_sql.h 104HEADERS += pim/otodoaccesssql.h pim/ocontactaccessbackend_sql.h
109SOURCES += pim/otodoaccesssql.cpp pim/ocontactaccessbackend_sql.cpp 105SOURCES += pim/otodoaccesssql.cpp pim/ocontactaccessbackend_sql.cpp
110 106
111} 107}
112 108
113INTERFACES = otimepickerbase.ui orecurrancebase.ui 109INTERFACES = otimepickerbase.ui orecurrancebase.ui
114TARGET = opie 110TARGET = opie
115 111
116TRANSLATIONS = ../i18n/de/libopie.ts \ 112TRANSLATIONS = ../i18n/de/libopie.ts \
117 ../i18n/nl/libopie.ts \ 113 ../i18n/nl/libopie.ts \
118 ../i18n/xx/libopie.ts \ 114 ../i18n/xx/libopie.ts \
119 ../i18n/en/libopie.ts \ 115 ../i18n/en/libopie.ts \
120 ../i18n/es/libopie.ts \ 116 ../i18n/es/libopie.ts \
121 ../i18n/fr/libopie.ts \ 117 ../i18n/fr/libopie.ts \
122 ../i18n/hu/libopie.ts \ 118 ../i18n/hu/libopie.ts \
123 ../i18n/ja/libopie.ts \ 119 ../i18n/ja/libopie.ts \
124 ../i18n/ko/libopie.ts \ 120 ../i18n/ko/libopie.ts \
125 ../i18n/no/libopie.ts \ 121 ../i18n/no/libopie.ts \
126 ../i18n/pl/libopie.ts \ 122 ../i18n/pl/libopie.ts \
127 ../i18n/pt/libopie.ts \ 123 ../i18n/pt/libopie.ts \
128 ../i18n/pt_BR/libopie.ts \ 124 ../i18n/pt_BR/libopie.ts \
129 ../i18n/sl/libopie.ts \ 125 ../i18n/sl/libopie.ts \
130 ../i18n/zh_CN/libopie.ts \ 126 ../i18n/zh_CN/libopie.ts \
131 ../i18n/zh_TW/libopie.ts \ 127 ../i18n/zh_TW/libopie.ts \
132 ../i18n/da/libopie.ts 128 ../i18n/da/libopie.ts
133 129
134include ( big-screen/big-screen.pro ) 130include ( big-screen/big-screen.pro )
135 131
136include ( $(OPIEDIR)/include.pro ) 132include ( $(OPIEDIR)/include.pro )
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 3edf8e7..fef623a 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,2598 +1,2600 @@
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#ifndef QT_NO_SOUND
26#include <linux/soundcard.h> 27#include <linux/soundcard.h>
28#endif
27#include <math.h> 29#include <math.h>
28 30
29#include <qapplication.h> 31#include <qapplication.h>
30 32
31#include <qfile.h> 33#include <qfile.h>
32#include <qtextstream.h> 34#include <qtextstream.h>
33#include <qpe/sound.h> 35#include <qpe/sound.h>
34#include <qpe/resource.h> 36#include <qpe/resource.h>
35#include <qpe/config.h> 37#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 38#include <qpe/qcopenvelope_qws.h>
37 39
38#include "odevice.h" 40#include "odevice.h"
39 41
40#include <qwindowsystem_qws.h> 42#include <qwindowsystem_qws.h>
41 43
42#ifndef ARRAY_SIZE 44#ifndef ARRAY_SIZE
43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 45#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
44#endif 46#endif
45 47
46// _IO and friends are only defined in kernel headers ... 48// _IO and friends are only defined in kernel headers ...
47 49
48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 50#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
49 51
50#define OD_IO(type,number) OD_IOC(0,type,number,0) 52#define OD_IO(type,number) OD_IOC(0,type,number,0)
51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 53#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 54#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 55#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
54 56
55using namespace Opie; 57using namespace Opie;
56 58
57class ODeviceData { 59class ODeviceData {
58public: 60public:
59 QString m_vendorstr; 61 QString m_vendorstr;
60 OVendor m_vendor; 62 OVendor m_vendor;
61 63
62 QString m_modelstr; 64 QString m_modelstr;
63 OModel m_model; 65 OModel m_model;
64 66
65 QString m_systemstr; 67 QString m_systemstr;
66 OSystem m_system; 68 OSystem m_system;
67 69
68 QString m_sysverstr; 70 QString m_sysverstr;
69 71
70 Transformation m_rotation; 72 Transformation m_rotation;
71 ODirection m_direction; 73 ODirection m_direction;
72 74
73 QValueList <ODeviceButton> *m_buttons; 75 QValueList <ODeviceButton> *m_buttons;
74 uint m_holdtime; 76 uint m_holdtime;
75 QStrList *m_cpu_frequencies; 77 QStrList *m_cpu_frequencies;
76}; 78};
77 79
78class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 80class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
79protected: 81protected:
80 virtual void init ( ); 82 virtual void init ( );
81 virtual void initButtons ( ); 83 virtual void initButtons ( );
82 84
83public: 85public:
84 virtual bool setSoftSuspend ( bool soft ); 86 virtual bool setSoftSuspend ( bool soft );
85 87
86 virtual bool setDisplayBrightness ( int b ); 88 virtual bool setDisplayBrightness ( int b );
87 virtual int displayBrightnessResolution ( ) const; 89 virtual int displayBrightnessResolution ( ) const;
88 90
89 virtual void alarmSound ( ); 91 virtual void alarmSound ( );
90 92
91 virtual QValueList <OLed> ledList ( ) const; 93 virtual QValueList <OLed> ledList ( ) const;
92 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 94 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
93 virtual OLedState ledState ( OLed led ) const; 95 virtual OLedState ledState ( OLed led ) const;
94 virtual bool setLedState ( OLed led, OLedState st ); 96 virtual bool setLedState ( OLed led, OLedState st );
95 97
96 virtual bool hasLightSensor ( ) const; 98 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 99 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 100 virtual int lightSensorResolution ( ) const;
99 101
100protected: 102protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 103 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 104 virtual void timerEvent ( QTimerEvent *te );
103 105
104 int m_power_timer; 106 int m_power_timer;
105 107
106 OLedState m_leds [2]; 108 OLedState m_leds [2];
107}; 109};
108 110
109class Jornada : public ODevice { 111class Jornada : public ODevice {
110protected: 112protected:
111 virtual void init ( ); 113 virtual void init ( );
112 //virtual void initButtons ( ); 114 //virtual void initButtons ( );
113public: 115public:
114 virtual bool setSoftSuspend ( bool soft ); 116 virtual bool setSoftSuspend ( bool soft );
115 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
116 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
117 static bool isJornada(); 119 static bool isJornada();
118 120
119}; 121};
120 122
121class Zaurus : public ODevice { 123class Zaurus : public ODevice {
122protected: 124protected:
123 virtual void init ( ); 125 virtual void init ( );
124 virtual void initButtons ( ); 126 virtual void initButtons ( );
125 127
126public: 128public:
127 virtual bool setSoftSuspend ( bool soft ); 129 virtual bool setSoftSuspend ( bool soft );
128 130
129 virtual bool setDisplayBrightness ( int b ); 131 virtual bool setDisplayBrightness ( int b );
130 virtual int displayBrightnessResolution ( ) const; 132 virtual int displayBrightnessResolution ( ) const;
131 133
132 virtual void alarmSound ( ); 134 virtual void alarmSound ( );
133 virtual void keySound ( ); 135 virtual void keySound ( );
134 virtual void touchSound ( ); 136 virtual void touchSound ( );
135 137
136 virtual QValueList <OLed> ledList ( ) const; 138 virtual QValueList <OLed> ledList ( ) const;
137 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 139 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
138 virtual OLedState ledState ( OLed led ) const; 140 virtual OLedState ledState ( OLed led ) const;
139 virtual bool setLedState ( OLed led, OLedState st ); 141 virtual bool setLedState ( OLed led, OLedState st );
140 142
141 static bool isZaurus(); 143 static bool isZaurus();
142 144
143protected: 145protected:
144 virtual void buzzer ( int snd ); 146 virtual void buzzer ( int snd );
145 147
146 OLedState m_leds [1]; 148 OLedState m_leds [1];
147 bool m_embedix; 149 bool m_embedix;
148}; 150};
149 151
150class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 152class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
151protected: 153protected:
152 virtual void init ( ); 154 virtual void init ( );
153 virtual void initButtons ( ); 155 virtual void initButtons ( );
154 156
155public: 157public:
156 virtual bool setSoftSuspend ( bool soft ); 158 virtual bool setSoftSuspend ( bool soft );
157 virtual bool suspend(); 159 virtual bool suspend();
158 160
159 virtual bool setDisplayStatus( bool on ); 161 virtual bool setDisplayStatus( bool on );
160 virtual bool setDisplayBrightness ( int b ); 162 virtual bool setDisplayBrightness ( int b );
161 virtual int displayBrightnessResolution ( ) const; 163 virtual int displayBrightnessResolution ( ) const;
162 164
163 virtual void alarmSound ( ); 165 virtual void alarmSound ( );
164 166
165 virtual QValueList <OLed> ledList ( ) const; 167 virtual QValueList <OLed> ledList ( ) const;
166 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 168 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
167 virtual OLedState ledState ( OLed led ) const; 169 virtual OLedState ledState ( OLed led ) const;
168 virtual bool setLedState ( OLed led, OLedState st ); 170 virtual bool setLedState ( OLed led, OLedState st );
169 171
170protected: 172protected:
171 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 173 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
172 virtual void timerEvent ( QTimerEvent *te ); 174 virtual void timerEvent ( QTimerEvent *te );
173 175
174 int m_power_timer; 176 int m_power_timer;
175 177
176 OLedState m_leds [1]; //FIXME check if really only one 178 OLedState m_leds [1]; //FIXME check if really only one
177}; 179};
178 180
179class Ramses : public ODevice, public QWSServer::KeyboardFilter { 181class Ramses : public ODevice, public QWSServer::KeyboardFilter {
180protected: 182protected:
181 virtual void init ( ); 183 virtual void init ( );
182 184
183public: 185public:
184 virtual bool setSoftSuspend ( bool soft ); 186 virtual bool setSoftSuspend ( bool soft );
185 virtual bool suspend ( ); 187 virtual bool suspend ( );
186 188
187 virtual bool setDisplayStatus( bool on ); 189 virtual bool setDisplayStatus( bool on );
188 virtual bool setDisplayBrightness ( int b ); 190 virtual bool setDisplayBrightness ( int b );
189 virtual int displayBrightnessResolution ( ) const; 191 virtual int displayBrightnessResolution ( ) const;
190 virtual bool setDisplayContrast ( int b ); 192 virtual bool setDisplayContrast ( int b );
191 virtual int displayContrastResolution ( ) const; 193 virtual int displayContrastResolution ( ) const;
192 194
193protected: 195protected:
194 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 196 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
195 virtual void timerEvent ( QTimerEvent *te ); 197 virtual void timerEvent ( QTimerEvent *te );
196 198
197 int m_power_timer; 199 int m_power_timer;
198}; 200};
199 201
200struct i_button { 202struct i_button {
201 uint model; 203 uint model;
202 Qt::Key code; 204 Qt::Key code;
203 char *utext; 205 char *utext;
204 char *pix; 206 char *pix;
205 char *fpressedservice; 207 char *fpressedservice;
206 char *fpressedaction; 208 char *fpressedaction;
207 char *fheldservice; 209 char *fheldservice;
208 char *fheldaction; 210 char *fheldaction;
209} ipaq_buttons [] = { 211} ipaq_buttons [] = {
210 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 212 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
211 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 213 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
212 "devicebuttons/ipaq_calendar", 214 "devicebuttons/ipaq_calendar",
213 "datebook", "nextView()", 215 "datebook", "nextView()",
214 "today", "raise()" }, 216 "today", "raise()" },
215 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 217 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
216 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 218 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
217 "devicebuttons/ipaq_contact", 219 "devicebuttons/ipaq_contact",
218 "addressbook", "raise()", 220 "addressbook", "raise()",
219 "addressbook", "beamBusinessCard()" }, 221 "addressbook", "beamBusinessCard()" },
220 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 222 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
221 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 223 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
222 "devicebuttons/ipaq_menu", 224 "devicebuttons/ipaq_menu",
223 "QPE/TaskBar", "toggleMenu()", 225 "QPE/TaskBar", "toggleMenu()",
224 "QPE/TaskBar", "toggleStartMenu()" }, 226 "QPE/TaskBar", "toggleStartMenu()" },
225 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 227 { Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
226 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 228 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
227 "devicebuttons/ipaq_mail", 229 "devicebuttons/ipaq_mail",
228 "mail", "raise()", 230 "mail", "raise()",
229 "mail", "newMail()" }, 231 "mail", "newMail()" },
230 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 232 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
231 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 233 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
232 "devicebuttons/ipaq_home", 234 "devicebuttons/ipaq_home",
233 "QPE/Launcher", "home()", 235 "QPE/Launcher", "home()",
234 "buttonsettings", "raise()" }, 236 "buttonsettings", "raise()" },
235 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx, 237 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx | Model_iPAQ_H5xxx,
236 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 238 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
237 "devicebuttons/ipaq_record", 239 "devicebuttons/ipaq_record",
238 "QPE/VMemo", "toggleRecord()", 240 "QPE/VMemo", "toggleRecord()",
239 "sound", "raise()" }, 241 "sound", "raise()" },
240}; 242};
241 243
242struct z_button { 244struct z_button {
243 Qt::Key code; 245 Qt::Key code;
244 char *utext; 246 char *utext;
245 char *pix; 247 char *pix;
246 char *fpressedservice; 248 char *fpressedservice;
247 char *fpressedaction; 249 char *fpressedaction;
248 char *fheldservice; 250 char *fheldservice;
249 char *fheldaction; 251 char *fheldaction;
250} z_buttons [] = { 252} z_buttons [] = {
251 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 253 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
252 "devicebuttons/z_calendar", 254 "devicebuttons/z_calendar",
253 "datebook", "nextView()", 255 "datebook", "nextView()",
254 "today", "raise()" }, 256 "today", "raise()" },
255 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 257 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
256 "devicebuttons/z_contact", 258 "devicebuttons/z_contact",
257 "addressbook", "raise()", 259 "addressbook", "raise()",
258 "addressbook", "beamBusinessCard()" }, 260 "addressbook", "beamBusinessCard()" },
259 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 261 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
260 "devicebuttons/z_home", 262 "devicebuttons/z_home",
261 "QPE/Launcher", "home()", 263 "QPE/Launcher", "home()",
262 "buttonsettings", "raise()" }, 264 "buttonsettings", "raise()" },
263 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 265 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
264 "devicebuttons/z_menu", 266 "devicebuttons/z_menu",
265 "QPE/TaskBar", "toggleMenu()", 267 "QPE/TaskBar", "toggleMenu()",
266 "QPE/TaskBar", "toggleStartMenu()" }, 268 "QPE/TaskBar", "toggleStartMenu()" },
267 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 269 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
268 "devicebuttons/z_mail", 270 "devicebuttons/z_mail",
269 "mail", "raise()", 271 "mail", "raise()",
270 "mail", "newMail()" }, 272 "mail", "newMail()" },
271}; 273};
272 274
273struct z_button z_buttons_c700 [] = { 275struct z_button z_buttons_c700 [] = {
274 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 276 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
275 "devicebuttons/z_calendar", 277 "devicebuttons/z_calendar",
276 "datebook", "nextView()", 278 "datebook", "nextView()",
277 "today", "raise()" }, 279 "today", "raise()" },
278 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 280 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
279 "devicebuttons/z_contact", 281 "devicebuttons/z_contact",
280 "addressbook", "raise()", 282 "addressbook", "raise()",
281 "addressbook", "beamBusinessCard()" }, 283 "addressbook", "beamBusinessCard()" },
282 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 284 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
283 "devicebuttons/z_home", 285 "devicebuttons/z_home",
284 "QPE/Launcher", "home()", 286 "QPE/Launcher", "home()",
285 "buttonsettings", "raise()" }, 287 "buttonsettings", "raise()" },
286 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 288 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
287 "devicebuttons/z_menu", 289 "devicebuttons/z_menu",
288 "QPE/TaskBar", "toggleMenu()", 290 "QPE/TaskBar", "toggleMenu()",
289 "QPE/TaskBar", "toggleStartMenu()" }, 291 "QPE/TaskBar", "toggleStartMenu()" },
290 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 292 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
291 "", 293 "",
292 "QPE/Rotation", "flip()", 294 "QPE/Rotation", "flip()",
293 "QPE/Rotation", "flip()" }, 295 "QPE/Rotation", "flip()" },
294}; 296};
295 297
296struct s_button { 298struct s_button {
297 uint model; 299 uint model;
298 Qt::Key code; 300 Qt::Key code;
299 char *utext; 301 char *utext;
300 char *pix; 302 char *pix;
301 char *fpressedservice; 303 char *fpressedservice;
302 char *fpressedaction; 304 char *fpressedaction;
303 char *fheldservice; 305 char *fheldservice;
304 char *fheldaction; 306 char *fheldaction;
305} simpad_buttons [] = { 307} simpad_buttons [] = {
306 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 308 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
307 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"), 309 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
308 "devicebuttons/simpad_lower_up", 310 "devicebuttons/simpad_lower_up",
309 "datebook", "nextView()", 311 "datebook", "nextView()",
310 "today", "raise()" }, 312 "today", "raise()" },
311 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 313 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
312 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"), 314 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
313 "devicebuttons/simpad_lower_down", 315 "devicebuttons/simpad_lower_down",
314 "addressbook", "raise()", 316 "addressbook", "raise()",
315 "addressbook", "beamBusinessCard()" }, 317 "addressbook", "beamBusinessCard()" },
316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 318 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
317 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"), 319 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
318 "devicebuttons/simpad_lower_right", 320 "devicebuttons/simpad_lower_right",
319 "QPE/TaskBar", "toggleMenu()", 321 "QPE/TaskBar", "toggleMenu()",
320 "QPE/TaskBar", "toggleStartMenu()" }, 322 "QPE/TaskBar", "toggleStartMenu()" },
321 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 323 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
322 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"), 324 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
323 "devicebuttons/simpad_lower_left", 325 "devicebuttons/simpad_lower_left",
324 "mail", "raise()", 326 "mail", "raise()",
325 "mail", "newMail()" }, 327 "mail", "newMail()" },
326 328
327 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 329 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
328 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), 330 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
329 "devicebuttons/simpad_upper_up", 331 "devicebuttons/simpad_upper_up",
330 "QPE/Launcher", "home()", 332 "QPE/Launcher", "home()",
331 "buttonsettings", "raise()" }, 333 "buttonsettings", "raise()" },
332 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 334 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
333 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), 335 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
334 "devicebuttons/simpad_upper_down", 336 "devicebuttons/simpad_upper_down",
335 "addressbook", "raise()", 337 "addressbook", "raise()",
336 "addressbook", "beamBusinessCard()" }, 338 "addressbook", "beamBusinessCard()" },
337 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 339 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
338 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), 340 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
339 "devicebuttons/simpad_upper_right", 341 "devicebuttons/simpad_upper_right",
340 "QPE/TaskBar", "toggleMenu()", 342 "QPE/TaskBar", "toggleMenu()",
341 "QPE/TaskBar", "toggleStartMenu()" }, 343 "QPE/TaskBar", "toggleStartMenu()" },
342 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 344 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
343 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), 345 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
344 "devicebuttons/simpad_upper_left", 346 "devicebuttons/simpad_upper_left",
345 "QPE/Rotation", "flip()", 347 "QPE/Rotation", "flip()",
346 "QPE/Rotation", "flip()" }, 348 "QPE/Rotation", "flip()" },
347 /* 349 /*
348 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 350 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
349 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 351 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
350 "devicebuttons/simpad_lower_upper", 352 "devicebuttons/simpad_lower_upper",
351 "QPE/Launcher", "home()", 353 "QPE/Launcher", "home()",
352 "buttonsettings", "raise()" }, 354 "buttonsettings", "raise()" },
353 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 355 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
354 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), 356 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
355 "devicebuttons/simpad_upper_lower", 357 "devicebuttons/simpad_upper_lower",
356 "QPE/Launcher", "home()", 358 "QPE/Launcher", "home()",
357 "buttonsettings", "raise()" }, 359 "buttonsettings", "raise()" },
358 */ 360 */
359}; 361};
360 362
361struct r_button { 363struct r_button {
362 uint model; 364 uint model;
363 Qt::Key code; 365 Qt::Key code;
364 char *utext; 366 char *utext;
365 char *pix; 367 char *pix;
366 char *fpressedservice; 368 char *fpressedservice;
367 char *fpressedaction; 369 char *fpressedaction;
368 char *fheldservice; 370 char *fheldservice;
369 char *fheldaction; 371 char *fheldaction;
370} ramses_buttons [] = { 372} ramses_buttons [] = {
371 { Model_Ramses_MNCI, 373 { Model_Ramses_MNCI,
372 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 374 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
373 "devicebuttons/z_menu", 375 "devicebuttons/z_menu",
374 "QPE/TaskBar", "toggleMenu()", 376 "QPE/TaskBar", "toggleMenu()",
375 "QPE/TaskBar", "toggleStartMenu()" }, 377 "QPE/TaskBar", "toggleStartMenu()" },
376 { Model_Ramses_MNCI, 378 { Model_Ramses_MNCI,
377 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 379 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
378 "devicebuttons/ipaq_home", 380 "devicebuttons/ipaq_home",
379 "QPE/Launcher", "home()", 381 "QPE/Launcher", "home()",
380 "buttonsettings", "raise()" }, 382 "buttonsettings", "raise()" },
381}; 383};
382 384
383class Yopy : public ODevice { 385class Yopy : public ODevice {
384protected: 386protected:
385 virtual void init ( ); 387 virtual void init ( );
386 virtual void initButtons ( ); 388 virtual void initButtons ( );
387 389
388public: 390public:
389 virtual bool suspend ( ); 391 virtual bool suspend ( );
390 392
391 virtual bool setDisplayBrightness ( int b ); 393 virtual bool setDisplayBrightness ( int b );
392 virtual int displayBrightnessResolution ( ) const; 394 virtual int displayBrightnessResolution ( ) const;
393 395
394 static bool isYopy ( ); 396 static bool isYopy ( );
395}; 397};
396 398
397struct yopy_button { 399struct yopy_button {
398 Qt::Key code; 400 Qt::Key code;
399 char *utext; 401 char *utext;
400 char *pix; 402 char *pix;
401 char *fpressedservice; 403 char *fpressedservice;
402 char *fpressedaction; 404 char *fpressedaction;
403 char *fheldservice; 405 char *fheldservice;
404 char *fheldaction; 406 char *fheldaction;
405} yopy_buttons [] = { 407} yopy_buttons [] = {
406 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), 408 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"),
407 "devicebuttons/yopy_action", 409 "devicebuttons/yopy_action",
408 "datebook", "nextView()", 410 "datebook", "nextView()",
409 "today", "raise()" }, 411 "today", "raise()" },
410 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), 412 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"),
411 "devicebuttons/yopy_ok", 413 "devicebuttons/yopy_ok",
412 "addressbook", "raise()", 414 "addressbook", "raise()",
413 "addressbook", "beamBusinessCard()" }, 415 "addressbook", "beamBusinessCard()" },
414 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), 416 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"),
415 "devicebuttons/yopy_end", 417 "devicebuttons/yopy_end",
416 "QPE/Launcher", "home()", 418 "QPE/Launcher", "home()",
417 "buttonsettings", "raise()" }, 419 "buttonsettings", "raise()" },
418}; 420};
419 421
420static QCString makeChannel ( const char *str ) 422static QCString makeChannel ( const char *str )
421{ 423{
422 if ( str && !::strchr ( str, '/' )) 424 if ( str && !::strchr ( str, '/' ))
423 return QCString ( "QPE/Application/" ) + str; 425 return QCString ( "QPE/Application/" ) + str;
424 else 426 else
425 return str; 427 return str;
426} 428}
427 429
428static inline bool isQWS() 430static inline bool isQWS()
429{ 431{
430 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 432 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
431} 433}
432 434
433ODevice *ODevice::inst ( ) 435ODevice *ODevice::inst ( )
434{ 436{
435 static ODevice *dev = 0; 437 static ODevice *dev = 0;
436 438
437 if ( !dev ) { 439 if ( !dev ) {
438 if ( QFile::exists ( "/proc/hal/model" )) 440 if ( QFile::exists ( "/proc/hal/model" ))
439 dev = new iPAQ ( ); 441 dev = new iPAQ ( );
440 else if ( Zaurus::isZaurus() ) 442 else if ( Zaurus::isZaurus() )
441 dev = new Zaurus ( ); 443 dev = new Zaurus ( );
442 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 444 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
443 dev = new SIMpad ( ); 445 dev = new SIMpad ( );
444 else if ( QFile::exists ( "/proc/sys/board/name" )) 446 else if ( QFile::exists ( "/proc/sys/board/name" ))
445 dev = new Ramses ( ); 447 dev = new Ramses ( );
446 else if ( Yopy::isYopy() ) 448 else if ( Yopy::isYopy() )
447 dev = new Yopy ( ); 449 dev = new Yopy ( );
448 else if ( Jornada::isJornada() ) 450 else if ( Jornada::isJornada() )
449 dev = new Jornada ( ); 451 dev = new Jornada ( );
450 else 452 else
451 dev = new ODevice ( ); 453 dev = new ODevice ( );
452 dev-> init ( ); 454 dev-> init ( );
453 } 455 }
454 return dev; 456 return dev;
455} 457}
456 458
457 459
458/************************************************** 460/**************************************************
459 * 461 *
460 * common 462 * common
461 * 463 *
462 **************************************************/ 464 **************************************************/
463 465
464 466
465ODevice::ODevice ( ) 467ODevice::ODevice ( )
466{ 468{
467 d = new ODeviceData; 469 d = new ODeviceData;
468 470
469 d-> m_modelstr = "Unknown"; 471 d-> m_modelstr = "Unknown";
470 d-> m_model = Model_Unknown; 472 d-> m_model = Model_Unknown;
471 d-> m_vendorstr = "Unknown"; 473 d-> m_vendorstr = "Unknown";
472 d-> m_vendor = Vendor_Unknown; 474 d-> m_vendor = Vendor_Unknown;
473 d-> m_systemstr = "Unknown"; 475 d-> m_systemstr = "Unknown";
474 d-> m_system = System_Unknown; 476 d-> m_system = System_Unknown;
475 d-> m_sysverstr = "0.0"; 477 d-> m_sysverstr = "0.0";
476 d-> m_rotation = Rot0; 478 d-> m_rotation = Rot0;
477 d-> m_direction = CW; 479 d-> m_direction = CW;
478 480
479 d-> m_holdtime = 1000; // 1000ms 481 d-> m_holdtime = 1000; // 1000ms
480 d-> m_buttons = 0; 482 d-> m_buttons = 0;
481 d-> m_cpu_frequencies = new QStrList; 483 d-> m_cpu_frequencies = new QStrList;
482} 484}
483 485
484void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 486void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
485{ 487{
486 if ( msg == "deviceButtonMappingChanged()" ) { 488 if ( msg == "deviceButtonMappingChanged()" ) {
487 reloadButtonMapping ( ); 489 reloadButtonMapping ( );
488 } 490 }
489} 491}
490 492
491void ODevice::init ( ) 493void ODevice::init ( )
492{ 494{
493} 495}
494 496
495/** 497/**
496 * This method initialises the button mapping 498 * This method initialises the button mapping
497 */ 499 */
498void ODevice::initButtons ( ) 500void ODevice::initButtons ( )
499{ 501{
500 if ( d-> m_buttons ) 502 if ( d-> m_buttons )
501 return; 503 return;
502 504
503 // Simulation uses iPAQ 3660 device buttons 505 // Simulation uses iPAQ 3660 device buttons
504 506
505 qDebug ( "init Buttons" ); 507 qDebug ( "init Buttons" );
506 d-> m_buttons = new QValueList <ODeviceButton>; 508 d-> m_buttons = new QValueList <ODeviceButton>;
507 509
508 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 510 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
509 i_button *ib = ipaq_buttons + i; 511 i_button *ib = ipaq_buttons + i;
510 ODeviceButton b; 512 ODeviceButton b;
511 513
512 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 514 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
513 b. setKeycode ( ib-> code ); 515 b. setKeycode ( ib-> code );
514 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 516 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
515 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 517 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
516 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 518 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
517 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 519 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
518 d-> m_buttons-> append ( b ); 520 d-> m_buttons-> append ( b );
519 } 521 }
520 } 522 }
521 reloadButtonMapping ( ); 523 reloadButtonMapping ( );
522 524
523 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 525 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
524 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 526 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
525} 527}
526 528
527ODevice::~ODevice ( ) 529ODevice::~ODevice ( )
528{ 530{
529// we leak m_devicebuttons and m_cpu_frequency 531// we leak m_devicebuttons and m_cpu_frequency
530// but it's a singleton and it is not so importantant 532// but it's a singleton and it is not so importantant
531// -zecke 533// -zecke
532 delete d; 534 delete d;
533} 535}
534 536
535bool ODevice::setSoftSuspend ( bool /*soft*/ ) 537bool ODevice::setSoftSuspend ( bool /*soft*/ )
536{ 538{
537 return false; 539 return false;
538} 540}
539 541
540//#include <linux/apm_bios.h> 542//#include <linux/apm_bios.h>
541 543
542#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 544#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
543 545
544/** 546/**
545 * This method will try to suspend the device 547 * This method will try to suspend the device
546 * It only works if the user is the QWS Server and the apm application 548 * It only works if the user is the QWS Server and the apm application
547 * is installed. 549 * is installed.
548 * It tries to suspend and then waits some time cause some distributions 550 * It tries to suspend and then waits some time cause some distributions
549 * do have asynchronus apm implementations. 551 * do have asynchronus apm implementations.
550 * This method will either fail and return false or it'll suspend the 552 * This method will either fail and return false or it'll suspend the
551 * device and return once the device got woken up 553 * device and return once the device got woken up
552 * 554 *
553 * @return if the device got suspended 555 * @return if the device got suspended
554 */ 556 */
555bool ODevice::suspend ( ) 557bool ODevice::suspend ( )
556{ 558{
557 qDebug("ODevice::suspend"); 559 qDebug("ODevice::suspend");
558 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 560 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
559 return false; 561 return false;
560 562
561 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 563 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
562 return false; 564 return false;
563 565
564 bool res = false; 566 bool res = false;
565 567
566 struct timeval tvs, tvn; 568 struct timeval tvs, tvn;
567 ::gettimeofday ( &tvs, 0 ); 569 ::gettimeofday ( &tvs, 0 );
568 570
569 ::sync ( ); // flush fs caches 571 ::sync ( ); // flush fs caches
570 res = ( ::system ( "apm --suspend" ) == 0 ); 572 res = ( ::system ( "apm --suspend" ) == 0 );
571 573
572 // This is needed because the iPAQ apm implementation is asynchronous and we 574 // This is needed because the iPAQ apm implementation is asynchronous and we
573 // can not be sure when exactly the device is really suspended 575 // can not be sure when exactly the device is really suspended
574 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 576 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
575 577
576 if ( res ) { 578 if ( res ) {
577 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 579 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
578 ::usleep ( 200 * 1000 ); 580 ::usleep ( 200 * 1000 );
579 ::gettimeofday ( &tvn, 0 ); 581 ::gettimeofday ( &tvn, 0 );
580 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 582 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
581 } 583 }
582 584
583 return res; 585 return res;
584} 586}
585 587
586//#include <linux/fb.h> better not rely on kernel headers in userspace ... 588//#include <linux/fb.h> better not rely on kernel headers in userspace ...
587 589
588#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 590#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
589 591
590/* VESA Blanking Levels */ 592/* VESA Blanking Levels */
591#define VESA_NO_BLANKING 0 593#define VESA_NO_BLANKING 0
592#define VESA_VSYNC_SUSPEND 1 594#define VESA_VSYNC_SUSPEND 1
593#define VESA_HSYNC_SUSPEND 2 595#define VESA_HSYNC_SUSPEND 2
594#define VESA_POWERDOWN 3 596#define VESA_POWERDOWN 3
595 597
596/** 598/**
597 * This sets the display on or off 599 * This sets the display on or off
598 */ 600 */
599bool ODevice::setDisplayStatus ( bool on ) 601bool ODevice::setDisplayStatus ( bool on )
600{ 602{
601 qDebug("ODevice::setDisplayStatus(%d)", on); 603 qDebug("ODevice::setDisplayStatus(%d)", on);
602 604
603 if ( d-> m_model == Model_Unknown ) 605 if ( d-> m_model == Model_Unknown )
604 return false; 606 return false;
605 607
606 bool res = false; 608 bool res = false;
607 int fd; 609 int fd;
608 610
609 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 611 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
610 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 612 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
611 ::close ( fd ); 613 ::close ( fd );
612 } 614 }
613 return res; 615 return res;
614} 616}
615 617
616/** 618/**
617 * This sets the display brightness 619 * This sets the display brightness
618 * 620 *
619 * @param p The brightness to be set on a scale from 0 to 255 621 * @param p The brightness to be set on a scale from 0 to 255
620 * @return success or failure 622 * @return success or failure
621 */ 623 */
622bool ODevice::setDisplayBrightness ( int p) 624bool ODevice::setDisplayBrightness ( int p)
623{ 625{
624 Q_UNUSED( p ) 626 Q_UNUSED( p )
625 return false; 627 return false;
626} 628}
627 629
628/** 630/**
629 * @return returns the number of steppings on the brightness slider 631 * @return returns the number of steppings on the brightness slider
630 * in the Light-'n-Power settings. 632 * in the Light-'n-Power settings.
631 */ 633 */
632int ODevice::displayBrightnessResolution ( ) const 634int ODevice::displayBrightnessResolution ( ) const
633{ 635{
634 return 16; 636 return 16;
635} 637}
636 638
637/** 639/**
638 * This sets the display contrast 640 * This sets the display contrast
639 * @param p The contrast to be set on a scale from 0 to 255 641 * @param p The contrast to be set on a scale from 0 to 255
640 * @return success or failure 642 * @return success or failure
641 */ 643 */
642bool ODevice::setDisplayContrast ( int p) 644bool ODevice::setDisplayContrast ( int p)
643{ 645{
644 Q_UNUSED( p ) 646 Q_UNUSED( p )
645 return false; 647 return false;
646} 648}
647 649
648/** 650/**
649 * @return return the max value for the brightness settings slider 651 * @return return the max value for the brightness settings slider
650 * or 0 if the device doesn't support setting of a contrast 652 * or 0 if the device doesn't support setting of a contrast
651 */ 653 */
652int ODevice::displayContrastResolution ( ) const 654int ODevice::displayContrastResolution ( ) const
653{ 655{
654 return 0; 656 return 0;
655} 657}
656 658
657/** 659/**
658 * This returns the vendor as string 660 * This returns the vendor as string
659 * @return Vendor as QString 661 * @return Vendor as QString
660 */ 662 */
661QString ODevice::vendorString ( ) const 663QString ODevice::vendorString ( ) const
662{ 664{
663 return d-> m_vendorstr; 665 return d-> m_vendorstr;
664} 666}
665 667
666/** 668/**
667 * This returns the vendor as one of the values of OVendor 669 * This returns the vendor as one of the values of OVendor
668 * @return OVendor 670 * @return OVendor
669 */ 671 */
670OVendor ODevice::vendor ( ) const 672OVendor ODevice::vendor ( ) const
671{ 673{
672 return d-> m_vendor; 674 return d-> m_vendor;
673} 675}
674 676
675/** 677/**
676 * This returns the model as a string 678 * This returns the model as a string
677 * @return A string representing the model 679 * @return A string representing the model
678 */ 680 */
679QString ODevice::modelString ( ) const 681QString ODevice::modelString ( ) const
680{ 682{
681 return d-> m_modelstr; 683 return d-> m_modelstr;
682} 684}
683 685
684/** 686/**
685 * This does return the OModel used 687 * This does return the OModel used
686 */ 688 */
687OModel ODevice::model ( ) const 689OModel ODevice::model ( ) const
688{ 690{
689 return d-> m_model; 691 return d-> m_model;
690} 692}
691 693
692/** 694/**
693 * This does return the systen name 695 * This does return the systen name
694 */ 696 */
695QString ODevice::systemString ( ) const 697QString ODevice::systemString ( ) const
696{ 698{
697 return d-> m_systemstr; 699 return d-> m_systemstr;
698} 700}
699 701
700/** 702/**
701 * Return System as OSystem value 703 * Return System as OSystem value
702 */ 704 */
703OSystem ODevice::system ( ) const 705OSystem ODevice::system ( ) const
704{ 706{
705 return d-> m_system; 707 return d-> m_system;
706} 708}
707 709
708/** 710/**
709 * @return the version string of the base system 711 * @return the version string of the base system
710 */ 712 */
711QString ODevice::systemVersionString ( ) const 713QString ODevice::systemVersionString ( ) const
712{ 714{
713 return d-> m_sysverstr; 715 return d-> m_sysverstr;
714} 716}
715 717
716/** 718/**
717 * @return the current Transformation 719 * @return the current Transformation
718 */ 720 */
719Transformation ODevice::rotation ( ) const 721Transformation ODevice::rotation ( ) const
720{ 722{
721 return d-> m_rotation; 723 return d-> m_rotation;
722} 724}
723 725
724/** 726/**
725 * @return the current rotation direction 727 * @return the current rotation direction
726 */ 728 */
727ODirection ODevice::direction ( ) const 729ODirection ODevice::direction ( ) const
728{ 730{
729 return d-> m_direction; 731 return d-> m_direction;
730} 732}
731 733
732/** 734/**
733 * This plays an alarmSound 735 * This plays an alarmSound
734 */ 736 */
735void ODevice::alarmSound ( ) 737void ODevice::alarmSound ( )
736{ 738{
737#ifndef QT_NO_SOUND 739#ifndef QT_NO_SOUND
738 static Sound snd ( "alarm" ); 740 static Sound snd ( "alarm" );
739 741
740 if ( snd. isFinished ( )) 742 if ( snd. isFinished ( ))
741 snd. play ( ); 743 snd. play ( );
742#endif 744#endif
743} 745}
744 746
745/** 747/**
746 * This plays a key sound 748 * This plays a key sound
747 */ 749 */
748void ODevice::keySound ( ) 750void ODevice::keySound ( )
749{ 751{
750#ifndef QT_NO_SOUND 752#ifndef QT_NO_SOUND
751 static Sound snd ( "keysound" ); 753 static Sound snd ( "keysound" );
752 754
753 if ( snd. isFinished ( )) 755 if ( snd. isFinished ( ))
754 snd. play ( ); 756 snd. play ( );
755#endif 757#endif
756} 758}
757 759
758/** 760/**
759 * This plays a touch sound 761 * This plays a touch sound
760 */ 762 */
761void ODevice::touchSound ( ) 763void ODevice::touchSound ( )
762{ 764{
763#ifndef QT_NO_SOUND 765#ifndef QT_NO_SOUND
764 static Sound snd ( "touchsound" ); 766 static Sound snd ( "touchsound" );
765 767
766 if ( snd. isFinished ( )) 768 if ( snd. isFinished ( ))
767 snd. play ( ); 769 snd. play ( );
768#endif 770#endif
769} 771}
770 772
771/** 773/**
772 * This method will return a list of leds 774 * This method will return a list of leds
773 * available on this device 775 * available on this device
774 * @return a list of LEDs. 776 * @return a list of LEDs.
775 */ 777 */
776QValueList <OLed> ODevice::ledList ( ) const 778QValueList <OLed> ODevice::ledList ( ) const
777{ 779{
778 return QValueList <OLed> ( ); 780 return QValueList <OLed> ( );
779} 781}
780 782
781/** 783/**
782 * This does return the state of the LEDs 784 * This does return the state of the LEDs
783 */ 785 */
784QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 786QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
785{ 787{
786 return QValueList <OLedState> ( ); 788 return QValueList <OLedState> ( );
787} 789}
788 790
789/** 791/**
790 * @return the state for a given OLed 792 * @return the state for a given OLed
791 */ 793 */
792OLedState ODevice::ledState ( OLed /*which*/ ) const 794OLedState ODevice::ledState ( OLed /*which*/ ) const
793{ 795{
794 return Led_Off; 796 return Led_Off;
795} 797}
796 798
797/** 799/**
798 * Set the state for a LED 800 * Set the state for a LED
799 * @param which Which OLed to use 801 * @param which Which OLed to use
800 * @param st The state to set 802 * @param st The state to set
801 * @return success or failure 803 * @return success or failure
802 */ 804 */
803bool ODevice::setLedState ( OLed which, OLedState st ) 805bool ODevice::setLedState ( OLed which, OLedState st )
804{ 806{
805 Q_UNUSED( which ) 807 Q_UNUSED( which )
806 Q_UNUSED( st ) 808 Q_UNUSED( st )
807 return false; 809 return false;
808} 810}
809 811
810/** 812/**
811 * @return if the device has a light sensor 813 * @return if the device has a light sensor
812 */ 814 */
813bool ODevice::hasLightSensor ( ) const 815bool ODevice::hasLightSensor ( ) const
814{ 816{
815 return false; 817 return false;
816} 818}
817 819
818/** 820/**
819 * @return a value from the light senso 821 * @return a value from the light senso
820 */ 822 */
821int ODevice::readLightSensor ( ) 823int ODevice::readLightSensor ( )
822{ 824{
823 return -1; 825 return -1;
824} 826}
825 827
826/** 828/**
827 * @return the light sensor resolution whatever that is ;) 829 * @return the light sensor resolution whatever that is ;)
828 */ 830 */
829int ODevice::lightSensorResolution ( ) const 831int ODevice::lightSensorResolution ( ) const
830{ 832{
831 return 0; 833 return 0;
832} 834}
833 835
834/** 836/**
835 * @return a list with CPU frequencies supported by the hardware 837 * @return a list with CPU frequencies supported by the hardware
836 */ 838 */
837const QStrList &ODevice::allowedCpuFrequencies ( ) const 839const QStrList &ODevice::allowedCpuFrequencies ( ) const
838{ 840{
839 return *d->m_cpu_frequencies; 841 return *d->m_cpu_frequencies;
840} 842}
841 843
842 844
843/** 845/**
844 * Set desired CPU frequency 846 * Set desired CPU frequency
845 * 847 *
846 * @param index index into d->m_cpu_frequencies of the frequency to be set 848 * @param index index into d->m_cpu_frequencies of the frequency to be set
847 */ 849 */
848bool ODevice::setCurrentCpuFrequency(uint index) 850bool ODevice::setCurrentCpuFrequency(uint index)
849{ 851{
850 if (index >= d->m_cpu_frequencies->count()) 852 if (index >= d->m_cpu_frequencies->count())
851 return false; 853 return false;
852 854
853 char *freq = d->m_cpu_frequencies->at(index); 855 char *freq = d->m_cpu_frequencies->at(index);
854 qWarning("set freq to %s", freq); 856 qWarning("set freq to %s", freq);
855 857
856 int fd; 858 int fd;
857 859
858 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { 860 if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) {
859 char writeCommand[50]; 861 char writeCommand[50];
860 const int count = sprintf(writeCommand, "%s\n", freq); 862 const int count = sprintf(writeCommand, "%s\n", freq);
861 int res = (::write(fd, writeCommand, count) != -1); 863 int res = (::write(fd, writeCommand, count) != -1);
862 ::close(fd); 864 ::close(fd);
863 return res; 865 return res;
864 } 866 }
865 867
866 return false; 868 return false;
867} 869}
868 870
869 871
870/** 872/**
871 * @return a list of hardware buttons 873 * @return a list of hardware buttons
872 */ 874 */
873const QValueList <ODeviceButton> &ODevice::buttons ( ) 875const QValueList <ODeviceButton> &ODevice::buttons ( )
874{ 876{
875 initButtons ( ); 877 initButtons ( );
876 878
877 return *d-> m_buttons; 879 return *d-> m_buttons;
878} 880}
879 881
880/** 882/**
881 * @return The amount of time that would count as a hold 883 * @return The amount of time that would count as a hold
882 */ 884 */
883uint ODevice::buttonHoldTime ( ) const 885uint ODevice::buttonHoldTime ( ) const
884{ 886{
885 return d-> m_holdtime; 887 return d-> m_holdtime;
886} 888}
887 889
888/** 890/**
889 * This method return a ODeviceButton for a key code 891 * This method return a ODeviceButton for a key code
890 * or 0 if no special hardware button is available for the device 892 * or 0 if no special hardware button is available for the device
891 * 893 *
892 * @return The devicebutton or 0l 894 * @return The devicebutton or 0l
893 * @see ODeviceButton 895 * @see ODeviceButton
894 */ 896 */
895const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 897const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
896{ 898{
897 initButtons ( ); 899 initButtons ( );
898 900
899 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 901 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
900 if ( (*it). keycode ( ) == code ) 902 if ( (*it). keycode ( ) == code )
901 return &(*it); 903 return &(*it);
902 } 904 }
903 return 0; 905 return 0;
904} 906}
905 907
906void ODevice::reloadButtonMapping ( ) 908void ODevice::reloadButtonMapping ( )
907{ 909{
908 initButtons ( ); 910 initButtons ( );
909 911
910 Config cfg ( "ButtonSettings" ); 912 Config cfg ( "ButtonSettings" );
911 913
912 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 914 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
913 ODeviceButton &b = ( *d-> m_buttons ) [i]; 915 ODeviceButton &b = ( *d-> m_buttons ) [i];
914 QString group = "Button" + QString::number ( i ); 916 QString group = "Button" + QString::number ( i );
915 917
916 QCString pch, hch; 918 QCString pch, hch;
917 QCString pm, hm; 919 QCString pm, hm;
918 QByteArray pdata, hdata; 920 QByteArray pdata, hdata;
919 921
920 if ( cfg. hasGroup ( group )) { 922 if ( cfg. hasGroup ( group )) {
921 cfg. setGroup ( group ); 923 cfg. setGroup ( group );
922 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 924 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
923 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 925 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
924 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 926 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
925 927
926 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 928 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
927 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 929 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
928 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 930 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
929 } 931 }
930 932
931 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 933 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
932 934
933 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 935 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
934 } 936 }
935} 937}
936 938
937void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 939void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
938{ 940{
939 initButtons ( ); 941 initButtons ( );
940 942
941 QString mb_chan; 943 QString mb_chan;
942 944
943 if ( button >= (int) d-> m_buttons-> count ( )) 945 if ( button >= (int) d-> m_buttons-> count ( ))
944 return; 946 return;
945 947
946 ODeviceButton &b = ( *d-> m_buttons ) [button]; 948 ODeviceButton &b = ( *d-> m_buttons ) [button];
947 b. setPressedAction ( action ); 949 b. setPressedAction ( action );
948 950
949 mb_chan=b. pressedAction ( ). channel ( ); 951 mb_chan=b. pressedAction ( ). channel ( );
950 952
951 Config buttonFile ( "ButtonSettings" ); 953 Config buttonFile ( "ButtonSettings" );
952 buttonFile. setGroup ( "Button" + QString::number ( button )); 954 buttonFile. setGroup ( "Button" + QString::number ( button ));
953 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 955 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
954 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 956 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
955 957
956 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 958 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
957 959
958 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 960 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
959} 961}
960 962
961void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 963void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
962{ 964{
963 initButtons ( ); 965 initButtons ( );
964 966
965 if ( button >= (int) d-> m_buttons-> count ( )) 967 if ( button >= (int) d-> m_buttons-> count ( ))
966 return; 968 return;
967 969
968 ODeviceButton &b = ( *d-> m_buttons ) [button]; 970 ODeviceButton &b = ( *d-> m_buttons ) [button];
969 b. setHeldAction ( action ); 971 b. setHeldAction ( action );
970 972
971 Config buttonFile ( "ButtonSettings" ); 973 Config buttonFile ( "ButtonSettings" );
972 buttonFile. setGroup ( "Button" + QString::number ( button )); 974 buttonFile. setGroup ( "Button" + QString::number ( button ));
973 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 975 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
974 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 976 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
975 977
976 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 978 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
977 979
978 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 980 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
979} 981}
980void ODevice::virtual_hook(int, void* ){ 982void ODevice::virtual_hook(int, void* ){
981 983
982} 984}
983 985
984/************************************************** 986/**************************************************
985 * 987 *
986 * Yopy 3500/3700 988 * Yopy 3500/3700
987 * 989 *
988 **************************************************/ 990 **************************************************/
989 991
990bool Yopy::isYopy ( ) 992bool Yopy::isYopy ( )
991{ 993{
992 QFile f( "/proc/cpuinfo" ); 994 QFile f( "/proc/cpuinfo" );
993 if ( f. open ( IO_ReadOnly ) ) { 995 if ( f. open ( IO_ReadOnly ) ) {
994 QTextStream ts ( &f ); 996 QTextStream ts ( &f );
995 QString line; 997 QString line;
996 while( line = ts. readLine ( ) ) { 998 while( line = ts. readLine ( ) ) {
997 if ( line. left ( 8 ) == "Hardware" ) { 999 if ( line. left ( 8 ) == "Hardware" ) {
998 int loc = line. find ( ":" ); 1000 int loc = line. find ( ":" );
999 if ( loc != -1 ) { 1001 if ( loc != -1 ) {
1000 QString model = 1002 QString model =
1001 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1003 line. mid ( loc + 2 ). simplifyWhiteSpace( );
1002 return ( model == "Yopy" ); 1004 return ( model == "Yopy" );
1003 } 1005 }
1004 } 1006 }
1005 } 1007 }
1006 } 1008 }
1007 return false; 1009 return false;
1008} 1010}
1009 1011
1010void Yopy::init ( ) 1012void Yopy::init ( )
1011{ 1013{
1012 d-> m_vendorstr = "G.Mate"; 1014 d-> m_vendorstr = "G.Mate";
1013 d-> m_vendor = Vendor_GMate; 1015 d-> m_vendor = Vendor_GMate;
1014 d-> m_modelstr = "Yopy3700"; 1016 d-> m_modelstr = "Yopy3700";
1015 d-> m_model = Model_Yopy_3700; 1017 d-> m_model = Model_Yopy_3700;
1016 d-> m_rotation = Rot0; 1018 d-> m_rotation = Rot0;
1017 1019
1018 d-> m_systemstr = "Linupy"; 1020 d-> m_systemstr = "Linupy";
1019 d-> m_system = System_Linupy; 1021 d-> m_system = System_Linupy;
1020 1022
1021 QFile f ( "/etc/issue" ); 1023 QFile f ( "/etc/issue" );
1022 if ( f. open ( IO_ReadOnly )) { 1024 if ( f. open ( IO_ReadOnly )) {
1023 QTextStream ts ( &f ); 1025 QTextStream ts ( &f );
1024 ts.readLine(); 1026 ts.readLine();
1025 d-> m_sysverstr = ts. readLine ( ); 1027 d-> m_sysverstr = ts. readLine ( );
1026 f. close ( ); 1028 f. close ( );
1027 } 1029 }
1028} 1030}
1029 1031
1030void Yopy::initButtons ( ) 1032void Yopy::initButtons ( )
1031{ 1033{
1032 if ( d-> m_buttons ) 1034 if ( d-> m_buttons )
1033 return; 1035 return;
1034 1036
1035 d-> m_buttons = new QValueList <ODeviceButton>; 1037 d-> m_buttons = new QValueList <ODeviceButton>;
1036 1038
1037 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { 1039 for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) {
1038 1040
1039 yopy_button *ib = yopy_buttons + i; 1041 yopy_button *ib = yopy_buttons + i;
1040 1042
1041 ODeviceButton b; 1043 ODeviceButton b;
1042 1044
1043 b. setKeycode ( ib-> code ); 1045 b. setKeycode ( ib-> code );
1044 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1046 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1045 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1047 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1046 b. setFactoryPresetPressedAction 1048 b. setFactoryPresetPressedAction
1047 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); 1049 (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction));
1048 b. setFactoryPresetHeldAction 1050 b. setFactoryPresetHeldAction
1049 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); 1051 (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction));
1050 1052
1051 d-> m_buttons-> append ( b ); 1053 d-> m_buttons-> append ( b );
1052 } 1054 }
1053 reloadButtonMapping ( ); 1055 reloadButtonMapping ( );
1054 1056
1055 QCopChannel *sysch = new QCopChannel("QPE/System", this); 1057 QCopChannel *sysch = new QCopChannel("QPE/System", this);
1056 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )), 1058 connect(sysch, SIGNAL(received(const QCString &, const QByteArray & )),
1057 this, SLOT(systemMessage(const QCString &, const QByteArray & ))); 1059 this, SLOT(systemMessage(const QCString &, const QByteArray & )));
1058} 1060}
1059 1061
1060bool Yopy::suspend() 1062bool Yopy::suspend()
1061{ 1063{
1062 /* Opie for Yopy does not implement its own power management at the 1064 /* Opie for Yopy does not implement its own power management at the
1063 moment. The public version runs parallel to X, and relies on the 1065 moment. The public version runs parallel to X, and relies on the
1064 existing power management features. */ 1066 existing power management features. */
1065 return false; 1067 return false;
1066} 1068}
1067 1069
1068bool Yopy::setDisplayBrightness(int bright) 1070bool Yopy::setDisplayBrightness(int bright)
1069{ 1071{
1070 /* The code here works, but is disabled as the current version runs 1072 /* The code here works, but is disabled as the current version runs
1071 parallel to X, and relies on the existing backlight demon. */ 1073 parallel to X, and relies on the existing backlight demon. */
1072#if 0 1074#if 0
1073 if ( QFile::exists("/proc/sys/pm/light") ) { 1075 if ( QFile::exists("/proc/sys/pm/light") ) {
1074 int fd = ::open("/proc/sys/pm/light", O_WRONLY); 1076 int fd = ::open("/proc/sys/pm/light", O_WRONLY);
1075 if (fd >= 0 ) { 1077 if (fd >= 0 ) {
1076 if (bright) 1078 if (bright)
1077 ::write(fd, "1\n", 2); 1079 ::write(fd, "1\n", 2);
1078 else 1080 else
1079 ::write(fd, "0\n", 2); 1081 ::write(fd, "0\n", 2);
1080 ::close(fd); 1082 ::close(fd);
1081 return true; 1083 return true;
1082 } 1084 }
1083 } 1085 }
1084#endif 1086#endif
1085 return false; 1087 return false;
1086} 1088}
1087 1089
1088int Yopy::displayBrightnessResolution() const 1090int Yopy::displayBrightnessResolution() const
1089{ 1091{
1090 return 2; 1092 return 2;
1091} 1093}
1092 1094
1093/************************************************** 1095/**************************************************
1094 * 1096 *
1095 * iPAQ 1097 * iPAQ
1096 * 1098 *
1097 **************************************************/ 1099 **************************************************/
1098 1100
1099void iPAQ::init ( ) 1101void iPAQ::init ( )
1100{ 1102{
1101 d-> m_vendorstr = "HP"; 1103 d-> m_vendorstr = "HP";
1102 d-> m_vendor = Vendor_HP; 1104 d-> m_vendor = Vendor_HP;
1103 1105
1104 QFile f ( "/proc/hal/model" ); 1106 QFile f ( "/proc/hal/model" );
1105 1107
1106 if ( f. open ( IO_ReadOnly )) { 1108 if ( f. open ( IO_ReadOnly )) {
1107 QTextStream ts ( &f ); 1109 QTextStream ts ( &f );
1108 1110
1109 d-> m_modelstr = "H" + ts. readLine ( ); 1111 d-> m_modelstr = "H" + ts. readLine ( );
1110 1112
1111 if ( d-> m_modelstr == "H3100" ) 1113 if ( d-> m_modelstr == "H3100" )
1112 d-> m_model = Model_iPAQ_H31xx; 1114 d-> m_model = Model_iPAQ_H31xx;
1113 else if ( d-> m_modelstr == "H3600" ) 1115 else if ( d-> m_modelstr == "H3600" )
1114 d-> m_model = Model_iPAQ_H36xx; 1116 d-> m_model = Model_iPAQ_H36xx;
1115 else if ( d-> m_modelstr == "H3700" ) 1117 else if ( d-> m_modelstr == "H3700" )
1116 d-> m_model = Model_iPAQ_H37xx; 1118 d-> m_model = Model_iPAQ_H37xx;
1117 else if ( d-> m_modelstr == "H3800" ) 1119 else if ( d-> m_modelstr == "H3800" )
1118 d-> m_model = Model_iPAQ_H38xx; 1120 d-> m_model = Model_iPAQ_H38xx;
1119 else if ( d-> m_modelstr == "H3900" ) 1121 else if ( d-> m_modelstr == "H3900" )
1120 d-> m_model = Model_iPAQ_H39xx; 1122 d-> m_model = Model_iPAQ_H39xx;
1121 else if ( d-> m_modelstr == "H5400" ) 1123 else if ( d-> m_modelstr == "H5400" )
1122 d-> m_model = Model_iPAQ_H5xxx; 1124 d-> m_model = Model_iPAQ_H5xxx;
1123 else 1125 else
1124 d-> m_model = Model_Unknown; 1126 d-> m_model = Model_Unknown;
1125 1127
1126 f. close ( ); 1128 f. close ( );
1127 } 1129 }
1128 1130
1129 switch ( d-> m_model ) { 1131 switch ( d-> m_model ) {
1130 case Model_iPAQ_H31xx: 1132 case Model_iPAQ_H31xx:
1131 case Model_iPAQ_H38xx: 1133 case Model_iPAQ_H38xx:
1132 d-> m_rotation = Rot90; 1134 d-> m_rotation = Rot90;
1133 break; 1135 break;
1134 case Model_iPAQ_H36xx: 1136 case Model_iPAQ_H36xx:
1135 case Model_iPAQ_H37xx: 1137 case Model_iPAQ_H37xx:
1136 case Model_iPAQ_H39xx: 1138 case Model_iPAQ_H39xx:
1137 default: 1139 default:
1138 d-> m_rotation = Rot270; 1140 d-> m_rotation = Rot270;
1139 break; 1141 break;
1140 case Model_iPAQ_H5xxx: 1142 case Model_iPAQ_H5xxx:
1141 d-> m_rotation = Rot0; 1143 d-> m_rotation = Rot0;
1142 } 1144 }
1143 1145
1144 f. setName ( "/etc/familiar-version" ); 1146 f. setName ( "/etc/familiar-version" );
1145 if ( f. open ( IO_ReadOnly )) { 1147 if ( f. open ( IO_ReadOnly )) {
1146 d-> m_systemstr = "Familiar"; 1148 d-> m_systemstr = "Familiar";
1147 d-> m_system = System_Familiar; 1149 d-> m_system = System_Familiar;
1148 1150
1149 QTextStream ts ( &f ); 1151 QTextStream ts ( &f );
1150 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1152 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1151 1153
1152 f. close ( ); 1154 f. close ( );
1153 } else { 1155 } else {
1154 f. setName ( "/etc/oz_version" ); 1156 f. setName ( "/etc/oz_version" );
1155 1157
1156 if ( f. open ( IO_ReadOnly )) { 1158 if ( f. open ( IO_ReadOnly )) {
1157 d-> m_systemstr = "OpenEmbedded/iPaq"; 1159 d-> m_systemstr = "OpenEmbedded/iPaq";
1158 d-> m_system = System_Familiar; 1160 d-> m_system = System_Familiar;
1159 1161
1160 QTextStream ts ( &f ); 1162 QTextStream ts ( &f );
1161 ts.setDevice ( &f ); 1163 ts.setDevice ( &f );
1162 d-> m_sysverstr = ts. readLine ( ); 1164 d-> m_sysverstr = ts. readLine ( );
1163 f. close ( ); 1165 f. close ( );
1164 } 1166 }
1165 } 1167 }
1166 1168
1167 1169
1168 1170
1169 1171
1170 1172
1171 m_leds [0] = m_leds [1] = Led_Off; 1173 m_leds [0] = m_leds [1] = Led_Off;
1172 1174
1173 m_power_timer = 0; 1175 m_power_timer = 0;
1174 1176
1175} 1177}
1176 1178
1177void iPAQ::initButtons ( ) 1179void iPAQ::initButtons ( )
1178{ 1180{
1179 if ( d-> m_buttons ) 1181 if ( d-> m_buttons )
1180 return; 1182 return;
1181 1183
1182 if ( isQWS( ) ) 1184 if ( isQWS( ) )
1183 QWSServer::setKeyboardFilter ( this ); 1185 QWSServer::setKeyboardFilter ( this );
1184 1186
1185 d-> m_buttons = new QValueList <ODeviceButton>; 1187 d-> m_buttons = new QValueList <ODeviceButton>;
1186 1188
1187 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 1189 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
1188 i_button *ib = ipaq_buttons + i; 1190 i_button *ib = ipaq_buttons + i;
1189 ODeviceButton b; 1191 ODeviceButton b;
1190 1192
1191 if (( ib-> model & d-> m_model ) == d-> m_model ) { 1193 if (( ib-> model & d-> m_model ) == d-> m_model ) {
1192 b. setKeycode ( ib-> code ); 1194 b. setKeycode ( ib-> code );
1193 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 1195 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
1194 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 1196 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
1195 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 1197 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
1196 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 1198 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
1197 1199
1198 d-> m_buttons-> append ( b ); 1200 d-> m_buttons-> append ( b );
1199 } 1201 }
1200 } 1202 }
1201 reloadButtonMapping ( ); 1203 reloadButtonMapping ( );
1202 1204
1203 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1205 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1204 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1206 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1205} 1207}
1206 1208
1207 1209
1208//#include <linux/h3600_ts.h> // including kernel headers is evil ... 1210//#include <linux/h3600_ts.h> // including kernel headers is evil ...
1209 1211
1210typedef struct { 1212typedef struct {
1211 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 1213 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
1212 unsigned char TotalTime; /* Units of 5 seconds */ 1214 unsigned char TotalTime; /* Units of 5 seconds */
1213 unsigned char OnTime; /* units of 100m/s */ 1215 unsigned char OnTime; /* units of 100m/s */
1214 unsigned char OffTime; /* units of 100m/s */ 1216 unsigned char OffTime; /* units of 100m/s */
1215} LED_IN; 1217} LED_IN;
1216 1218
1217typedef struct { 1219typedef struct {
1218 unsigned char mode; 1220 unsigned char mode;
1219 unsigned char pwr; 1221 unsigned char pwr;
1220 unsigned char brightness; 1222 unsigned char brightness;
1221} FLITE_IN; 1223} FLITE_IN;
1222 1224
1223#define LED_ON OD_IOW( 'f', 5, LED_IN ) 1225#define LED_ON OD_IOW( 'f', 5, LED_IN )
1224#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 1226#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
1225 1227
1226 1228
1227QValueList <OLed> iPAQ::ledList ( ) const 1229QValueList <OLed> iPAQ::ledList ( ) const
1228{ 1230{
1229 QValueList <OLed> vl; 1231 QValueList <OLed> vl;
1230 vl << Led_Power; 1232 vl << Led_Power;
1231 1233
1232 if ( d-> m_model == Model_iPAQ_H38xx ) 1234 if ( d-> m_model == Model_iPAQ_H38xx )
1233 vl << Led_BlueTooth; 1235 vl << Led_BlueTooth;
1234 return vl; 1236 return vl;
1235} 1237}
1236 1238
1237QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 1239QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
1238{ 1240{
1239 QValueList <OLedState> vl; 1241 QValueList <OLedState> vl;
1240 1242
1241 if ( l == Led_Power ) 1243 if ( l == Led_Power )
1242 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 1244 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
1243 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 1245 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
1244 vl << Led_Off; // << Led_On << ??? 1246 vl << Led_Off; // << Led_On << ???
1245 1247
1246 return vl; 1248 return vl;
1247} 1249}
1248 1250
1249OLedState iPAQ::ledState ( OLed l ) const 1251OLedState iPAQ::ledState ( OLed l ) const
1250{ 1252{
1251 switch ( l ) { 1253 switch ( l ) {
1252 case Led_Power: 1254 case Led_Power:
1253 return m_leds [0]; 1255 return m_leds [0];
1254 case Led_BlueTooth: 1256 case Led_BlueTooth:
1255 return m_leds [1]; 1257 return m_leds [1];
1256 default: 1258 default:
1257 return Led_Off; 1259 return Led_Off;
1258 } 1260 }
1259} 1261}
1260 1262
1261bool iPAQ::setLedState ( OLed l, OLedState st ) 1263bool iPAQ::setLedState ( OLed l, OLedState st )
1262{ 1264{
1263 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 1265 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
1264 1266
1265 if ( l == Led_Power ) { 1267 if ( l == Led_Power ) {
1266 if ( fd >= 0 ) { 1268 if ( fd >= 0 ) {
1267 LED_IN leds; 1269 LED_IN leds;
1268 ::memset ( &leds, 0, sizeof( leds )); 1270 ::memset ( &leds, 0, sizeof( leds ));
1269 leds. TotalTime = 0; 1271 leds. TotalTime = 0;
1270 leds. OnTime = 0; 1272 leds. OnTime = 0;
1271 leds. OffTime = 1; 1273 leds. OffTime = 1;
1272 leds. OffOnBlink = 2; 1274 leds. OffOnBlink = 2;
1273 1275
1274 switch ( st ) { 1276 switch ( st ) {
1275 case Led_Off : leds. OffOnBlink = 0; break; 1277 case Led_Off : leds. OffOnBlink = 0; break;
1276 case Led_On : leds. OffOnBlink = 1; break; 1278 case Led_On : leds. OffOnBlink = 1; break;
1277 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1279 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1278 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1280 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1279 } 1281 }
1280 1282
1281 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 1283 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
1282 m_leds [0] = st; 1284 m_leds [0] = st;
1283 return true; 1285 return true;
1284 } 1286 }
1285 } 1287 }
1286 } 1288 }
1287 return false; 1289 return false;
1288} 1290}
1289 1291
1290 1292
1291bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1293bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1292{ 1294{
1293 int newkeycode = keycode; 1295 int newkeycode = keycode;
1294 1296
1295 switch ( keycode ) { 1297 switch ( keycode ) {
1296 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1298 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
1297 case HardKey_Menu: { 1299 case HardKey_Menu: {
1298 if (( d-> m_model == Model_iPAQ_H38xx ) || 1300 if (( d-> m_model == Model_iPAQ_H38xx ) ||
1299 ( d-> m_model == Model_iPAQ_H39xx ) || 1301 ( d-> m_model == Model_iPAQ_H39xx ) ||
1300 ( d-> m_model == Model_iPAQ_H5xxx)) { 1302 ( d-> m_model == Model_iPAQ_H5xxx)) {
1301 newkeycode = HardKey_Mail; 1303 newkeycode = HardKey_Mail;
1302 } 1304 }
1303 break; 1305 break;
1304 } 1306 }
1305 1307
1306 // Rotate cursor keys 180° 1308 // Rotate cursor keys 180°
1307 case Key_Left : 1309 case Key_Left :
1308 case Key_Right: 1310 case Key_Right:
1309 case Key_Up : 1311 case Key_Up :
1310 case Key_Down : { 1312 case Key_Down : {
1311 if (( d-> m_model == Model_iPAQ_H31xx ) || 1313 if (( d-> m_model == Model_iPAQ_H31xx ) ||
1312 ( d-> m_model == Model_iPAQ_H38xx )) { 1314 ( d-> m_model == Model_iPAQ_H38xx )) {
1313 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1315 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
1314 } 1316 }
1315 break; 1317 break;
1316 } 1318 }
1317 1319
1318 // map Power Button short/long press to F34/F35 1320 // map Power Button short/long press to F34/F35
1319 case Key_SysReq: { 1321 case Key_SysReq: {
1320 if ( isPress ) { 1322 if ( isPress ) {
1321 if ( m_power_timer ) 1323 if ( m_power_timer )
1322 killTimer ( m_power_timer ); 1324 killTimer ( m_power_timer );
1323 m_power_timer = startTimer ( 500 ); 1325 m_power_timer = startTimer ( 500 );
1324 } 1326 }
1325 else if ( m_power_timer ) { 1327 else if ( m_power_timer ) {
1326 killTimer ( m_power_timer ); 1328 killTimer ( m_power_timer );
1327 m_power_timer = 0; 1329 m_power_timer = 0;
1328 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1330 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1329 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1331 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1330 } 1332 }
1331 newkeycode = Key_unknown; 1333 newkeycode = Key_unknown;
1332 break; 1334 break;
1333 } 1335 }
1334 } 1336 }
1335 1337
1336 if ( newkeycode != keycode ) { 1338 if ( newkeycode != keycode ) {
1337 if ( newkeycode != Key_unknown ) 1339 if ( newkeycode != Key_unknown )
1338 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1340 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1339 return true; 1341 return true;
1340 } 1342 }
1341 else 1343 else
1342 return false; 1344 return false;
1343} 1345}
1344 1346
1345void iPAQ::timerEvent ( QTimerEvent * ) 1347void iPAQ::timerEvent ( QTimerEvent * )
1346{ 1348{
1347 killTimer ( m_power_timer ); 1349 killTimer ( m_power_timer );
1348 m_power_timer = 0; 1350 m_power_timer = 0;
1349 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1351 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1350 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1352 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1351} 1353}
1352 1354
1353 1355
1354void iPAQ::alarmSound ( ) 1356void iPAQ::alarmSound ( )
1355{ 1357{
1356#ifndef QT_NO_SOUND 1358#ifndef QT_NO_SOUND
1357 static Sound snd ( "alarm" ); 1359 static Sound snd ( "alarm" );
1358 int fd; 1360 int fd;
1359 int vol; 1361 int vol;
1360 bool vol_reset = false; 1362 bool vol_reset = false;
1361 1363
1362 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1364 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1363 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1365 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1364 Config cfg ( "qpe" ); 1366 Config cfg ( "qpe" );
1365 cfg. setGroup ( "Volume" ); 1367 cfg. setGroup ( "Volume" );
1366 1368
1367 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1369 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1368 if ( volalarm < 0 ) 1370 if ( volalarm < 0 )
1369 volalarm = 0; 1371 volalarm = 0;
1370 else if ( volalarm > 100 ) 1372 else if ( volalarm > 100 )
1371 volalarm = 100; 1373 volalarm = 100;
1372 volalarm |= ( volalarm << 8 ); 1374 volalarm |= ( volalarm << 8 );
1373 1375
1374 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1376 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1375 vol_reset = true; 1377 vol_reset = true;
1376 } 1378 }
1377 } 1379 }
1378 1380
1379 snd. play ( ); 1381 snd. play ( );
1380 while ( !snd. isFinished ( )) 1382 while ( !snd. isFinished ( ))
1381 qApp-> processEvents ( ); 1383 qApp-> processEvents ( );
1382 1384
1383 if ( fd >= 0 ) { 1385 if ( fd >= 0 ) {
1384 if ( vol_reset ) 1386 if ( vol_reset )
1385 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1387 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1386 ::close ( fd ); 1388 ::close ( fd );
1387 } 1389 }
1388#endif 1390#endif
1389} 1391}
1390 1392
1391 1393
1392bool iPAQ::setSoftSuspend ( bool soft ) 1394bool iPAQ::setSoftSuspend ( bool soft )
1393{ 1395{
1394 bool res = false; 1396 bool res = false;
1395 int fd; 1397 int fd;
1396 1398
1397 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1399 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1398 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1400 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1399 res = true; 1401 res = true;
1400 else 1402 else
1401 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1403 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1402 1404
1403 ::close ( fd ); 1405 ::close ( fd );
1404 } 1406 }
1405 else 1407 else
1406 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1408 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1407 1409
1408 return res; 1410 return res;
1409} 1411}
1410 1412
1411 1413
1412bool iPAQ::setDisplayBrightness ( int bright ) 1414bool iPAQ::setDisplayBrightness ( int bright )
1413{ 1415{
1414 bool res = false; 1416 bool res = false;
1415 int fd; 1417 int fd;
1416 1418
1417 if ( bright > 255 ) 1419 if ( bright > 255 )
1418 bright = 255; 1420 bright = 255;
1419 if ( bright < 0 ) 1421 if ( bright < 0 )
1420 bright = 0; 1422 bright = 0;
1421 1423
1422 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1424 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1423 FLITE_IN bl; 1425 FLITE_IN bl;
1424 bl. mode = 1; 1426 bl. mode = 1;
1425 bl. pwr = bright ? 1 : 0; 1427 bl. pwr = bright ? 1 : 0;
1426 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1428 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1427 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1429 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1428 ::close ( fd ); 1430 ::close ( fd );
1429 } 1431 }
1430 return res; 1432 return res;
1431} 1433}
1432 1434
1433int iPAQ::displayBrightnessResolution ( ) const 1435int iPAQ::displayBrightnessResolution ( ) const
1434{ 1436{
1435 switch ( model ( )) { 1437 switch ( model ( )) {
1436 case Model_iPAQ_H31xx: 1438 case Model_iPAQ_H31xx:
1437 case Model_iPAQ_H36xx: 1439 case Model_iPAQ_H36xx:
1438 case Model_iPAQ_H37xx: 1440 case Model_iPAQ_H37xx:
1439 return 128; // really 256, but >128 could damage the LCD 1441 return 128; // really 256, but >128 could damage the LCD
1440 1442
1441 case Model_iPAQ_H38xx: 1443 case Model_iPAQ_H38xx:
1442 case Model_iPAQ_H39xx: 1444 case Model_iPAQ_H39xx:
1443 return 64; 1445 return 64;
1444 case Model_iPAQ_H5xxx: 1446 case Model_iPAQ_H5xxx:
1445 return 255; 1447 return 255;
1446 1448
1447 default: 1449 default:
1448 return 2; 1450 return 2;
1449 } 1451 }
1450} 1452}
1451 1453
1452 1454
1453bool iPAQ::hasLightSensor ( ) const 1455bool iPAQ::hasLightSensor ( ) const
1454{ 1456{
1455 return true; 1457 return true;
1456} 1458}
1457 1459
1458int iPAQ::readLightSensor ( ) 1460int iPAQ::readLightSensor ( )
1459{ 1461{
1460 int fd; 1462 int fd;
1461 int val = -1; 1463 int val = -1;
1462 1464
1463 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1465 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1464 char buffer [8]; 1466 char buffer [8];
1465 1467
1466 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1468 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1467 char *endptr; 1469 char *endptr;
1468 1470
1469 buffer [4] = 0; 1471 buffer [4] = 0;
1470 val = ::strtol ( buffer + 2, &endptr, 16 ); 1472 val = ::strtol ( buffer + 2, &endptr, 16 );
1471 1473
1472 if ( *endptr != 0 ) 1474 if ( *endptr != 0 )
1473 val = -1; 1475 val = -1;
1474 } 1476 }
1475 ::close ( fd ); 1477 ::close ( fd );
1476 } 1478 }
1477 1479
1478 return val; 1480 return val;
1479} 1481}
1480 1482
1481int iPAQ::lightSensorResolution ( ) const 1483int iPAQ::lightSensorResolution ( ) const
1482{ 1484{
1483 return 256; 1485 return 256;
1484} 1486}
1485 1487
1486/************************************************** 1488/**************************************************
1487 * 1489 *
1488 * Zaurus 1490 * Zaurus
1489 * 1491 *
1490 **************************************************/ 1492 **************************************************/
1491 1493
1492// Check whether this device is the sharp zaurus.. 1494// Check whether this device is the sharp zaurus..
1493bool Zaurus::isZaurus() 1495bool Zaurus::isZaurus()
1494{ 1496{
1495 1497
1496 // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! 1498 // If the special devices by embedix exist, it is quite simple: it is a Zaurus !
1497 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ 1499 if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){
1498 return true; 1500 return true;
1499 } 1501 }
1500 1502
1501 // On non-embedix kenrnels, we have too look closer. 1503 // On non-embedix kenrnels, we have too look closer.
1502 bool is_zaurus = false; 1504 bool is_zaurus = false;
1503 QFile f ( "/proc/cpuinfo" ); 1505 QFile f ( "/proc/cpuinfo" );
1504 if ( f. open ( IO_ReadOnly ) ) { 1506 if ( f. open ( IO_ReadOnly ) ) {
1505 QString model; 1507 QString model;
1506 QFile f ( "/proc/cpuinfo" ); 1508 QFile f ( "/proc/cpuinfo" );
1507 1509
1508 QTextStream ts ( &f ); 1510 QTextStream ts ( &f );
1509 QString line; 1511 QString line;
1510 while( line = ts. readLine ( ) ) { 1512 while( line = ts. readLine ( ) ) {
1511 if ( line. left ( 8 ) == "Hardware" ) 1513 if ( line. left ( 8 ) == "Hardware" )
1512 break; 1514 break;
1513 } 1515 }
1514 int loc = line. find ( ":" ); 1516 int loc = line. find ( ":" );
1515 if ( loc != -1 ) 1517 if ( loc != -1 )
1516 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1518 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1517 1519
1518 if ( model == "Sharp-Collie" 1520 if ( model == "Sharp-Collie"
1519 || model == "Collie" 1521 || model == "Collie"
1520 || model == "SHARP Corgi" 1522 || model == "SHARP Corgi"
1521 || model == "SHARP Shepherd" 1523 || model == "SHARP Shepherd"
1522 || model == "SHARP Poodle" 1524 || model == "SHARP Poodle"
1523 ) 1525 )
1524 is_zaurus = true; 1526 is_zaurus = true;
1525 1527
1526 } 1528 }
1527 return is_zaurus; 1529 return is_zaurus;
1528} 1530}
1529 1531
1530 1532
1531void Zaurus::init ( ) 1533void Zaurus::init ( )
1532{ 1534{
1533 d-> m_vendorstr = "Sharp"; 1535 d-> m_vendorstr = "Sharp";
1534 d-> m_vendor = Vendor_Sharp; 1536 d-> m_vendor = Vendor_Sharp;
1535 m_embedix = true; // Not openzaurus means: It has an embedix kernel ! 1537 m_embedix = true; // Not openzaurus means: It has an embedix kernel !
1536 1538
1537 // QFile f ( "/proc/filesystems" ); 1539 // QFile f ( "/proc/filesystems" );
1538 QString model; 1540 QString model;
1539 1541
1540 // It isn't a good idea to check the system configuration to 1542 // It isn't a good idea to check the system configuration to
1541 // detect the distribution ! 1543 // detect the distribution !
1542 // Otherwise it may happen that any other distribution is detected as openzaurus, just 1544 // Otherwise it may happen that any other distribution is detected as openzaurus, just
1543 // because it uses a jffs2 filesystem.. 1545 // because it uses a jffs2 filesystem..
1544 // (eilers) 1546 // (eilers)
1545 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1547 // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1546 QFile f ("/etc/oz_version"); 1548 QFile f ("/etc/oz_version");
1547 if ( f.exists() ){ 1549 if ( f.exists() ){
1548 d-> m_vendorstr = "OpenZaurus Team"; 1550 d-> m_vendorstr = "OpenZaurus Team";
1549 d-> m_systemstr = "OpenZaurus"; 1551 d-> m_systemstr = "OpenZaurus";
1550 d-> m_system = System_OpenZaurus; 1552 d-> m_system = System_OpenZaurus;
1551 1553
1552 if ( f. open ( IO_ReadOnly )) { 1554 if ( f. open ( IO_ReadOnly )) {
1553 QTextStream ts ( &f ); 1555 QTextStream ts ( &f );
1554 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1556 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1555 f. close ( ); 1557 f. close ( );
1556 } 1558 }
1557 1559
1558 // Openzaurus sometimes uses the embedix kernel! 1560 // Openzaurus sometimes uses the embedix kernel!
1559 // => Check whether this is an embedix kernel 1561 // => Check whether this is an embedix kernel
1560 FILE *uname = popen("uname -r", "r"); 1562 FILE *uname = popen("uname -r", "r");
1561 QString line; 1563 QString line;
1562 if ( f.open(IO_ReadOnly, uname) ) { 1564 if ( f.open(IO_ReadOnly, uname) ) {
1563 QTextStream ts ( &f ); 1565 QTextStream ts ( &f );
1564 line = ts. readLine ( ); 1566 line = ts. readLine ( );
1565 int loc = line. find ( "embedix" ); 1567 int loc = line. find ( "embedix" );
1566 if ( loc != -1 ) 1568 if ( loc != -1 )
1567 m_embedix = true; 1569 m_embedix = true;
1568 else 1570 else
1569 m_embedix = false; 1571 m_embedix = false;
1570 f. close ( ); 1572 f. close ( );
1571 } 1573 }
1572 pclose(uname); 1574 pclose(uname);
1573 } 1575 }
1574 else { 1576 else {
1575 d-> m_systemstr = "Zaurus"; 1577 d-> m_systemstr = "Zaurus";
1576 d-> m_system = System_Zaurus; 1578 d-> m_system = System_Zaurus;
1577 } 1579 }
1578 1580
1579 f. setName ( "/proc/cpuinfo" ); 1581 f. setName ( "/proc/cpuinfo" );
1580 if ( f. open ( IO_ReadOnly ) ) { 1582 if ( f. open ( IO_ReadOnly ) ) {
1581 QTextStream ts ( &f ); 1583 QTextStream ts ( &f );
1582 QString line; 1584 QString line;
1583 while( line = ts. readLine ( ) ) { 1585 while( line = ts. readLine ( ) ) {
1584 if ( line. left ( 8 ) == "Hardware" ) 1586 if ( line. left ( 8 ) == "Hardware" )
1585 break; 1587 break;
1586 } 1588 }
1587 int loc = line. find ( ":" ); 1589 int loc = line. find ( ":" );
1588 if ( loc != -1 ) 1590 if ( loc != -1 )
1589 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1591 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1590 } 1592 }
1591 1593
1592 if ( model == "SHARP Corgi" ) { 1594 if ( model == "SHARP Corgi" ) {
1593 d-> m_model = Model_Zaurus_SLC700; 1595 d-> m_model = Model_Zaurus_SLC700;
1594 d-> m_modelstr = "Zaurus SL-C700"; 1596 d-> m_modelstr = "Zaurus SL-C700";
1595 } else if ( model == "SHARP Shepherd" ) { 1597 } else if ( model == "SHARP Shepherd" ) {
1596 d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers) 1598 d-> m_model = Model_Zaurus_SLC700; // Do we need a special type for the C750 ? (eilers)
1597 d-> m_modelstr = "Zaurus SL-C750"; 1599 d-> m_modelstr = "Zaurus SL-C750";
1598 } else if ( model == "SHARP Poodle" ) { 1600 } else if ( model == "SHARP Poodle" ) {
1599 d-> m_model = Model_Zaurus_SLB600; 1601 d-> m_model = Model_Zaurus_SLB600;
1600 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1602 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1601 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 1603 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
1602 d-> m_model = Model_Zaurus_SL5500; 1604 d-> m_model = Model_Zaurus_SL5500;
1603 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1605 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1604 } else { 1606 } else {
1605 d-> m_model = Model_Zaurus_SL5500; 1607 d-> m_model = Model_Zaurus_SL5500;
1606 d-> m_modelstr = "Zaurus (Model unknown)"; 1608 d-> m_modelstr = "Zaurus (Model unknown)";
1607 } 1609 }
1608 1610
1609 bool flipstate = false; 1611 bool flipstate = false;
1610 switch ( d-> m_model ) { 1612 switch ( d-> m_model ) {
1611 case Model_Zaurus_SLA300: 1613 case Model_Zaurus_SLA300:
1612 d-> m_rotation = Rot0; 1614 d-> m_rotation = Rot0;
1613 break; 1615 break;
1614 case Model_Zaurus_SLC700: 1616 case Model_Zaurus_SLC700:
1615 // Note: need to 1) set flipstate based on physical screen orientation 1617 // Note: need to 1) set flipstate based on physical screen orientation
1616 // and 2) check to see if the user overrode the rotation direction 1618 // and 2) check to see if the user overrode the rotation direction
1617 // using appearance, and if so, remove that item from the Config to 1619 // using appearance, and if so, remove that item from the Config to
1618 // ensure the rotate applet flips us back to the previous state. 1620 // ensure the rotate applet flips us back to the previous state.
1619 if ( flipstate ) { 1621 if ( flipstate ) {
1620 // 480x640 1622 // 480x640
1621 d-> m_rotation = Rot0; 1623 d-> m_rotation = Rot0;
1622 d-> m_direction = CW; 1624 d-> m_direction = CW;
1623 } else { 1625 } else {
1624 // 640x480 1626 // 640x480
1625 d-> m_rotation = Rot270; 1627 d-> m_rotation = Rot270;
1626 d-> m_direction = CCW; 1628 d-> m_direction = CCW;
1627 } 1629 }
1628 break; 1630 break;
1629 case Model_Zaurus_SLB600: 1631 case Model_Zaurus_SLB600:
1630 case Model_Zaurus_SL5500: 1632 case Model_Zaurus_SL5500:
1631 case Model_Zaurus_SL5000: 1633 case Model_Zaurus_SL5000:
1632 default: 1634 default:
1633 d-> m_rotation = Rot270; 1635 d-> m_rotation = Rot270;
1634 break; 1636 break;
1635 } 1637 }
1636 m_leds [0] = Led_Off; 1638 m_leds [0] = Led_Off;
1637} 1639}
1638 1640
1639void Zaurus::initButtons ( ) 1641void Zaurus::initButtons ( )
1640{ 1642{
1641 if ( d-> m_buttons ) 1643 if ( d-> m_buttons )
1642 return; 1644 return;
1643 1645
1644 d-> m_buttons = new QValueList <ODeviceButton>; 1646 d-> m_buttons = new QValueList <ODeviceButton>;
1645 1647
1646 struct z_button * pz_buttons; 1648 struct z_button * pz_buttons;
1647 int buttoncount; 1649 int buttoncount;
1648 switch ( d-> m_model ) { 1650 switch ( d-> m_model ) {
1649 case Model_Zaurus_SLC700: 1651 case Model_Zaurus_SLC700:
1650 pz_buttons = z_buttons_c700; 1652 pz_buttons = z_buttons_c700;
1651 buttoncount = ARRAY_SIZE(z_buttons_c700); 1653 buttoncount = ARRAY_SIZE(z_buttons_c700);
1652 break; 1654 break;
1653 default: 1655 default:
1654 pz_buttons = z_buttons; 1656 pz_buttons = z_buttons;
1655 buttoncount = ARRAY_SIZE(z_buttons); 1657 buttoncount = ARRAY_SIZE(z_buttons);
1656 break; 1658 break;
1657 } 1659 }
1658 1660
1659 for ( int i = 0; i < buttoncount; i++ ) { 1661 for ( int i = 0; i < buttoncount; i++ ) {
1660 struct z_button *zb = pz_buttons + i; 1662 struct z_button *zb = pz_buttons + i;
1661 ODeviceButton b; 1663 ODeviceButton b;
1662 1664
1663 b. setKeycode ( zb-> code ); 1665 b. setKeycode ( zb-> code );
1664 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1666 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1665 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1667 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1666 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), 1668 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ),
1667 zb-> fpressedaction )); 1669 zb-> fpressedaction ));
1668 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), 1670 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ),
1669 zb-> fheldaction )); 1671 zb-> fheldaction ));
1670 1672
1671 d-> m_buttons-> append ( b ); 1673 d-> m_buttons-> append ( b );
1672 } 1674 }
1673 1675
1674 reloadButtonMapping ( ); 1676 reloadButtonMapping ( );
1675 1677
1676 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1678 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1677 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), 1679 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )),
1678 this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1680 this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1679} 1681}
1680 1682
1681#include <unistd.h> 1683#include <unistd.h>
1682#include <fcntl.h> 1684#include <fcntl.h>
1683#include <sys/ioctl.h> 1685#include <sys/ioctl.h>
1684 1686
1685//#include <asm/sharp_char.h> // including kernel headers is evil ... 1687//#include <asm/sharp_char.h> // including kernel headers is evil ...
1686 1688
1687#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1689#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1688 1690
1689 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1691 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1690#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1692#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1691 1693
1692#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1694#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1693#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1695#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1694#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1696#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1695 1697
1696/* --- for SHARP_BUZZER device --- */ 1698/* --- for SHARP_BUZZER device --- */
1697 1699
1698 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1700 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1699//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1701//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1700 1702
1701#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1703#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1702#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1704#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1703#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1705#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1704#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1706#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1705#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1707#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1706 1708
1707//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1709//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1708//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1710//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1709 1711
1710//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1712//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1711//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1713//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1712//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1714//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1713//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1715//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1714//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1716//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1715//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1717//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1716//#define SHARP_PDA_APPSTART 9 /* application start */ 1718//#define SHARP_PDA_APPSTART 9 /* application start */
1717//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1719//#define SHARP_PDA_APPQUIT 10 /* application ends */
1718 1720
1719//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1721//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1720//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1722//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1721//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1723//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1722//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1724//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1723// 1725//
1724 1726
1725 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1727 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1726#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1728#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1727 1729
1728typedef struct sharp_led_status { 1730typedef struct sharp_led_status {
1729 int which; /* select which LED status is wanted. */ 1731 int which; /* select which LED status is wanted. */
1730 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1732 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1731} sharp_led_status; 1733} sharp_led_status;
1732 1734
1733#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1735#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1734 1736
1735#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1737#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1736#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1738#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1737#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1739#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1738 1740
1739// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1741// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1740 1742
1741#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1743#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1742#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1744#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1743#define APM_EVT_POWER_BUTTON (1 << 0) 1745#define APM_EVT_POWER_BUTTON (1 << 0)
1744 1746
1745#define FL_IOCTL_STEP_CONTRAST 100 1747#define FL_IOCTL_STEP_CONTRAST 100
1746 1748
1747 1749
1748void Zaurus::buzzer ( int sound ) 1750void Zaurus::buzzer ( int sound )
1749{ 1751{
1750#ifndef QT_NO_SOUND 1752#ifndef QT_NO_SOUND
1751 QString soundname; 1753 QString soundname;
1752 1754
1753 // Not all devices have real sound. But I expect 1755 // Not all devices have real sound. But I expect
1754 // that Openzaurus now has a sound driver which 1756 // that Openzaurus now has a sound driver which
1755 // I will use instead the buzzer... 1757 // I will use instead the buzzer...
1756 if ( ( d->m_model == Model_Zaurus_SLC700 ) 1758 if ( ( d->m_model == Model_Zaurus_SLC700 )
1757 || d->m_system == System_OpenZaurus ){ 1759 || d->m_system == System_OpenZaurus ){
1758 1760
1759 switch ( sound ){ 1761 switch ( sound ){
1760 case SHARP_BUZ_SCHEDULE_ALARM: 1762 case SHARP_BUZ_SCHEDULE_ALARM:
1761 soundname = "alarm"; 1763 soundname = "alarm";
1762 break; 1764 break;
1763 case SHARP_BUZ_TOUCHSOUND: 1765 case SHARP_BUZ_TOUCHSOUND:
1764 soundname = "touchsound"; 1766 soundname = "touchsound";
1765 break; 1767 break;
1766 case SHARP_BUZ_KEYSOUND: 1768 case SHARP_BUZ_KEYSOUND:
1767 soundname = "keysound"; 1769 soundname = "keysound";
1768 break; 1770 break;
1769 default: 1771 default:
1770 soundname = "alarm"; 1772 soundname = "alarm";
1771 1773
1772 } 1774 }
1773 } 1775 }
1774 1776
1775 // If a soundname is defined, we expect that this device has 1777 // If a soundname is defined, we expect that this device has
1776 // sound capabilities.. Otherwise we expect to have the buzzer 1778 // sound capabilities.. Otherwise we expect to have the buzzer
1777 // device.. 1779 // device..
1778 if ( !soundname.isEmpty() ){ 1780 if ( !soundname.isEmpty() ){
1779 int fd; 1781 int fd;
1780 int vol; 1782 int vol;
1781 bool vol_reset = false; 1783 bool vol_reset = false;
1782 1784
1783 Sound snd ( soundname ); 1785 Sound snd ( soundname );
1784 1786
1785 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1787 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1786 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1788 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1787 Config cfg ( "qpe" ); 1789 Config cfg ( "qpe" );
1788 cfg. setGroup ( "Volume" ); 1790 cfg. setGroup ( "Volume" );
1789 1791
1790 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1792 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1791 if ( volalarm < 0 ) 1793 if ( volalarm < 0 )
1792 volalarm = 0; 1794 volalarm = 0;
1793 else if ( volalarm > 100 ) 1795 else if ( volalarm > 100 )
1794 volalarm = 100; 1796 volalarm = 100;
1795 volalarm |= ( volalarm << 8 ); 1797 volalarm |= ( volalarm << 8 );
1796 1798
1797 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1799 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1798 vol_reset = true; 1800 vol_reset = true;
1799 } 1801 }
1800 } 1802 }
1801 1803
1802 snd. play ( ); 1804 snd. play ( );
1803 while ( !snd. isFinished ( )) 1805 while ( !snd. isFinished ( ))
1804 qApp-> processEvents ( ); 1806 qApp-> processEvents ( );
1805 1807
1806 if ( fd >= 0 ) { 1808 if ( fd >= 0 ) {
1807 if ( vol_reset ) 1809 if ( vol_reset )
1808 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1810 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1809 ::close ( fd ); 1811 ::close ( fd );
1810 } 1812 }
1811 } else { 1813 } else {
1812 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1814 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1813 1815
1814 if ( fd >= 0 ) { 1816 if ( fd >= 0 ) {
1815 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1817 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1816 ::close ( fd ); 1818 ::close ( fd );
1817 } 1819 }
1818 1820
1819 } 1821 }
1820#endif 1822#endif
1821} 1823}
1822 1824
1823 1825
1824void Zaurus::alarmSound ( ) 1826void Zaurus::alarmSound ( )
1825{ 1827{
1826 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1828 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1827} 1829}
1828 1830
1829void Zaurus::touchSound ( ) 1831void Zaurus::touchSound ( )
1830{ 1832{
1831 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1833 buzzer ( SHARP_BUZ_TOUCHSOUND );
1832} 1834}
1833 1835
1834void Zaurus::keySound ( ) 1836void Zaurus::keySound ( )
1835{ 1837{
1836 buzzer ( SHARP_BUZ_KEYSOUND ); 1838 buzzer ( SHARP_BUZ_KEYSOUND );
1837} 1839}
1838 1840
1839 1841
1840QValueList <OLed> Zaurus::ledList ( ) const 1842QValueList <OLed> Zaurus::ledList ( ) const
1841{ 1843{
1842 QValueList <OLed> vl; 1844 QValueList <OLed> vl;
1843 vl << Led_Mail; 1845 vl << Led_Mail;
1844 return vl; 1846 return vl;
1845} 1847}
1846 1848
1847QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1849QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1848{ 1850{
1849 QValueList <OLedState> vl; 1851 QValueList <OLedState> vl;
1850 1852
1851 if ( l == Led_Mail ) 1853 if ( l == Led_Mail )
1852 vl << Led_Off << Led_On << Led_BlinkSlow; 1854 vl << Led_Off << Led_On << Led_BlinkSlow;
1853 return vl; 1855 return vl;
1854} 1856}
1855 1857
1856OLedState Zaurus::ledState ( OLed which ) const 1858OLedState Zaurus::ledState ( OLed which ) const
1857{ 1859{
1858 if ( which == Led_Mail ) 1860 if ( which == Led_Mail )
1859 return m_leds [0]; 1861 return m_leds [0];
1860 else 1862 else
1861 return Led_Off; 1863 return Led_Off;
1862} 1864}
1863 1865
1864bool Zaurus::setLedState ( OLed which, OLedState st ) 1866bool Zaurus::setLedState ( OLed which, OLedState st )
1865{ 1867{
1866 if (!m_embedix) // Currently not supported on non_embedix kernels 1868 if (!m_embedix) // Currently not supported on non_embedix kernels
1867 return false; 1869 return false;
1868 1870
1869 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1871 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1870 1872
1871 if ( which == Led_Mail ) { 1873 if ( which == Led_Mail ) {
1872 if ( fd >= 0 ) { 1874 if ( fd >= 0 ) {
1873 struct sharp_led_status leds; 1875 struct sharp_led_status leds;
1874 ::memset ( &leds, 0, sizeof( leds )); 1876 ::memset ( &leds, 0, sizeof( leds ));
1875 leds. which = SHARP_LED_MAIL_EXISTS; 1877 leds. which = SHARP_LED_MAIL_EXISTS;
1876 bool ok = true; 1878 bool ok = true;
1877 1879
1878 switch ( st ) { 1880 switch ( st ) {
1879 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1881 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1880 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1882 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1881 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1883 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1882 default : ok = false; 1884 default : ok = false;
1883 } 1885 }
1884 1886
1885 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1887 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1886 m_leds [0] = st; 1888 m_leds [0] = st;
1887 return true; 1889 return true;
1888 } 1890 }
1889 } 1891 }
1890 } 1892 }
1891 return false; 1893 return false;
1892} 1894}
1893 1895
1894bool Zaurus::setSoftSuspend ( bool soft ) 1896bool Zaurus::setSoftSuspend ( bool soft )
1895{ 1897{
1896 if (!m_embedix) { 1898 if (!m_embedix) {
1897 /* non-Embedix kernels dont have kernel autosuspend */ 1899 /* non-Embedix kernels dont have kernel autosuspend */
1898 return ODevice::setSoftSuspend( soft ); 1900 return ODevice::setSoftSuspend( soft );
1899 } 1901 }
1900 1902
1901 bool res = false; 1903 bool res = false;
1902 int fd; 1904 int fd;
1903 1905
1904 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1906 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1905 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1907 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1906 1908
1907 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1909 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1908 1910
1909 if ( sources >= 0 ) { 1911 if ( sources >= 0 ) {
1910 if ( soft ) 1912 if ( soft )
1911 sources &= ~APM_EVT_POWER_BUTTON; 1913 sources &= ~APM_EVT_POWER_BUTTON;
1912 else 1914 else
1913 sources |= APM_EVT_POWER_BUTTON; 1915 sources |= APM_EVT_POWER_BUTTON;
1914 1916
1915 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1917 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1916 res = true; 1918 res = true;
1917 else 1919 else
1918 perror ( "APM_IOCGEVTSRC" ); 1920 perror ( "APM_IOCGEVTSRC" );
1919 } 1921 }
1920 else 1922 else
1921 perror ( "APM_IOCGEVTSRC" ); 1923 perror ( "APM_IOCGEVTSRC" );
1922 1924
1923 ::close ( fd ); 1925 ::close ( fd );
1924 } 1926 }
1925 else 1927 else
1926 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1928 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1927 1929
1928 return res; 1930 return res;
1929} 1931}
1930 1932
1931 1933
1932bool Zaurus::setDisplayBrightness ( int bright ) 1934bool Zaurus::setDisplayBrightness ( int bright )
1933{ 1935{
1934 bool res = false; 1936 bool res = false;
1935 int fd; 1937 int fd;
1936 1938
1937 if ( bright > 255 ) 1939 if ( bright > 255 )
1938 bright = 255; 1940 bright = 255;
1939 if ( bright < 0 ) 1941 if ( bright < 0 )
1940 bright = 0; 1942 bright = 0;
1941 1943
1942 if (m_embedix) { 1944 if (m_embedix) {
1943 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1945 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1944 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1946 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1945 if ( bright && !bl ) 1947 if ( bright && !bl )
1946 bl = 1; 1948 bl = 1;
1947 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1949 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1948 ::close ( fd ); 1950 ::close ( fd );
1949 } 1951 }
1950 } else { 1952 } else {
1951#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 1953#define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
1952 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 1954 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
1953 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 1955 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
1954 ::close ( fd ); 1956 ::close ( fd );
1955 } 1957 }
1956 } 1958 }
1957 return res; 1959 return res;
1958} 1960}
1959 1961
1960 1962
1961int Zaurus::displayBrightnessResolution ( ) const 1963int Zaurus::displayBrightnessResolution ( ) const
1962{ 1964{
1963 if (m_embedix) 1965 if (m_embedix)
1964 return 5; 1966 return 5;
1965 else 1967 else
1966 return 256; 1968 return 256;
1967} 1969}
1968 1970
1969/************************************************** 1971/**************************************************
1970 * 1972 *
1971 * SIMpad 1973 * SIMpad
1972 * 1974 *
1973 **************************************************/ 1975 **************************************************/
1974 1976
1975void SIMpad::init ( ) 1977void SIMpad::init ( )
1976{ 1978{
1977 d-> m_vendorstr = "SIEMENS"; 1979 d-> m_vendorstr = "SIEMENS";
1978 d-> m_vendor = Vendor_SIEMENS; 1980 d-> m_vendor = Vendor_SIEMENS;
1979 1981
1980 QFile f ( "/proc/hal/model" ); 1982 QFile f ( "/proc/hal/model" );
1981 1983
1982 //TODO Implement model checking 1984 //TODO Implement model checking
1983 //FIXME For now we assume an SL4 1985 //FIXME For now we assume an SL4
1984 1986
1985 d-> m_modelstr = "SL4"; 1987 d-> m_modelstr = "SL4";
1986 d-> m_model = Model_SIMpad_SL4; 1988 d-> m_model = Model_SIMpad_SL4;
1987 1989
1988 switch ( d-> m_model ) { 1990 switch ( d-> m_model ) {
1989 default: 1991 default:
1990 d-> m_rotation = Rot0; 1992 d-> m_rotation = Rot0;
1991 d-> m_direction = CCW; 1993 d-> m_direction = CCW;
1992 d-> m_holdtime = 1000; // 1000ms 1994 d-> m_holdtime = 1000; // 1000ms
1993 1995
1994 break; 1996 break;
1995 } 1997 }
1996 1998
1997 f. setName ( "/etc/familiar-version" ); 1999 f. setName ( "/etc/familiar-version" );
1998 if ( f. open ( IO_ReadOnly )) { 2000 if ( f. open ( IO_ReadOnly )) {
1999 d-> m_systemstr = "Familiar"; 2001 d-> m_systemstr = "Familiar";
2000 d-> m_system = System_Familiar; 2002 d-> m_system = System_Familiar;
2001 2003
2002 QTextStream ts ( &f ); 2004 QTextStream ts ( &f );
2003 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 2005 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
2004 2006
2005 f. close ( ); 2007 f. close ( );
2006 } else { 2008 } else {
2007 f. setName ( "/etc/oz_version" ); 2009 f. setName ( "/etc/oz_version" );
2008 2010
2009 if ( f. open ( IO_ReadOnly )) { 2011 if ( f. open ( IO_ReadOnly )) {
2010 d-> m_systemstr = "OpenEmbedded/SIMpad"; 2012 d-> m_systemstr = "OpenEmbedded/SIMpad";
2011 d-> m_system = System_OpenZaurus; 2013 d-> m_system = System_OpenZaurus;
2012 2014
2013 QTextStream ts ( &f ); 2015 QTextStream ts ( &f );
2014 ts.setDevice ( &f ); 2016 ts.setDevice ( &f );
2015 d-> m_sysverstr = ts. readLine ( ); 2017 d-> m_sysverstr = ts. readLine ( );
2016 f. close ( ); 2018 f. close ( );
2017 } 2019 }
2018 } 2020 }
2019 2021
2020 m_leds [0] = m_leds [1] = Led_Off; 2022 m_leds [0] = m_leds [1] = Led_Off;
2021 2023
2022 m_power_timer = 0; 2024 m_power_timer = 0;
2023 2025
2024} 2026}
2025 2027
2026void SIMpad::initButtons ( ) 2028void SIMpad::initButtons ( )
2027{ 2029{
2028 if ( d-> m_buttons ) 2030 if ( d-> m_buttons )
2029 return; 2031 return;
2030 2032
2031 if ( isQWS( ) ) 2033 if ( isQWS( ) )
2032 QWSServer::setKeyboardFilter ( this ); 2034 QWSServer::setKeyboardFilter ( this );
2033 2035
2034 d-> m_buttons = new QValueList <ODeviceButton>; 2036 d-> m_buttons = new QValueList <ODeviceButton>;
2035 2037
2036 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 2038 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
2037 s_button *sb = simpad_buttons + i; 2039 s_button *sb = simpad_buttons + i;
2038 ODeviceButton b; 2040 ODeviceButton b;
2039 2041
2040 if (( sb-> model & d-> m_model ) == d-> m_model ) { 2042 if (( sb-> model & d-> m_model ) == d-> m_model ) {
2041 b. setKeycode ( sb-> code ); 2043 b. setKeycode ( sb-> code );
2042 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 2044 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
2043 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 2045 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
2044 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 2046 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
2045 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 2047 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
2046 2048
2047 d-> m_buttons-> append ( b ); 2049 d-> m_buttons-> append ( b );
2048 } 2050 }
2049 } 2051 }
2050 reloadButtonMapping ( ); 2052 reloadButtonMapping ( );
2051 2053
2052 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 2054 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2053 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 2055 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
2054} 2056}
2055 2057
2056// SIMpad boardcontrol register CS3 2058// SIMpad boardcontrol register CS3
2057#define SIMPAD_BOARDCONTROL "/proc/cs3" 2059#define SIMPAD_BOARDCONTROL "/proc/cs3"
2058#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 2060#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
2059#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 2061#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
2060#define SIMPAD_EN1 0x0004 // This is only for EPROM's 2062#define SIMPAD_EN1 0x0004 // This is only for EPROM's
2061#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 2063#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
2062#define SIMPAD_DISPLAY_ON 0x0010 2064#define SIMPAD_DISPLAY_ON 0x0010
2063#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 2065#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
2064#define SIMPAD_MQ_RESET 0x0040 2066#define SIMPAD_MQ_RESET 0x0040
2065#define SIMPAD_PCMCIA_RESET 0x0080 2067#define SIMPAD_PCMCIA_RESET 0x0080
2066#define SIMPAD_DECT_POWER_ON 0x0100 2068#define SIMPAD_DECT_POWER_ON 0x0100
2067#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 2069#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
2068#define SIMPAD_RS232_ON 0x0400 2070#define SIMPAD_RS232_ON 0x0400
2069#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 2071#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
2070#define SIMPAD_LED2_ON 0x1000 2072#define SIMPAD_LED2_ON 0x1000
2071#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 2073#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
2072#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 2074#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
2073#define SIMPAD_RESET_SIMCARD 0x8000 2075#define SIMPAD_RESET_SIMCARD 0x8000
2074 2076
2075//SIMpad touchscreen backlight strength control 2077//SIMpad touchscreen backlight strength control
2076#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 2078#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
2077#define SIMPAD_BACKLIGHT_MASK 0x00a10044 2079#define SIMPAD_BACKLIGHT_MASK 0x00a10044
2078 2080
2079QValueList <OLed> SIMpad::ledList ( ) const 2081QValueList <OLed> SIMpad::ledList ( ) const
2080{ 2082{
2081 QValueList <OLed> vl; 2083 QValueList <OLed> vl;
2082 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 2084 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
2083 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 2085 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
2084 return vl; 2086 return vl;
2085} 2087}
2086 2088
2087QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 2089QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
2088{ 2090{
2089 QValueList <OLedState> vl; 2091 QValueList <OLedState> vl;
2090 2092
2091 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 2093 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
2092 vl << Led_Off << Led_On; 2094 vl << Led_Off << Led_On;
2093 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 2095 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
2094 //vl << Led_Off; 2096 //vl << Led_Off;
2095 return vl; 2097 return vl;
2096} 2098}
2097 2099
2098OLedState SIMpad::ledState ( OLed l ) const 2100OLedState SIMpad::ledState ( OLed l ) const
2099{ 2101{
2100 switch ( l ) { 2102 switch ( l ) {
2101 case Led_Power: 2103 case Led_Power:
2102 return m_leds [0]; 2104 return m_leds [0];
2103 //case Led_Mail: 2105 //case Led_Mail:
2104 //return m_leds [1]; 2106 //return m_leds [1];
2105 default: 2107 default:
2106 return Led_Off; 2108 return Led_Off;
2107 } 2109 }
2108} 2110}
2109 2111
2110bool SIMpad::setLedState ( OLed l, OLedState st ) 2112bool SIMpad::setLedState ( OLed l, OLedState st )
2111{ 2113{
2112 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 2114 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
2113 2115
2114 if ( l == Led_Power ) { 2116 if ( l == Led_Power ) {
2115 if ( fd >= 0 ) { 2117 if ( fd >= 0 ) {
2116 LED_IN leds; 2118 LED_IN leds;
2117 ::memset ( &leds, 0, sizeof( leds )); 2119 ::memset ( &leds, 0, sizeof( leds ));
2118 leds. TotalTime = 0; 2120 leds. TotalTime = 0;
2119 leds. OnTime = 0; 2121 leds. OnTime = 0;
2120 leds. OffTime = 1; 2122 leds. OffTime = 1;
2121 leds. OffOnBlink = 2; 2123 leds. OffOnBlink = 2;
2122 2124
2123 switch ( st ) { 2125 switch ( st ) {
2124 case Led_Off : leds. OffOnBlink = 0; break; 2126 case Led_Off : leds. OffOnBlink = 0; break;
2125 case Led_On : leds. OffOnBlink = 1; break; 2127 case Led_On : leds. OffOnBlink = 1; break;
2126 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 2128 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
2127 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 2129 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
2128 } 2130 }
2129 2131
2130 { 2132 {
2131 /*TODO Implement this like that: 2133 /*TODO Implement this like that:
2132 read from cs3 2134 read from cs3
2133 && with SIMPAD_LED2_ON 2135 && with SIMPAD_LED2_ON
2134 write to cs3 */ 2136 write to cs3 */
2135 m_leds [0] = st; 2137 m_leds [0] = st;
2136 return true; 2138 return true;
2137 } 2139 }
2138 } 2140 }
2139 } 2141 }
2140 return false; 2142 return false;
2141} 2143}
2142 2144
2143 2145
2144bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 2146bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
2145{ 2147{
2146 //TODO 2148 //TODO
2147 return false; 2149 return false;
2148} 2150}
2149 2151
2150void SIMpad::timerEvent ( QTimerEvent * ) 2152void SIMpad::timerEvent ( QTimerEvent * )
2151{ 2153{
2152 killTimer ( m_power_timer ); 2154 killTimer ( m_power_timer );
2153 m_power_timer = 0; 2155 m_power_timer = 0;
2154 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 2156 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
2155 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 2157 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
2156} 2158}
2157 2159
2158 2160
2159void SIMpad::alarmSound ( ) 2161void SIMpad::alarmSound ( )
2160{ 2162{
2161#ifndef QT_NO_SOUND 2163#ifndef QT_NO_SOUND
2162 static Sound snd ( "alarm" ); 2164 static Sound snd ( "alarm" );
2163 int fd; 2165 int fd;
2164 int vol; 2166 int vol;
2165 bool vol_reset = false; 2167 bool vol_reset = false;
2166 2168
2167 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 2169 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
2168 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 2170 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
2169 Config cfg ( "qpe" ); 2171 Config cfg ( "qpe" );
2170 cfg. setGroup ( "Volume" ); 2172 cfg. setGroup ( "Volume" );
2171 2173
2172 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 2174 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
2173 if ( volalarm < 0 ) 2175 if ( volalarm < 0 )
2174 volalarm = 0; 2176 volalarm = 0;
2175 else if ( volalarm > 100 ) 2177 else if ( volalarm > 100 )
2176 volalarm = 100; 2178 volalarm = 100;
2177 volalarm |= ( volalarm << 8 ); 2179 volalarm |= ( volalarm << 8 );
2178 2180
2179 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 2181 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
2180 vol_reset = true; 2182 vol_reset = true;
2181 } 2183 }
2182 } 2184 }
2183 2185
2184 snd. play ( ); 2186 snd. play ( );
2185 while ( !snd. isFinished ( )) 2187 while ( !snd. isFinished ( ))
2186 qApp-> processEvents ( ); 2188 qApp-> processEvents ( );
2187 2189
2188 if ( fd >= 0 ) { 2190 if ( fd >= 0 ) {
2189 if ( vol_reset ) 2191 if ( vol_reset )
2190 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 2192 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
2191 ::close ( fd ); 2193 ::close ( fd );
2192 } 2194 }
2193#endif 2195#endif
2194} 2196}
2195 2197
2196 2198
2197bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 2199bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
2198{ 2200{
2199 qDebug( "ODevice for SIMpad: suspend()" ); 2201 qDebug( "ODevice for SIMpad: suspend()" );
2200 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 2202 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
2201 return false; 2203 return false;
2202 2204
2203 bool res = false; 2205 bool res = false;
2204 2206
2205 struct timeval tvs, tvn; 2207 struct timeval tvs, tvn;
2206 ::gettimeofday ( &tvs, 0 ); 2208 ::gettimeofday ( &tvs, 0 );
2207 2209
2208 ::sync ( ); // flush fs caches 2210 ::sync ( ); // flush fs caches
2209 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) 2211 res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :)
2210 2212
2211 return res; 2213 return res;
2212} 2214}
2213 2215
2214 2216
2215bool SIMpad::setSoftSuspend ( bool soft ) 2217bool SIMpad::setSoftSuspend ( bool soft )
2216{ 2218{
2217 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 2219 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
2218 return false; 2220 return false;
2219} 2221}
2220 2222
2221 2223
2222bool SIMpad::setDisplayStatus ( bool on ) 2224bool SIMpad::setDisplayStatus ( bool on )
2223{ 2225{
2224 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 2226 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
2225 2227
2226 bool res = false; 2228 bool res = false;
2227 int fd; 2229 int fd;
2228 2230
2229 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 2231 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
2230 2232
2231 res = ( ::system( (const char*) cmdline ) == 0 ); 2233 res = ( ::system( (const char*) cmdline ) == 0 );
2232 2234
2233 return res; 2235 return res;
2234} 2236}
2235 2237
2236 2238
2237bool SIMpad::setDisplayBrightness ( int bright ) 2239bool SIMpad::setDisplayBrightness ( int bright )
2238{ 2240{
2239 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 2241 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
2240 bool res = false; 2242 bool res = false;
2241 int fd; 2243 int fd;
2242 2244
2243 if ( bright > 255 ) 2245 if ( bright > 255 )
2244 bright = 255; 2246 bright = 255;
2245 if ( bright < 1 ) 2247 if ( bright < 1 )
2246 bright = 0; 2248 bright = 0;
2247 2249
2248 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 2250 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
2249 int value = 255 - bright; 2251 int value = 255 - bright;
2250 const int mask = SIMPAD_BACKLIGHT_MASK; 2252 const int mask = SIMPAD_BACKLIGHT_MASK;
2251 value = value << 8; 2253 value = value << 8;
2252 value += mask; 2254 value += mask;
2253 char writeCommand[100]; 2255 char writeCommand[100];
2254 const int count = sprintf( writeCommand, "0x%x\n", value ); 2256 const int count = sprintf( writeCommand, "0x%x\n", value );
2255 res = ( ::write ( fd, writeCommand, count ) != -1 ); 2257 res = ( ::write ( fd, writeCommand, count ) != -1 );
2256 ::close ( fd ); 2258 ::close ( fd );
2257 } 2259 }
2258 return res; 2260 return res;
2259} 2261}
2260 2262
2261 2263
2262int SIMpad::displayBrightnessResolution ( ) const 2264int SIMpad::displayBrightnessResolution ( ) const
2263{ 2265{
2264 return 255; // All SIMpad models share the same display 2266 return 255; // All SIMpad models share the same display
2265} 2267}
2266 2268
2267/************************************************** 2269/**************************************************
2268 * 2270 *
2269 * Ramses 2271 * Ramses
2270 * 2272 *
2271 **************************************************/ 2273 **************************************************/
2272 2274
2273void Ramses::init() 2275void Ramses::init()
2274{ 2276{
2275 d->m_vendorstr = "M und N"; 2277 d->m_vendorstr = "M und N";
2276 d->m_vendor = Vendor_MundN; 2278 d->m_vendor = Vendor_MundN;
2277 2279
2278 QFile f("/proc/sys/board/ramses"); 2280 QFile f("/proc/sys/board/ramses");
2279 2281
2280 d->m_modelstr = "Ramses"; 2282 d->m_modelstr = "Ramses";
2281 d->m_model = Model_Ramses_MNCI; 2283 d->m_model = Model_Ramses_MNCI;
2282 2284
2283 d->m_rotation = Rot0; 2285 d->m_rotation = Rot0;
2284 d->m_holdtime = 1000; 2286 d->m_holdtime = 1000;
2285 2287
2286 f.setName("/etc/oz_version"); 2288 f.setName("/etc/oz_version");
2287 2289
2288 if (f.open(IO_ReadOnly)) { 2290 if (f.open(IO_ReadOnly)) {
2289 d->m_systemstr = "OpenEmbedded/Ramses"; 2291 d->m_systemstr = "OpenEmbedded/Ramses";
2290 d->m_system = System_OpenZaurus; 2292 d->m_system = System_OpenZaurus;
2291 2293
2292 QTextStream ts(&f); 2294 QTextStream ts(&f);
2293 ts.setDevice(&f); 2295 ts.setDevice(&f);
2294 d->m_sysverstr = ts.readLine(); 2296 d->m_sysverstr = ts.readLine();
2295 f.close(); 2297 f.close();
2296 } 2298 }
2297 2299
2298 m_power_timer = 0; 2300 m_power_timer = 0;
2299 2301
2300#ifdef QT_QWS_ALLOW_OVERCLOCK 2302#ifdef QT_QWS_ALLOW_OVERCLOCK
2301#warning *** Overclocking enabled - this may fry your hardware - you have been warned *** 2303#warning *** Overclocking enabled - this may fry your hardware - you have been warned ***
2302#define OC(x...) x 2304#define OC(x...) x
2303#else 2305#else
2304#define OC(x...) 2306#define OC(x...)
2305#endif 2307#endif
2306 2308
2307 2309
2308 // This table is true for a Intel XScale PXA 255 2310 // This table is true for a Intel XScale PXA 255
2309 2311
2310 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 2312 d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50
2311 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem 2313 OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem
2312 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 2314 d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99
2313 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem 2315 OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem
2314 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 2316 d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99
2315 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem 2317 OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem
2316 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 2318 d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99
2317 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 2319 d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196
2318 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus 2320 OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus
2319 2321
2320} 2322}
2321 2323
2322bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) 2324bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat)
2323{ 2325{
2324 Q_UNUSED( keycode ); 2326 Q_UNUSED( keycode );
2325 Q_UNUSED( modifiers ); 2327 Q_UNUSED( modifiers );
2326 Q_UNUSED( isPress ); 2328 Q_UNUSED( isPress );
2327 Q_UNUSED( autoRepeat ); 2329 Q_UNUSED( autoRepeat );
2328 return false; 2330 return false;
2329} 2331}
2330 2332
2331void Ramses::timerEvent(QTimerEvent *) 2333void Ramses::timerEvent(QTimerEvent *)
2332{ 2334{
2333 killTimer(m_power_timer); 2335 killTimer(m_power_timer);
2334 m_power_timer = 0; 2336 m_power_timer = 0;
2335 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); 2337 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false);
2336 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); 2338 QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false);
2337} 2339}
2338 2340
2339 2341
2340bool Ramses::setSoftSuspend(bool soft) 2342bool Ramses::setSoftSuspend(bool soft)
2341{ 2343{
2342 qDebug("Ramses::setSoftSuspend(%d)", soft); 2344 qDebug("Ramses::setSoftSuspend(%d)", soft);
2343#if 0 2345#if 0
2344 bool res = false; 2346 bool res = false;
2345 int fd; 2347 int fd;
2346 2348
2347 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || 2349 if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) ||
2348 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { 2350 ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) {
2349 2351
2350 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources 2352 int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources
2351 2353
2352 if (sources >= 0) { 2354 if (sources >= 0) {
2353 if (soft) 2355 if (soft)
2354 sources &= ~APM_EVT_POWER_BUTTON; 2356 sources &= ~APM_EVT_POWER_BUTTON;
2355 else 2357 else
2356 sources |= APM_EVT_POWER_BUTTON; 2358 sources |= APM_EVT_POWER_BUTTON;
2357 2359
2358 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources 2360 if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources
2359 res = true; 2361 res = true;
2360 else 2362 else
2361 perror("APM_IOCGEVTSRC"); 2363 perror("APM_IOCGEVTSRC");
2362 } 2364 }
2363 else 2365 else
2364 perror("APM_IOCGEVTSRC"); 2366 perror("APM_IOCGEVTSRC");
2365 2367
2366 ::close(fd); 2368 ::close(fd);
2367 } 2369 }
2368 else 2370 else
2369 perror("/dev/apm_bios or /dev/misc/apm_bios"); 2371 perror("/dev/apm_bios or /dev/misc/apm_bios");
2370 2372
2371 return res; 2373 return res;
2372#else 2374#else
2373 return true; 2375 return true;
2374#endif 2376#endif
2375} 2377}
2376 2378
2377bool Ramses::suspend ( ) 2379bool Ramses::suspend ( )
2378{ 2380{
2379 qDebug("Ramses::suspend"); 2381 qDebug("Ramses::suspend");
2380 return false; 2382 return false;
2381} 2383}
2382 2384
2383/** 2385/**
2384 * This sets the display on or off 2386 * This sets the display on or off
2385 */ 2387 */
2386bool Ramses::setDisplayStatus(bool on) 2388bool Ramses::setDisplayStatus(bool on)
2387{ 2389{
2388 qDebug("Ramses::setDisplayStatus(%d)", on); 2390 qDebug("Ramses::setDisplayStatus(%d)", on);
2389#if 0 2391#if 0
2390 bool res = false; 2392 bool res = false;
2391 int fd; 2393 int fd;
2392 2394
2393 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { 2395 if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) {
2394 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); 2396 res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0);
2395 ::close(fd); 2397 ::close(fd);
2396 } 2398 }
2397 return res; 2399 return res;
2398#else 2400#else
2399 return true; 2401 return true;
2400#endif 2402#endif
2401} 2403}
2402 2404
2403 2405
2404/* 2406/*
2405 * We get something between 0..255 into us 2407 * We get something between 0..255 into us
2406*/ 2408*/
2407bool Ramses::setDisplayBrightness(int bright) 2409bool Ramses::setDisplayBrightness(int bright)
2408{ 2410{
2409 qDebug("Ramses::setDisplayBrightness(%d)", bright); 2411 qDebug("Ramses::setDisplayBrightness(%d)", bright);
2410 bool res = false; 2412 bool res = false;
2411 int fd; 2413 int fd;
2412 2414
2413 // pwm1 brighness: 20 steps 500..0 (dunkel->hell) 2415 // pwm1 brighness: 20 steps 500..0 (dunkel->hell)
2414 2416
2415 if (bright > 255 ) 2417 if (bright > 255 )
2416 bright = 255; 2418 bright = 255;
2417 if (bright < 0) 2419 if (bright < 0)
2418 bright = 0; 2420 bright = 0;
2419 2421
2420 // Turn backlight completely off 2422 // Turn backlight completely off
2421 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { 2423 if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) {
2422 char writeCommand[10]; 2424 char writeCommand[10];
2423 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); 2425 const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0);
2424 res = (::write(fd, writeCommand, count) != -1); 2426 res = (::write(fd, writeCommand, count) != -1);
2425 ::close(fd); 2427 ::close(fd);
2426 } 2428 }
2427 2429
2428 // scale backlight brightness to hardware 2430 // scale backlight brightness to hardware
2429 bright = 500-(bright * 500 / 255); 2431 bright = 500-(bright * 500 / 255);
2430 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { 2432 if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) {
2431 qDebug(" %d -> pwm1", bright); 2433 qDebug(" %d -> pwm1", bright);
2432 char writeCommand[100]; 2434 char writeCommand[100];
2433 const int count = sprintf(writeCommand, "%d\n", bright); 2435 const int count = sprintf(writeCommand, "%d\n", bright);
2434 res = (::write(fd, writeCommand, count) != -1); 2436 res = (::write(fd, writeCommand, count) != -1);
2435 ::close(fd); 2437 ::close(fd);
2436 } 2438 }
2437 return res; 2439 return res;
2438} 2440}
2439 2441
2440 2442
2441int Ramses::displayBrightnessResolution() const 2443int Ramses::displayBrightnessResolution() const
2442{ 2444{
2443 return 32; 2445 return 32;
2444} 2446}
2445 2447
2446bool Ramses::setDisplayContrast(int contr) 2448bool Ramses::setDisplayContrast(int contr)
2447{ 2449{
2448 qDebug("Ramses::setDisplayContrast(%d)", contr); 2450 qDebug("Ramses::setDisplayContrast(%d)", contr);
2449 bool res = false; 2451 bool res = false;
2450 int fd; 2452 int fd;
2451 2453
2452 // pwm0 contrast: 20 steps 79..90 (dunkel->hell) 2454 // pwm0 contrast: 20 steps 79..90 (dunkel->hell)
2453 2455
2454 if (contr > 255 ) 2456 if (contr > 255 )
2455 contr = 255; 2457 contr = 255;
2456 if (contr < 0) 2458 if (contr < 0)
2457 contr = 0; 2459 contr = 0;
2458 contr = 90 - (contr * 20 / 255); 2460 contr = 90 - (contr * 20 / 255);
2459 2461
2460 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { 2462 if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) {
2461 qDebug(" %d -> pwm0", contr); 2463 qDebug(" %d -> pwm0", contr);
2462 char writeCommand[100]; 2464 char writeCommand[100];
2463 const int count = sprintf(writeCommand, "%d\n", contr); 2465 const int count = sprintf(writeCommand, "%d\n", contr);
2464 res = (::write(fd, writeCommand, count) != -1); 2466 res = (::write(fd, writeCommand, count) != -1);
2465 res = true; 2467 res = true;
2466 ::close(fd); 2468 ::close(fd);
2467 } 2469 }
2468 return res; 2470 return res;
2469} 2471}
2470 2472
2471 2473
2472int Ramses::displayContrastResolution() const 2474int Ramses::displayContrastResolution() const
2473{ 2475{
2474 return 20; 2476 return 20;
2475} 2477}
2476 2478
2477 2479
2478/************************************************** 2480/**************************************************
2479 * * 2481 * *
2480 * Jornada * 2482 * Jornada *
2481 * * 2483 * *
2482 **************************************************/ 2484 **************************************************/
2483 2485
2484 2486
2485bool Jornada::isJornada ( ) 2487bool Jornada::isJornada ( )
2486{ 2488{
2487 QFile f( "/proc/cpuinfo" ); 2489 QFile f( "/proc/cpuinfo" );
2488 if ( f. open ( IO_ReadOnly ) ) { 2490 if ( f. open ( IO_ReadOnly ) ) {
2489 QTextStream ts ( &f ); 2491 QTextStream ts ( &f );
2490 QString line; 2492 QString line;
2491 while( line = ts. readLine ( ) ) { 2493 while( line = ts. readLine ( ) ) {
2492 if ( line. left ( 8 ) == "Hardware" ) { 2494 if ( line. left ( 8 ) == "Hardware" ) {
2493 int loc = line. find ( ":" ); 2495 int loc = line. find ( ":" );
2494 if ( loc != -1 ) { 2496 if ( loc != -1 ) {
2495 QString model = 2497 QString model =
2496 line. mid ( loc + 2 ). simplifyWhiteSpace( ); 2498 line. mid ( loc + 2 ). simplifyWhiteSpace( );
2497 return ( model == "HP Jornada 56x" ); 2499 return ( model == "HP Jornada 56x" );
2498 } 2500 }
2499 } 2501 }
2500 } 2502 }
2501 } 2503 }
2502 return false; 2504 return false;
2503} 2505}
2504 2506
2505void Jornada::init ( ) 2507void Jornada::init ( )
2506{ 2508{
2507 d-> m_vendorstr = "HP"; 2509 d-> m_vendorstr = "HP";
2508 d-> m_vendor = Vendor_HP; 2510 d-> m_vendor = Vendor_HP;
2509 d-> m_modelstr = "Jornada 56x"; 2511 d-> m_modelstr = "Jornada 56x";
2510 d-> m_model = Model_Jornada_56x; 2512 d-> m_model = Model_Jornada_56x;
2511 d-> m_systemstr = "Familiar"; 2513 d-> m_systemstr = "Familiar";
2512 d-> m_system = System_Familiar; 2514 d-> m_system = System_Familiar;
2513 d-> m_rotation = Rot0; 2515 d-> m_rotation = Rot0;
2514 2516
2515 QFile f ( "/etc/familiar-version" ); 2517 QFile f ( "/etc/familiar-version" );
2516 f. setName ( "/etc/familiar-version" ); 2518 f. setName ( "/etc/familiar-version" );
2517 if ( f. open ( IO_ReadOnly )) { 2519 if ( f. open ( IO_ReadOnly )) {
2518 2520
2519 QTextStream ts ( &f ); 2521 QTextStream ts ( &f );
2520 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 2522 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
2521 2523
2522 f. close ( ); 2524 f. close ( );
2523 } 2525 }
2524} 2526}
2525 2527
2526#if 0 2528#if 0
2527void Jornada::initButtons ( ) 2529void Jornada::initButtons ( )
2528{ 2530{
2529 if ( d-> m_buttons ) 2531 if ( d-> m_buttons )
2530 return; 2532 return;
2531 2533
2532 // Simulation uses iPAQ 3660 device buttons 2534 // Simulation uses iPAQ 3660 device buttons
2533 2535
2534 qDebug ( "init Buttons" ); 2536 qDebug ( "init Buttons" );
2535 d-> m_buttons = new QValueList <ODeviceButton>; 2537 d-> m_buttons = new QValueList <ODeviceButton>;
2536 2538
2537 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 2539 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
2538 i_button *ib = ipaq_buttons + i; 2540 i_button *ib = ipaq_buttons + i;
2539 ODeviceButton b; 2541 ODeviceButton b;
2540 2542
2541 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 2543 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
2542 b. setKeycode ( ib-> code ); 2544 b. setKeycode ( ib-> code );
2543 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 2545 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
2544 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 2546 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
2545 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 2547 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
2546 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 2548 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
2547 d-> m_buttons-> append ( b ); 2549 d-> m_buttons-> append ( b );
2548 } 2550 }
2549 } 2551 }
2550 reloadButtonMapping ( ); 2552 reloadButtonMapping ( );
2551 2553
2552 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 2554 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
2553 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 2555 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
2554} 2556}
2555#endif 2557#endif
2556int Jornada::displayBrightnessResolution ( ) const 2558int Jornada::displayBrightnessResolution ( ) const
2557{ 2559{
2558} 2560}
2559 2561
2560bool Jornada::setDisplayBrightness ( int bright ) 2562bool Jornada::setDisplayBrightness ( int bright )
2561{ 2563{
2562 bool res = false; 2564 bool res = false;
2563 int fd; 2565 int fd;
2564 2566
2565 if ( bright > 255 ) 2567 if ( bright > 255 )
2566 bright = 255; 2568 bright = 255;
2567 if ( bright < 0 ) 2569 if ( bright < 0 )
2568 bright = 0; 2570 bright = 0;
2569 2571
2570 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 2572 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
2571 FLITE_IN bl; 2573 FLITE_IN bl;
2572 bl. mode = 1; 2574 bl. mode = 1;
2573 bl. pwr = bright ? 1 : 0; 2575 bl. pwr = bright ? 1 : 0;
2574 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 2576 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
2575 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 2577 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
2576 ::close ( fd ); 2578 ::close ( fd );
2577 } 2579 }
2578 return res; 2580 return res;
2579} 2581}
2580 2582
2581bool Jornada::setSoftSuspend ( bool soft ) 2583bool Jornada::setSoftSuspend ( bool soft )
2582{ 2584{
2583 bool res = false; 2585 bool res = false;
2584 int fd; 2586 int fd;
2585 2587
2586 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 2588 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
2587 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 2589 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
2588 res = true; 2590 res = true;
2589 else 2591 else
2590 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 2592 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
2591 2593
2592 ::close ( fd ); 2594 ::close ( fd );
2593 } 2595 }
2594 else 2596 else
2595 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 2597 ::perror ( "/proc/sys/ts/suspend_button_mode" );
2596 2598
2597 return res; 2599 return res;
2598} 2600}