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