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