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