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