summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp8
1 files changed, 1 insertions, 7 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 6572fb6..1da8862 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -1,567 +1,561 @@
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 27
28#include <qapplication.h> 28#include <qapplication.h>
29 29
30#include <qfile.h> 30#include <qfile.h>
31#include <qtextstream.h> 31#include <qtextstream.h>
32#include <qpe/sound.h> 32#include <qpe/sound.h>
33#include <qpe/resource.h> 33#include <qpe/resource.h>
34#include <qpe/config.h> 34#include <qpe/config.h>
35 35
36 36
37 37
38#include "odevice.h" 38#include "odevice.h"
39 39
40 40
41class ODeviceData { 41class ODeviceData {
42public: 42public:
43 QString m_vendorstr; 43 QString m_vendorstr;
44 OVendor m_vendor; 44 OVendor m_vendor;
45 45
46 QString m_modelstr; 46 QString m_modelstr;
47 OModel m_model; 47 OModel m_model;
48 48
49 QString m_systemstr; 49 QString m_systemstr;
50 OSystem m_system; 50 OSystem m_system;
51 51
52 QString m_sysverstr; 52 QString m_sysverstr;
53 53
54 OLedState m_leds [4]; // just for convenience ... 54 OLedState m_leds [4]; // just for convenience ...
55}; 55};
56 56
57class ODeviceIPAQ : public ODevice { 57class ODeviceIPAQ : public ODevice {
58protected: 58protected:
59 virtual void init ( ); 59 virtual void init ( );
60 60
61public: 61public:
62 virtual void alarmSound ( ); 62 virtual void alarmSound ( );
63 63
64 virtual uint hasLeds ( ) const; 64 virtual uint hasLeds ( ) const;
65 virtual OLedState led ( uint which ) const; 65 virtual OLedState led ( uint which ) const;
66 virtual bool setLed ( uint which, OLedState st ); 66 virtual bool setLed ( uint which, OLedState st );
67}; 67};
68 68
69class ODeviceZaurus : public ODevice { 69class ODeviceZaurus : public ODevice {
70protected: 70protected:
71 virtual void init ( ); 71 virtual void init ( );
72 72
73 public: 73 public:
74 virtual void alarmSound ( ); 74 virtual void alarmSound ( );
75 virtual void keySound ( ); 75 virtual void keySound ( );
76 virtual void touchSound ( ); 76 virtual void touchSound ( );
77 77
78 virtual uint hasLeds ( ) const; 78 virtual uint hasLeds ( ) const;
79 virtual OLedState led ( uint which ) const; 79 virtual OLedState led ( uint which ) const;
80 virtual bool setLed ( uint which, OLedState st ); 80 virtual bool setLed ( uint which, OLedState st );
81 81
82protected: 82protected:
83 virtual void buzzer ( int snd ); 83 virtual void buzzer ( int snd );
84}; 84};
85 85
86 86
87 87
88 88
89ODevice *ODevice::inst ( ) 89ODevice *ODevice::inst ( )
90{ 90{
91 static ODevice *dev = 0; 91 static ODevice *dev = 0;
92 92
93 if ( !dev ) { 93 if ( !dev ) {
94 if ( QFile::exists ( "/proc/hal/model" )) 94 if ( QFile::exists ( "/proc/hal/model" ))
95 dev = new ODeviceIPAQ ( ); 95 dev = new ODeviceIPAQ ( );
96 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 96 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
97 dev = new ODeviceZaurus ( ); 97 dev = new ODeviceZaurus ( );
98 else 98 else
99 dev = new ODevice ( ); 99 dev = new ODevice ( );
100 100
101 dev-> init ( ); 101 dev-> init ( );
102 } 102 }
103 return dev; 103 return dev;
104} 104}
105 105
106ODevice::ODevice ( ) 106ODevice::ODevice ( )
107{ 107{
108 d = new ODeviceData; 108 d = new ODeviceData;
109 109
110 d-> m_modelstr = "Unknown"; 110 d-> m_modelstr = "Unknown";
111 d-> m_model = OMODEL_Unknown; 111 d-> m_model = OMODEL_Unknown;
112 d-> m_vendorstr = "Unkown"; 112 d-> m_vendorstr = "Unkown";
113 d-> m_vendor = OVENDOR_Unknown; 113 d-> m_vendor = OVENDOR_Unknown;
114 d-> m_systemstr = "Unkown"; 114 d-> m_systemstr = "Unkown";
115 d-> m_system = OSYSTEM_Unknown; 115 d-> m_system = OSYSTEM_Unknown;
116 d-> m_sysverstr = "0.0"; 116 d-> m_sysverstr = "0.0";
117} 117}
118 118
119void ODevice::init ( ) 119void ODevice::init ( )
120{ 120{
121} 121}
122 122
123ODevice::~ODevice ( ) 123ODevice::~ODevice ( )
124{ 124{
125 delete d; 125 delete d;
126} 126}
127 127
128//#include <linux/apm_bios.h> 128//#include <linux/apm_bios.h>
129 129
130//#define APM_IOC_SUSPEND _IO('A',2) 130//#define APM_IOC_SUSPEND _IO('A',2)
131 131
132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 )) 132#define APM_IOC_SUSPEND (( 0<<30 ) | ( 'A'<<8 ) | ( 2 ) | ( 0<<16 ))
133 133
134
135void ODevice::tstp_sighandler ( int )
136{
137}
138
139
140bool ODevice::suspend ( ) 134bool ODevice::suspend ( )
141{ 135{
142 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices 136 if ( d-> m_model == OMODEL_Unknown ) // better don't suspend in qvfb / on unkown devices
143 return false; 137 return false;
144 138
145 int fd; 139 int fd;
146 bool res = false; 140 bool res = false;
147 141
148 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 142 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
149 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 143 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
150 struct timeval tvs, tvn; 144 struct timeval tvs, tvn;
151 145
152 ::signal ( SIGTSTP, tstp_sighandler );// we don't want to be stopped 146 ::signal ( SIGTSTP, SIG_IGN );// we don't want to be stopped
153 ::gettimeofday ( &tvs, 0 ); 147 ::gettimeofday ( &tvs, 0 );
154 148
155 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending 149 res = ( ::ioctl ( fd, APM_IOC_SUSPEND ) == 0 ); // tell the kernel to "start" suspending
156 ::close ( fd ); 150 ::close ( fd );
157 151
158 if ( res ) { 152 if ( res ) {
159 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in out process group 153 ::kill ( -::getpid ( ), SIGTSTP ); // stop everthing in out process group
160 154
161 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 155 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
162 ::usleep ( 200 * 1000 ); 156 ::usleep ( 200 * 1000 );
163 ::gettimeofday ( &tvn, 0 ); 157 ::gettimeofday ( &tvn, 0 );
164 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 158 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
165 159
166 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group 160 ::kill ( -::getpid ( ), SIGCONT ); // continue everything in our process group
167 } 161 }
168 162
169 ::signal ( SIGTSTP, SIG_DFL ); 163 ::signal ( SIGTSTP, SIG_DFL );
170 } 164 }
171 165
172 return res; 166 return res;
173} 167}
174 168
175 169
176QString ODevice::vendorString ( ) 170QString ODevice::vendorString ( )
177{ 171{
178 return d-> m_vendorstr; 172 return d-> m_vendorstr;
179} 173}
180 174
181OVendor ODevice::vendor ( ) 175OVendor ODevice::vendor ( )
182{ 176{
183 return d-> m_vendor; 177 return d-> m_vendor;
184} 178}
185 179
186QString ODevice::modelString ( ) 180QString ODevice::modelString ( )
187{ 181{
188 return d-> m_modelstr; 182 return d-> m_modelstr;
189} 183}
190 184
191OModel ODevice::model ( ) 185OModel ODevice::model ( )
192{ 186{
193 return d-> m_model; 187 return d-> m_model;
194} 188}
195 189
196QString ODevice::systemString ( ) 190QString ODevice::systemString ( )
197{ 191{
198 return d-> m_systemstr; 192 return d-> m_systemstr;
199} 193}
200 194
201OSystem ODevice::system ( ) 195OSystem ODevice::system ( )
202{ 196{
203 return d-> m_system; 197 return d-> m_system;
204} 198}
205 199
206QString ODevice::systemVersionString ( ) 200QString ODevice::systemVersionString ( )
207{ 201{
208 return d-> m_sysverstr; 202 return d-> m_sysverstr;
209} 203}
210 204
211void ODevice::alarmSound ( ) 205void ODevice::alarmSound ( )
212{ 206{
213#ifndef QT_QWS_EBX 207#ifndef QT_QWS_EBX
214#ifndef QT_NO_SOUND 208#ifndef QT_NO_SOUND
215 static Sound snd ( "alarm" ); 209 static Sound snd ( "alarm" );
216 210
217 if ( snd. isFinished ( )) 211 if ( snd. isFinished ( ))
218 snd. play ( ); 212 snd. play ( );
219#endif 213#endif
220#endif 214#endif
221} 215}
222 216
223void ODevice::keySound ( ) 217void ODevice::keySound ( )
224{ 218{
225#ifndef QT_QWS_EBX 219#ifndef QT_QWS_EBX
226#ifndef QT_NO_SOUND 220#ifndef QT_NO_SOUND
227 static Sound snd ( "keysound" ); 221 static Sound snd ( "keysound" );
228 222
229 if ( snd. isFinished ( )) 223 if ( snd. isFinished ( ))
230 snd. play ( ); 224 snd. play ( );
231#endif 225#endif
232#endif 226#endif
233} 227}
234 228
235void ODevice::touchSound ( ) 229void ODevice::touchSound ( )
236{ 230{
237 231
238#ifndef QT_QWS_EBX 232#ifndef QT_QWS_EBX
239#ifndef QT_NO_SOUND 233#ifndef QT_NO_SOUND
240 static Sound snd ( "touchsound" ); 234 static Sound snd ( "touchsound" );
241//qDebug("touchSound"); 235//qDebug("touchSound");
242 if ( snd. isFinished ( )) { 236 if ( snd. isFinished ( )) {
243 snd. play ( ); 237 snd. play ( );
244 // qDebug("sound should play"); 238 // qDebug("sound should play");
245 } 239 }
246#endif 240#endif
247#endif 241#endif
248} 242}
249 243
250uint ODevice::hasLeds ( ) const 244uint ODevice::hasLeds ( ) const
251{ 245{
252 return 0; 246 return 0;
253} 247}
254 248
255OLedState ODevice::led ( uint /*which*/ ) const 249OLedState ODevice::led ( uint /*which*/ ) const
256{ 250{
257 return OLED_Off; 251 return OLED_Off;
258} 252}
259 253
260bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ ) 254bool ODevice::setLed ( uint /*which*/, OLedState /*st*/ )
261{ 255{
262 return false; 256 return false;
263} 257}
264 258
265 259
266 260
267 261
268//#if defined( QT_QWS_IPAQ ) // IPAQ 262//#if defined( QT_QWS_IPAQ ) // IPAQ
269 263
270 264
271void ODeviceIPAQ::init ( ) 265void ODeviceIPAQ::init ( )
272{ 266{
273 d-> m_vendorstr = "HP"; 267 d-> m_vendorstr = "HP";
274 d-> m_vendor = OVENDOR_HP; 268 d-> m_vendor = OVENDOR_HP;
275 269
276 QFile f ( "/proc/hal/model" ); 270 QFile f ( "/proc/hal/model" );
277 271
278 if ( f. open ( IO_ReadOnly )) { 272 if ( f. open ( IO_ReadOnly )) {
279 QTextStream ts ( &f ); 273 QTextStream ts ( &f );
280 274
281 d-> m_modelstr = "H" + ts. readLine ( ); 275 d-> m_modelstr = "H" + ts. readLine ( );
282 276
283 if ( d-> m_modelstr == "H3100" ) 277 if ( d-> m_modelstr == "H3100" )
284 d-> m_model = OMODEL_iPAQ_H31xx; 278 d-> m_model = OMODEL_iPAQ_H31xx;
285 else if ( d-> m_modelstr == "H3600" ) 279 else if ( d-> m_modelstr == "H3600" )
286 d-> m_model = OMODEL_iPAQ_H36xx; 280 d-> m_model = OMODEL_iPAQ_H36xx;
287 else if ( d-> m_modelstr == "H3700" ) 281 else if ( d-> m_modelstr == "H3700" )
288 d-> m_model = OMODEL_iPAQ_H37xx; 282 d-> m_model = OMODEL_iPAQ_H37xx;
289 else if ( d-> m_modelstr == "H3800" ) 283 else if ( d-> m_modelstr == "H3800" )
290 d-> m_model = OMODEL_iPAQ_H38xx; 284 d-> m_model = OMODEL_iPAQ_H38xx;
291 else 285 else
292 d-> m_model = OMODEL_Unknown; 286 d-> m_model = OMODEL_Unknown;
293 287
294 f. close ( ); 288 f. close ( );
295 } 289 }
296 290
297 f. setName ( "/etc/familiar-version" ); 291 f. setName ( "/etc/familiar-version" );
298 if ( f. open ( IO_ReadOnly )) { 292 if ( f. open ( IO_ReadOnly )) {
299 d-> m_systemstr = "Familiar"; 293 d-> m_systemstr = "Familiar";
300 d-> m_system = OSYSTEM_Familiar; 294 d-> m_system = OSYSTEM_Familiar;
301 295
302 QTextStream ts ( &f ); 296 QTextStream ts ( &f );
303 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 297 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
304 298
305 f. close ( ); 299 f. close ( );
306 } 300 }
307 301
308 d-> m_leds [0] = OLED_Off; 302 d-> m_leds [0] = OLED_Off;
309} 303}
310 304
311//#include <linux/h3600_ts.h> // including kernel headers is evil ... 305//#include <linux/h3600_ts.h> // including kernel headers is evil ...
312 306
313typedef struct h3600_ts_led { 307typedef struct h3600_ts_led {
314 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 308 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
315 unsigned char TotalTime; /* Units of 5 seconds */ 309 unsigned char TotalTime; /* Units of 5 seconds */
316 unsigned char OnTime; /* units of 100m/s */ 310 unsigned char OnTime; /* units of 100m/s */
317 unsigned char OffTime; /* units of 100m/s */ 311 unsigned char OffTime; /* units of 100m/s */
318} LED_IN; 312} LED_IN;
319 313
320 314
321// #define IOC_H3600_TS_MAGIC 'f' 315// #define IOC_H3600_TS_MAGIC 'f'
322// #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led) 316// #define LED_ON _IOW(IOC_H3600_TS_MAGIC, 5, struct h3600_ts_led)
323#define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :( 317#define LED_ON (( 1<<30 ) | ( 'f'<<8 ) | ( 5 ) | ( sizeof(struct h3600_ts_led)<<16 )) // _IOW only defined in kernel headers :(
324 318
325 319
326void ODeviceIPAQ::alarmSound ( ) 320void ODeviceIPAQ::alarmSound ( )
327{ 321{
328#if defined( QT_QWS_IPAQ ) // IPAQ 322#if defined( QT_QWS_IPAQ ) // IPAQ
329#ifndef QT_NO_SOUND 323#ifndef QT_NO_SOUND
330 static Sound snd ( "alarm" ); 324 static Sound snd ( "alarm" );
331 int fd; 325 int fd;
332 int vol; 326 int vol;
333 bool vol_reset = false; 327 bool vol_reset = false;
334 328
335 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) || 329 if ((( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) ||
336 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) { 330 (( fd = ::open ( "/dev/mixer", O_RDWR )) >= 0 )) {
337 331
338 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 332 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
339 Config cfg ( "qpe" ); 333 Config cfg ( "qpe" );
340 cfg. setGroup ( "Volume" ); 334 cfg. setGroup ( "Volume" );
341 335
342 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 336 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
343 if ( volalarm < 0 ) 337 if ( volalarm < 0 )
344 volalarm = 0; 338 volalarm = 0;
345 else if ( volalarm > 100 ) 339 else if ( volalarm > 100 )
346 volalarm = 100; 340 volalarm = 100;
347 volalarm |= ( volalarm << 8 ); 341 volalarm |= ( volalarm << 8 );
348 342
349 if (( volalarm & 0xff ) > ( vol & 0xff )) { 343 if (( volalarm & 0xff ) > ( vol & 0xff )) {
350 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 344 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
351 vol_reset = true; 345 vol_reset = true;
352 } 346 }
353 } 347 }
354 } 348 }
355 349
356 snd. play ( ); 350 snd. play ( );
357 while ( !snd. isFinished ( )) 351 while ( !snd. isFinished ( ))
358 qApp-> processEvents ( ); 352 qApp-> processEvents ( );
359 353
360 if ( fd >= 0 ) { 354 if ( fd >= 0 ) {
361 if ( vol_reset ) 355 if ( vol_reset )
362 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 356 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
363 ::close ( fd ); 357 ::close ( fd );
364 } 358 }
365#endif 359#endif
366#endif 360#endif
367} 361}
368 362
369uint ODeviceIPAQ::hasLeds ( ) const 363uint ODeviceIPAQ::hasLeds ( ) const
370{ 364{
371 return 1; 365 return 1;
372} 366}
373 367
374OLedState ODeviceIPAQ::led ( uint which ) const 368OLedState ODeviceIPAQ::led ( uint which ) const
375{ 369{
376 if ( which == 0 ) 370 if ( which == 0 )
377 return d-> m_leds [0]; 371 return d-> m_leds [0];
378 else 372 else
379 return OLED_Off; 373 return OLED_Off;
380} 374}
381 375
382bool ODeviceIPAQ::setLed ( uint which, OLedState st ) 376bool ODeviceIPAQ::setLed ( uint which, OLedState st )
383{ 377{
384 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK ); 378 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR|O_NONBLOCK );
385 379
386 if ( which == 0 ) { 380 if ( which == 0 ) {
387 if ( fd >= 0 ) { 381 if ( fd >= 0 ) {
388 struct h3600_ts_led leds; 382 struct h3600_ts_led leds;
389 ::memset ( &leds, 0, sizeof( leds )); 383 ::memset ( &leds, 0, sizeof( leds ));
390 leds. TotalTime = 0; 384 leds. TotalTime = 0;
391 leds. OnTime = 0; 385 leds. OnTime = 0;
392 leds. OffTime = 1; 386 leds. OffTime = 1;
393 leds. OffOnBlink = 2; 387 leds. OffOnBlink = 2;
394 388
395 switch ( st ) { 389 switch ( st ) {
396 case OLED_Off : leds. OffOnBlink = 0; break; 390 case OLED_Off : leds. OffOnBlink = 0; break;
397 case OLED_On : leds. OffOnBlink = 1; break; 391 case OLED_On : leds. OffOnBlink = 1; break;
398 case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 392 case OLED_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
399 case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 393 case OLED_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
400 } 394 }
401 395
402 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 396 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
403 d-> m_leds [0] = st; 397 d-> m_leds [0] = st;
404 return true; 398 return true;
405 } 399 }
406 } 400 }
407 } 401 }
408 return false; 402 return false;
409} 403}
410 404
411 405
412//#endif 406//#endif
413 407
414 408
415 409
416 410
417 411
418//#if defined( QT_QWS_EBX ) // Zaurus 412//#if defined( QT_QWS_EBX ) // Zaurus
419 413
420void ODeviceZaurus::init ( ) 414void ODeviceZaurus::init ( )
421{ 415{
422 d-> m_modelstr = "Zaurus SL5000"; 416 d-> m_modelstr = "Zaurus SL5000";
423 d-> m_model = OMODEL_Zaurus_SL5000; 417 d-> m_model = OMODEL_Zaurus_SL5000;
424 d-> m_vendorstr = "Sharp"; 418 d-> m_vendorstr = "Sharp";
425 d-> m_vendor = OVENDOR_Sharp; 419 d-> m_vendor = OVENDOR_Sharp;
426 420
427 QFile f ( "/proc/filesystems" ); 421 QFile f ( "/proc/filesystems" );
428 422
429 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 423 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
430 d-> m_systemstr = "OpenZaurus"; 424 d-> m_systemstr = "OpenZaurus";
431 d-> m_system = OSYSTEM_OpenZaurus; 425 d-> m_system = OSYSTEM_OpenZaurus;
432 426
433 f. close ( ); 427 f. close ( );
434 } 428 }
435 else { 429 else {
436 d-> m_systemstr = "Zaurus"; 430 d-> m_systemstr = "Zaurus";
437 d-> m_system = OSYSTEM_Zaurus; 431 d-> m_system = OSYSTEM_Zaurus;
438 } 432 }
439 433
440 d-> m_leds [0] = OLED_Off; 434 d-> m_leds [0] = OLED_Off;
441} 435}
442 436
443#include <unistd.h> 437#include <unistd.h>
444#include <fcntl.h> 438#include <fcntl.h>
445#include <sys/ioctl.h> 439#include <sys/ioctl.h>
446 440
447//#include <asm/sharp_char.h> // including kernel headers is evil ... 441//#include <asm/sharp_char.h> // including kernel headers is evil ...
448 442
449#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 443#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
450 444
451 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 445 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
452#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 446#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
453 447
454#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 448#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
455#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 449#define SHARP_BUZ_KEYSOUND 2 /* key sound */
456#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 450#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
457 451
458/* --- for SHARP_BUZZER device --- */ 452/* --- for SHARP_BUZZER device --- */
459 453
460 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 454 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
461//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 455//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
462 456
463#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 457#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
464#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 458#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
465#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 459#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
466#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 460#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
467#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 461#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
468 462
469//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 463//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
470//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 464//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
471 465
472//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 466//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
473//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 467//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
474//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 468//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
475//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 469//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
476//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 470//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
477//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 471//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
478//#define SHARP_PDA_APPSTART 9 /* application start */ 472//#define SHARP_PDA_APPSTART 9 /* application start */
479//#define SHARP_PDA_APPQUIT 10 /* application ends */ 473//#define SHARP_PDA_APPQUIT 10 /* application ends */
480 474
481//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 475//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
482//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 476//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
483//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 477//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
484//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 478//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
485// 479//
486 480
487 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 481 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
488#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 482#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
489 483
490typedef struct sharp_led_status { 484typedef struct sharp_led_status {
491 int which; /* select which LED status is wanted. */ 485 int which; /* select which LED status is wanted. */
492 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 486 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
493} sharp_led_status; 487} sharp_led_status;
494 488
495#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 489#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
496 490
497#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 491#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
498#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 492#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
499#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 493#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
500 494
501 495
502 496
503void ODeviceZaurus::buzzer ( int sound ) 497void ODeviceZaurus::buzzer ( int sound )
504{ 498{
505 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 499 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK );
506 500
507 if ( fd >= 0 ) 501 if ( fd >= 0 )
508 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 502 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
509} 503}
510 504
511 505
512void ODeviceZaurus::alarmSound ( ) 506void ODeviceZaurus::alarmSound ( )
513{ 507{
514 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 508 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
515} 509}
516 510
517void ODeviceZaurus::touchSound ( ) 511void ODeviceZaurus::touchSound ( )
518{ 512{
519 buzzer ( SHARP_BUZ_TOUCHSOUND ); 513 buzzer ( SHARP_BUZ_TOUCHSOUND );
520} 514}
521 515
522void ODeviceZaurus::keySound ( ) 516void ODeviceZaurus::keySound ( )
523{ 517{
524 buzzer ( SHARP_BUZ_KEYSOUND ); 518 buzzer ( SHARP_BUZ_KEYSOUND );
525} 519}
526 520
527 521
528uint ODeviceZaurus::hasLeds ( ) const 522uint ODeviceZaurus::hasLeds ( ) const
529{ 523{
530 return 1; 524 return 1;
531} 525}
532 526
533OLedState ODeviceZaurus::led ( uint which ) const 527OLedState ODeviceZaurus::led ( uint which ) const
534{ 528{
535 if ( which == 0 ) 529 if ( which == 0 )
536 return d-> m_leds [0]; 530 return d-> m_leds [0];
537 else 531 else
538 return OLED_Off; 532 return OLED_Off;
539} 533}
540 534
541bool ODeviceZaurus::setLed ( uint which, OLedState st ) 535bool ODeviceZaurus::setLed ( uint which, OLedState st )
542{ 536{
543 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 537 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
544 538
545 if ( which == 0 ) { 539 if ( which == 0 ) {
546 if ( fd >= 0 ) { 540 if ( fd >= 0 ) {
547 struct sharp_led_status leds; 541 struct sharp_led_status leds;
548 ::memset ( &leds, 0, sizeof( leds )); 542 ::memset ( &leds, 0, sizeof( leds ));
549 leds. which = SHARP_LED_MAIL_EXISTS; 543 leds. which = SHARP_LED_MAIL_EXISTS;
550 544
551 switch ( st ) { 545 switch ( st ) {
552 case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 546 case OLED_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
553 case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 547 case OLED_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
554 case OLED_BlinkSlow: 548 case OLED_BlinkSlow:
555 case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 549 case OLED_BlinkFast: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
556 } 550 }
557 551
558 if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) { 552 if ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 ) {
559 d-> m_leds [0] = st; 553 d-> m_leds [0] = st;
560 return true; 554 return true;
561 } 555 }
562 } 556 }
563 } 557 }
564 return false; 558 return false;
565} 559}
566 560
567//#endif 561//#endif