summaryrefslogtreecommitdiff
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp12
-rw-r--r--libopie/odevice.h1
2 files changed, 11 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9f64fc0..4c49c4f 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,901 +1,909 @@
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 36
37#include "odevice.h" 37#include "odevice.h"
38 38
39#include <qwindowsystem_qws.h> 39#include <qwindowsystem_qws.h>
40 40
41 41
42// _IO and friends are only defined in kernel headers ... 42// _IO and friends are only defined in kernel headers ...
43 43
44#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 44#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
45 45
46#define OD_IO(type,number) OD_IOC(0,type,number,0) 46#define OD_IO(type,number) OD_IOC(0,type,number,0)
47#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 47#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
48#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 48#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
49#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 49#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
50 50
51using namespace Opie; 51using namespace Opie;
52 52
53class ODeviceData { 53class ODeviceData {
54public: 54public:
55 bool m_qwsserver; 55 bool m_qwsserver;
56 56
57 QString m_vendorstr; 57 QString m_vendorstr;
58 OVendor m_vendor; 58 OVendor m_vendor;
59 59
60 QString m_modelstr; 60 QString m_modelstr;
61 OModel m_model; 61 OModel m_model;
62 62
63 QString m_systemstr; 63 QString m_systemstr;
64 OSystem m_system; 64 OSystem m_system;
65 65
66 QString m_sysverstr; 66 QString m_sysverstr;
67}; 67};
68 68
69 69
70class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter { 70class iPAQ : public QObject, public ODevice, public QWSServer::KeyboardFilter {
71protected: 71protected:
72 virtual void init ( ); 72 virtual void init ( );
73 73
74public: 74public:
75 virtual bool setSoftSuspend ( bool soft ); 75 virtual bool setSoftSuspend ( bool soft );
76 76
77 virtual bool setDisplayBrightness ( int b ); 77 virtual bool setDisplayBrightness ( int b );
78 virtual int displayBrightnessResolution ( ) const; 78 virtual int displayBrightnessResolution ( ) const;
79 79
80 virtual void alarmSound ( ); 80 virtual void alarmSound ( );
81 81
82 virtual QValueList <OLed> ledList ( ) const; 82 virtual QValueList <OLed> ledList ( ) const;
83 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 83 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
84 virtual OLedState ledState ( OLed led ) const; 84 virtual OLedState ledState ( OLed led ) const;
85 virtual bool setLedState ( OLed led, OLedState st ); 85 virtual bool setLedState ( OLed led, OLedState st );
86 86
87 virtual bool hasLightSensor ( ) const; 87 virtual bool hasLightSensor ( ) const;
88 virtual int readLightSensor ( ); 88 virtual int readLightSensor ( );
89 virtual int lightSensorResolution ( ) const;
89 90
90 //virtual QValueList <int> keyList ( ) const; 91 //virtual QValueList <int> keyList ( ) const;
91 92
92protected: 93protected:
93 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat ); 94 virtual bool filter ( int unicode, int keycode, int modifiers, bool isPress, bool autoRepeat );
94 virtual void timerEvent ( QTimerEvent *te ); 95 virtual void timerEvent ( QTimerEvent *te );
95 96
96 int m_power_timer; 97 int m_power_timer;
97 98
98 OLedState m_leds [2]; 99 OLedState m_leds [2];
99}; 100};
100 101
101class Zaurus : public ODevice { 102class Zaurus : public ODevice {
102protected: 103protected:
103 virtual void init ( ); 104 virtual void init ( );
104 105
105 public: 106 public:
106 virtual bool setSoftSuspend ( bool soft ); 107 virtual bool setSoftSuspend ( bool soft );
107 108
108 virtual bool setDisplayBrightness ( int b ); 109 virtual bool setDisplayBrightness ( int b );
109 virtual int displayBrightnessResolution ( ) const; 110 virtual int displayBrightnessResolution ( ) const;
110 111
111 virtual void alarmSound ( ); 112 virtual void alarmSound ( );
112 virtual void keySound ( ); 113 virtual void keySound ( );
113 virtual void touchSound ( ); 114 virtual void touchSound ( );
114 115
115 virtual QValueList <OLed> ledList ( ) const; 116 virtual QValueList <OLed> ledList ( ) const;
116 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 117 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
117 virtual OLedState ledState ( OLed led ) const; 118 virtual OLedState ledState ( OLed led ) const;
118 virtual bool setLedState ( OLed led, OLedState st ); 119 virtual bool setLedState ( OLed led, OLedState st );
119 120
120 //virtual QValueList <int> keyList ( ) const; 121 //virtual QValueList <int> keyList ( ) const;
121 122
122protected: 123protected:
123 virtual void buzzer ( int snd ); 124 virtual void buzzer ( int snd );
124 125
125 OLedState m_leds [1]; 126 OLedState m_leds [1];
126}; 127};
127 128
128 129
129 130
130 131
131 132
132 133
133 134
134ODevice *ODevice::inst ( ) 135ODevice *ODevice::inst ( )
135{ 136{
136 static ODevice *dev = 0; 137 static ODevice *dev = 0;
137 138
138 if ( !dev ) { 139 if ( !dev ) {
139 if ( QFile::exists ( "/proc/hal/model" )) 140 if ( QFile::exists ( "/proc/hal/model" ))
140 dev = new iPAQ ( ); 141 dev = new iPAQ ( );
141 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 142 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
142 dev = new Zaurus ( ); 143 dev = new Zaurus ( );
143 else 144 else
144 dev = new ODevice ( ); 145 dev = new ODevice ( );
145 146
146 dev-> init ( ); 147 dev-> init ( );
147 } 148 }
148 return dev; 149 return dev;
149} 150}
150 151
151 152
152/************************************************** 153/**************************************************
153 * 154 *
154 * common 155 * common
155 * 156 *
156 **************************************************/ 157 **************************************************/
157 158
158 159
159ODevice::ODevice ( ) 160ODevice::ODevice ( )
160{ 161{
161 d = new ODeviceData; 162 d = new ODeviceData;
162 163
163 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 164 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
164 165
165 d-> m_modelstr = "Unknown"; 166 d-> m_modelstr = "Unknown";
166 d-> m_model = Model_Unknown; 167 d-> m_model = Model_Unknown;
167 d-> m_vendorstr = "Unkown"; 168 d-> m_vendorstr = "Unkown";
168 d-> m_vendor = Vendor_Unknown; 169 d-> m_vendor = Vendor_Unknown;
169 d-> m_systemstr = "Unkown"; 170 d-> m_systemstr = "Unkown";
170 d-> m_system = System_Unknown; 171 d-> m_system = System_Unknown;
171 d-> m_sysverstr = "0.0"; 172 d-> m_sysverstr = "0.0";
172} 173}
173 174
174void ODevice::init ( ) 175void ODevice::init ( )
175{ 176{
176} 177}
177 178
178ODevice::~ODevice ( ) 179ODevice::~ODevice ( )
179{ 180{
180 delete d; 181 delete d;
181} 182}
182 183
183bool ODevice::setSoftSuspend ( bool /*soft*/ ) 184bool ODevice::setSoftSuspend ( bool /*soft*/ )
184{ 185{
185 return false; 186 return false;
186} 187}
187 188
188//#include <linux/apm_bios.h> 189//#include <linux/apm_bios.h>
189 190
190#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 191#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
191 192
192 193
193bool ODevice::suspend ( ) 194bool ODevice::suspend ( )
194{ 195{
195 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 196 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
196 return false; 197 return false;
197 198
198 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 199 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
199 return false; 200 return false;
200 201
201 int fd; 202 int fd;
202 bool res = false; 203 bool res = false;
203 204
204 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 205 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
205 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 206 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
206 struct timeval tvs, tvn; 207 struct timeval tvs, tvn;
207 208
208 // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped 209 // ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
209 ::gettimeofday ( &tvs, 0 ); 210 ::gettimeofday ( &tvs, 0 );
210 211
211 ::sync ( ); // flush fs caches 212 ::sync ( ); // flush fs caches
212 213
213 res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending 214 res = ( ::ioctl ( fd, APM_IOC_SUSPEND, 0 ) == 0 ); // tell the kernel to "start" suspending
214 ::close ( fd ); 215 ::close ( fd );
215 216
216 if ( res ) { 217 if ( res ) {
217 // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group 218 // ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in our process group
218 219
219 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 220 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
220 ::usleep ( 200 * 1000 ); 221 ::usleep ( 200 * 1000 );
221 ::gettimeofday ( &tvn, 0 ); 222 ::gettimeofday ( &tvn, 0 );
222 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 223 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
223 224
224 // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group 225 // ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
225 } 226 }
226 227
227 // ::signal ( SIGTSTP, SIG_DFL ); 228 // ::signal ( SIGTSTP, SIG_DFL );
228 } 229 }
229 230
230 return res; 231 return res;
231} 232}
232 233
233//#include <linux/fb.h> better not rely on kernel headers in userspace ... 234//#include <linux/fb.h> better not rely on kernel headers in userspace ...
234 235
235#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 236#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
236 237
237/* VESA Blanking Levels */ 238/* VESA Blanking Levels */
238#define VESA_NO_BLANKING 0 239#define VESA_NO_BLANKING 0
239#define VESA_VSYNC_SUSPEND 1 240#define VESA_VSYNC_SUSPEND 1
240#define VESA_HSYNC_SUSPEND 2 241#define VESA_HSYNC_SUSPEND 2
241#define VESA_POWERDOWN 3 242#define VESA_POWERDOWN 3
242 243
243 244
244bool ODevice::setDisplayStatus ( bool on ) 245bool ODevice::setDisplayStatus ( bool on )
245{ 246{
246 if ( d-> m_model == Model_Unknown ) 247 if ( d-> m_model == Model_Unknown )
247 return false; 248 return false;
248 249
249 bool res = false; 250 bool res = false;
250 int fd; 251 int fd;
251 252
252 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 253 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
253 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 254 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
254 ::close ( fd ); 255 ::close ( fd );
255 } 256 }
256 return res; 257 return res;
257} 258}
258 259
259bool ODevice::setDisplayBrightness ( int ) 260bool ODevice::setDisplayBrightness ( int )
260{ 261{
261 return false; 262 return false;
262} 263}
263 264
264int ODevice::displayBrightnessResolution ( ) const 265int ODevice::displayBrightnessResolution ( ) const
265{ 266{
266 return 16; 267 return 16;
267} 268}
268 269
269QString ODevice::vendorString ( ) const 270QString ODevice::vendorString ( ) const
270{ 271{
271 return d-> m_vendorstr; 272 return d-> m_vendorstr;
272} 273}
273 274
274OVendor ODevice::vendor ( ) const 275OVendor ODevice::vendor ( ) const
275{ 276{
276 return d-> m_vendor; 277 return d-> m_vendor;
277} 278}
278 279
279QString ODevice::modelString ( ) const 280QString ODevice::modelString ( ) const
280{ 281{
281 return d-> m_modelstr; 282 return d-> m_modelstr;
282} 283}
283 284
284OModel ODevice::model ( ) const 285OModel ODevice::model ( ) const
285{ 286{
286 return d-> m_model; 287 return d-> m_model;
287} 288}
288 289
289QString ODevice::systemString ( ) const 290QString ODevice::systemString ( ) const
290{ 291{
291 return d-> m_systemstr; 292 return d-> m_systemstr;
292} 293}
293 294
294OSystem ODevice::system ( ) const 295OSystem ODevice::system ( ) const
295{ 296{
296 return d-> m_system; 297 return d-> m_system;
297} 298}
298 299
299QString ODevice::systemVersionString ( ) const 300QString ODevice::systemVersionString ( ) const
300{ 301{
301 return d-> m_sysverstr; 302 return d-> m_sysverstr;
302} 303}
303 304
304void ODevice::alarmSound ( ) 305void ODevice::alarmSound ( )
305{ 306{
306#ifndef QT_QWS_EBX 307#ifndef QT_QWS_EBX
307#ifndef QT_NO_SOUND 308#ifndef QT_NO_SOUND
308 static Sound snd ( "alarm" ); 309 static Sound snd ( "alarm" );
309 310
310 if ( snd. isFinished ( )) 311 if ( snd. isFinished ( ))
311 snd. play ( ); 312 snd. play ( );
312#endif 313#endif
313#endif 314#endif
314} 315}
315 316
316void ODevice::keySound ( ) 317void ODevice::keySound ( )
317{ 318{
318#ifndef QT_QWS_EBX 319#ifndef QT_QWS_EBX
319#ifndef QT_NO_SOUND 320#ifndef QT_NO_SOUND
320 static Sound snd ( "keysound" ); 321 static Sound snd ( "keysound" );
321 322
322 if ( snd. isFinished ( )) 323 if ( snd. isFinished ( ))
323 snd. play ( ); 324 snd. play ( );
324#endif 325#endif
325#endif 326#endif
326} 327}
327 328
328void ODevice::touchSound ( ) 329void ODevice::touchSound ( )
329{ 330{
330 331
331#ifndef QT_QWS_EBX 332#ifndef QT_QWS_EBX
332#ifndef QT_NO_SOUND 333#ifndef QT_NO_SOUND
333 static Sound snd ( "touchsound" ); 334 static Sound snd ( "touchsound" );
334 335
335 if ( snd. isFinished ( )) 336 if ( snd. isFinished ( ))
336 snd. play ( ); 337 snd. play ( );
337#endif 338#endif
338#endif 339#endif
339} 340}
340 341
341 342
342QValueList <OLed> ODevice::ledList ( ) const 343QValueList <OLed> ODevice::ledList ( ) const
343{ 344{
344 return QValueList <OLed> ( ); 345 return QValueList <OLed> ( );
345} 346}
346 347
347QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 348QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
348{ 349{
349 return QValueList <OLedState> ( ); 350 return QValueList <OLedState> ( );
350} 351}
351 352
352OLedState ODevice::ledState ( OLed /*which*/ ) const 353OLedState ODevice::ledState ( OLed /*which*/ ) const
353{ 354{
354 return Led_Off; 355 return Led_Off;
355} 356}
356 357
357bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 358bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
358{ 359{
359 return false; 360 return false;
360} 361}
361 362
362bool ODevice::hasLightSensor ( ) const 363bool ODevice::hasLightSensor ( ) const
363{ 364{
364 return false; 365 return false;
365} 366}
366 367
367int ODevice::readLightSensor ( ) 368int ODevice::readLightSensor ( )
368{ 369{
369 return -1; 370 return -1;
370} 371}
371 372
373int ODevice::lightSensorResolution ( ) const
374{
375 return 0;
376}
372 377
373//QValueList <int> ODevice::keyList ( ) const 378//QValueList <int> ODevice::keyList ( ) const
374//{ 379//{
375 //return QValueList <int> ( ); 380 //return QValueList <int> ( );
376//} 381//}
377 382
378 383
379 384
380/************************************************** 385/**************************************************
381 * 386 *
382 * iPAQ 387 * iPAQ
383 * 388 *
384 **************************************************/ 389 **************************************************/
385 390
386void iPAQ::init ( ) 391void iPAQ::init ( )
387{ 392{
388 d-> m_vendorstr = "HP"; 393 d-> m_vendorstr = "HP";
389 d-> m_vendor = Vendor_HP; 394 d-> m_vendor = Vendor_HP;
390 395
391 QFile f ( "/proc/hal/model" ); 396 QFile f ( "/proc/hal/model" );
392 397
393 if ( f. open ( IO_ReadOnly )) { 398 if ( f. open ( IO_ReadOnly )) {
394 QTextStream ts ( &f ); 399 QTextStream ts ( &f );
395 400
396 d-> m_modelstr = "H" + ts. readLine ( ); 401 d-> m_modelstr = "H" + ts. readLine ( );
397 402
398 if ( d-> m_modelstr == "H3100" ) 403 if ( d-> m_modelstr == "H3100" )
399 d-> m_model = Model_iPAQ_H31xx; 404 d-> m_model = Model_iPAQ_H31xx;
400 else if ( d-> m_modelstr == "H3600" ) 405 else if ( d-> m_modelstr == "H3600" )
401 d-> m_model = Model_iPAQ_H36xx; 406 d-> m_model = Model_iPAQ_H36xx;
402 else if ( d-> m_modelstr == "H3700" ) 407 else if ( d-> m_modelstr == "H3700" )
403 d-> m_model = Model_iPAQ_H37xx; 408 d-> m_model = Model_iPAQ_H37xx;
404 else if ( d-> m_modelstr == "H3800" ) 409 else if ( d-> m_modelstr == "H3800" )
405 d-> m_model = Model_iPAQ_H38xx; 410 d-> m_model = Model_iPAQ_H38xx;
406 else 411 else
407 d-> m_model = Model_Unknown; 412 d-> m_model = Model_Unknown;
408 413
409 f. close ( ); 414 f. close ( );
410 } 415 }
411 416
412 f. setName ( "/etc/familiar-version" ); 417 f. setName ( "/etc/familiar-version" );
413 if ( f. open ( IO_ReadOnly )) { 418 if ( f. open ( IO_ReadOnly )) {
414 d-> m_systemstr = "Familiar"; 419 d-> m_systemstr = "Familiar";
415 d-> m_system = System_Familiar; 420 d-> m_system = System_Familiar;
416 421
417 QTextStream ts ( &f ); 422 QTextStream ts ( &f );
418 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 423 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
419 424
420 f. close ( ); 425 f. close ( );
421 } 426 }
422 427
423 m_leds [0] = m_leds [1] = Led_Off; 428 m_leds [0] = m_leds [1] = Led_Off;
424 429
425 m_power_timer = 0; 430 m_power_timer = 0;
426 431
427 if ( d-> m_qwsserver ) 432 if ( d-> m_qwsserver )
428 QWSServer::setKeyboardFilter ( this ); 433 QWSServer::setKeyboardFilter ( this );
429} 434}
430 435
431//#include <linux/h3600_ts.h> // including kernel headers is evil ... 436//#include <linux/h3600_ts.h> // including kernel headers is evil ...
432 437
433typedef struct { 438typedef struct {
434 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 439 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
435 unsigned char TotalTime; /* Units of 5 seconds */ 440 unsigned char TotalTime; /* Units of 5 seconds */
436 unsigned char OnTime; /* units of 100m/s */ 441 unsigned char OnTime; /* units of 100m/s */
437 unsigned char OffTime; /* units of 100m/s */ 442 unsigned char OffTime; /* units of 100m/s */
438} LED_IN; 443} LED_IN;
439 444
440typedef struct { 445typedef struct {
441 unsigned char mode; 446 unsigned char mode;
442 unsigned char pwr; 447 unsigned char pwr;
443 unsigned char brightness; 448 unsigned char brightness;
444} FLITE_IN; 449} FLITE_IN;
445 450
446#define LED_ON OD_IOW( 'f', 5, LED_IN ) 451#define LED_ON OD_IOW( 'f', 5, LED_IN )
447#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 452#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
448 453
449 454
450 455
451QValueList <OLed> iPAQ::ledList ( ) const 456QValueList <OLed> iPAQ::ledList ( ) const
452{ 457{
453 QValueList <OLed> vl; 458 QValueList <OLed> vl;
454 vl << Led_Power; 459 vl << Led_Power;
455 460
456 if ( d-> m_model == Model_iPAQ_H38xx ) 461 if ( d-> m_model == Model_iPAQ_H38xx )
457 vl << Led_BlueTooth; 462 vl << Led_BlueTooth;
458 return vl; 463 return vl;
459} 464}
460 465
461QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 466QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
462{ 467{
463 QValueList <OLedState> vl; 468 QValueList <OLedState> vl;
464 469
465 if ( l == Led_Power ) 470 if ( l == Led_Power )
466 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 471 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
467 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 472 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
468 vl << Led_Off; // << Led_On << ??? 473 vl << Led_Off; // << Led_On << ???
469 474
470 return vl; 475 return vl;
471} 476}
472 477
473OLedState iPAQ::ledState ( OLed l ) const 478OLedState iPAQ::ledState ( OLed l ) const
474 { 479 {
475 switch ( l ) { 480 switch ( l ) {
476 case Led_Power: 481 case Led_Power:
477 return m_leds [0]; 482 return m_leds [0];
478 case Led_BlueTooth: 483 case Led_BlueTooth:
479 return m_leds [1]; 484 return m_leds [1];
480 default: 485 default:
481 return Led_Off; 486 return Led_Off;
482 } 487 }
483} 488}
484 489
485bool iPAQ::setLedState ( OLed l, OLedState st ) 490bool iPAQ::setLedState ( OLed l, OLedState st )
486{ 491{
487 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 492 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
488 493
489 if ( l == Led_Power ) { 494 if ( l == Led_Power ) {
490 if ( fd >= 0 ) { 495 if ( fd >= 0 ) {
491 LED_IN leds; 496 LED_IN leds;
492 ::memset ( &leds, 0, sizeof( leds )); 497 ::memset ( &leds, 0, sizeof( leds ));
493 leds. TotalTime = 0; 498 leds. TotalTime = 0;
494 leds. OnTime = 0; 499 leds. OnTime = 0;
495 leds. OffTime = 1; 500 leds. OffTime = 1;
496 leds. OffOnBlink = 2; 501 leds. OffOnBlink = 2;
497 502
498 switch ( st ) { 503 switch ( st ) {
499 case Led_Off : leds. OffOnBlink = 0; break; 504 case Led_Off : leds. OffOnBlink = 0; break;
500 case Led_On : leds. OffOnBlink = 1; break; 505 case Led_On : leds. OffOnBlink = 1; break;
501 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 506 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
502 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 507 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
503 } 508 }
504 509
505 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 510 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
506 m_leds [0] = st; 511 m_leds [0] = st;
507 return true; 512 return true;
508 } 513 }
509 } 514 }
510 } 515 }
511 return false; 516 return false;
512} 517}
513 518
514 519
515//QValueList <int> iPAQ::keyList ( ) const 520//QValueList <int> iPAQ::keyList ( ) const
516//{ 521//{
517 //QValueList <int> vl; 522 //QValueList <int> vl;
518 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight; 523 //vl << HardKey_Datebook << HardKey_Contacts << ( model ( ) == Model_iPAQ_H38xx ? HardKey_Mail : HardKey_Menu ) << HardKey_Home << HardKey_Record << HardKey_Suspend << HardKey_Backlight;
519 //return vl; 524 //return vl;
520//} 525//}
521 526
522bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 527bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
523{ 528{
524 int newkeycode = keycode; 529 int newkeycode = keycode;
525 530
526 531
527 // simple susbstitutions 532 // simple susbstitutions
528 switch ( d-> m_model ) { 533 switch ( d-> m_model ) {
529 case Model_iPAQ_H38xx: 534 case Model_iPAQ_H38xx:
530 // H38xx has no "Q" key anymore - this is now the Mail key 535 // H38xx has no "Q" key anymore - this is now the Mail key
531 if ( keycode == HardKey_Menu ) 536 if ( keycode == HardKey_Menu )
532 newkeycode = HardKey_Mail; 537 newkeycode = HardKey_Mail;
533 //nobreak 538 //nobreak
534 539
535 case Model_iPAQ_H31xx: 540 case Model_iPAQ_H31xx:
536 // Rotate cursor keys 180° 541 // Rotate cursor keys 180°
537 switch ( keycode ) { 542 switch ( keycode ) {
538 case Key_Left : newkeycode = Key_Right; break; 543 case Key_Left : newkeycode = Key_Right; break;
539 case Key_Right: newkeycode = Key_Left; break; 544 case Key_Right: newkeycode = Key_Left; break;
540 case Key_Up : newkeycode = Key_Down; break; 545 case Key_Up : newkeycode = Key_Down; break;
541 case Key_Down : newkeycode = Key_Up; break; 546 case Key_Down : newkeycode = Key_Up; break;
542 } 547 }
543 //nobreak; 548 //nobreak;
544 549
545 case Model_iPAQ_H36xx: 550 case Model_iPAQ_H36xx:
546 case Model_iPAQ_H37xx: 551 case Model_iPAQ_H37xx:
547 // map Power Button short/long press to F34/F35 552 // map Power Button short/long press to F34/F35
548 if ( keycode == Key_SysReq ) { 553 if ( keycode == Key_SysReq ) {
549 if ( isPress ) { 554 if ( isPress ) {
550 if ( m_power_timer ) 555 if ( m_power_timer )
551 killTimer ( m_power_timer ); 556 killTimer ( m_power_timer );
552 m_power_timer = startTimer ( 500 ); 557 m_power_timer = startTimer ( 500 );
553 } 558 }
554 else if ( m_power_timer ) { 559 else if ( m_power_timer ) {
555 killTimer ( m_power_timer ); 560 killTimer ( m_power_timer );
556 m_power_timer = 0; 561 m_power_timer = 0;
557 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 562 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
558 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 563 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
559 } 564 }
560 newkeycode = Key_unknown; 565 newkeycode = Key_unknown;
561 } 566 }
562 //nobreak; 567 //nobreak;
563 568
564 default: 569 default:
565 break; 570 break;
566 } 571 }
567 572
568 if ( newkeycode != keycode ) { 573 if ( newkeycode != keycode ) {
569 if ( newkeycode != Key_unknown ) 574 if ( newkeycode != Key_unknown )
570 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 575 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
571 return true; 576 return true;
572 } 577 }
573 else 578 else
574 return false; 579 return false;
575} 580}
576 581
577void iPAQ::timerEvent ( QTimerEvent * ) 582void iPAQ::timerEvent ( QTimerEvent * )
578{ 583{
579 killTimer ( m_power_timer ); 584 killTimer ( m_power_timer );
580 m_power_timer = 0; 585 m_power_timer = 0;
581 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 586 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
582 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 587 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
583} 588}
584 589
585 590
586void iPAQ::alarmSound ( ) 591void iPAQ::alarmSound ( )
587{ 592{
588#if defined( QT_QWS_IPAQ ) // IPAQ 593#if defined( QT_QWS_IPAQ ) // IPAQ
589#ifndef QT_NO_SOUND 594#ifndef QT_NO_SOUND
590 static Sound snd ( "alarm" ); 595 static Sound snd ( "alarm" );
591 int fd; 596 int fd;
592 int vol; 597 int vol;
593 bool vol_reset = false; 598 bool vol_reset = false;
594 599
595 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 600 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
596 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 601 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
597 Config cfg ( "qpe" ); 602 Config cfg ( "qpe" );
598 cfg. setGroup ( "Volume" ); 603 cfg. setGroup ( "Volume" );
599 604
600 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 605 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
601 if ( volalarm < 0 ) 606 if ( volalarm < 0 )
602 volalarm = 0; 607 volalarm = 0;
603 else if ( volalarm > 100 ) 608 else if ( volalarm > 100 )
604 volalarm = 100; 609 volalarm = 100;
605 volalarm |= ( volalarm << 8 ); 610 volalarm |= ( volalarm << 8 );
606 611
607 if (( volalarm & 0xff ) > ( vol & 0xff )) { 612 if (( volalarm & 0xff ) > ( vol & 0xff )) {
608 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 613 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
609 vol_reset = true; 614 vol_reset = true;
610 } 615 }
611 } 616 }
612 } 617 }
613 618
614 snd. play ( ); 619 snd. play ( );
615 while ( !snd. isFinished ( )) 620 while ( !snd. isFinished ( ))
616 qApp-> processEvents ( ); 621 qApp-> processEvents ( );
617 622
618 if ( fd >= 0 ) { 623 if ( fd >= 0 ) {
619 if ( vol_reset ) 624 if ( vol_reset )
620 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 625 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
621 ::close ( fd ); 626 ::close ( fd );
622 } 627 }
623#endif 628#endif
624#endif 629#endif
625} 630}
626 631
627 632
628bool iPAQ::setSoftSuspend ( bool soft ) 633bool iPAQ::setSoftSuspend ( bool soft )
629{ 634{
630 bool res = false; 635 bool res = false;
631 int fd; 636 int fd;
632 637
633 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 638 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
634 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 639 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
635 res = true; 640 res = true;
636 else 641 else
637 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 642 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
638 643
639 ::close ( fd ); 644 ::close ( fd );
640 } 645 }
641 else 646 else
642 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 647 ::perror ( "/proc/sys/ts/suspend_button_mode" );
643 648
644 return res; 649 return res;
645} 650}
646 651
647 652
648bool iPAQ::setDisplayBrightness ( int bright ) 653bool iPAQ::setDisplayBrightness ( int bright )
649{ 654{
650 bool res = false; 655 bool res = false;
651 int fd; 656 int fd;
652 657
653 if ( bright > 255 ) 658 if ( bright > 255 )
654 bright = 255; 659 bright = 255;
655 if ( bright < 0 ) 660 if ( bright < 0 )
656 bright = 0; 661 bright = 0;
657 662
658 // 128 is the maximum if you want a decent lifetime for the LCD 663 // 128 is the maximum if you want a decent lifetime for the LCD
659 664
660 if ( bright > 1 ) 665 if ( bright > 1 )
661 bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic 666 bright = (int) ( 0.5 + ( ::pow ( 2, double( bright ) / 255.0 ) - 1 ) * 128.0 ); // logarithmic
662 //bright = ( bright + 1 ) / 2; 667 //bright = ( bright + 1 ) / 2;
663 668
664 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 669 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
665 FLITE_IN bl; 670 FLITE_IN bl;
666 bl. mode = 1; 671 bl. mode = 1;
667 bl. pwr = bright ? 1 : 0; 672 bl. pwr = bright ? 1 : 0;
668 bl. brightness = bright; 673 bl. brightness = bright;
669 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 674 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
670 ::close ( fd ); 675 ::close ( fd );
671 } 676 }
672 return res; 677 return res;
673} 678}
674 679
675int iPAQ::displayBrightnessResolution ( ) const 680int iPAQ::displayBrightnessResolution ( ) const
676{ 681{
677 return 256; // really 128, but logarithmic control is smoother this way 682 return 256; // really 128, but logarithmic control is smoother this way
678} 683}
679 684
680 685
681bool iPAQ::hasLightSensor ( ) const 686bool iPAQ::hasLightSensor ( ) const
682{ 687{
683 return true; 688 return true;
684} 689}
685#include <errno.h> 690
686#include <string.h>
687int iPAQ::readLightSensor ( ) 691int iPAQ::readLightSensor ( )
688{ 692{
689 int fd; 693 int fd;
690 int val = -1; 694 int val = -1;
691 695
692 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 696 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
693 char buffer [8]; 697 char buffer [8];
694 698
695 if ( ::read ( fd, buffer, 5 ) == 5 ) { 699 if ( ::read ( fd, buffer, 5 ) == 5 ) {
696 char *endptr; 700 char *endptr;
697 701
698 buffer [4] = 0; 702 buffer [4] = 0;
699 val = ::strtol ( buffer + 2, &endptr, 16 ); 703 val = ::strtol ( buffer + 2, &endptr, 16 );
700 704
701 if ( *endptr != 0 ) 705 if ( *endptr != 0 )
702 val = -1; 706 val = -1;
703 } 707 }
704 ::close ( fd ); 708 ::close ( fd );
705 } 709 }
706 710
707 return val; 711 return val;
708} 712}
709 713
714int iPAQ::lightSensorResolution ( ) const
715{
716 return 256;
717}
710 718
711/************************************************** 719/**************************************************
712 * 720 *
713 * Zaurus 721 * Zaurus
714 * 722 *
715 **************************************************/ 723 **************************************************/
716 724
717 725
718 726
719void Zaurus::init ( ) 727void Zaurus::init ( )
720{ 728{
721 d-> m_modelstr = "Zaurus SL5000"; 729 d-> m_modelstr = "Zaurus SL5000";
722 d-> m_model = Model_Zaurus_SL5000; 730 d-> m_model = Model_Zaurus_SL5000;
723 d-> m_vendorstr = "Sharp"; 731 d-> m_vendorstr = "Sharp";
724 d-> m_vendor = Vendor_Sharp; 732 d-> m_vendor = Vendor_Sharp;
725 733
726 QFile f ( "/proc/filesystems" ); 734 QFile f ( "/proc/filesystems" );
727 735
728 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 736 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
729 d-> m_systemstr = "OpenZaurus"; 737 d-> m_systemstr = "OpenZaurus";
730 d-> m_system = System_OpenZaurus; 738 d-> m_system = System_OpenZaurus;
731 739
732 f. close ( ); 740 f. close ( );
733 741
734 f. setName ( "/etc/oz_version" ); 742 f. setName ( "/etc/oz_version" );
735 if ( f. open ( IO_ReadOnly )) { 743 if ( f. open ( IO_ReadOnly )) {
736 QTextStream ts ( &f ); 744 QTextStream ts ( &f );
737 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 745 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
738 f. close ( ); 746 f. close ( );
739 } 747 }
740 } 748 }
741 else { 749 else {
742 d-> m_systemstr = "Zaurus"; 750 d-> m_systemstr = "Zaurus";
743 d-> m_system = System_Zaurus; 751 d-> m_system = System_Zaurus;
744 } 752 }
745 753
746 754
747 m_leds [0] = Led_Off; 755 m_leds [0] = Led_Off;
748} 756}
749 757
750#include <unistd.h> 758#include <unistd.h>
751#include <fcntl.h> 759#include <fcntl.h>
752#include <sys/ioctl.h> 760#include <sys/ioctl.h>
753 761
754//#include <asm/sharp_char.h> // including kernel headers is evil ... 762//#include <asm/sharp_char.h> // including kernel headers is evil ...
755 763
756#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 764#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
757 765
758 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 766 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
759#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 767#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
760 768
761#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 769#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
762#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 770#define SHARP_BUZ_KEYSOUND 2 /* key sound */
763#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 771#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
764 772
765/* --- for SHARP_BUZZER device --- */ 773/* --- for SHARP_BUZZER device --- */
766 774
767 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 775 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
768//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 776//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
769 777
770#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 778#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
771#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 779#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
772#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 780#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
773#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 781#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
774#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 782#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
775 783
776//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 784//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
777//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 785//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
778 786
779//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 787//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
780//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 788//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
781//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 789//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
782//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 790//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
783//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 791//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
784//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 792//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
785//#define SHARP_PDA_APPSTART 9 /* application start */ 793//#define SHARP_PDA_APPSTART 9 /* application start */
786//#define SHARP_PDA_APPQUIT 10 /* application ends */ 794//#define SHARP_PDA_APPQUIT 10 /* application ends */
787 795
788//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 796//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
789//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 797//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
790//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 798//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
791//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 799//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
792// 800//
793 801
794 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 802 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
795#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 803#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
796 804
797typedef struct sharp_led_status { 805typedef struct sharp_led_status {
798 int which; /* select which LED status is wanted. */ 806 int which; /* select which LED status is wanted. */
799 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 807 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
800} sharp_led_status; 808} sharp_led_status;
801 809
802#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 810#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
803 811
804#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 812#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
805#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 813#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
806#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 814#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
807 815
808// #include <asm/sharp_apm.h> // including kernel headers is evil ... 816// #include <asm/sharp_apm.h> // including kernel headers is evil ...
809 817
810#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 818#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
811#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 819#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
812#define APM_EVT_POWER_BUTTON (1 << 0) 820#define APM_EVT_POWER_BUTTON (1 << 0)
813 821
814#define FL_IOCTL_STEP_CONTRAST 100 822#define FL_IOCTL_STEP_CONTRAST 100
815 823
816 824
817void Zaurus::buzzer ( int sound ) 825void Zaurus::buzzer ( int sound )
818{ 826{
819 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 827 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
820 828
821 if ( fd >= 0 ) 829 if ( fd >= 0 )
822 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 830 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
823} 831}
824 832
825 833
826void Zaurus::alarmSound ( ) 834void Zaurus::alarmSound ( )
827{ 835{
828 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 836 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
829} 837}
830 838
831void Zaurus::touchSound ( ) 839void Zaurus::touchSound ( )
832{ 840{
833 buzzer ( SHARP_BUZ_TOUCHSOUND ); 841 buzzer ( SHARP_BUZ_TOUCHSOUND );
834} 842}
835 843
836void Zaurus::keySound ( ) 844void Zaurus::keySound ( )
837{ 845{
838 buzzer ( SHARP_BUZ_KEYSOUND ); 846 buzzer ( SHARP_BUZ_KEYSOUND );
839} 847}
840 848
841 849
842QValueList <OLed> Zaurus::ledList ( ) const 850QValueList <OLed> Zaurus::ledList ( ) const
843{ 851{
844 QValueList <OLed> vl; 852 QValueList <OLed> vl;
845 vl << Led_Mail; 853 vl << Led_Mail;
846 return vl; 854 return vl;
847} 855}
848 856
849QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 857QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
850{ 858{
851 QValueList <OLedState> vl; 859 QValueList <OLedState> vl;
852 860
853 if ( l == Led_Mail ) 861 if ( l == Led_Mail )
854 vl << Led_Off << Led_On << Led_BlinkSlow; 862 vl << Led_Off << Led_On << Led_BlinkSlow;
855 return vl; 863 return vl;
856} 864}
857 865
858OLedState Zaurus::ledState ( OLed which ) const 866OLedState Zaurus::ledState ( OLed which ) const
859{ 867{
860 if ( which == Led_Mail ) 868 if ( which == Led_Mail )
861 return m_leds [0]; 869 return m_leds [0];
862 else 870 else
863 return Led_Off; 871 return Led_Off;
864} 872}
865 873
866bool Zaurus::setLedState ( OLed which, OLedState st ) 874bool Zaurus::setLedState ( OLed which, OLedState st )
867{ 875{
868 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 876 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
869 877
870 if ( which == Led_Mail ) { 878 if ( which == Led_Mail ) {
871 if ( fd >= 0 ) { 879 if ( fd >= 0 ) {
872 struct sharp_led_status leds; 880 struct sharp_led_status leds;
873 ::memset ( &leds, 0, sizeof( leds )); 881 ::memset ( &leds, 0, sizeof( leds ));
874 leds. which = SHARP_LED_MAIL_EXISTS; 882 leds. which = SHARP_LED_MAIL_EXISTS;
875 bool ok = true; 883 bool ok = true;
876 884
877 switch ( st ) { 885 switch ( st ) {
878 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 886 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
879 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 887 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
880 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 888 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
881 default : ok = false; 889 default : ok = false;
882 } 890 }
883 891
884 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 892 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
885 m_leds [0] = st; 893 m_leds [0] = st;
886 return true; 894 return true;
887 } 895 }
888 } 896 }
889 } 897 }
890 return false; 898 return false;
891} 899}
892 900
893bool Zaurus::setSoftSuspend ( bool soft ) 901bool Zaurus::setSoftSuspend ( bool soft )
894{ 902{
895 bool res = false; 903 bool res = false;
896 int fd; 904 int fd;
897 905
898 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 906 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
899 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 907 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
900 908
901 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 909 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
diff --git a/libopie/odevice.h b/libopie/odevice.h
index be2a9c7..e07b91c 100644
--- a/libopie/odevice.h
+++ b/libopie/odevice.h
@@ -1,145 +1,146 @@
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#ifndef _LIBOPIE_ODEVICE_H_ 20#ifndef _LIBOPIE_ODEVICE_H_
21#define _LIBOPIE_ODEVICE_H_ 21#define _LIBOPIE_ODEVICE_H_
22 22
23#include <qstring.h> 23#include <qstring.h>
24#include <qnamespace.h> 24#include <qnamespace.h>
25 25
26class ODeviceData; 26class ODeviceData;
27 27
28namespace Opie { 28namespace Opie {
29 29
30enum OModel { 30enum OModel {
31 Model_Unknown, 31 Model_Unknown,
32 32
33 Model_iPAQ = ( 1 << 16 ), 33 Model_iPAQ = ( 1 << 16 ),
34 34
35 Model_iPAQ_H31xx = ( Model_iPAQ | 1 ), 35 Model_iPAQ_H31xx = ( Model_iPAQ | 1 ),
36 Model_iPAQ_H36xx = ( Model_iPAQ | 2 ), 36 Model_iPAQ_H36xx = ( Model_iPAQ | 2 ),
37 Model_iPAQ_H37xx = ( Model_iPAQ | 3 ), 37 Model_iPAQ_H37xx = ( Model_iPAQ | 3 ),
38 Model_iPAQ_H38xx = ( Model_iPAQ | 4 ), 38 Model_iPAQ_H38xx = ( Model_iPAQ | 4 ),
39 39
40 Model_Zaurus = ( 2 << 16 ), 40 Model_Zaurus = ( 2 << 16 ),
41 41
42 Model_Zaurus_SL5000 = ( Model_Zaurus | 1 ), 42 Model_Zaurus_SL5000 = ( Model_Zaurus | 1 ),
43}; 43};
44 44
45 enum OVendor { 45 enum OVendor {
46 Vendor_Unknown, 46 Vendor_Unknown,
47 47
48 Vendor_HP, 48 Vendor_HP,
49 Vendor_Sharp 49 Vendor_Sharp
50 }; 50 };
51 51
52enum OSystem { 52enum OSystem {
53 System_Unknown, 53 System_Unknown,
54 54
55 System_Familiar, 55 System_Familiar,
56 System_Zaurus, 56 System_Zaurus,
57 System_OpenZaurus 57 System_OpenZaurus
58}; 58};
59 59
60enum OLedState { 60enum OLedState {
61 Led_Off, 61 Led_Off,
62 Led_On, 62 Led_On,
63 Led_BlinkSlow, 63 Led_BlinkSlow,
64 Led_BlinkFast 64 Led_BlinkFast
65}; 65};
66 66
67enum OLed { 67enum OLed {
68 Led_Mail, 68 Led_Mail,
69 Led_Power, 69 Led_Power,
70 Led_BlueTooth 70 Led_BlueTooth
71}; 71};
72 72
73enum OHardKey { 73enum OHardKey {
74 HardKey_Datebook = Qt::Key_F9, 74 HardKey_Datebook = Qt::Key_F9,
75 HardKey_Contacts = Qt::Key_F10, 75 HardKey_Contacts = Qt::Key_F10,
76 HardKey_Menu = Qt::Key_F11, 76 HardKey_Menu = Qt::Key_F11,
77 HardKey_Home = Qt::Key_F12, 77 HardKey_Home = Qt::Key_F12,
78 HardKey_Mail = Qt::Key_F14, 78 HardKey_Mail = Qt::Key_F14,
79 HardKey_Record = Qt::Key_F24, 79 HardKey_Record = Qt::Key_F24,
80 HardKey_Suspend = Qt::Key_F34, 80 HardKey_Suspend = Qt::Key_F34,
81 HardKey_Backlight = Qt::Key_F35, 81 HardKey_Backlight = Qt::Key_F35,
82}; 82};
83 83
84 84
85class ODevice 85class ODevice
86{ 86{
87private: 87private:
88 ODevice ( const ODevice & ); 88 ODevice ( const ODevice & );
89 89
90protected: 90protected:
91 ODevice ( ); 91 ODevice ( );
92 virtual void init ( ); 92 virtual void init ( );
93 93
94 ODeviceData *d; 94 ODeviceData *d;
95 95
96public: 96public:
97 virtual ~ODevice ( ); 97 virtual ~ODevice ( );
98 98
99 static ODevice *inst ( ); 99 static ODevice *inst ( );
100 100
101 101
102 102
103// information 103// information
104 104
105 QString modelString ( ) const; 105 QString modelString ( ) const;
106 OModel model ( ) const; 106 OModel model ( ) const;
107 107
108 QString vendorString ( ) const; 108 QString vendorString ( ) const;
109 OVendor vendor ( ) const; 109 OVendor vendor ( ) const;
110 110
111 QString systemString ( ) const; 111 QString systemString ( ) const;
112 OSystem system ( ) const; 112 OSystem system ( ) const;
113 113
114 QString systemVersionString ( ) const; 114 QString systemVersionString ( ) const;
115 115
116 // system 116 // system
117 117
118 virtual bool setSoftSuspend ( bool on ); 118 virtual bool setSoftSuspend ( bool on );
119 virtual bool suspend ( ); 119 virtual bool suspend ( );
120 120
121 virtual bool setDisplayStatus ( bool on ); 121 virtual bool setDisplayStatus ( bool on );
122 virtual bool setDisplayBrightness ( int brightness ); 122 virtual bool setDisplayBrightness ( int brightness );
123 virtual int displayBrightnessResolution ( ) const; 123 virtual int displayBrightnessResolution ( ) const;
124 124
125// input / output 125// input / output
126 126
127 virtual void alarmSound ( ); 127 virtual void alarmSound ( );
128 virtual void keySound ( ); 128 virtual void keySound ( );
129 virtual void touchSound ( ); 129 virtual void touchSound ( );
130 130
131 virtual QValueList <OLed> ledList ( ) const; 131 virtual QValueList <OLed> ledList ( ) const;
132 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 132 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
133 virtual OLedState ledState ( OLed led ) const; 133 virtual OLedState ledState ( OLed led ) const;
134 virtual bool setLedState ( OLed led, OLedState st ); 134 virtual bool setLedState ( OLed led, OLedState st );
135 135
136 virtual bool hasLightSensor ( ) const; 136 virtual bool hasLightSensor ( ) const;
137 virtual int readLightSensor ( ); 137 virtual int readLightSensor ( );
138 virtual int lightSensorResolution ( ) const;
138 139
139 //virtual QValueList <int> keyList ( ) const; 140 //virtual QValueList <int> keyList ( ) const;
140}; 141};
141 142
142} 143}
143 144
144#endif 145#endif
145 146