summaryrefslogtreecommitdiff
authorkergoth <kergoth>2003-04-01 20:33:39 (UTC)
committer kergoth <kergoth>2003-04-01 20:33:39 (UTC)
commit76b83c2b77e626fadf1d1bbbfd19a9a8a795334b (patch) (unidiff)
tree02d425c7e185842d0a12d9fe3d0b6377005fed67
parenta7ad29eb41163eec88b3bd835108bd80140ff086 (diff)
downloadopie-76b83c2b77e626fadf1d1bbbfd19a9a8a795334b.zip
opie-76b83c2b77e626fadf1d1bbbfd19a9a8a795334b.tar.gz
opie-76b83c2b77e626fadf1d1bbbfd19a9a8a795334b.tar.bz2
Open zaurus buzzer device as write only, and close it.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 55ba7bd..cea4f35 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -106,1158 +106,1160 @@ protected:
106 106
107class Zaurus : public ODevice { 107class Zaurus : public ODevice {
108protected: 108protected:
109 virtual void init ( ); 109 virtual void init ( );
110 virtual void initButtons ( ); 110 virtual void initButtons ( );
111 111
112 public: 112 public:
113 virtual bool setSoftSuspend ( bool soft ); 113 virtual bool setSoftSuspend ( bool soft );
114 114
115 virtual bool setDisplayBrightness ( int b ); 115 virtual bool setDisplayBrightness ( int b );
116 virtual int displayBrightnessResolution ( ) const; 116 virtual int displayBrightnessResolution ( ) const;
117 117
118 virtual void alarmSound ( ); 118 virtual void alarmSound ( );
119 virtual void keySound ( ); 119 virtual void keySound ( );
120 virtual void touchSound ( ); 120 virtual void touchSound ( );
121 121
122 virtual QValueList <OLed> ledList ( ) const; 122 virtual QValueList <OLed> ledList ( ) const;
123 virtual QValueList <OLedState> ledStateList ( OLed led ) const; 123 virtual QValueList <OLedState> ledStateList ( OLed led ) const;
124 virtual OLedState ledState ( OLed led ) const; 124 virtual OLedState ledState ( OLed led ) const;
125 virtual bool setLedState ( OLed led, OLedState st ); 125 virtual bool setLedState ( OLed led, OLedState st );
126 126
127protected: 127protected:
128 virtual void buzzer ( int snd ); 128 virtual void buzzer ( int snd );
129 129
130 OLedState m_leds [1]; 130 OLedState m_leds [1];
131}; 131};
132 132
133 133
134struct i_button { 134struct i_button {
135 uint model; 135 uint model;
136 Qt::Key code; 136 Qt::Key code;
137 char *utext; 137 char *utext;
138 char *pix; 138 char *pix;
139 char *fpressedservice; 139 char *fpressedservice;
140 char *fpressedaction; 140 char *fpressedaction;
141 char *fheldservice; 141 char *fheldservice;
142 char *fheldaction; 142 char *fheldaction;
143} ipaq_buttons [] = { 143} ipaq_buttons [] = {
144 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 144 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
145 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 145 Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
146 "devicebuttons/ipaq_calendar", 146 "devicebuttons/ipaq_calendar",
147 "datebook", "nextView()", 147 "datebook", "nextView()",
148 "today", "raise()" }, 148 "today", "raise()" },
149 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 149 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
150 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 150 Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
151 "devicebuttons/ipaq_contact", 151 "devicebuttons/ipaq_contact",
152 "addressbook", "raise()", 152 "addressbook", "raise()",
153 "addressbook", "beamBusinessCard()" }, 153 "addressbook", "beamBusinessCard()" },
154 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx, 154 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx,
155 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 155 Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
156 "devicebuttons/ipaq_menu", 156 "devicebuttons/ipaq_menu",
157 "QPE/TaskBar", "toggleMenu()", 157 "QPE/TaskBar", "toggleMenu()",
158 "QPE/TaskBar", "toggleStartMenu()" }, 158 "QPE/TaskBar", "toggleStartMenu()" },
159 { Model_iPAQ_H38xx | Model_iPAQ_H39xx, 159 { Model_iPAQ_H38xx | Model_iPAQ_H39xx,
160 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 160 Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
161 "devicebuttons/ipaq_mail", 161 "devicebuttons/ipaq_mail",
162 "mail", "raise()", 162 "mail", "raise()",
163 "mail", "newMail()" }, 163 "mail", "newMail()" },
164 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 164 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
165 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 165 Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
166 "devicebuttons/ipaq_home", 166 "devicebuttons/ipaq_home",
167 "QPE/Launcher", "home()", 167 "QPE/Launcher", "home()",
168 "buttonsettings", "raise()" }, 168 "buttonsettings", "raise()" },
169 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx, 169 { Model_iPAQ_H31xx | Model_iPAQ_H36xx | Model_iPAQ_H37xx | Model_iPAQ_H38xx | Model_iPAQ_H39xx,
170 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"), 170 Qt::Key_F24, QT_TRANSLATE_NOOP("Button", "Record Button"),
171 "devicebuttons/ipaq_record", 171 "devicebuttons/ipaq_record",
172 "QPE/VMemo", "toggleRecord()", 172 "QPE/VMemo", "toggleRecord()",
173 "sound", "raise()" }, 173 "sound", "raise()" },
174}; 174};
175 175
176struct z_button { 176struct z_button {
177 Qt::Key code; 177 Qt::Key code;
178 char *utext; 178 char *utext;
179 char *pix; 179 char *pix;
180 char *fpressedservice; 180 char *fpressedservice;
181 char *fpressedaction; 181 char *fpressedaction;
182 char *fheldservice; 182 char *fheldservice;
183 char *fheldaction; 183 char *fheldaction;
184} z_buttons [] = { 184} z_buttons [] = {
185 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 185 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
186 "devicebuttons/z_calendar", 186 "devicebuttons/z_calendar",
187 "datebook", "nextView()", 187 "datebook", "nextView()",
188 "today", "raise()" }, 188 "today", "raise()" },
189 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 189 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
190 "devicebuttons/z_contact", 190 "devicebuttons/z_contact",
191 "addressbook", "raise()", 191 "addressbook", "raise()",
192 "addressbook", "beamBusinessCard()" }, 192 "addressbook", "beamBusinessCard()" },
193 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 193 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
194 "devicebuttons/z_home", 194 "devicebuttons/z_home",
195 "QPE/Launcher", "home()", 195 "QPE/Launcher", "home()",
196 "buttonsettings", "raise()" }, 196 "buttonsettings", "raise()" },
197 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 197 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
198 "devicebuttons/z_menu", 198 "devicebuttons/z_menu",
199 "QPE/TaskBar", "toggleMenu()", 199 "QPE/TaskBar", "toggleMenu()",
200 "QPE/TaskBar", "toggleStartMenu()" }, 200 "QPE/TaskBar", "toggleStartMenu()" },
201 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"), 201 { Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Mail Button"),
202 "devicebuttons/z_mail", 202 "devicebuttons/z_mail",
203 "mail", "raise()", 203 "mail", "raise()",
204 "mail", "newMail()" }, 204 "mail", "newMail()" },
205}; 205};
206 206
207static QCString makeChannel ( const char *str ) 207static QCString makeChannel ( const char *str )
208{ 208{
209 if ( str && !::strchr ( str, '/' )) 209 if ( str && !::strchr ( str, '/' ))
210 return QCString ( "QPE/Application/" ) + str; 210 return QCString ( "QPE/Application/" ) + str;
211 else 211 else
212 return str; 212 return str;
213} 213}
214 214
215 215
216 216
217 217
218ODevice *ODevice::inst ( ) 218ODevice *ODevice::inst ( )
219{ 219{
220 static ODevice *dev = 0; 220 static ODevice *dev = 0;
221 221
222 if ( !dev ) { 222 if ( !dev ) {
223 if ( QFile::exists ( "/proc/hal/model" )) 223 if ( QFile::exists ( "/proc/hal/model" ))
224 dev = new iPAQ ( ); 224 dev = new iPAQ ( );
225 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" )) 225 else if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ))
226 dev = new Zaurus ( ); 226 dev = new Zaurus ( );
227 else 227 else
228 dev = new ODevice ( ); 228 dev = new ODevice ( );
229 229
230 dev-> init ( ); 230 dev-> init ( );
231 } 231 }
232 return dev; 232 return dev;
233} 233}
234 234
235 235
236/************************************************** 236/**************************************************
237 * 237 *
238 * common 238 * common
239 * 239 *
240 **************************************************/ 240 **************************************************/
241 241
242 242
243ODevice::ODevice ( ) 243ODevice::ODevice ( )
244{ 244{
245 d = new ODeviceData; 245 d = new ODeviceData;
246 246
247 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; 247 d-> m_qwsserver = qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false;
248 248
249 d-> m_modelstr = "Unknown"; 249 d-> m_modelstr = "Unknown";
250 d-> m_model = Model_Unknown; 250 d-> m_model = Model_Unknown;
251 d-> m_vendorstr = "Unknown"; 251 d-> m_vendorstr = "Unknown";
252 d-> m_vendor = Vendor_Unknown; 252 d-> m_vendor = Vendor_Unknown;
253 d-> m_systemstr = "Unknown"; 253 d-> m_systemstr = "Unknown";
254 d-> m_system = System_Unknown; 254 d-> m_system = System_Unknown;
255 d-> m_sysverstr = "0.0"; 255 d-> m_sysverstr = "0.0";
256 d-> m_rotation = Rot0; 256 d-> m_rotation = Rot0;
257 257
258 d-> m_holdtime = 1000; // 1000ms 258 d-> m_holdtime = 1000; // 1000ms
259 d-> m_buttons = 0; 259 d-> m_buttons = 0;
260} 260}
261 261
262void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) 262void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
263{ 263{
264 if ( msg == "deviceButtonMappingChanged()" ) { 264 if ( msg == "deviceButtonMappingChanged()" ) {
265 reloadButtonMapping ( ); 265 reloadButtonMapping ( );
266 } 266 }
267} 267}
268 268
269void ODevice::init ( ) 269void ODevice::init ( )
270{ 270{
271} 271}
272 272
273void ODevice::initButtons ( ) 273void ODevice::initButtons ( )
274{ 274{
275 if ( d-> m_buttons ) 275 if ( d-> m_buttons )
276 return; 276 return;
277 277
278 // Simulation uses iPAQ 3660 device buttons 278 // Simulation uses iPAQ 3660 device buttons
279 279
280 qDebug ( "init Buttons" ); 280 qDebug ( "init Buttons" );
281 d-> m_buttons = new QValueList <ODeviceButton>; 281 d-> m_buttons = new QValueList <ODeviceButton>;
282 282
283 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 283 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
284 i_button *ib = ipaq_buttons + i; 284 i_button *ib = ipaq_buttons + i;
285 ODeviceButton b; 285 ODeviceButton b;
286 286
287 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { 287 if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) {
288 b. setKeycode ( ib-> code ); 288 b. setKeycode ( ib-> code );
289 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 289 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
290 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 290 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
291 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 291 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
292 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 292 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
293 d-> m_buttons-> append ( b ); 293 d-> m_buttons-> append ( b );
294 } 294 }
295 } 295 }
296 reloadButtonMapping ( ); 296 reloadButtonMapping ( );
297 297
298 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 298 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
299 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 299 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
300} 300}
301 301
302ODevice::~ODevice ( ) 302ODevice::~ODevice ( )
303{ 303{
304 delete d; 304 delete d;
305} 305}
306 306
307bool ODevice::setSoftSuspend ( bool /*soft*/ ) 307bool ODevice::setSoftSuspend ( bool /*soft*/ )
308{ 308{
309 return false; 309 return false;
310} 310}
311 311
312//#include <linux/apm_bios.h> 312//#include <linux/apm_bios.h>
313 313
314#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 314#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
315 315
316 316
317bool ODevice::suspend ( ) 317bool ODevice::suspend ( )
318{ 318{
319 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 319 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
320 return false; 320 return false;
321 321
322 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 322 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
323 return false; 323 return false;
324 324
325 bool res = false; 325 bool res = false;
326 326
327 struct timeval tvs, tvn; 327 struct timeval tvs, tvn;
328 ::gettimeofday ( &tvs, 0 ); 328 ::gettimeofday ( &tvs, 0 );
329 329
330 ::sync ( ); // flush fs caches 330 ::sync ( ); // flush fs caches
331 res = ( ::system ( "apm --suspend" ) == 0 ); 331 res = ( ::system ( "apm --suspend" ) == 0 );
332 332
333 // This is needed because the iPAQ apm implementation is asynchronous and we 333 // This is needed because the iPAQ apm implementation is asynchronous and we
334 // can not be sure when exactly the device is really suspended 334 // can not be sure when exactly the device is really suspended
335 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. 335 // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists.
336 336
337 if ( res ) { 337 if ( res ) {
338 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed 338 do { // wait at most 1.5 sec: either suspend didn't work or the device resumed
339 ::usleep ( 200 * 1000 ); 339 ::usleep ( 200 * 1000 );
340 ::gettimeofday ( &tvn, 0 ); 340 ::gettimeofday ( &tvn, 0 );
341 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); 341 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 );
342 } 342 }
343 343
344 return res; 344 return res;
345} 345}
346 346
347//#include <linux/fb.h> better not rely on kernel headers in userspace ... 347//#include <linux/fb.h> better not rely on kernel headers in userspace ...
348 348
349#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 349#define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611
350 350
351/* VESA Blanking Levels */ 351/* VESA Blanking Levels */
352#define VESA_NO_BLANKING 0 352#define VESA_NO_BLANKING 0
353#define VESA_VSYNC_SUSPEND 1 353#define VESA_VSYNC_SUSPEND 1
354#define VESA_HSYNC_SUSPEND 2 354#define VESA_HSYNC_SUSPEND 2
355#define VESA_POWERDOWN 3 355#define VESA_POWERDOWN 3
356 356
357 357
358bool ODevice::setDisplayStatus ( bool on ) 358bool ODevice::setDisplayStatus ( bool on )
359{ 359{
360 if ( d-> m_model == Model_Unknown ) 360 if ( d-> m_model == Model_Unknown )
361 return false; 361 return false;
362 362
363 bool res = false; 363 bool res = false;
364 int fd; 364 int fd;
365 365
366 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { 366 if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) {
367 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 367 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
368 ::close ( fd ); 368 ::close ( fd );
369 } 369 }
370 return res; 370 return res;
371} 371}
372 372
373bool ODevice::setDisplayBrightness ( int ) 373bool ODevice::setDisplayBrightness ( int )
374{ 374{
375 return false; 375 return false;
376} 376}
377 377
378int ODevice::displayBrightnessResolution ( ) const 378int ODevice::displayBrightnessResolution ( ) const
379{ 379{
380 return 16; 380 return 16;
381} 381}
382 382
383QString ODevice::vendorString ( ) const 383QString ODevice::vendorString ( ) const
384{ 384{
385 return d-> m_vendorstr; 385 return d-> m_vendorstr;
386} 386}
387 387
388OVendor ODevice::vendor ( ) const 388OVendor ODevice::vendor ( ) const
389{ 389{
390 return d-> m_vendor; 390 return d-> m_vendor;
391} 391}
392 392
393QString ODevice::modelString ( ) const 393QString ODevice::modelString ( ) const
394{ 394{
395 return d-> m_modelstr; 395 return d-> m_modelstr;
396} 396}
397 397
398OModel ODevice::model ( ) const 398OModel ODevice::model ( ) const
399{ 399{
400 return d-> m_model; 400 return d-> m_model;
401} 401}
402 402
403QString ODevice::systemString ( ) const 403QString ODevice::systemString ( ) const
404{ 404{
405 return d-> m_systemstr; 405 return d-> m_systemstr;
406} 406}
407 407
408OSystem ODevice::system ( ) const 408OSystem ODevice::system ( ) const
409{ 409{
410 return d-> m_system; 410 return d-> m_system;
411} 411}
412 412
413QString ODevice::systemVersionString ( ) const 413QString ODevice::systemVersionString ( ) const
414{ 414{
415 return d-> m_sysverstr; 415 return d-> m_sysverstr;
416} 416}
417 417
418Transformation ODevice::rotation ( ) const 418Transformation ODevice::rotation ( ) const
419{ 419{
420 return d-> m_rotation; 420 return d-> m_rotation;
421} 421}
422 422
423void ODevice::alarmSound ( ) 423void ODevice::alarmSound ( )
424{ 424{
425#ifndef QT_NO_SOUND 425#ifndef QT_NO_SOUND
426 static Sound snd ( "alarm" ); 426 static Sound snd ( "alarm" );
427 427
428 if ( snd. isFinished ( )) 428 if ( snd. isFinished ( ))
429 snd. play ( ); 429 snd. play ( );
430#endif 430#endif
431} 431}
432 432
433void ODevice::keySound ( ) 433void ODevice::keySound ( )
434{ 434{
435#ifndef QT_NO_SOUND 435#ifndef QT_NO_SOUND
436 static Sound snd ( "keysound" ); 436 static Sound snd ( "keysound" );
437 437
438 if ( snd. isFinished ( )) 438 if ( snd. isFinished ( ))
439 snd. play ( ); 439 snd. play ( );
440#endif 440#endif
441} 441}
442 442
443void ODevice::touchSound ( ) 443void ODevice::touchSound ( )
444{ 444{
445 445
446#ifndef QT_NO_SOUND 446#ifndef QT_NO_SOUND
447 static Sound snd ( "touchsound" ); 447 static Sound snd ( "touchsound" );
448 448
449 if ( snd. isFinished ( )) 449 if ( snd. isFinished ( ))
450 snd. play ( ); 450 snd. play ( );
451#endif 451#endif
452} 452}
453 453
454 454
455QValueList <OLed> ODevice::ledList ( ) const 455QValueList <OLed> ODevice::ledList ( ) const
456{ 456{
457 return QValueList <OLed> ( ); 457 return QValueList <OLed> ( );
458} 458}
459 459
460QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 460QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
461{ 461{
462 return QValueList <OLedState> ( ); 462 return QValueList <OLedState> ( );
463} 463}
464 464
465OLedState ODevice::ledState ( OLed /*which*/ ) const 465OLedState ODevice::ledState ( OLed /*which*/ ) const
466{ 466{
467 return Led_Off; 467 return Led_Off;
468} 468}
469 469
470bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 470bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ )
471{ 471{
472 return false; 472 return false;
473} 473}
474 474
475bool ODevice::hasLightSensor ( ) const 475bool ODevice::hasLightSensor ( ) const
476{ 476{
477 return false; 477 return false;
478} 478}
479 479
480int ODevice::readLightSensor ( ) 480int ODevice::readLightSensor ( )
481{ 481{
482 return -1; 482 return -1;
483} 483}
484 484
485int ODevice::lightSensorResolution ( ) const 485int ODevice::lightSensorResolution ( ) const
486{ 486{
487 return 0; 487 return 0;
488} 488}
489 489
490const QValueList <ODeviceButton> &ODevice::buttons ( ) 490const QValueList <ODeviceButton> &ODevice::buttons ( )
491{ 491{
492 initButtons ( ); 492 initButtons ( );
493 493
494 return *d-> m_buttons; 494 return *d-> m_buttons;
495} 495}
496 496
497uint ODevice::buttonHoldTime ( ) const 497uint ODevice::buttonHoldTime ( ) const
498{ 498{
499 return d-> m_holdtime; 499 return d-> m_holdtime;
500} 500}
501 501
502const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 502const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
503{ 503{
504 initButtons ( ); 504 initButtons ( );
505 505
506 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 506 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
507 if ( (*it). keycode ( ) == code ) 507 if ( (*it). keycode ( ) == code )
508 return &(*it); 508 return &(*it);
509 } 509 }
510 return 0; 510 return 0;
511} 511}
512 512
513void ODevice::reloadButtonMapping ( ) 513void ODevice::reloadButtonMapping ( )
514{ 514{
515 initButtons ( ); 515 initButtons ( );
516 516
517 Config cfg ( "ButtonSettings" ); 517 Config cfg ( "ButtonSettings" );
518 518
519 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { 519 for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) {
520 ODeviceButton &b = ( *d-> m_buttons ) [i]; 520 ODeviceButton &b = ( *d-> m_buttons ) [i];
521 QString group = "Button" + QString::number ( i ); 521 QString group = "Button" + QString::number ( i );
522 522
523 QCString pch, hch; 523 QCString pch, hch;
524 QCString pm, hm; 524 QCString pm, hm;
525 QByteArray pdata, hdata; 525 QByteArray pdata, hdata;
526 526
527 if ( cfg. hasGroup ( group )) { 527 if ( cfg. hasGroup ( group )) {
528 cfg. setGroup ( group ); 528 cfg. setGroup ( group );
529 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); 529 pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( );
530 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); 530 pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( );
531 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); 531 // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" ));
532 532
533 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); 533 hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( );
534 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); 534 hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( );
535 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); 535 // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" ));
536 } 536 }
537 537
538 b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); 538 b. setPressedAction ( OQCopMessage ( pch, pm, pdata ));
539 539
540 b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); 540 b. setHeldAction ( OQCopMessage ( hch, hm, hdata ));
541 } 541 }
542} 542}
543 543
544void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 544void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
545{ 545{
546 initButtons ( ); 546 initButtons ( );
547 547
548 QString mb_chan; 548 QString mb_chan;
549 549
550 if ( button >= (int) d-> m_buttons-> count ( )) 550 if ( button >= (int) d-> m_buttons-> count ( ))
551 return; 551 return;
552 552
553 ODeviceButton &b = ( *d-> m_buttons ) [button]; 553 ODeviceButton &b = ( *d-> m_buttons ) [button];
554 b. setPressedAction ( action ); 554 b. setPressedAction ( action );
555 555
556 mb_chan=b. pressedAction ( ). channel ( ); 556 mb_chan=b. pressedAction ( ). channel ( );
557 557
558 Config buttonFile ( "ButtonSettings" ); 558 Config buttonFile ( "ButtonSettings" );
559 buttonFile. setGroup ( "Button" + QString::number ( button )); 559 buttonFile. setGroup ( "Button" + QString::number ( button ));
560 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 560 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
561 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); 561 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( ));
562 562
563 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); 563 //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( )));
564 564
565 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 565 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
566} 566}
567 567
568void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 568void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
569{ 569{
570 initButtons ( ); 570 initButtons ( );
571 571
572 if ( button >= (int) d-> m_buttons-> count ( )) 572 if ( button >= (int) d-> m_buttons-> count ( ))
573 return; 573 return;
574 574
575 ODeviceButton &b = ( *d-> m_buttons ) [button]; 575 ODeviceButton &b = ( *d-> m_buttons ) [button];
576 b. setHeldAction ( action ); 576 b. setHeldAction ( action );
577 577
578 Config buttonFile ( "ButtonSettings" ); 578 Config buttonFile ( "ButtonSettings" );
579 buttonFile. setGroup ( "Button" + QString::number ( button )); 579 buttonFile. setGroup ( "Button" + QString::number ( button ));
580 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); 580 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( ));
581 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); 581 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( ));
582 582
583 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); 583 //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( )));
584 584
585 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 585 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
586} 586}
587 587
588 588
589 589
590 590
591/************************************************** 591/**************************************************
592 * 592 *
593 * iPAQ 593 * iPAQ
594 * 594 *
595 **************************************************/ 595 **************************************************/
596 596
597void iPAQ::init ( ) 597void iPAQ::init ( )
598{ 598{
599 d-> m_vendorstr = "HP"; 599 d-> m_vendorstr = "HP";
600 d-> m_vendor = Vendor_HP; 600 d-> m_vendor = Vendor_HP;
601 601
602 QFile f ( "/proc/hal/model" ); 602 QFile f ( "/proc/hal/model" );
603 603
604 if ( f. open ( IO_ReadOnly )) { 604 if ( f. open ( IO_ReadOnly )) {
605 QTextStream ts ( &f ); 605 QTextStream ts ( &f );
606 606
607 d-> m_modelstr = "H" + ts. readLine ( ); 607 d-> m_modelstr = "H" + ts. readLine ( );
608 608
609 if ( d-> m_modelstr == "H3100" ) 609 if ( d-> m_modelstr == "H3100" )
610 d-> m_model = Model_iPAQ_H31xx; 610 d-> m_model = Model_iPAQ_H31xx;
611 else if ( d-> m_modelstr == "H3600" ) 611 else if ( d-> m_modelstr == "H3600" )
612 d-> m_model = Model_iPAQ_H36xx; 612 d-> m_model = Model_iPAQ_H36xx;
613 else if ( d-> m_modelstr == "H3700" ) 613 else if ( d-> m_modelstr == "H3700" )
614 d-> m_model = Model_iPAQ_H37xx; 614 d-> m_model = Model_iPAQ_H37xx;
615 else if ( d-> m_modelstr == "H3800" ) 615 else if ( d-> m_modelstr == "H3800" )
616 d-> m_model = Model_iPAQ_H38xx; 616 d-> m_model = Model_iPAQ_H38xx;
617 else if ( d-> m_modelstr == "H3900" ) 617 else if ( d-> m_modelstr == "H3900" )
618 d-> m_model = Model_iPAQ_H39xx; 618 d-> m_model = Model_iPAQ_H39xx;
619 else 619 else
620 d-> m_model = Model_Unknown; 620 d-> m_model = Model_Unknown;
621 621
622 f. close ( ); 622 f. close ( );
623 } 623 }
624 624
625 switch ( d-> m_model ) { 625 switch ( d-> m_model ) {
626 case Model_iPAQ_H31xx: 626 case Model_iPAQ_H31xx:
627 case Model_iPAQ_H38xx: 627 case Model_iPAQ_H38xx:
628 d-> m_rotation = Rot90; 628 d-> m_rotation = Rot90;
629 break; 629 break;
630 case Model_iPAQ_H36xx: 630 case Model_iPAQ_H36xx:
631 case Model_iPAQ_H37xx: 631 case Model_iPAQ_H37xx:
632 case Model_iPAQ_H39xx: 632 case Model_iPAQ_H39xx:
633 default: 633 default:
634 d-> m_rotation = Rot270; 634 d-> m_rotation = Rot270;
635 break; 635 break;
636 } 636 }
637 637
638 f. setName ( "/etc/familiar-version" ); 638 f. setName ( "/etc/familiar-version" );
639 if ( f. open ( IO_ReadOnly )) { 639 if ( f. open ( IO_ReadOnly )) {
640 d-> m_systemstr = "Familiar"; 640 d-> m_systemstr = "Familiar";
641 d-> m_system = System_Familiar; 641 d-> m_system = System_Familiar;
642 642
643 QTextStream ts ( &f ); 643 QTextStream ts ( &f );
644 d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); 644 d-> m_sysverstr = ts. readLine ( ). mid ( 10 );
645 645
646 f. close ( ); 646 f. close ( );
647 } 647 }
648 648
649 m_leds [0] = m_leds [1] = Led_Off; 649 m_leds [0] = m_leds [1] = Led_Off;
650 650
651 m_power_timer = 0; 651 m_power_timer = 0;
652 652
653 if ( d-> m_qwsserver ) 653 if ( d-> m_qwsserver )
654 QWSServer::setKeyboardFilter ( this ); 654 QWSServer::setKeyboardFilter ( this );
655} 655}
656 656
657void iPAQ::initButtons ( ) 657void iPAQ::initButtons ( )
658{ 658{
659 if ( d-> m_buttons ) 659 if ( d-> m_buttons )
660 return; 660 return;
661 661
662 d-> m_buttons = new QValueList <ODeviceButton>; 662 d-> m_buttons = new QValueList <ODeviceButton>;
663 663
664 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { 664 for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) {
665 i_button *ib = ipaq_buttons + i; 665 i_button *ib = ipaq_buttons + i;
666 ODeviceButton b; 666 ODeviceButton b;
667 667
668 if (( ib-> model & d-> m_model ) == d-> m_model ) { 668 if (( ib-> model & d-> m_model ) == d-> m_model ) {
669 b. setKeycode ( ib-> code ); 669 b. setKeycode ( ib-> code );
670 b. setUserText ( QObject::tr ( "Button", ib-> utext )); 670 b. setUserText ( QObject::tr ( "Button", ib-> utext ));
671 b. setPixmap ( Resource::loadPixmap ( ib-> pix )); 671 b. setPixmap ( Resource::loadPixmap ( ib-> pix ));
672 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); 672 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction ));
673 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); 673 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction ));
674 674
675 d-> m_buttons-> append ( b ); 675 d-> m_buttons-> append ( b );
676 } 676 }
677 } 677 }
678 reloadButtonMapping ( ); 678 reloadButtonMapping ( );
679 679
680 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 680 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
681 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 681 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
682} 682}
683 683
684 684
685//#include <linux/h3600_ts.h> // including kernel headers is evil ... 685//#include <linux/h3600_ts.h> // including kernel headers is evil ...
686 686
687typedef struct { 687typedef struct {
688 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 688 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
689 unsigned char TotalTime; /* Units of 5 seconds */ 689 unsigned char TotalTime; /* Units of 5 seconds */
690 unsigned char OnTime; /* units of 100m/s */ 690 unsigned char OnTime; /* units of 100m/s */
691 unsigned char OffTime; /* units of 100m/s */ 691 unsigned char OffTime; /* units of 100m/s */
692} LED_IN; 692} LED_IN;
693 693
694typedef struct { 694typedef struct {
695 unsigned char mode; 695 unsigned char mode;
696 unsigned char pwr; 696 unsigned char pwr;
697 unsigned char brightness; 697 unsigned char brightness;
698} FLITE_IN; 698} FLITE_IN;
699 699
700#define LED_ON OD_IOW( 'f', 5, LED_IN ) 700#define LED_ON OD_IOW( 'f', 5, LED_IN )
701#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) 701#define FLITE_ON OD_IOW( 'f', 7, FLITE_IN )
702 702
703 703
704QValueList <OLed> iPAQ::ledList ( ) const 704QValueList <OLed> iPAQ::ledList ( ) const
705{ 705{
706 QValueList <OLed> vl; 706 QValueList <OLed> vl;
707 vl << Led_Power; 707 vl << Led_Power;
708 708
709 if ( d-> m_model == Model_iPAQ_H38xx ) 709 if ( d-> m_model == Model_iPAQ_H38xx )
710 vl << Led_BlueTooth; 710 vl << Led_BlueTooth;
711 return vl; 711 return vl;
712} 712}
713 713
714QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const 714QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const
715{ 715{
716 QValueList <OLedState> vl; 716 QValueList <OLedState> vl;
717 717
718 if ( l == Led_Power ) 718 if ( l == Led_Power )
719 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; 719 vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast;
720 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) 720 else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx )
721 vl << Led_Off; // << Led_On << ??? 721 vl << Led_Off; // << Led_On << ???
722 722
723 return vl; 723 return vl;
724} 724}
725 725
726OLedState iPAQ::ledState ( OLed l ) const 726OLedState iPAQ::ledState ( OLed l ) const
727 { 727 {
728 switch ( l ) { 728 switch ( l ) {
729 case Led_Power: 729 case Led_Power:
730 return m_leds [0]; 730 return m_leds [0];
731 case Led_BlueTooth: 731 case Led_BlueTooth:
732 return m_leds [1]; 732 return m_leds [1];
733 default: 733 default:
734 return Led_Off; 734 return Led_Off;
735 } 735 }
736} 736}
737 737
738bool iPAQ::setLedState ( OLed l, OLedState st ) 738bool iPAQ::setLedState ( OLed l, OLedState st )
739{ 739{
740 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); 740 static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK );
741 741
742 if ( l == Led_Power ) { 742 if ( l == Led_Power ) {
743 if ( fd >= 0 ) { 743 if ( fd >= 0 ) {
744 LED_IN leds; 744 LED_IN leds;
745 ::memset ( &leds, 0, sizeof( leds )); 745 ::memset ( &leds, 0, sizeof( leds ));
746 leds. TotalTime = 0; 746 leds. TotalTime = 0;
747 leds. OnTime = 0; 747 leds. OnTime = 0;
748 leds. OffTime = 1; 748 leds. OffTime = 1;
749 leds. OffOnBlink = 2; 749 leds. OffOnBlink = 2;
750 750
751 switch ( st ) { 751 switch ( st ) {
752 case Led_Off : leds. OffOnBlink = 0; break; 752 case Led_Off : leds. OffOnBlink = 0; break;
753 case Led_On : leds. OffOnBlink = 1; break; 753 case Led_On : leds. OffOnBlink = 1; break;
754 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; 754 case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break;
755 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; 755 case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break;
756 } 756 }
757 757
758 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { 758 if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) {
759 m_leds [0] = st; 759 m_leds [0] = st;
760 return true; 760 return true;
761 } 761 }
762 } 762 }
763 } 763 }
764 return false; 764 return false;
765} 765}
766 766
767 767
768bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 768bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat )
769{ 769{
770 int newkeycode = keycode; 770 int newkeycode = keycode;
771 771
772 switch ( keycode ) { 772 switch ( keycode ) {
773 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key 773 // H38xx/H39xx have no "Q" key anymore - this is now the Mail key
774 case HardKey_Menu: { 774 case HardKey_Menu: {
775 if (( d-> m_model == Model_iPAQ_H38xx ) || 775 if (( d-> m_model == Model_iPAQ_H38xx ) ||
776 ( d-> m_model == Model_iPAQ_H39xx )) { 776 ( d-> m_model == Model_iPAQ_H39xx )) {
777 newkeycode = HardKey_Mail; 777 newkeycode = HardKey_Mail;
778 } 778 }
779 break; 779 break;
780 } 780 }
781 781
782 // Rotate cursor keys 180° 782 // Rotate cursor keys 180°
783 case Key_Left : 783 case Key_Left :
784 case Key_Right: 784 case Key_Right:
785 case Key_Up : 785 case Key_Up :
786 case Key_Down : { 786 case Key_Down : {
787 if (( d-> m_model == Model_iPAQ_H31xx ) || 787 if (( d-> m_model == Model_iPAQ_H31xx ) ||
788 ( d-> m_model == Model_iPAQ_H38xx )) { 788 ( d-> m_model == Model_iPAQ_H38xx )) {
789 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; 789 newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4;
790 } 790 }
791 break; 791 break;
792 } 792 }
793 793
794 // map Power Button short/long press to F34/F35 794 // map Power Button short/long press to F34/F35
795 case Key_SysReq: { 795 case Key_SysReq: {
796 if ( isPress ) { 796 if ( isPress ) {
797 if ( m_power_timer ) 797 if ( m_power_timer )
798 killTimer ( m_power_timer ); 798 killTimer ( m_power_timer );
799 m_power_timer = startTimer ( 500 ); 799 m_power_timer = startTimer ( 500 );
800 } 800 }
801 else if ( m_power_timer ) { 801 else if ( m_power_timer ) {
802 killTimer ( m_power_timer ); 802 killTimer ( m_power_timer );
803 m_power_timer = 0; 803 m_power_timer = 0;
804 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 804 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
805 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 805 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
806 } 806 }
807 newkeycode = Key_unknown; 807 newkeycode = Key_unknown;
808 break; 808 break;
809 } 809 }
810 } 810 }
811 811
812 if ( newkeycode != keycode ) { 812 if ( newkeycode != keycode ) {
813 if ( newkeycode != Key_unknown ) 813 if ( newkeycode != Key_unknown )
814 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 814 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
815 return true; 815 return true;
816 } 816 }
817 else 817 else
818 return false; 818 return false;
819} 819}
820 820
821void iPAQ::timerEvent ( QTimerEvent * ) 821void iPAQ::timerEvent ( QTimerEvent * )
822{ 822{
823 killTimer ( m_power_timer ); 823 killTimer ( m_power_timer );
824 m_power_timer = 0; 824 m_power_timer = 0;
825 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 825 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
826 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 826 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
827} 827}
828 828
829 829
830void iPAQ::alarmSound ( ) 830void iPAQ::alarmSound ( )
831{ 831{
832#ifndef QT_NO_SOUND 832#ifndef QT_NO_SOUND
833 static Sound snd ( "alarm" ); 833 static Sound snd ( "alarm" );
834 int fd; 834 int fd;
835 int vol; 835 int vol;
836 bool vol_reset = false; 836 bool vol_reset = false;
837 837
838 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { 838 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
839 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { 839 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
840 Config cfg ( "qpe" ); 840 Config cfg ( "qpe" );
841 cfg. setGroup ( "Volume" ); 841 cfg. setGroup ( "Volume" );
842 842
843 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); 843 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
844 if ( volalarm < 0 ) 844 if ( volalarm < 0 )
845 volalarm = 0; 845 volalarm = 0;
846 else if ( volalarm > 100 ) 846 else if ( volalarm > 100 )
847 volalarm = 100; 847 volalarm = 100;
848 volalarm |= ( volalarm << 8 ); 848 volalarm |= ( volalarm << 8 );
849 849
850 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) 850 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
851 vol_reset = true; 851 vol_reset = true;
852 } 852 }
853 } 853 }
854 854
855 snd. play ( ); 855 snd. play ( );
856 while ( !snd. isFinished ( )) 856 while ( !snd. isFinished ( ))
857 qApp-> processEvents ( ); 857 qApp-> processEvents ( );
858 858
859 if ( fd >= 0 ) { 859 if ( fd >= 0 ) {
860 if ( vol_reset ) 860 if ( vol_reset )
861 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); 861 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
862 ::close ( fd ); 862 ::close ( fd );
863 } 863 }
864#endif 864#endif
865} 865}
866 866
867 867
868bool iPAQ::setSoftSuspend ( bool soft ) 868bool iPAQ::setSoftSuspend ( bool soft )
869{ 869{
870 bool res = false; 870 bool res = false;
871 int fd; 871 int fd;
872 872
873 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 873 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
874 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 874 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
875 res = true; 875 res = true;
876 else 876 else
877 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 877 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
878 878
879 ::close ( fd ); 879 ::close ( fd );
880 } 880 }
881 else 881 else
882 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 882 ::perror ( "/proc/sys/ts/suspend_button_mode" );
883 883
884 return res; 884 return res;
885} 885}
886 886
887 887
888bool iPAQ::setDisplayBrightness ( int bright ) 888bool iPAQ::setDisplayBrightness ( int bright )
889{ 889{
890 bool res = false; 890 bool res = false;
891 int fd; 891 int fd;
892 892
893 if ( bright > 255 ) 893 if ( bright > 255 )
894 bright = 255; 894 bright = 255;
895 if ( bright < 0 ) 895 if ( bright < 0 )
896 bright = 0; 896 bright = 0;
897 897
898 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 898 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
899 FLITE_IN bl; 899 FLITE_IN bl;
900 bl. mode = 1; 900 bl. mode = 1;
901 bl. pwr = bright ? 1 : 0; 901 bl. pwr = bright ? 1 : 0;
902 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; 902 bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255;
903 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 903 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
904 ::close ( fd ); 904 ::close ( fd );
905 } 905 }
906 return res; 906 return res;
907} 907}
908 908
909int iPAQ::displayBrightnessResolution ( ) const 909int iPAQ::displayBrightnessResolution ( ) const
910{ 910{
911 switch ( model ( )) { 911 switch ( model ( )) {
912 case Model_iPAQ_H31xx: 912 case Model_iPAQ_H31xx:
913 case Model_iPAQ_H36xx: 913 case Model_iPAQ_H36xx:
914 case Model_iPAQ_H37xx: 914 case Model_iPAQ_H37xx:
915 return 128; // really 256, but >128 could damage the LCD 915 return 128; // really 256, but >128 could damage the LCD
916 916
917 case Model_iPAQ_H38xx: 917 case Model_iPAQ_H38xx:
918 case Model_iPAQ_H39xx: 918 case Model_iPAQ_H39xx:
919 return 64; 919 return 64;
920 920
921 default: 921 default:
922 return 2; 922 return 2;
923 } 923 }
924} 924}
925 925
926 926
927bool iPAQ::hasLightSensor ( ) const 927bool iPAQ::hasLightSensor ( ) const
928{ 928{
929 return true; 929 return true;
930} 930}
931 931
932int iPAQ::readLightSensor ( ) 932int iPAQ::readLightSensor ( )
933{ 933{
934 int fd; 934 int fd;
935 int val = -1; 935 int val = -1;
936 936
937 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { 937 if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) {
938 char buffer [8]; 938 char buffer [8];
939 939
940 if ( ::read ( fd, buffer, 5 ) == 5 ) { 940 if ( ::read ( fd, buffer, 5 ) == 5 ) {
941 char *endptr; 941 char *endptr;
942 942
943 buffer [4] = 0; 943 buffer [4] = 0;
944 val = ::strtol ( buffer + 2, &endptr, 16 ); 944 val = ::strtol ( buffer + 2, &endptr, 16 );
945 945
946 if ( *endptr != 0 ) 946 if ( *endptr != 0 )
947 val = -1; 947 val = -1;
948 } 948 }
949 ::close ( fd ); 949 ::close ( fd );
950 } 950 }
951 951
952 return val; 952 return val;
953} 953}
954 954
955int iPAQ::lightSensorResolution ( ) const 955int iPAQ::lightSensorResolution ( ) const
956{ 956{
957 return 256; 957 return 256;
958} 958}
959 959
960/************************************************** 960/**************************************************
961 * 961 *
962 * Zaurus 962 * Zaurus
963 * 963 *
964 **************************************************/ 964 **************************************************/
965 965
966 966
967 967
968void Zaurus::init ( ) 968void Zaurus::init ( )
969{ 969{
970 d-> m_vendorstr = "Sharp"; 970 d-> m_vendorstr = "Sharp";
971 d-> m_vendor = Vendor_Sharp; 971 d-> m_vendor = Vendor_Sharp;
972 972
973 QFile f ( "/proc/filesystems" ); 973 QFile f ( "/proc/filesystems" );
974 974
975 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { 975 if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) {
976 d-> m_vendorstr = "OpenZaurus Team"; 976 d-> m_vendorstr = "OpenZaurus Team";
977 d-> m_systemstr = "OpenZaurus"; 977 d-> m_systemstr = "OpenZaurus";
978 d-> m_system = System_OpenZaurus; 978 d-> m_system = System_OpenZaurus;
979 979
980 f. close ( ); 980 f. close ( );
981 981
982 f. setName ( "/etc/oz_version" ); 982 f. setName ( "/etc/oz_version" );
983 if ( f. open ( IO_ReadOnly )) { 983 if ( f. open ( IO_ReadOnly )) {
984 QTextStream ts ( &f ); 984 QTextStream ts ( &f );
985 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); 985 d-> m_sysverstr = ts. readLine ( );//. mid ( 10 );
986 f. close ( ); 986 f. close ( );
987 } 987 }
988 } 988 }
989 else { 989 else {
990 d-> m_systemstr = "Zaurus"; 990 d-> m_systemstr = "Zaurus";
991 d-> m_system = System_Zaurus; 991 d-> m_system = System_Zaurus;
992 } 992 }
993 993
994 f. setName ( "/proc/deviceinfo/product" ); 994 f. setName ( "/proc/deviceinfo/product" );
995 if ( f. open ( IO_ReadOnly ) ) { 995 if ( f. open ( IO_ReadOnly ) ) {
996 QTextStream ts ( &f ); 996 QTextStream ts ( &f );
997 QString model = ts. readLine ( ); 997 QString model = ts. readLine ( );
998 f. close ( ); 998 f. close ( );
999 999
1000 d-> m_modelstr = QString("Zaurus ") + model; 1000 d-> m_modelstr = QString("Zaurus ") + model;
1001 if ( model == "SL-5500" ) 1001 if ( model == "SL-5500" )
1002 d-> m_model = Model_Zaurus_SL5500; 1002 d-> m_model = Model_Zaurus_SL5500;
1003 else if ( model == "SL-C700" ) 1003 else if ( model == "SL-C700" )
1004 d-> m_model = Model_Zaurus_SLC700; 1004 d-> m_model = Model_Zaurus_SLC700;
1005 else if ( model == "SL-A300" ) 1005 else if ( model == "SL-A300" )
1006 d-> m_model = Model_Zaurus_SLA300; 1006 d-> m_model = Model_Zaurus_SLA300;
1007 else if ( model == "SL-B600" || model == "SL-5600" ) 1007 else if ( model == "SL-B600" || model == "SL-5600" )
1008 d-> m_model = Model_Zaurus_SLB600; 1008 d-> m_model = Model_Zaurus_SLB600;
1009 else 1009 else
1010 d-> m_model = Model_Zaurus_SL5000; 1010 d-> m_model = Model_Zaurus_SL5000;
1011 } 1011 }
1012 else { 1012 else {
1013 d-> m_model = Model_Zaurus_SL5000; 1013 d-> m_model = Model_Zaurus_SL5000;
1014 d-> m_modelstr = "Zaurus (model unknown)"; 1014 d-> m_modelstr = "Zaurus (model unknown)";
1015 } 1015 }
1016 1016
1017 switch ( d-> m_model ) { 1017 switch ( d-> m_model ) {
1018 case Model_Zaurus_SLA300: 1018 case Model_Zaurus_SLA300:
1019 d-> m_rotation = Rot0; 1019 d-> m_rotation = Rot0;
1020 break; 1020 break;
1021 case Model_Zaurus_SLC700: 1021 case Model_Zaurus_SLC700:
1022 /* note for C700, we must check the display rotation 1022 /* note for C700, we must check the display rotation
1023 * sensor to set an appropriate value 1023 * sensor to set an appropriate value
1024 */ 1024 */
1025 case Model_Zaurus_SLB600: 1025 case Model_Zaurus_SLB600:
1026 case Model_Zaurus_SL5500: 1026 case Model_Zaurus_SL5500:
1027 case Model_Zaurus_SL5000: 1027 case Model_Zaurus_SL5000:
1028 default: 1028 default:
1029 d-> m_rotation = Rot270; 1029 d-> m_rotation = Rot270;
1030 break; 1030 break;
1031 } 1031 }
1032 m_leds [0] = Led_Off; 1032 m_leds [0] = Led_Off;
1033} 1033}
1034 1034
1035void Zaurus::initButtons ( ) 1035void Zaurus::initButtons ( )
1036{ 1036{
1037 if ( d-> m_buttons ) 1037 if ( d-> m_buttons )
1038 return; 1038 return;
1039 1039
1040 d-> m_buttons = new QValueList <ODeviceButton>; 1040 d-> m_buttons = new QValueList <ODeviceButton>;
1041 1041
1042 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) { 1042 for ( uint i = 0; i < ( sizeof( z_buttons ) / sizeof( z_button )); i++ ) {
1043 z_button *zb = z_buttons + i; 1043 z_button *zb = z_buttons + i;
1044 ODeviceButton b; 1044 ODeviceButton b;
1045 1045
1046 b. setKeycode ( zb-> code ); 1046 b. setKeycode ( zb-> code );
1047 b. setUserText ( QObject::tr ( "Button", zb-> utext )); 1047 b. setUserText ( QObject::tr ( "Button", zb-> utext ));
1048 b. setPixmap ( Resource::loadPixmap ( zb-> pix )); 1048 b. setPixmap ( Resource::loadPixmap ( zb-> pix ));
1049 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction )); 1049 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), zb-> fpressedaction ));
1050 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction )); 1050 b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), zb-> fheldaction ));
1051 1051
1052 d-> m_buttons-> append ( b ); 1052 d-> m_buttons-> append ( b );
1053 } 1053 }
1054 1054
1055 reloadButtonMapping ( ); 1055 reloadButtonMapping ( );
1056 1056
1057 QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); 1057 QCopChannel *sysch = new QCopChannel ( "QPE/System", this );
1058 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & ))); 1058 connect ( sysch, SIGNAL( received( const QCString &, const QByteArray & )), this, SLOT( systemMessage ( const QCString &, const QByteArray & )));
1059} 1059}
1060 1060
1061#include <unistd.h> 1061#include <unistd.h>
1062#include <fcntl.h> 1062#include <fcntl.h>
1063#include <sys/ioctl.h> 1063#include <sys/ioctl.h>
1064 1064
1065//#include <asm/sharp_char.h> // including kernel headers is evil ... 1065//#include <asm/sharp_char.h> // including kernel headers is evil ...
1066 1066
1067#define SHARP_DEV_IOCTL_COMMAND_START 0x5680 1067#define SHARP_DEV_IOCTL_COMMAND_START 0x5680
1068 1068
1069 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1069 #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1070#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1070#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1071 1071
1072#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1072#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1073#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1073#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1074#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1074#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1075 1075
1076/* --- for SHARP_BUZZER device --- */ 1076/* --- for SHARP_BUZZER device --- */
1077 1077
1078 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1078 //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1079//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) 1079//#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START)
1080 1080
1081#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) 1081#define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1)
1082#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) 1082#define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2)
1083#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) 1083#define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3)
1084#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) 1084#define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4)
1085#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 1085#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
1086 1086
1087//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 1087//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
1088//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 1088//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
1089 1089
1090//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 1090//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
1091//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 1091//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
1092//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 1092//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
1093//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 1093//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
1094//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 1094//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
1095//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 1095//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
1096//#define SHARP_PDA_APPSTART 9 /* application start */ 1096//#define SHARP_PDA_APPSTART 9 /* application start */
1097//#define SHARP_PDA_APPQUIT 10 /* application ends */ 1097//#define SHARP_PDA_APPQUIT 10 /* application ends */
1098 1098
1099//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 1099//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
1100//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 1100//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
1101//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 1101//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
1102//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 1102//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
1103// 1103//
1104 1104
1105 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 1105 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
1106#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 1106#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
1107 1107
1108typedef struct sharp_led_status { 1108typedef struct sharp_led_status {
1109 int which; /* select which LED status is wanted. */ 1109 int which; /* select which LED status is wanted. */
1110 int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 1110 int status; /* set new led status if you call SHARP_LED_SETSTATUS */
1111} sharp_led_status; 1111} sharp_led_status;
1112 1112
1113#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 1113#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
1114 1114
1115#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 1115#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
1116#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 1116#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
1117#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 1117#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
1118 1118
1119// #include <asm/sharp_apm.h> // including kernel headers is evil ... 1119// #include <asm/sharp_apm.h> // including kernel headers is evil ...
1120 1120
1121#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 1121#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
1122#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 1122#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
1123#define APM_EVT_POWER_BUTTON (1 << 0) 1123#define APM_EVT_POWER_BUTTON (1 << 0)
1124 1124
1125#define FL_IOCTL_STEP_CONTRAST 100 1125#define FL_IOCTL_STEP_CONTRAST 100
1126 1126
1127 1127
1128void Zaurus::buzzer ( int sound ) 1128void Zaurus::buzzer ( int sound )
1129{ 1129{
1130 static int fd = ::open ( "/dev/sharp_buz", O_RDWR|O_NONBLOCK ); 1130 static int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
1131 1131
1132 if ( fd >= 0 ) 1132 if ( fd >= 0 ) {
1133 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 1133 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
1134 ::close ( fd );
1135 }
1134} 1136}
1135 1137
1136 1138
1137void Zaurus::alarmSound ( ) 1139void Zaurus::alarmSound ( )
1138{ 1140{
1139 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 1141 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
1140} 1142}
1141 1143
1142void Zaurus::touchSound ( ) 1144void Zaurus::touchSound ( )
1143{ 1145{
1144 buzzer ( SHARP_BUZ_TOUCHSOUND ); 1146 buzzer ( SHARP_BUZ_TOUCHSOUND );
1145} 1147}
1146 1148
1147void Zaurus::keySound ( ) 1149void Zaurus::keySound ( )
1148{ 1150{
1149 buzzer ( SHARP_BUZ_KEYSOUND ); 1151 buzzer ( SHARP_BUZ_KEYSOUND );
1150} 1152}
1151 1153
1152 1154
1153QValueList <OLed> Zaurus::ledList ( ) const 1155QValueList <OLed> Zaurus::ledList ( ) const
1154{ 1156{
1155 QValueList <OLed> vl; 1157 QValueList <OLed> vl;
1156 vl << Led_Mail; 1158 vl << Led_Mail;
1157 return vl; 1159 return vl;
1158} 1160}
1159 1161
1160QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 1162QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
1161{ 1163{
1162 QValueList <OLedState> vl; 1164 QValueList <OLedState> vl;
1163 1165
1164 if ( l == Led_Mail ) 1166 if ( l == Led_Mail )
1165 vl << Led_Off << Led_On << Led_BlinkSlow; 1167 vl << Led_Off << Led_On << Led_BlinkSlow;
1166 return vl; 1168 return vl;
1167} 1169}
1168 1170
1169OLedState Zaurus::ledState ( OLed which ) const 1171OLedState Zaurus::ledState ( OLed which ) const
1170{ 1172{
1171 if ( which == Led_Mail ) 1173 if ( which == Led_Mail )
1172 return m_leds [0]; 1174 return m_leds [0];
1173 else 1175 else
1174 return Led_Off; 1176 return Led_Off;
1175} 1177}
1176 1178
1177bool Zaurus::setLedState ( OLed which, OLedState st ) 1179bool Zaurus::setLedState ( OLed which, OLedState st )
1178{ 1180{
1179 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); 1181 static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK );
1180 1182
1181 if ( which == Led_Mail ) { 1183 if ( which == Led_Mail ) {
1182 if ( fd >= 0 ) { 1184 if ( fd >= 0 ) {
1183 struct sharp_led_status leds; 1185 struct sharp_led_status leds;
1184 ::memset ( &leds, 0, sizeof( leds )); 1186 ::memset ( &leds, 0, sizeof( leds ));
1185 leds. which = SHARP_LED_MAIL_EXISTS; 1187 leds. which = SHARP_LED_MAIL_EXISTS;
1186 bool ok = true; 1188 bool ok = true;
1187 1189
1188 switch ( st ) { 1190 switch ( st ) {
1189 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; 1191 case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break;
1190 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; 1192 case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break;
1191 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; 1193 case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break;
1192 default : ok = false; 1194 default : ok = false;
1193 } 1195 }
1194 1196
1195 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { 1197 if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) {
1196 m_leds [0] = st; 1198 m_leds [0] = st;
1197 return true; 1199 return true;
1198 } 1200 }
1199 } 1201 }
1200 } 1202 }
1201 return false; 1203 return false;
1202} 1204}
1203 1205
1204bool Zaurus::setSoftSuspend ( bool soft ) 1206bool Zaurus::setSoftSuspend ( bool soft )
1205{ 1207{
1206 bool res = false; 1208 bool res = false;
1207 int fd; 1209 int fd;
1208 1210
1209 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 1211 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
1210 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 1212 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
1211 1213
1212 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 1214 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
1213 1215
1214 if ( sources >= 0 ) { 1216 if ( sources >= 0 ) {
1215 if ( soft ) 1217 if ( soft )
1216 sources &= ~APM_EVT_POWER_BUTTON; 1218 sources &= ~APM_EVT_POWER_BUTTON;
1217 else 1219 else
1218 sources |= APM_EVT_POWER_BUTTON; 1220 sources |= APM_EVT_POWER_BUTTON;
1219 1221
1220 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 1222 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
1221 res = true; 1223 res = true;
1222 else 1224 else
1223 perror ( "APM_IOCGEVTSRC" ); 1225 perror ( "APM_IOCGEVTSRC" );
1224 } 1226 }
1225 else 1227 else
1226 perror ( "APM_IOCGEVTSRC" ); 1228 perror ( "APM_IOCGEVTSRC" );
1227 1229
1228 ::close ( fd ); 1230 ::close ( fd );
1229 } 1231 }
1230 else 1232 else
1231 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 1233 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
1232 1234
1233 return res; 1235 return res;
1234} 1236}
1235 1237
1236 1238
1237bool Zaurus::setDisplayBrightness ( int bright ) 1239bool Zaurus::setDisplayBrightness ( int bright )
1238{ 1240{
1239 bool res = false; 1241 bool res = false;
1240 int fd; 1242 int fd;
1241 1243
1242 if ( bright > 255 ) 1244 if ( bright > 255 )
1243 bright = 255; 1245 bright = 255;
1244 if ( bright < 0 ) 1246 if ( bright < 0 )
1245 bright = 0; 1247 bright = 0;
1246 1248
1247 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 1249 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
1248 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 1250 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
1249 if ( bright && !bl ) 1251 if ( bright && !bl )
1250 bl = 1; 1252 bl = 1;
1251 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 1253 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
1252 ::close ( fd ); 1254 ::close ( fd );
1253 } 1255 }
1254 return res; 1256 return res;
1255} 1257}
1256 1258
1257 1259
1258int Zaurus::displayBrightnessResolution ( ) const 1260int Zaurus::displayBrightnessResolution ( ) const
1259{ 1261{
1260 return 5; 1262 return 5;
1261} 1263}
1262 1264
1263 1265