summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp59
1 files changed, 50 insertions, 9 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 2873407..01932c9 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,1803 +1,1844 @@
1/* This file is part of the OPIE libraries 1/* This file is part of the OPIE libraries
2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org) 2 Copyright (C) 2002 Robert Griebl (sandman@handhelds.org)
3 3
4 This library is free software; you can redistribute it and/or 4 This library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Library General Public 5 modify it under the terms of the GNU Library General Public
6 License as published by the Free Software Foundation; either 6 License as published by the Free Software Foundation; either
7 version 2 of the License, or (at your option) any later version. 7 version 2 of the License, or (at your option) any later version.
8 8
9 This library is distributed in the hope that it will be useful, 9 This library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of 10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Library General Public License for more details. 12 Library General Public License for more details.
13 13
14 You should have received a copy of the GNU Library General Public License 14 You should have received a copy of the GNU Library General Public License
15 along with this library; see the file COPYING.LIB. If not, write to 15 along with this library; see the file COPYING.LIB. If not, write to
16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 16 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 Boston, MA 02111-1307, USA. 17 Boston, MA 02111-1307, USA.
18*/ 18*/
19 19
20#include <stdlib.h> 20#include <stdlib.h>
21#include <unistd.h> 21#include <unistd.h>
22#include <fcntl.h> 22#include <fcntl.h>
23#include <sys/ioctl.h> 23#include <sys/ioctl.h>
24#include <signal.h> 24#include <signal.h>
25#include <sys/time.h> 25#include <sys/time.h>
26#include <linux/soundcard.h> 26#include <linux/soundcard.h>
27#include <math.h> 27#include <math.h>
28 28
29#include <qapplication.h> 29#include <qapplication.h>
30 30
31#include <qfile.h> 31#include <qfile.h>
32#include <qtextstream.h> 32#include <qtextstream.h>
33#include <qpe/sound.h> 33#include <qpe/sound.h>
34#include <qpe/resource.h> 34#include <qpe/resource.h>
35#include <qpe/config.h> 35#include <qpe/config.h>
36#include <qpe/qcopenvelope_qws.h> 36#include <qpe/qcopenvelope_qws.h>
37 37
38#include "odevice.h" 38#include "odevice.h"
39 39
40#include <qwindowsystem_qws.h> 40#include <qwindowsystem_qws.h>
41 41
42#ifndef ARRAY_SIZE 42#ifndef ARRAY_SIZE
43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) 43#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
44#endif 44#endif
45 45
46// _IO and friends are only defined in kernel headers ... 46// _IO and friends are only defined in kernel headers ...
47 47
48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 48#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
49 49
50#define OD_IO(type,number) OD_IOC(0,type,number,0) 50#define OD_IO(type,number) OD_IOC(0,type,number,0)
51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 51#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 52#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 53#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
54 54
55using namespace Opie; 55using namespace Opie;
56 56
57class ODeviceData { 57class ODeviceData {
58public: 58public:
59 QString m_vendorstr; 59 QString m_vendorstr;
60 OVendor m_vendor; 60 OVendor m_vendor;
61 61
62 QString m_modelstr; 62 QString m_modelstr;
63 OModel m_model; 63 OModel m_model;
64 64
65 QString m_systemstr; 65 QString m_systemstr;
66 OSystem m_system; 66 OSystem m_system;
67 67
68 QString m_sysverstr; 68 QString m_sysverstr;
69 69
70 Transformation m_rotation; 70 Transformation m_rotation;
71 ODirection m_direction; 71 ODirection m_direction;
72 72
73 QValueList <ODeviceButton> *m_buttons; 73 QValueList <ODeviceButton> *m_buttons;
74 uint m_holdtime; 74 uint m_holdtime;
75}; 75};
76 76
77 77
78class iPAQ : public ODevice, public QWSServer::KeyboardFilter { 78class iPAQ : public ODevice, public QWSServer::KeyboardFilter {
79protected: 79protected:
80 virtual void init ( ); 80 virtual void init ( );
81 virtual void initButtons ( ); 81 virtual void initButtons ( );
82 82
83public: 83public:
84 virtual bool setSoftSuspend ( bool soft ); 84 virtual bool setSoftSuspend ( bool soft );
85 85
86 virtual bool setDisplayBrightness ( int b ); 86 virtual bool setDisplayBrightness ( int b );
87 virtual int displayBrightnessResolution ( ) const; 87 virtual int displayBrightnessResolution ( ) const;
88 88
89 virtual void alarmSound ( ); 89 virtual void alarmSound ( );
90 90
91 virtual QValueList <OLed> ledList ( ) const; 91 virtual QValueList <OLed> ledList ( ) const;
92 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 92 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
93 virtual OLedState ledState ( OLed led ) const; 93 virtual OLedState ledState ( OLed led ) const;
94 virtual bool setLedState ( OLed led, OLedState st ); 94 virtual bool setLedState ( OLed led, OLedState st );
95 95
96 virtual bool hasLightSensor ( ) const; 96 virtual bool hasLightSensor ( ) const;
97 virtual int readLightSensor ( ); 97 virtual int readLightSensor ( );
98 virtual int lightSensorResolution ( ) const; 98 virtual int lightSensorResolution ( ) const;
99 99
100protected: 100protected:
101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 101 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
102 virtual void timerEvent ( QTimerEvent *te ); 102 virtual void timerEvent ( QTimerEvent *te );
103 103
104 int m_power_timer; 104 int m_power_timer;
105 105
106 OLedState m_leds [2]; 106 OLedState m_leds [2];
107}; 107};
108 108
109class Zaurus : public ODevice { 109class Zaurus : public ODevice {
110protected: 110protected:
111 virtual void init ( ); 111 virtual void init ( );
112 virtual void initButtons ( ); 112 virtual void initButtons ( );
113 113
114public: 114public:
115 virtual bool setSoftSuspend ( bool soft ); 115 virtual bool setSoftSuspend ( bool soft );
116 116
117 virtual bool setDisplayBrightness ( int b ); 117 virtual bool setDisplayBrightness ( int b );
118 virtual int displayBrightnessResolution ( ) const; 118 virtual int displayBrightnessResolution ( ) const;
119 119
120 virtual void alarmSound ( ); 120 virtual void alarmSound ( );
121 virtual void keySound ( ); 121 virtual void keySound ( );
122 virtual void touchSound ( ); 122 virtual void touchSound ( );
123 123
124 virtual QValueList <OLed> ledList ( ) const; 124 virtual QValueList <OLed> ledList ( ) const;
125 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 125 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
126 virtual OLedState ledState ( OLed led ) const; 126 virtual OLedState ledState ( OLed led ) const;
127 virtual bool setLedState ( OLed led, OLedState st ); 127 virtual bool setLedState ( OLed led, OLedState st );
128 128
129protected: 129protected:
130 virtual void buzzer ( int snd ); 130 virtual void buzzer ( int snd );
131 131
132 OLedState m_leds [1]; 132 OLedState m_leds [1];
133}; 133};
134 134
135class SIMpad : public ODevice, public QWSServer::KeyboardFilter { 135class SIMpad : public ODevice, public QWSServer::KeyboardFilter {
136protected: 136protected:
137 virtual void init ( ); 137 virtual void init ( );
138 virtual void initButtons ( ); 138 virtual void initButtons ( );
139 139
140public: 140public:
141 virtual bool setSoftSuspend ( bool soft ); 141 virtual bool setSoftSuspend ( bool soft );
142 virtual bool suspend(); 142 virtual bool suspend();
143 143
144 virtual bool setDisplayStatus( bool on ); 144 virtual bool setDisplayStatus( bool on );
145 virtual bool setDisplayBrightness ( int b ); 145 virtual bool setDisplayBrightness ( int b );
146 virtual int displayBrightnessResolution ( ) const; 146 virtual int displayBrightnessResolution ( ) const;
147 147
148 virtual void alarmSound ( ); 148 virtual void alarmSound ( );
149 149
150 virtual QValueList <OLed> ledList ( ) const; 150 virtual QValueList <OLed> ledList ( ) const;
151 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 151 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
152 virtual OLedState ledState ( OLed led ) const; 152 virtual OLedState ledState ( OLed led ) const;
153 virtual bool setLedState ( OLed led, OLedState st ); 153 virtual bool setLedState ( OLed led, OLedState st );
154 154
155protected: 155protected:
156 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 156 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
157 virtual void timerEvent ( QTimerEvent *te ); 157 virtual void timerEvent ( QTimerEvent *te );
158 158
159 int m_power_timer; 159 int m_power_timer;
160 160
161 OLedState m_leds [1]; //FIXME check if really only one 161 OLedState m_leds [1]; //FIXME check if really only one
162}; 162};
163 163
164struct i_button { 164struct i_button {
165 uint model; 165 uint model;
166 Qt::Key code; 166 Qt::Key code;
167 char *utext; 167 char *utext;
168 char *pix; 168 char *pix;
169 char *fpressedservice; 169 char *fpressedservice;
170 char *fpressedaction; 170 char *fpressedaction;
171 char *fheldservice; 171 char *fheldservice;
172 char *fheldaction; 172 char *fheldaction;
173} ipaq_buttons [] = { 173} ipaq_buttons [] = {
174 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 174 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
175 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 175 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
176 "devicebuttons/ipaq_calendar", 176 "devicebuttons/ipaq_calendar",
177 "datebook", "nextView()", 177 "datebook", "nextView()",
178 "today", "raise()" }, 178 "today", "raise()" },
179 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 179 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
180 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 180 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
181 "devicebuttons/ipaq_contact", 181 "devicebuttons/ipaq_contact",
182 "addressbook", "raise()", 182 "addressbook", "raise()",
183 "addressbook", "beamBusinessCard()" }, 183 "addressbook", "beamBusinessCard()" },
184 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 184 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
185 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 185 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
186 "devicebuttons/ipaq_menu", 186 "devicebuttons/ipaq_menu",
187 "QPE/TaskBar", "toggleMenu()", 187 "QPE/TaskBar", "toggleMenu()",
188 "QPE/TaskBar", "toggleStartMenu()" }, 188 "QPE/TaskBar", "toggleStartMenu()" },
189 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 189 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
190 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 190 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
191 "devicebuttons/ipaq_mail", 191 "devicebuttons/ipaq_mail",
192 "mail", "raise()", 192 "mail", "raise()",
193 "mail", "newMail()" }, 193 "mail", "newMail()" },
194 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 194 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
195 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 195 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
196 "devicebuttons/ipaq_home", 196 "devicebuttons/ipaq_home",
197 "QPE/Launcher", "home()", 197 "QPE/Launcher", "home()",
198 "buttonsettings", "raise()" }, 198 "buttonsettings", "raise()" },
199 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 199 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
200 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 200 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
201 "devicebuttons/ipaq_record", 201 "devicebuttons/ipaq_record",
202 "QPE/VMemo", "toggleRecord()", 202 "QPE/VMemo", "toggleRecord()",
203 "sound", "raise()" }, 203 "sound", "raise()" },
204}; 204};
205 205
206struct z_button { 206struct z_button {
207 Qt::Key code; 207 Qt::Key code;
208 char *utext; 208 char *utext;
209 char *pix; 209 char *pix;
210 char *fpressedservice; 210 char *fpressedservice;
211 char *fpressedaction; 211 char *fpressedaction;
212 char *fheldservice; 212 char *fheldservice;
213 char *fheldaction; 213 char *fheldaction;
214} z_buttons [] = { 214} z_buttons [] = {
215 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 215 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
216 "devicebuttons/z_calendar", 216 "devicebuttons/z_calendar",
217 "datebook", "nextView()", 217 "datebook", "nextView()",
218 "today", "raise()" }, 218 "today", "raise()" },
219 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 219 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
220 "devicebuttons/z_contact", 220 "devicebuttons/z_contact",
221 "addressbook", "raise()", 221 "addressbook", "raise()",
222 "addressbook", "beamBusinessCard()" }, 222 "addressbook", "beamBusinessCard()" },
223 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 223 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
224 "devicebuttons/z_home", 224 "devicebuttons/z_home",
225 "QPE/Launcher", "home()", 225 "QPE/Launcher", "home()",
226 "buttonsettings", "raise()" }, 226 "buttonsettings", "raise()" },
227 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 227 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
228 "devicebuttons/z_menu", 228 "devicebuttons/z_menu",
229 "QPE/TaskBar", "toggleMenu()", 229 "QPE/TaskBar", "toggleMenu()",
230 "QPE/TaskBar", "toggleStartMenu()" }, 230 "QPE/TaskBar", "toggleStartMenu()" },
231 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 231 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
232 "devicebuttons/z_mail", 232 "devicebuttons/z_mail",
233 "mail", "raise()", 233 "mail", "raise()",
234 "mail", "newMail()" }, 234 "mail", "newMail()" },
235}; 235};
236 236
237struct z_button z_buttons_c700 [] = { 237struct z_button z_buttons_c700 [] = {
238 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 238 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
239 "devicebuttons/z_calendar", 239 "devicebuttons/z_calendar",
240 "datebook", "nextView()", 240 "datebook", "nextView()",
241 "today", "raise()" }, 241 "today", "raise()" },
242 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 242 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
243 "devicebuttons/z_contact", 243 "devicebuttons/z_contact",
244 "addressbook", "raise()", 244 "addressbook", "raise()",
245 "addressbook", "beamBusinessCard()" }, 245 "addressbook", "beamBusinessCard()" },
246 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 246 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
247 "devicebuttons/z_home", 247 "devicebuttons/z_home",
248 "QPE/Launcher", "home()", 248 "QPE/Launcher", "home()",
249 "buttonsettings", "raise()" }, 249 "buttonsettings", "raise()" },
250 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 250 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
251 "devicebuttons/z_menu", 251 "devicebuttons/z_menu",
252 "QPE/TaskBar", "toggleMenu()", 252 "QPE/TaskBar", "toggleMenu()",
253 "QPE/TaskBar", "toggleStartMenu()" }, 253 "QPE/TaskBar", "toggleStartMenu()" },
254 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"), 254 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Display Rotate"),
255 "", 255 "",
256 "QPE/Rotation", "flip()", 256 "QPE/Rotation", "flip()",
257 "QPE/Rotation", "flip()" }, 257 "QPE/Rotation", "flip()" },
258}; 258};
259 259
260struct s_button { 260struct s_button {
261 uint model; 261 uint model;
262 Qt::Key code; 262 Qt::Key code;
263 char *utext; 263 char *utext;
264 char *pix; 264 char *pix;
265 char *fpressedservice; 265 char *fpressedservice;
266 char *fpressedaction; 266 char *fpressedaction;
267 char *fheldservice; 267 char *fheldservice;
268 char *fheldaction; 268 char *fheldaction;
269} simpad_buttons [] = { 269} simpad_buttons [] = {
270 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 270 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
271 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 271 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Lower+Up"),
272 "devicebuttons/simpad_menu", 272 "devicebuttons/simpad_lower_up",
273 "QPE/TaskBar", "toggleMenu()", 273 "datebook", "nextView()",
274 "QPE/TaskBar", "toggleStartMenu()" }, 274 "today", "raise()" },
275 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, 275 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
276 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 276 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Lower+Down"),
277 "devicebuttons/ipaq_home", 277 "devicebuttons/simpad_lower_down",
278 "QPE/Launcher", "home()", 278 "addressbook", "raise()",
279 "buttonsettings", "raise()" }, 279 "addressbook", "beamBusinessCard()" },
280 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
281 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Lower+Right"),
282 "devicebuttons/simpad_lower_right",
283 "QPE/TaskBar", "toggleMenu()",
284 "QPE/TaskBar", "toggleStartMenu()" },
285 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
286 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
287 "devicebuttons/simpad_lower_upper",
288 "QPE/Launcher", "home()",
289 "buttonsettings", "raise()" },
290 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
291 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Lower+Left"),
292 "devicebuttons/simpad_lower_left",
293 "mail", "raise()",
294 "mail", "newMail()" },
295
296 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
297 Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"),
298 "devicebuttons/simpad_upper_up",
299 "datebook", "nextView()",
300 "today", "raise()" },
301 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
302 Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"),
303 "devicebuttons/simpad_upper_down",
304 "addressbook", "raise()",
305 "addressbook", "beamBusinessCard()" },
306 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
307 Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"),
308 "devicebuttons/simpad_upper_right",
309 "QPE/TaskBar", "toggleMenu()",
310 "QPE/TaskBar", "toggleStartMenu()" },
311 /*{ Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
312 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"),
313 "devicebuttons/simpad_lower_upper",
314 "QPE/Launcher", "home()",
315 "buttonsettings", "raise()" },*/
316 { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus,
317 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"),
318 "devicebuttons/simpad_upper_left",
319 "mail", "raise()",
320 "mail", "newMail()" },
280}; 321};
281 322
282static QCString makeChannel ( const char *str ) 323static QCString makeChannel ( const char *str )
283{ 324{
284 if ( str && !::strchr ( str, '/' )) 325 if ( str && !::strchr ( str, '/' ))
285 return QCString ( "QPE/Application/" ) + str; 326 return QCString ( "QPE/Application/" ) + str;
286 else 327 else
287 return str; 328 return str;
288} 329}
289 330
290static inline bool isQWS() 331static inline bool isQWS()
291{ 332{
292 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 333 return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
293} 334}
294 335
295ODevice *ODevice::inst ( ) 336ODevice *ODevice::inst ( )
296{ 337{
297 static ODevice *dev = 0; 338 static ODevice *dev = 0;
298 339
299 if ( !dev ) { 340 if ( !dev ) {
300 if ( QFile::exists ( "/proc/hal/model" )) 341 if ( QFile::exists ( "/proc/hal/model" ))
301 dev = new iPAQ ( ); 342 dev = new iPAQ ( );
302 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 343 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
303 dev = new Zaurus ( ); 344 dev = new Zaurus ( );
304 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) 345 else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" ))
305 dev = new SIMpad ( ); 346 dev = new SIMpad ( );
306 else 347 else
307 dev = new ODevice ( ); 348 dev = new ODevice ( );
308 349
309 dev-> init ( ); 350 dev-> init ( );
310 } 351 }
311 return dev; 352 return dev;
312} 353}
313 354
314 355
315/************************************************** 356/**************************************************
316 * 357 *
317 * common 358 * common
318 * 359 *
319 **************************************************/ 360 **************************************************/
320 361
321 362
322ODevice::ODevice ( ) 363ODevice::ODevice ( )
323{ 364{
324 d = new ODeviceData; 365 d = new ODeviceData;
325 366
326 d-> m_modelstr = "Unknown"; 367 d-> m_modelstr = "Unknown";
327 d-> m_model = Model_Unknown; 368 d-> m_model = Model_Unknown;
328 d-> m_vendorstr = "Unknown"; 369 d-> m_vendorstr = "Unknown";
329 d-> m_vendor = Vendor_Unknown; 370 d-> m_vendor = Vendor_Unknown;
330 d-> m_systemstr = "Unknown"; 371 d-> m_systemstr = "Unknown";
331 d-> m_system = System_Unknown; 372 d-> m_system = System_Unknown;
332 d-> m_sysverstr = "0.0"; 373 d-> m_sysverstr = "0.0";
333 d-> m_rotation = Rot0; 374 d-> m_rotation = Rot0;
334 d-> m_direction = CW; 375 d-> m_direction = CW;
335 376
336 d-> m_holdtime = 1000; // 1000ms 377 d-> m_holdtime = 1000; // 1000ms
337 d-> m_buttons = 0; 378 d-> m_buttons = 0;
338} 379}
339 380
340void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 381void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
341{ 382{
342 if ( msg == "deviceButtonMappingChanged()" ) { 383 if ( msg == "deviceButtonMappingChanged()" ) {
343 reloadButtonMapping ( ); 384 reloadButtonMapping ( );
344 } 385 }
345} 386}
346 387
347void ODevice::init ( ) 388void ODevice::init ( )
348{ 389{
349} 390}
350 391
351/** 392/**
352 * This method initialises the button mapping 393 * This method initialises the button mapping
353 */ 394 */
354void ODevice::initButtons ( ) 395void ODevice::initButtons ( )
355{ 396{
356 if ( d-> m_buttons ) 397 if ( d-> m_buttons )
357 return; 398 return;
358 399
359 // Simulation uses iPAQ 3660 device buttons 400 // Simulation uses iPAQ 3660 device buttons
360 401
361 qDebug ( "init Buttons" ); 402 qDebug ( "init Buttons" );
362 d-> m_buttons = new QValueList <ODeviceButton>; 403 d-> m_buttons = new QValueList <ODeviceButton>;
363 404
364 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 405 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
365 i_button *ib = ipaq_buttons + i; 406 i_button *ib = ipaq_buttons + i;
366 ODeviceButton b; 407 ODeviceButton b;
367 408
368 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 409 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
369 b. setKeycode ( ib-> code ); 410 b. setKeycode ( ib-> code );
370 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 411 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
371 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 412 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
372 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 413 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
373 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 414 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
374 d-> m_buttons-> append ( b ); 415 d-> m_buttons-> append ( b );
375 } 416 }
376 } 417 }
377 reloadButtonMapping ( ); 418 reloadButtonMapping ( );
378 419
379 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 420 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
380 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 421 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
381} 422}
382 423
383ODevice::~ODevice ( ) 424ODevice::~ODevice ( )
384{ 425{
385 delete d; 426 delete d;
386} 427}
387 428
388bool ODevice::setSoftSuspend ( bool /*soft*/ ) 429bool ODevice::setSoftSuspend ( bool /*soft*/ )
389{ 430{
390 return false; 431 return false;
391} 432}
392 433
393//#include <linux/apm_bios.h> 434//#include <linux/apm_bios.h>
394 435
395#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 436#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
396 437
397/** 438/**
398 * This method will try to suspend the device 439 * This method will try to suspend the device
399 * It only works if the user is the QWS Server and the apm application 440 * It only works if the user is the QWS Server and the apm application
400 * is installed. 441 * is installed.
401 * It tries to suspend and then waits some time cause some distributions 442 * It tries to suspend and then waits some time cause some distributions
402 * do have asynchronus apm implementations. 443 * do have asynchronus apm implementations.
403 * This method will either fail and return false or it'll suspend the 444 * This method will either fail and return false or it'll suspend the
404 * device and return once the device got woken up 445 * device and return once the device got woken up
405 * 446 *
406 * @return if the device got suspended 447 * @return if the device got suspended
407 */ 448 */
408bool ODevice::suspend ( ) 449bool ODevice::suspend ( )
409{ 450{
410 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 451 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
411 return false; 452 return false;
412 453
413 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 454 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
414 return false; 455 return false;
415 456
416 bool res = false; 457 bool res = false;
417 458
418 struct timeval tvs, tvn; 459 struct timeval tvs, tvn;
419 ::gettimeofday ( &tvs, 0 ); 460 ::gettimeofday ( &tvs, 0 );
420 461
421 ::sync ( ); // flush fs caches 462 ::sync ( ); // flush fs caches
422 res = ( ::system ( "apm --suspend" ) == 0 ); 463 res = ( ::system ( "apm --suspend" ) == 0 );
423 464
424 // This is needed because the iPAQ apm implementation is asynchronous and we 465 // This is needed because the iPAQ apm implementation is asynchronous and we
425 // can not be sure when exactly the device is really suspended 466 // can not be sure when exactly the device is really suspended
426 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 467 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
427 468
428 if ( res ) { 469 if ( res ) {
429 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 470 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
430 ::usleep ( 200 * 1000 ); 471 ::usleep ( 200 * 1000 );
431 ::gettimeofday ( &tvn, 0 ); 472 ::gettimeofday ( &tvn, 0 );
432 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 473 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
433 } 474 }
434 475
435 return res; 476 return res;
436} 477}
437 478
438//#include <linux/fb.h> better not rely on kernel headers in userspace ... 479//#include <linux/fb.h> better not rely on kernel headers in userspace ...
439 480
440#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 481#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
441 482
442/* VESA Blanking Levels */ 483/* VESA Blanking Levels */
443#define VESA_NO_BLANKING 0 484#define VESA_NO_BLANKING 0
444#define VESA_VSYNC_SUSPEND 1 485#define VESA_VSYNC_SUSPEND 1
445#define VESA_HSYNC_SUSPEND 2 486#define VESA_HSYNC_SUSPEND 2
446#define VESA_POWERDOWN 3 487#define VESA_POWERDOWN 3
447 488
448/** 489/**
449 * This sets the display on or off 490 * This sets the display on or off
450 */ 491 */
451bool ODevice::setDisplayStatus ( bool on ) 492bool ODevice::setDisplayStatus ( bool on )
452{ 493{
453 if ( d-> m_model == Model_Unknown ) 494 if ( d-> m_model == Model_Unknown )
454 return false; 495 return false;
455 496
456 bool res = false; 497 bool res = false;
457 int fd; 498 int fd;
458 499
459 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 500 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
460 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 501 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
461 ::close ( fd ); 502 ::close ( fd );
462 } 503 }
463 return res; 504 return res;
464} 505}
465 506
466/** 507/**
467 * This sets the display brightness 508 * This sets the display brightness
468 * @return success or failure 509 * @return success or failure
469 */ 510 */
470bool ODevice::setDisplayBrightness ( int p) 511bool ODevice::setDisplayBrightness ( int p)
471{ 512{
472 Q_UNUSED( p ) 513 Q_UNUSED( p )
473 return false; 514 return false;
474} 515}
475 516
476int ODevice::displayBrightnessResolution ( ) const 517int ODevice::displayBrightnessResolution ( ) const
477{ 518{
478 return 16; 519 return 16;
479} 520}
480 521
481/** 522/**
482 * This returns the vendor as string 523 * This returns the vendor as string
483 * @return Vendor as QString 524 * @return Vendor as QString
484 */ 525 */
485QString ODevice::vendorString ( ) const 526QString ODevice::vendorString ( ) const
486{ 527{
487 return d-> m_vendorstr; 528 return d-> m_vendorstr;
488} 529}
489 530
490/** 531/**
491 * This returns the vendor as one of the values of OVendor 532 * This returns the vendor as one of the values of OVendor
492 * @return OVendor 533 * @return OVendor
493 */ 534 */
494OVendor ODevice::vendor ( ) const 535OVendor ODevice::vendor ( ) const
495{ 536{
496 return d-> m_vendor; 537 return d-> m_vendor;
497} 538}
498 539
499/** 540/**
500 * This returns the model as a string 541 * This returns the model as a string
501 * @return A string representing the model 542 * @return A string representing the model
502 */ 543 */
503QString ODevice::modelString ( ) const 544QString ODevice::modelString ( ) const
504{ 545{
505 return d-> m_modelstr; 546 return d-> m_modelstr;
506} 547}
507 548
508/** 549/**
509 * This does return the OModel used 550 * This does return the OModel used
510 */ 551 */
511OModel ODevice::model ( ) const 552OModel ODevice::model ( ) const
512{ 553{
513 return d-> m_model; 554 return d-> m_model;
514} 555}
515 556
516/** 557/**
517 * This does return the systen name 558 * This does return the systen name
518 */ 559 */
519QString ODevice::systemString ( ) const 560QString ODevice::systemString ( ) const
520{ 561{
521 return d-> m_systemstr; 562 return d-> m_systemstr;
522} 563}
523 564
524/** 565/**
525 * Return System as OSystem value 566 * Return System as OSystem value
526 */ 567 */
527OSystem ODevice::system ( ) const 568OSystem ODevice::system ( ) const
528{ 569{
529 return d-> m_system; 570 return d-> m_system;
530} 571}
531 572
532/** 573/**
533 * @return the version string of the base system 574 * @return the version string of the base system
534 */ 575 */
535QString ODevice::systemVersionString ( ) const 576QString ODevice::systemVersionString ( ) const
536{ 577{
537 return d-> m_sysverstr; 578 return d-> m_sysverstr;
538} 579}
539 580
540/** 581/**
541 * @return the current Transformation 582 * @return the current Transformation
542 */ 583 */
543Transformation ODevice::rotation ( ) const 584Transformation ODevice::rotation ( ) const
544{ 585{
545 return d-> m_rotation; 586 return d-> m_rotation;
546} 587}
547 588
548/** 589/**
549 * @return the current rotation direction 590 * @return the current rotation direction
550 */ 591 */
551ODirection ODevice::direction ( ) const 592ODirection ODevice::direction ( ) const
552{ 593{
553 return d-> m_direction; 594 return d-> m_direction;
554} 595}
555 596
556/** 597/**
557 * This plays an alarmSound 598 * This plays an alarmSound
558 */ 599 */
559void ODevice::alarmSound ( ) 600void ODevice::alarmSound ( )
560{ 601{
561#ifndef QT_NO_SOUND 602#ifndef QT_NO_SOUND
562 static Sound snd ( "alarm" ); 603 static Sound snd ( "alarm" );
563 604
564 if ( snd. isFinished ( )) 605 if ( snd. isFinished ( ))
565 snd. play ( ); 606 snd. play ( );
566#endif 607#endif
567} 608}
568 609
569/** 610/**
570 * This plays a key sound 611 * This plays a key sound
571 */ 612 */
572void ODevice::keySound ( ) 613void ODevice::keySound ( )
573{ 614{
574#ifndef QT_NO_SOUND 615#ifndef QT_NO_SOUND
575 static Sound snd ( "keysound" ); 616 static Sound snd ( "keysound" );
576 617
577 if ( snd. isFinished ( )) 618 if ( snd. isFinished ( ))
578 snd. play ( ); 619 snd. play ( );
579#endif 620#endif
580} 621}
581 622
582/** 623/**
583 * This plays a touch sound 624 * This plays a touch sound
584 */ 625 */
585void ODevice::touchSound ( ) 626void ODevice::touchSound ( )
586{ 627{
587 628
588#ifndef QT_NO_SOUND 629#ifndef QT_NO_SOUND
589 static Sound snd ( "touchsound" ); 630 static Sound snd ( "touchsound" );
590 631
591 if ( snd. isFinished ( )) 632 if ( snd. isFinished ( ))
592 snd. play ( ); 633 snd. play ( );
593#endif 634#endif
594} 635}
595 636
596/** 637/**
597 * This method will return a list of leds 638 * This method will return a list of leds
598 * available on this device 639 * available on this device
599 * @return a list of LEDs. 640 * @return a list of LEDs.
600 */ 641 */
601QValueList <OLed> ODevice::ledList ( ) const 642QValueList <OLed> ODevice::ledList ( ) const
602{ 643{
603 return QValueList <OLed> ( ); 644 return QValueList <OLed> ( );
604} 645}
605 646
606/** 647/**
607 * This does return the state of the LEDs 648 * This does return the state of the LEDs
608 */ 649 */
609QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 650QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
610{ 651{
611 return QValueList <OLedState> ( ); 652 return QValueList <OLedState> ( );
612} 653}
613 654
614/** 655/**
615 * @return the state for a given OLed 656 * @return the state for a given OLed
616 */ 657 */
617OLedState ODevice::ledState ( OLed /*which*/ ) const 658OLedState ODevice::ledState ( OLed /*which*/ ) const
618{ 659{
619 return Led_Off; 660 return Led_Off;
620} 661}
621 662
622/** 663/**
623 * Set the state for a LED 664 * Set the state for a LED
624 * @param which Which OLed to use 665 * @param which Which OLed to use
625 * @param st The state to set 666 * @param st The state to set
626 * @return success or failure 667 * @return success or failure
627 */ 668 */
628bool ODevice::setLedState ( OLed which, OLedState st ) 669bool ODevice::setLedState ( OLed which, OLedState st )
629{ 670{
630 Q_UNUSED( which ) 671 Q_UNUSED( which )
631 Q_UNUSED( st ) 672 Q_UNUSED( st )
632 return false; 673 return false;
633} 674}
634 675
635/** 676/**
636 * @return if the device has a light sensor 677 * @return if the device has a light sensor
637 */ 678 */
638bool ODevice::hasLightSensor ( ) const 679bool ODevice::hasLightSensor ( ) const
639{ 680{
640 return false; 681 return false;
641} 682}
642 683
643/** 684/**
644 * @return a value from the light senso 685 * @return a value from the light senso
645 */ 686 */
646int ODevice::readLightSensor ( ) 687int ODevice::readLightSensor ( )
647{ 688{
648 return -1; 689 return -1;
649} 690}
650 691
651/** 692/**
652 * @return the light sensor resolution whatever that is ;) 693 * @return the light sensor resolution whatever that is ;)
653 */ 694 */
654int ODevice::lightSensorResolution ( ) const 695int ODevice::lightSensorResolution ( ) const
655{ 696{
656 return 0; 697 return 0;
657} 698}
658 699
659/** 700/**
660 * @return a list of hardware buttons 701 * @return a list of hardware buttons
661 */ 702 */
662const QValueList <ODeviceButton> &ODevice::buttons ( ) 703const QValueList <ODeviceButton> &ODevice::buttons ( )
663{ 704{
664 initButtons ( ); 705 initButtons ( );
665 706
666 return *d-> m_buttons; 707 return *d-> m_buttons;
667} 708}
668 709
669/** 710/**
670 * @return The amount of time that would count as a hold 711 * @return The amount of time that would count as a hold
671 */ 712 */
672uint ODevice::buttonHoldTime ( ) const 713uint ODevice::buttonHoldTime ( ) const
673{ 714{
674 return d-> m_holdtime; 715 return d-> m_holdtime;
675} 716}
676 717
677/** 718/**
678 * This method return a ODeviceButton for a key code 719 * This method return a ODeviceButton for a key code
679 * or 0 if no special hardware button is available for the device 720 * or 0 if no special hardware button is available for the device
680 * 721 *
681 * @return The devicebutton or 0l 722 * @return The devicebutton or 0l
682 * @see ODeviceButton 723 * @see ODeviceButton
683 */ 724 */
684const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 725const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
685{ 726{
686 initButtons ( ); 727 initButtons ( );
687 728
688 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 729 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
689 if ( (*it). keycode ( ) == code ) 730 if ( (*it). keycode ( ) == code )
690 return &(*it); 731 return &(*it);
691 } 732 }
692 return 0; 733 return 0;
693} 734}
694 735
695void ODevice::reloadButtonMapping ( ) 736void ODevice::reloadButtonMapping ( )
696{ 737{
697 initButtons ( ); 738 initButtons ( );
698 739
699 Config cfg ( "ButtonSettings" ); 740 Config cfg ( "ButtonSettings" );
700 741
701 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 742 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
702 ODeviceButton &b = ( *d-> m_buttons ) [i]; 743 ODeviceButton &b = ( *d-> m_buttons ) [i];
703 QString group = "Button" + QString::number ( i ); 744 QString group = "Button" + QString::number ( i );
704 745
705 QCString pch, hch; 746 QCString pch, hch;
706 QCString pm, hm; 747 QCString pm, hm;
707 QByteArray pdata, hdata; 748 QByteArray pdata, hdata;
708 749
709 if ( cfg. hasGroup ( group )) { 750 if ( cfg. hasGroup ( group )) {
710 cfg. setGroup ( group ); 751 cfg. setGroup ( group );
711 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 752 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
712 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 753 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
713 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 754 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
714 755
715 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 756 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
716 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 757 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
717 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 758 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
718 } 759 }
719 760
720 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 761 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
721 762
722 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 763 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
723 } 764 }
724} 765}
725 766
726void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 767void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
727{ 768{
728 initButtons ( ); 769 initButtons ( );
729 770
730 QString mb_chan; 771 QString mb_chan;
731 772
732 if ( button >= (int) d-> m_buttons-> count ( )) 773 if ( button >= (int) d-> m_buttons-> count ( ))
733 return; 774 return;
734 775
735 ODeviceButton &b = ( *d-> m_buttons ) [button]; 776 ODeviceButton &b = ( *d-> m_buttons ) [button];
736 b. setPressedAction ( action ); 777 b. setPressedAction ( action );
737 778
738 mb_chan=b. pressedAction ( ). channel ( ); 779 mb_chan=b. pressedAction ( ). channel ( );
739 780
740 Config buttonFile ( "ButtonSettings" ); 781 Config buttonFile ( "ButtonSettings" );
741 buttonFile. setGroup ( "Button" + QString::number ( button )); 782 buttonFile. setGroup ( "Button" + QString::number ( button ));
742 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 783 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
743 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 784 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
744 785
745 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 786 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
746 787
747 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 788 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
748} 789}
749 790
750void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 791void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
751{ 792{
752 initButtons ( ); 793 initButtons ( );
753 794
754 if ( button >= (int) d-> m_buttons-> count ( )) 795 if ( button >= (int) d-> m_buttons-> count ( ))
755 return; 796 return;
756 797
757 ODeviceButton &b = ( *d-> m_buttons ) [button]; 798 ODeviceButton &b = ( *d-> m_buttons ) [button];
758 b. setHeldAction ( action ); 799 b. setHeldAction ( action );
759 800
760 Config buttonFile ( "ButtonSettings" ); 801 Config buttonFile ( "ButtonSettings" );
761 buttonFile. setGroup ( "Button" + QString::number ( button )); 802 buttonFile. setGroup ( "Button" + QString::number ( button ));
762 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 803 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
763 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 804 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
764 805
765 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 806 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
766 807
767 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 808 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
768} 809}
769 810
770 811
771 812
772 813
773/************************************************** 814/**************************************************
774 * 815 *
775 * iPAQ 816 * iPAQ
776 * 817 *
777 **************************************************/ 818 **************************************************/
778 819
779void iPAQ::init ( ) 820void iPAQ::init ( )
780{ 821{
781 d-> m_vendorstr = "HP"; 822 d-> m_vendorstr = "HP";
782 d-> m_vendor = Vendor_HP; 823 d-> m_vendor = Vendor_HP;
783 824
784 QFile f ( "/proc/hal/model" ); 825 QFile f ( "/proc/hal/model" );
785 826
786 if ( f. open ( IO_ReadOnly )) { 827 if ( f. open ( IO_ReadOnly )) {
787 QTextStream ts ( &f ); 828 QTextStream ts ( &f );
788 829
789 d-> m_modelstr = "H" + ts. readLine ( ); 830 d-> m_modelstr = "H" + ts. readLine ( );
790 831
791 if ( d-> m_modelstr == "H3100" ) 832 if ( d-> m_modelstr == "H3100" )
792 d-> m_model = Model_iPAQ_H31xx; 833 d-> m_model = Model_iPAQ_H31xx;
793 else if ( d-> m_modelstr == "H3600" ) 834 else if ( d-> m_modelstr == "H3600" )
794 d-> m_model = Model_iPAQ_H36xx; 835 d-> m_model = Model_iPAQ_H36xx;
795 else if ( d-> m_modelstr == "H3700" ) 836 else if ( d-> m_modelstr == "H3700" )
796 d-> m_model = Model_iPAQ_H37xx; 837 d-> m_model = Model_iPAQ_H37xx;
797 else if ( d-> m_modelstr == "H3800" ) 838 else if ( d-> m_modelstr == "H3800" )
798 d-> m_model = Model_iPAQ_H38xx; 839 d-> m_model = Model_iPAQ_H38xx;
799 else if ( d-> m_modelstr == "H3900" ) 840 else if ( d-> m_modelstr == "H3900" )
800 d-> m_model = Model_iPAQ_H39xx; 841 d-> m_model = Model_iPAQ_H39xx;
801 else 842 else
802 d-> m_model = Model_Unknown; 843 d-> m_model = Model_Unknown;
803 844
804 f. close ( ); 845 f. close ( );
805 } 846 }
806 847
807 switch ( d-> m_model ) { 848 switch ( d-> m_model ) {
808 case Model_iPAQ_H31xx: 849 case Model_iPAQ_H31xx:
809 case Model_iPAQ_H38xx: 850 case Model_iPAQ_H38xx:
810 d-> m_rotation = Rot90; 851 d-> m_rotation = Rot90;
811 break; 852 break;
812 case Model_iPAQ_H36xx: 853 case Model_iPAQ_H36xx:
813 case Model_iPAQ_H37xx: 854 case Model_iPAQ_H37xx:
814 case Model_iPAQ_H39xx: 855 case Model_iPAQ_H39xx:
815 default: 856 default:
816 d-> m_rotation = Rot270; 857 d-> m_rotation = Rot270;
817 break; 858 break;
818 } 859 }
819 860
820 f. setName ( "/etc/familiar-version" ); 861 f. setName ( "/etc/familiar-version" );
821 if ( f. open ( IO_ReadOnly )) { 862 if ( f. open ( IO_ReadOnly )) {
822 d-> m_systemstr = "Familiar"; 863 d-> m_systemstr = "Familiar";
823 d-> m_system = System_Familiar; 864 d-> m_system = System_Familiar;
824 865
825 QTextStream ts ( &f ); 866 QTextStream ts ( &f );
826 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 867 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
827 868
828 f. close ( ); 869 f. close ( );
829 } else { 870 } else {
830 f. setName ( "/etc/oz_version" ); 871 f. setName ( "/etc/oz_version" );
831 872
832 if ( f. open ( IO_ReadOnly )) { 873 if ( f. open ( IO_ReadOnly )) {
833 d-> m_systemstr = "OpenEmbedded/iPaq"; 874 d-> m_systemstr = "OpenEmbedded/iPaq";
834 d-> m_system = System_Familiar; 875 d-> m_system = System_Familiar;
835 876
836 QTextStream ts ( &f ); 877 QTextStream ts ( &f );
837 ts.setDevice ( &f ); 878 ts.setDevice ( &f );
838 d-> m_sysverstr = ts. readLine ( ); 879 d-> m_sysverstr = ts. readLine ( );
839 f. close ( ); 880 f. close ( );
840 } 881 }
841 } 882 }
842 883
843 884
844 885
845 886
846 887
847 m_leds [0] = m_leds [1] = Led_Off; 888 m_leds [0] = m_leds [1] = Led_Off;
848 889
849 m_power_timer = 0; 890 m_power_timer = 0;
850 891
851} 892}
852 893
853void iPAQ::initButtons ( ) 894void iPAQ::initButtons ( )
854{ 895{
855 if ( d-> m_buttons ) 896 if ( d-> m_buttons )
856 return; 897 return;
857 898
858 if ( isQWS( ) ) 899 if ( isQWS( ) )
859 QWSServer::setKeyboardFilter ( this ); 900 QWSServer::setKeyboardFilter ( this );
860 901
861 d-> m_buttons = new QValueList <ODeviceButton>; 902 d-> m_buttons = new QValueList <ODeviceButton>;
862 903
863 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 904 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
864 i_button *ib = ipaq_buttons + i; 905 i_button *ib = ipaq_buttons + i;
865 ODeviceButton b; 906 ODeviceButton b;
866 907
867 if (( ib-> model & d-> m_model ) == d-> m_model ) { 908 if (( ib-> model & d-> m_model ) == d-> m_model ) {
868 b. setKeycode ( ib-> code ); 909 b. setKeycode ( ib-> code );
869 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 910 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
870 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 911 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
871 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 912 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
872 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 913 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
873 914
874 d-> m_buttons-> append ( b ); 915 d-> m_buttons-> append ( b );
875 } 916 }
876 } 917 }
877 reloadButtonMapping ( ); 918 reloadButtonMapping ( );
878 919
879 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 920 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
880 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 921 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
881} 922}
882 923
883 924
884//#include <linux/h3600_ts.h> // including kernel headers is evil ... 925//#include <linux/h3600_ts.h> // including kernel headers is evil ...
885 926
886typedef struct { 927typedef struct {
887 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 928 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
888 unsigned char TotalTime; /* Units of 5 seconds */ 929 unsigned char TotalTime; /* Units of 5 seconds */
889 unsigned char OnTime; /* units of 100m/s */ 930 unsigned char OnTime; /* units of 100m/s */
890 unsigned char OffTime; /* units of 100m/s */ 931 unsigned char OffTime; /* units of 100m/s */
891} LED_IN; 932} LED_IN;
892 933
893typedef struct { 934typedef struct {
894 unsigned char mode; 935 unsigned char mode;
895 unsigned char pwr; 936 unsigned char pwr;
896 unsigned char brightness; 937 unsigned char brightness;
897} FLITE_IN; 938} FLITE_IN;
898 939
899#define LED_ON OD_IOW( 'f', 5, LED_IN ) 940#define LED_ON OD_IOW( 'f', 5, LED_IN )
900#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 941#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
901 942
902 943
903QValueList <OLed> iPAQ::ledList ( ) const 944QValueList <OLed> iPAQ::ledList ( ) const
904{ 945{
905 QValueList <OLed> vl; 946 QValueList <OLed> vl;
906 vl << Led_Power; 947 vl << Led_Power;
907 948
908 if ( d-> m_model == Model_iPAQ_H38xx ) 949 if ( d-> m_model == Model_iPAQ_H38xx )
909 vl << Led_BlueTooth; 950 vl << Led_BlueTooth;
910 return vl; 951 return vl;
911} 952}
912 953
913QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 954QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
914{ 955{
915 QValueList <OLedState> vl; 956 QValueList <OLedState> vl;
916 957
917 if ( l == Led_Power ) 958 if ( l == Led_Power )
918 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 959 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
919 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 960 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
920 vl << Led_Off; // << Led_On << ??? 961 vl << Led_Off; // << Led_On << ???
921 962
922 return vl; 963 return vl;
923} 964}
924 965
925OLedState iPAQ::ledState ( OLed l ) const 966OLedState iPAQ::ledState ( OLed l ) const
926{ 967{
927 switch ( l ) { 968 switch ( l ) {
928 case Led_Power: 969 case Led_Power:
929 return m_leds [0]; 970 return m_leds [0];
930 case Led_BlueTooth: 971 case Led_BlueTooth:
931 return m_leds [1]; 972 return m_leds [1];
932 default: 973 default:
933 return Led_Off; 974 return Led_Off;
934 } 975 }
935} 976}
936 977
937bool iPAQ::setLedState ( OLed l, OLedState st ) 978bool iPAQ::setLedState ( OLed l, OLedState st )
938{ 979{
939 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 980 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
940 981
941 if ( l == Led_Power ) { 982 if ( l == Led_Power ) {
942 if ( fd >= 0 ) { 983 if ( fd >= 0 ) {
943 LED_IN leds; 984 LED_IN leds;
944 ::memset ( &leds, 0, sizeof( leds )); 985 ::memset ( &leds, 0, sizeof( leds ));
945 leds. TotalTime = 0; 986 leds. TotalTime = 0;
946 leds. OnTime = 0; 987 leds. OnTime = 0;
947 leds. OffTime = 1; 988 leds. OffTime = 1;
948 leds. OffOnBlink = 2; 989 leds. OffOnBlink = 2;
949 990
950 switch ( st ) { 991 switch ( st ) {
951 case Led_Off : leds. OffOnBlink = 0; break; 992 case Led_Off : leds. OffOnBlink = 0; break;
952 case Led_On : leds. OffOnBlink = 1; break; 993 case Led_On : leds. OffOnBlink = 1; break;
953 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 994 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
954 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 995 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
955 } 996 }
956 997
957 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 998 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
958 m_leds [0] = st; 999 m_leds [0] = st;
959 return true; 1000 return true;
960 } 1001 }
961 } 1002 }
962 } 1003 }
963 return false; 1004 return false;
964} 1005}
965 1006
966 1007
967bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1008bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
968{ 1009{
969 int newkeycode = keycode; 1010 int newkeycode = keycode;
970 1011
971 switch ( keycode ) { 1012 switch ( keycode ) {
972 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 1013 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
973 case HardKey_Menu: { 1014 case HardKey_Menu: {
974 if (( d-> m_model == Model_iPAQ_H38xx ) || 1015 if (( d-> m_model == Model_iPAQ_H38xx ) ||
975 ( d-> m_model == Model_iPAQ_H39xx )) { 1016 ( d-> m_model == Model_iPAQ_H39xx )) {
976 newkeycode = HardKey_Mail; 1017 newkeycode = HardKey_Mail;
977 } 1018 }
978 break; 1019 break;
979 } 1020 }
980 1021
981 // Rotate cursor keys 180° 1022 // Rotate cursor keys 180°
982 case Key_Left : 1023 case Key_Left :
983 case Key_Right: 1024 case Key_Right:
984 case Key_Up : 1025 case Key_Up :
985 case Key_Down : { 1026 case Key_Down : {
986 if (( d-> m_model == Model_iPAQ_H31xx ) || 1027 if (( d-> m_model == Model_iPAQ_H31xx ) ||
987 ( d-> m_model == Model_iPAQ_H38xx )) { 1028 ( d-> m_model == Model_iPAQ_H38xx )) {
988 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 1029 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
989 } 1030 }
990 break; 1031 break;
991 } 1032 }
992 1033
993 // map Power Button short/long press to F34/F35 1034 // map Power Button short/long press to F34/F35
994 case Key_SysReq: { 1035 case Key_SysReq: {
995 if ( isPress ) { 1036 if ( isPress ) {
996 if ( m_power_timer ) 1037 if ( m_power_timer )
997 killTimer ( m_power_timer ); 1038 killTimer ( m_power_timer );
998 m_power_timer = startTimer ( 500 ); 1039 m_power_timer = startTimer ( 500 );
999 } 1040 }
1000 else if ( m_power_timer ) { 1041 else if ( m_power_timer ) {
1001 killTimer ( m_power_timer ); 1042 killTimer ( m_power_timer );
1002 m_power_timer = 0; 1043 m_power_timer = 0;
1003 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 1044 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
1004 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 1045 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
1005 } 1046 }
1006 newkeycode = Key_unknown; 1047 newkeycode = Key_unknown;
1007 break; 1048 break;
1008 } 1049 }
1009 } 1050 }
1010 1051
1011 if ( newkeycode != keycode ) { 1052 if ( newkeycode != keycode ) {
1012 if ( newkeycode != Key_unknown ) 1053 if ( newkeycode != Key_unknown )
1013 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 1054 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
1014 return true; 1055 return true;
1015 } 1056 }
1016 else 1057 else
1017 return false; 1058 return false;
1018} 1059}
1019 1060
1020void iPAQ::timerEvent ( QTimerEvent * ) 1061void iPAQ::timerEvent ( QTimerEvent * )
1021{ 1062{
1022 killTimer ( m_power_timer ); 1063 killTimer ( m_power_timer );
1023 m_power_timer = 0; 1064 m_power_timer = 0;
1024 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1065 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1025 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1066 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1026} 1067}
1027 1068
1028 1069
1029void iPAQ::alarmSound ( ) 1070void iPAQ::alarmSound ( )
1030{ 1071{
1031#ifndef QT_NO_SOUND 1072#ifndef QT_NO_SOUND
1032 static Sound snd ( "alarm" ); 1073 static Sound snd ( "alarm" );
1033 int fd; 1074 int fd;
1034 int vol; 1075 int vol;
1035 bool vol_reset = false; 1076 bool vol_reset = false;
1036 1077
1037 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1078 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1038 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1079 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1039 Config cfg ( "qpe" ); 1080 Config cfg ( "qpe" );
1040 cfg. setGroup ( "Volume" ); 1081 cfg. setGroup ( "Volume" );
1041 1082
1042 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1083 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1043 if ( volalarm < 0 ) 1084 if ( volalarm < 0 )
1044 volalarm = 0; 1085 volalarm = 0;
1045 else if ( volalarm > 100 ) 1086 else if ( volalarm > 100 )
1046 volalarm = 100; 1087 volalarm = 100;
1047 volalarm |= ( volalarm << 8 ); 1088 volalarm |= ( volalarm << 8 );
1048 1089
1049 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1090 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1050 vol_reset = true; 1091 vol_reset = true;
1051 } 1092 }
1052 } 1093 }
1053 1094
1054 snd. play ( ); 1095 snd. play ( );
1055 while ( !snd. isFinished ( )) 1096 while ( !snd. isFinished ( ))
1056 qApp-> processEvents ( ); 1097 qApp-> processEvents ( );
1057 1098
1058 if ( fd >= 0 ) { 1099 if ( fd >= 0 ) {
1059 if ( vol_reset ) 1100 if ( vol_reset )
1060 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1101 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1061 ::close ( fd ); 1102 ::close ( fd );
1062 } 1103 }
1063#endif 1104#endif
1064} 1105}
1065 1106
1066 1107
1067bool iPAQ::setSoftSuspend ( bool soft ) 1108bool iPAQ::setSoftSuspend ( bool soft )
1068{ 1109{
1069 bool res = false; 1110 bool res = false;
1070 int fd; 1111 int fd;
1071 1112
1072 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 1113 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
1073 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 1114 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
1074 res = true; 1115 res = true;
1075 else 1116 else
1076 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 1117 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
1077 1118
1078 ::close ( fd ); 1119 ::close ( fd );
1079 } 1120 }
1080 else 1121 else
1081 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 1122 ::perror ( "/proc/sys/ts/suspend_button_mode" );
1082 1123
1083 return res; 1124 return res;
1084} 1125}
1085 1126
1086 1127
1087bool iPAQ::setDisplayBrightness ( int bright ) 1128bool iPAQ::setDisplayBrightness ( int bright )
1088{ 1129{
1089 bool res = false; 1130 bool res = false;
1090 int fd; 1131 int fd;
1091 1132
1092 if ( bright > 255 ) 1133 if ( bright > 255 )
1093 bright = 255; 1134 bright = 255;
1094 if ( bright < 0 ) 1135 if ( bright < 0 )
1095 bright = 0; 1136 bright = 0;
1096 1137
1097 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 1138 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
1098 FLITE_IN bl; 1139 FLITE_IN bl;
1099 bl. mode = 1; 1140 bl. mode = 1;
1100 bl. pwr = bright ? 1 : 0; 1141 bl. pwr = bright ? 1 : 0;
1101 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 1142 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
1102 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 1143 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
1103 ::close ( fd ); 1144 ::close ( fd );
1104 } 1145 }
1105 return res; 1146 return res;
1106} 1147}
1107 1148
1108int iPAQ::displayBrightnessResolution ( ) const 1149int iPAQ::displayBrightnessResolution ( ) const
1109{ 1150{
1110 switch ( model ( )) { 1151 switch ( model ( )) {
1111 case Model_iPAQ_H31xx: 1152 case Model_iPAQ_H31xx:
1112 case Model_iPAQ_H36xx: 1153 case Model_iPAQ_H36xx:
1113 case Model_iPAQ_H37xx: 1154 case Model_iPAQ_H37xx:
1114 return 128; // really 256, but >128 could damage the LCD 1155 return 128; // really 256, but >128 could damage the LCD
1115 1156
1116 case Model_iPAQ_H38xx: 1157 case Model_iPAQ_H38xx:
1117 case Model_iPAQ_H39xx: 1158 case Model_iPAQ_H39xx:
1118 return 64; 1159 return 64;
1119 1160
1120 default: 1161 default:
1121 return 2; 1162 return 2;
1122 } 1163 }
1123} 1164}
1124 1165
1125 1166
1126bool iPAQ::hasLightSensor ( ) const 1167bool iPAQ::hasLightSensor ( ) const
1127{ 1168{
1128 return true; 1169 return true;
1129} 1170}
1130 1171
1131int iPAQ::readLightSensor ( ) 1172int iPAQ::readLightSensor ( )
1132{ 1173{
1133 int fd; 1174 int fd;
1134 int val = -1; 1175 int val = -1;
1135 1176
1136 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 1177 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
1137 char buffer [8]; 1178 char buffer [8];
1138 1179
1139 if ( ::read ( fd, buffer, 5 ) == 5 ) { 1180 if ( ::read ( fd, buffer, 5 ) == 5 ) {
1140 char *endptr; 1181 char *endptr;
1141 1182
1142 buffer [4] = 0; 1183 buffer [4] = 0;
1143 val = ::strtol ( buffer + 2, &endptr, 16 ); 1184 val = ::strtol ( buffer + 2, &endptr, 16 );
1144 1185
1145 if ( *endptr != 0 ) 1186 if ( *endptr != 0 )
1146 val = -1; 1187 val = -1;
1147 } 1188 }
1148 ::close ( fd ); 1189 ::close ( fd );
1149 } 1190 }
1150 1191
1151 return val; 1192 return val;
1152} 1193}
1153 1194
1154int iPAQ::lightSensorResolution ( ) const 1195int iPAQ::lightSensorResolution ( ) const
1155{ 1196{
1156 return 256; 1197 return 256;
1157} 1198}
1158 1199
1159/************************************************** 1200/**************************************************
1160 * 1201 *
1161 * Zaurus 1202 * Zaurus
1162 * 1203 *
1163 **************************************************/ 1204 **************************************************/
1164 1205
1165 1206
1166 1207
1167void Zaurus::init ( ) 1208void Zaurus::init ( )
1168{ 1209{
1169 d-> m_vendorstr = "Sharp"; 1210 d-> m_vendorstr = "Sharp";
1170 d-> m_vendor = Vendor_Sharp; 1211 d-> m_vendor = Vendor_Sharp;
1171 1212
1172 QFile f ( "/proc/filesystems" ); 1213 QFile f ( "/proc/filesystems" );
1173 QString model; 1214 QString model;
1174 1215
1175 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 1216 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
1176 d-> m_vendorstr = "OpenZaurus Team"; 1217 d-> m_vendorstr = "OpenZaurus Team";
1177 d-> m_systemstr = "OpenZaurus"; 1218 d-> m_systemstr = "OpenZaurus";
1178 d-> m_system = System_OpenZaurus; 1219 d-> m_system = System_OpenZaurus;
1179 1220
1180 f. close ( ); 1221 f. close ( );
1181 1222
1182 f. setName ( "/etc/oz_version" ); 1223 f. setName ( "/etc/oz_version" );
1183 if ( f. open ( IO_ReadOnly )) { 1224 if ( f. open ( IO_ReadOnly )) {
1184 QTextStream ts ( &f ); 1225 QTextStream ts ( &f );
1185 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 1226 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
1186 f. close ( ); 1227 f. close ( );
1187 } 1228 }
1188 } 1229 }
1189 else { 1230 else {
1190 d-> m_systemstr = "Zaurus"; 1231 d-> m_systemstr = "Zaurus";
1191 d-> m_system = System_Zaurus; 1232 d-> m_system = System_Zaurus;
1192 } 1233 }
1193 1234
1194 f. setName ( "/proc/cpuinfo" ); 1235 f. setName ( "/proc/cpuinfo" );
1195 if ( f. open ( IO_ReadOnly ) ) { 1236 if ( f. open ( IO_ReadOnly ) ) {
1196 QTextStream ts ( &f ); 1237 QTextStream ts ( &f );
1197 QString line; 1238 QString line;
1198 while( line = ts. readLine ( ) ) { 1239 while( line = ts. readLine ( ) ) {
1199 if ( line. left ( 8 ) == "Hardware" ) 1240 if ( line. left ( 8 ) == "Hardware" )
1200 break; 1241 break;
1201 } 1242 }
1202 int loc = line. find ( ":" ); 1243 int loc = line. find ( ":" );
1203 if ( loc != -1 ) 1244 if ( loc != -1 )
1204 model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); 1245 model = line. mid ( loc + 2 ). simplifyWhiteSpace( );
1205 } 1246 }
1206 1247
1207 if ( model == "SHARP Corgi" ) { 1248 if ( model == "SHARP Corgi" ) {
1208 d-> m_model = Model_Zaurus_SLC700; 1249 d-> m_model = Model_Zaurus_SLC700;
1209 d-> m_modelstr = "Zaurus SL-C700"; 1250 d-> m_modelstr = "Zaurus SL-C700";
1210 } else if ( model == "SHARP Poodle" ) { 1251 } else if ( model == "SHARP Poodle" ) {
1211 d-> m_model = Model_Zaurus_SLB600; 1252 d-> m_model = Model_Zaurus_SLB600;
1212 d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; 1253 d-> m_modelstr = "Zaurus SL-B500 or SL-5600";
1213 } else if ( model = "Sharp-Collie" ) { 1254 } else if ( model = "Sharp-Collie" ) {
1214 d-> m_model = Model_Zaurus_SL5500; 1255 d-> m_model = Model_Zaurus_SL5500;
1215 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; 1256 d-> m_modelstr = "Zaurus SL-5500 or SL-5000d";
1216 } else { 1257 } else {
1217 d-> m_model = Model_Zaurus_SL5500; 1258 d-> m_model = Model_Zaurus_SL5500;
1218 d-> m_modelstr = "Zaurus (Model unknown)"; 1259 d-> m_modelstr = "Zaurus (Model unknown)";
1219 } 1260 }
1220 1261
1221 bool flipstate = false; 1262 bool flipstate = false;
1222 switch ( d-> m_model ) { 1263 switch ( d-> m_model ) {
1223 case Model_Zaurus_SLA300: 1264 case Model_Zaurus_SLA300:
1224 d-> m_rotation = Rot0; 1265 d-> m_rotation = Rot0;
1225 break; 1266 break;
1226 case Model_Zaurus_SLC700: 1267 case Model_Zaurus_SLC700:
1227 // Note: need to 1) set flipstate based on physical screen orientation 1268 // Note: need to 1) set flipstate based on physical screen orientation
1228 // and 2) check to see if the user overrode the rotation direction 1269 // and 2) check to see if the user overrode the rotation direction
1229 // using appearance, and if so, remove that item from the Config to 1270 // using appearance, and if so, remove that item from the Config to
1230 // ensure the rotate applet flips us back to the previous state. 1271 // ensure the rotate applet flips us back to the previous state.
1231 if ( flipstate ) { 1272 if ( flipstate ) {
1232 // 480x640 1273 // 480x640
1233 d-> m_rotation = Rot0; 1274 d-> m_rotation = Rot0;
1234 d-> m_direction = CW; 1275 d-> m_direction = CW;
1235 } else { 1276 } else {
1236 // 640x480 1277 // 640x480
1237 d-> m_rotation = Rot270; 1278 d-> m_rotation = Rot270;
1238 d-> m_direction = CCW; 1279 d-> m_direction = CCW;
1239 } 1280 }
1240 break; 1281 break;
1241 case Model_Zaurus_SLB600: 1282 case Model_Zaurus_SLB600:
1242 case Model_Zaurus_SL5500: 1283 case Model_Zaurus_SL5500:
1243 case Model_Zaurus_SL5000: 1284 case Model_Zaurus_SL5000:
1244 default: 1285 default:
1245 d-> m_rotation = Rot270; 1286 d-> m_rotation = Rot270;
1246 break; 1287 break;
1247 } 1288 }
1248 m_leds [0] = Led_Off; 1289 m_leds [0] = Led_Off;
1249} 1290}
1250 1291
1251void Zaurus::initButtons ( ) 1292void Zaurus::initButtons ( )
1252{ 1293{
1253 if ( d-> m_buttons ) 1294 if ( d-> m_buttons )
1254 return; 1295 return;
1255 1296
1256 d-> m_buttons = new QValueList <ODeviceButton>; 1297 d-> m_buttons = new QValueList <ODeviceButton>;
1257 1298
1258 struct z_button * pz_buttons; 1299 struct z_button * pz_buttons;
1259 int buttoncount; 1300 int buttoncount;
1260 switch ( d-> m_model ) { 1301 switch ( d-> m_model ) {
1261 case Model_Zaurus_SLC700: 1302 case Model_Zaurus_SLC700:
1262 pz_buttons = z_buttons_c700; 1303 pz_buttons = z_buttons_c700;
1263 buttoncount = ARRAY_SIZE(z_buttons_c700); 1304 buttoncount = ARRAY_SIZE(z_buttons_c700);
1264 break; 1305 break;
1265 default: 1306 default:
1266 pz_buttons = z_buttons; 1307 pz_buttons = z_buttons;
1267 buttoncount = ARRAY_SIZE(z_buttons); 1308 buttoncount = ARRAY_SIZE(z_buttons);
1268 break; 1309 break;
1269 } 1310 }
1270 1311
1271 for ( int i = 0; i < buttoncount; i++ ) { 1312 for ( int i = 0; i < buttoncount; i++ ) {
1272 struct z_button *zb = pz_buttons + i; 1313 struct z_button *zb = pz_buttons + i;
1273 ODeviceButton b; 1314 ODeviceButton b;
1274 1315
1275 b. setKeycode ( zb-> code ); 1316 b. setKeycode ( zb-> code );
1276 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1317 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1277 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1318 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1278 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1319 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1279 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1320 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1280 1321
1281 d-> m_buttons-> append ( b ); 1322 d-> m_buttons-> append ( b );
1282 } 1323 }
1283 1324
1284 reloadButtonMapping ( ); 1325 reloadButtonMapping ( );
1285 1326
1286 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1327 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1287 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1328 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1288} 1329}
1289 1330
1290#include <unistd.h> 1331#include <unistd.h>
1291#include <fcntl.h> 1332#include <fcntl.h>
1292#include <sys/ioctl.h> 1333#include <sys/ioctl.h>
1293 1334
1294//#include <asm/sharp_char.h> // including kernel headers is evil ... 1335//#include <asm/sharp_char.h> // including kernel headers is evil ...
1295 1336
1296#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1337#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1297 1338
1298 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1339 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1299#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1340#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1300 1341
1301#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1342#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1302#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1343#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1303#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1344#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1304 1345
1305/* --- for SHARP_BUZZER device --- */ 1346/* --- for SHARP_BUZZER device --- */
1306 1347
1307 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1348 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1308//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1349//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1309 1350
1310#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1351#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1311#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1352#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1312#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1353#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1313#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1354#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1314#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1355#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1315 1356
1316//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1357//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1317//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1358//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1318 1359
1319//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1360//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1320//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1361//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1321//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1362//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1322//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1363//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1323//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1364//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1324//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1365//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1325//#define SHARP_PDA_APPSTART 9 /* application start */ 1366//#define SHARP_PDA_APPSTART 9 /* application start */
1326//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1367//#define SHARP_PDA_APPQUIT 10 /* application ends */
1327 1368
1328//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1369//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1329//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1370//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1330//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1371//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1331//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1372//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1332// 1373//
1333 1374
1334 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1375 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1335#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1376#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1336 1377
1337typedef struct sharp_led_status { 1378typedef struct sharp_led_status {
1338 int which; /* select which LED status is wanted. */ 1379 int which; /* select which LED status is wanted. */
1339 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1380 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1340} sharp_led_status; 1381} sharp_led_status;
1341 1382
1342#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1383#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1343 1384
1344#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1385#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1345#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1386#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1346#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1387#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1347 1388
1348// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1389// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1349 1390
1350#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1391#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1351#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1392#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1352#define APM_EVT_POWER_BUTTON (1 << 0) 1393#define APM_EVT_POWER_BUTTON (1 << 0)
1353 1394
1354#define FL_IOCTL_STEP_CONTRAST 100 1395#define FL_IOCTL_STEP_CONTRAST 100
1355 1396
1356 1397
1357void Zaurus::buzzer ( int sound ) 1398void Zaurus::buzzer ( int sound )
1358{ 1399{
1359 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 1400 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1360 1401
1361 if ( fd >= 0 ) { 1402 if ( fd >= 0 ) {
1362 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1403 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1363 ::close ( fd ); 1404 ::close ( fd );
1364 } 1405 }
1365} 1406}
1366 1407
1367 1408
1368void Zaurus::alarmSound ( ) 1409void Zaurus::alarmSound ( )
1369{ 1410{
1370 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1411 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1371} 1412}
1372 1413
1373void Zaurus::touchSound ( ) 1414void Zaurus::touchSound ( )
1374{ 1415{
1375 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1416 buzzer ( SHARP_BUZ_TOUCHSOUND );
1376} 1417}
1377 1418
1378void Zaurus::keySound ( ) 1419void Zaurus::keySound ( )
1379{ 1420{
1380 buzzer ( SHARP_BUZ_KEYSOUND ); 1421 buzzer ( SHARP_BUZ_KEYSOUND );
1381} 1422}
1382 1423
1383 1424
1384QValueList <OLed> Zaurus::ledList ( ) const 1425QValueList <OLed> Zaurus::ledList ( ) const
1385{ 1426{
1386 QValueList <OLed> vl; 1427 QValueList <OLed> vl;
1387 vl << Led_Mail; 1428 vl << Led_Mail;
1388 return vl; 1429 return vl;
1389} 1430}
1390 1431
1391QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1432QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1392{ 1433{
1393 QValueList <OLedState> vl; 1434 QValueList <OLedState> vl;
1394 1435
1395 if ( l == Led_Mail ) 1436 if ( l == Led_Mail )
1396 vl << Led_Off << Led_On << Led_BlinkSlow; 1437 vl << Led_Off << Led_On << Led_BlinkSlow;
1397 return vl; 1438 return vl;
1398} 1439}
1399 1440
1400OLedState Zaurus::ledState ( OLed which ) const 1441OLedState Zaurus::ledState ( OLed which ) const
1401{ 1442{
1402 if ( which == Led_Mail ) 1443 if ( which == Led_Mail )
1403 return m_leds [0]; 1444 return m_leds [0];
1404 else 1445 else
1405 return Led_Off; 1446 return Led_Off;
1406} 1447}
1407 1448
1408bool Zaurus::setLedState ( OLed which, OLedState st ) 1449bool Zaurus::setLedState ( OLed which, OLedState st )
1409{ 1450{
1410 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1451 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1411 1452
1412 if ( which == Led_Mail ) { 1453 if ( which == Led_Mail ) {
1413 if ( fd >= 0 ) { 1454 if ( fd >= 0 ) {
1414 struct sharp_led_status leds; 1455 struct sharp_led_status leds;
1415 ::memset ( &leds, 0, sizeof( leds )); 1456 ::memset ( &leds, 0, sizeof( leds ));
1416 leds. which = SHARP_LED_MAIL_EXISTS; 1457 leds. which = SHARP_LED_MAIL_EXISTS;
1417 bool ok = true; 1458 bool ok = true;
1418 1459
1419 switch ( st ) { 1460 switch ( st ) {
1420 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1461 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1421 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1462 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1422 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1463 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1423 default : ok = false; 1464 default : ok = false;
1424 } 1465 }
1425 1466
1426 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1467 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1427 m_leds [0] = st; 1468 m_leds [0] = st;
1428 return true; 1469 return true;
1429 } 1470 }
1430 } 1471 }
1431 } 1472 }
1432 return false; 1473 return false;
1433} 1474}
1434 1475
1435bool Zaurus::setSoftSuspend ( bool soft ) 1476bool Zaurus::setSoftSuspend ( bool soft )
1436{ 1477{
1437 bool res = false; 1478 bool res = false;
1438 int fd; 1479 int fd;
1439 1480
1440 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1481 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1441 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1482 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1442 1483
1443 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1484 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1444 1485
1445 if ( sources >= 0 ) { 1486 if ( sources >= 0 ) {
1446 if ( soft ) 1487 if ( soft )
1447 sources &= ~APM_EVT_POWER_BUTTON; 1488 sources &= ~APM_EVT_POWER_BUTTON;
1448 else 1489 else
1449 sources |= APM_EVT_POWER_BUTTON; 1490 sources |= APM_EVT_POWER_BUTTON;
1450 1491
1451 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1492 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1452 res = true; 1493 res = true;
1453 else 1494 else
1454 perror ( "APM_IOCGEVTSRC" ); 1495 perror ( "APM_IOCGEVTSRC" );
1455 } 1496 }
1456 else 1497 else
1457 perror ( "APM_IOCGEVTSRC" ); 1498 perror ( "APM_IOCGEVTSRC" );
1458 1499
1459 ::close ( fd ); 1500 ::close ( fd );
1460 } 1501 }
1461 else 1502 else
1462 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1503 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1463 1504
1464 return res; 1505 return res;
1465} 1506}
1466 1507
1467 1508
1468bool Zaurus::setDisplayBrightness ( int bright ) 1509bool Zaurus::setDisplayBrightness ( int bright )
1469{ 1510{
1470 bool res = false; 1511 bool res = false;
1471 int fd; 1512 int fd;
1472 1513
1473 if ( bright > 255 ) 1514 if ( bright > 255 )
1474 bright = 255; 1515 bright = 255;
1475 if ( bright < 0 ) 1516 if ( bright < 0 )
1476 bright = 0; 1517 bright = 0;
1477 1518
1478 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1519 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1479 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1520 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1480 if ( bright && !bl ) 1521 if ( bright && !bl )
1481 bl = 1; 1522 bl = 1;
1482 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1523 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1483 ::close ( fd ); 1524 ::close ( fd );
1484 } 1525 }
1485 return res; 1526 return res;
1486} 1527}
1487 1528
1488 1529
1489int Zaurus::displayBrightnessResolution ( ) const 1530int Zaurus::displayBrightnessResolution ( ) const
1490{ 1531{
1491 return 5; 1532 return 5;
1492} 1533}
1493 1534
1494 1535
1495/************************************************** 1536/**************************************************
1496 * 1537 *
1497 * SIMpad 1538 * SIMpad
1498 * 1539 *
1499 **************************************************/ 1540 **************************************************/
1500 1541
1501void SIMpad::init ( ) 1542void SIMpad::init ( )
1502{ 1543{
1503 d-> m_vendorstr = "SIEMENS"; 1544 d-> m_vendorstr = "SIEMENS";
1504 d-> m_vendor = Vendor_SIEMENS; 1545 d-> m_vendor = Vendor_SIEMENS;
1505 1546
1506 QFile f ( "/proc/hal/model" ); 1547 QFile f ( "/proc/hal/model" );
1507 1548
1508 //TODO Implement model checking 1549 //TODO Implement model checking
1509 //FIXME For now we assume an SL4 1550 //FIXME For now we assume an SL4
1510 1551
1511 d-> m_modelstr = "SL4"; 1552 d-> m_modelstr = "SL4";
1512 d-> m_model = Model_SIMpad_SL4; 1553 d-> m_model = Model_SIMpad_SL4;
1513 1554
1514 switch ( d-> m_model ) { 1555 switch ( d-> m_model ) {
1515 default: 1556 default:
1516 d-> m_rotation = Rot0; 1557 d-> m_rotation = Rot0;
1517 d-> m_direction = CCW; 1558 d-> m_direction = CCW;
1518 d-> m_holdtime = 1000; // 1000ms 1559 d-> m_holdtime = 1000; // 1000ms
1519 1560
1520 break; 1561 break;
1521 } 1562 }
1522 1563
1523 f. setName ( "/etc/familiar-version" ); 1564 f. setName ( "/etc/familiar-version" );
1524 if ( f. open ( IO_ReadOnly )) { 1565 if ( f. open ( IO_ReadOnly )) {
1525 d-> m_systemstr = "Familiar"; 1566 d-> m_systemstr = "Familiar";
1526 d-> m_system = System_Familiar; 1567 d-> m_system = System_Familiar;
1527 1568
1528 QTextStream ts ( &f ); 1569 QTextStream ts ( &f );
1529 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 1570 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
1530 1571
1531 f. close ( ); 1572 f. close ( );
1532 } else { 1573 } else {
1533 f. setName ( "/etc/oz_version" ); 1574 f. setName ( "/etc/oz_version" );
1534 1575
1535 if ( f. open ( IO_ReadOnly )) { 1576 if ( f. open ( IO_ReadOnly )) {
1536 d-> m_systemstr = "OpenEmbedded/SIMpad"; 1577 d-> m_systemstr = "OpenEmbedded/SIMpad";
1537 d-> m_system = System_OpenZaurus; 1578 d-> m_system = System_OpenZaurus;
1538 1579
1539 QTextStream ts ( &f ); 1580 QTextStream ts ( &f );
1540 ts.setDevice ( &f ); 1581 ts.setDevice ( &f );
1541 d-> m_sysverstr = ts. readLine ( ); 1582 d-> m_sysverstr = ts. readLine ( );
1542 f. close ( ); 1583 f. close ( );
1543 } 1584 }
1544 } 1585 }
1545 1586
1546 m_leds [0] = m_leds [1] = Led_Off; 1587 m_leds [0] = m_leds [1] = Led_Off;
1547 1588
1548 m_power_timer = 0; 1589 m_power_timer = 0;
1549 1590
1550} 1591}
1551 1592
1552void SIMpad::initButtons ( ) 1593void SIMpad::initButtons ( )
1553{ 1594{
1554 if ( d-> m_buttons ) 1595 if ( d-> m_buttons )
1555 return; 1596 return;
1556 1597
1557 if ( isQWS( ) ) 1598 if ( isQWS( ) )
1558 QWSServer::setKeyboardFilter ( this ); 1599 QWSServer::setKeyboardFilter ( this );
1559 1600
1560 d-> m_buttons = new QValueList <ODeviceButton>; 1601 d-> m_buttons = new QValueList <ODeviceButton>;
1561 1602
1562 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { 1603 for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) {
1563 s_button *sb = simpad_buttons + i; 1604 s_button *sb = simpad_buttons + i;
1564 ODeviceButton b; 1605 ODeviceButton b;
1565 1606
1566 if (( sb-> model & d-> m_model ) == d-> m_model ) { 1607 if (( sb-> model & d-> m_model ) == d-> m_model ) {
1567 b. setKeycode ( sb-> code ); 1608 b. setKeycode ( sb-> code );
1568 b. setUserText ( QObject::tr ( "Button", sb-> utext )); 1609 b. setUserText ( QObject::tr ( "Button", sb-> utext ));
1569 b. setPixmap ( Resource::loadPixmap ( sb-> pix )); 1610 b. setPixmap ( Resource::loadPixmap ( sb-> pix ));
1570 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); 1611 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction ));
1571 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); 1612 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction ));
1572 1613
1573 d-> m_buttons-> append ( b ); 1614 d-> m_buttons-> append ( b );
1574 } 1615 }
1575 } 1616 }
1576 reloadButtonMapping ( ); 1617 reloadButtonMapping ( );
1577 1618
1578 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1619 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1579 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1620 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1580} 1621}
1581 1622
1582// SIMpad boardcontrol register CS3 1623// SIMpad boardcontrol register CS3
1583#define SIMPAD_BOARDCONTROL "/proc/cs3" 1624#define SIMPAD_BOARDCONTROL "/proc/cs3"
1584#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA 1625#define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA
1585#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA 1626#define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA
1586#define SIMPAD_EN1 0x0004 // This is only for EPROM's 1627#define SIMPAD_EN1 0x0004 // This is only for EPROM's
1587#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V 1628#define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V
1588#define SIMPAD_DISPLAY_ON 0x0010 1629#define SIMPAD_DISPLAY_ON 0x0010
1589#define SIMPAD_PCMCIA_BUFF_DIS 0x0020 1630#define SIMPAD_PCMCIA_BUFF_DIS 0x0020
1590#define SIMPAD_MQ_RESET 0x0040 1631#define SIMPAD_MQ_RESET 0x0040
1591#define SIMPAD_PCMCIA_RESET 0x0080 1632#define SIMPAD_PCMCIA_RESET 0x0080
1592#define SIMPAD_DECT_POWER_ON 0x0100 1633#define SIMPAD_DECT_POWER_ON 0x0100
1593#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave 1634#define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave
1594#define SIMPAD_RS232_ON 0x0400 1635#define SIMPAD_RS232_ON 0x0400
1595#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave 1636#define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave
1596#define SIMPAD_LED2_ON 0x1000 1637#define SIMPAD_LED2_ON 0x1000
1597#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode 1638#define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode
1598#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit 1639#define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit
1599#define SIMPAD_RESET_SIMCARD 0x8000 1640#define SIMPAD_RESET_SIMCARD 0x8000
1600 1641
1601//SIMpad touchscreen backlight strength control 1642//SIMpad touchscreen backlight strength control
1602#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 1643#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
1603#define SIMPAD_BACKLIGHT_MASK 0x00a10044 1644#define SIMPAD_BACKLIGHT_MASK 0x00a10044
1604 1645
1605QValueList <OLed> SIMpad::ledList ( ) const 1646QValueList <OLed> SIMpad::ledList ( ) const
1606{ 1647{
1607 QValueList <OLed> vl; 1648 QValueList <OLed> vl;
1608 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 1649 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
1609 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 1650 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
1610 return vl; 1651 return vl;
1611} 1652}
1612 1653
1613QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 1654QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
1614{ 1655{
1615 QValueList <OLedState> vl; 1656 QValueList <OLedState> vl;
1616 1657
1617 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 1658 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
1618 vl << Led_Off << Led_On; 1659 vl << Led_Off << Led_On;
1619 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 1660 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
1620 //vl << Led_Off; 1661 //vl << Led_Off;
1621 return vl; 1662 return vl;
1622} 1663}
1623 1664
1624OLedState SIMpad::ledState ( OLed l ) const 1665OLedState SIMpad::ledState ( OLed l ) const
1625{ 1666{
1626 switch ( l ) { 1667 switch ( l ) {
1627 case Led_Power: 1668 case Led_Power:
1628 return m_leds [0]; 1669 return m_leds [0];
1629 //case Led_Mail: 1670 //case Led_Mail:
1630 //return m_leds [1]; 1671 //return m_leds [1];
1631 default: 1672 default:
1632 return Led_Off; 1673 return Led_Off;
1633 } 1674 }
1634} 1675}
1635 1676
1636bool SIMpad::setLedState ( OLed l, OLedState st ) 1677bool SIMpad::setLedState ( OLed l, OLedState st )
1637{ 1678{
1638 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 1679 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
1639 1680
1640 if ( l == Led_Power ) { 1681 if ( l == Led_Power ) {
1641 if ( fd >= 0 ) { 1682 if ( fd >= 0 ) {
1642 LED_IN leds; 1683 LED_IN leds;
1643 ::memset ( &leds, 0, sizeof( leds )); 1684 ::memset ( &leds, 0, sizeof( leds ));
1644 leds. TotalTime = 0; 1685 leds. TotalTime = 0;
1645 leds. OnTime = 0; 1686 leds. OnTime = 0;
1646 leds. OffTime = 1; 1687 leds. OffTime = 1;
1647 leds. OffOnBlink = 2; 1688 leds. OffOnBlink = 2;
1648 1689
1649 switch ( st ) { 1690 switch ( st ) {
1650 case Led_Off : leds. OffOnBlink = 0; break; 1691 case Led_Off : leds. OffOnBlink = 0; break;
1651 case Led_On : leds. OffOnBlink = 1; break; 1692 case Led_On : leds. OffOnBlink = 1; break;
1652 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 1693 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
1653 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 1694 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
1654 } 1695 }
1655 1696
1656 { 1697 {
1657 /*TODO Implement this like that: 1698 /*TODO Implement this like that:
1658 read from cs3 1699 read from cs3
1659 && with SIMPAD_LED2_ON 1700 && with SIMPAD_LED2_ON
1660 write to cs3 */ 1701 write to cs3 */
1661 m_leds [0] = st; 1702 m_leds [0] = st;
1662 return true; 1703 return true;
1663 } 1704 }
1664 } 1705 }
1665 } 1706 }
1666 return false; 1707 return false;
1667} 1708}
1668 1709
1669 1710
1670bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 1711bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
1671{ 1712{
1672 //TODO 1713 //TODO
1673 return false; 1714 return false;
1674} 1715}
1675 1716
1676void SIMpad::timerEvent ( QTimerEvent * ) 1717void SIMpad::timerEvent ( QTimerEvent * )
1677{ 1718{
1678 killTimer ( m_power_timer ); 1719 killTimer ( m_power_timer );
1679 m_power_timer = 0; 1720 m_power_timer = 0;
1680 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 1721 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
1681 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 1722 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
1682} 1723}
1683 1724
1684 1725
1685void SIMpad::alarmSound ( ) 1726void SIMpad::alarmSound ( )
1686{ 1727{
1687#ifndef QT_NO_SOUND 1728#ifndef QT_NO_SOUND
1688 static Sound snd ( "alarm" ); 1729 static Sound snd ( "alarm" );
1689 int fd; 1730 int fd;
1690 int vol; 1731 int vol;
1691 bool vol_reset = false; 1732 bool vol_reset = false;
1692 1733
1693 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 1734 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
1694 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 1735 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
1695 Config cfg ( "qpe" ); 1736 Config cfg ( "qpe" );
1696 cfg. setGroup ( "Volume" ); 1737 cfg. setGroup ( "Volume" );
1697 1738
1698 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 1739 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
1699 if ( volalarm < 0 ) 1740 if ( volalarm < 0 )
1700 volalarm = 0; 1741 volalarm = 0;
1701 else if ( volalarm > 100 ) 1742 else if ( volalarm > 100 )
1702 volalarm = 100; 1743 volalarm = 100;
1703 volalarm |= ( volalarm << 8 ); 1744 volalarm |= ( volalarm << 8 );
1704 1745
1705 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 1746 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
1706 vol_reset = true; 1747 vol_reset = true;
1707 } 1748 }
1708 } 1749 }
1709 1750
1710 snd. play ( ); 1751 snd. play ( );
1711 while ( !snd. isFinished ( )) 1752 while ( !snd. isFinished ( ))
1712 qApp-> processEvents ( ); 1753 qApp-> processEvents ( );
1713 1754
1714 if ( fd >= 0 ) { 1755 if ( fd >= 0 ) {
1715 if ( vol_reset ) 1756 if ( vol_reset )
1716 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 1757 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
1717 ::close ( fd ); 1758 ::close ( fd );
1718 } 1759 }
1719#endif 1760#endif
1720} 1761}
1721 1762
1722 1763
1723bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm 1764bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm
1724{ 1765{
1725 qDebug( "ODevice for SIMpad: suspend()" ); 1766 qDebug( "ODevice for SIMpad: suspend()" );
1726 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 1767 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
1727 return false; 1768 return false;
1728 1769
1729 bool res = false; 1770 bool res = false;
1730 1771
1731 struct timeval tvs, tvn; 1772 struct timeval tvs, tvn;
1732 ::gettimeofday ( &tvs, 0 ); 1773 ::gettimeofday ( &tvs, 0 );
1733 1774
1734 ::sync ( ); // flush fs caches 1775 ::sync ( ); // flush fs caches
1735 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :) 1776 res = ( ::system ( "echo > /proc/sys/pm/suspend" ) == 0 ); //TODO make better :)
1736 1777
1737 return res; 1778 return res;
1738} 1779}
1739 1780
1740 1781
1741bool SIMpad::setSoftSuspend ( bool soft ) 1782bool SIMpad::setSoftSuspend ( bool soft )
1742{ 1783{
1743 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 1784 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
1744 return false; 1785 return false;
1745} 1786}
1746 1787
1747 1788
1748bool SIMpad::setDisplayStatus ( bool on ) 1789bool SIMpad::setDisplayStatus ( bool on )
1749{ 1790{
1750 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 1791 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
1751 1792
1752 bool res = false; 1793 bool res = false;
1753 int fd; 1794 int fd;
1754 1795
1755 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 1796 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
1756 1797
1757 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 1798 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
1758 res = ( ::system( (const char*) cmdline ) == 0 ); 1799 res = ( ::system( (const char*) cmdline ) == 0 );
1759 ::close ( fd ); 1800 ::close ( fd );
1760 } 1801 }
1761 return res; 1802 return res;
1762} 1803}
1763 1804
1764 1805
1765bool SIMpad::setDisplayBrightness ( int bright ) 1806bool SIMpad::setDisplayBrightness ( int bright )
1766{ 1807{
1767 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 1808 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
1768 bool res = false; 1809 bool res = false;
1769 int fd; 1810 int fd;
1770 1811
1771 if ( bright > 255 ) 1812 if ( bright > 255 )
1772 bright = 255; 1813 bright = 255;
1773 if ( bright < 0 ) 1814 if ( bright < 0 )
1774 bright = 0; 1815 bright = 0;
1775 1816
1776 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 1817 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
1777 int value = 255 - bright; 1818 int value = 255 - bright;
1778 const int mask = SIMPAD_BACKLIGHT_MASK; 1819 const int mask = SIMPAD_BACKLIGHT_MASK;
1779 value = value << 8; 1820 value = value << 8;
1780 value += mask; 1821 value += mask;
1781 char writeCommand[100]; 1822 char writeCommand[100];
1782 const int count = sprintf( writeCommand, "0x%x\n", value ); 1823 const int count = sprintf( writeCommand, "0x%x\n", value );
1783 res = ( ::write ( fd, writeCommand, count ) != -1 ); 1824 res = ( ::write ( fd, writeCommand, count ) != -1 );
1784 ::close ( fd ); 1825 ::close ( fd );
1785 } 1826 }
1786 return res; 1827 return res;
1787} 1828}
1788 1829
1789 1830
1790int SIMpad::displayBrightnessResolution ( ) const 1831int SIMpad::displayBrightnessResolution ( ) const
1791{ 1832{
1792 switch ( model ( )) { 1833 switch ( model ( )) {
1793 case Model_SIMpad_CL4: 1834 case Model_SIMpad_CL4:
1794 case Model_SIMpad_SL4: 1835 case Model_SIMpad_SL4:
1795 case Model_SIMpad_SLC: 1836 case Model_SIMpad_SLC:
1796 case Model_SIMpad_TSinus: 1837 case Model_SIMpad_TSinus:
1797 return 255; //TODO find out if this is save 1838 return 255; //TODO find out if this is save
1798 1839
1799 default: 1840 default:
1800 return 2; 1841 return 2;
1801 } 1842 }
1802} 1843}
1803 1844