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