summaryrefslogtreecommitdiff
path: root/libopie/odevice.cpp
Unidiff
Diffstat (limited to 'libopie/odevice.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie/odevice.cpp108
1 files changed, 102 insertions, 6 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp
index 9b2a954..8f954b1 100644
--- a/libopie/odevice.cpp
+++ b/libopie/odevice.cpp
@@ -50,13 +50,13 @@
50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 50#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
51 51
52using namespace Opie; 52using namespace Opie;
53 53
54class ODeviceData { 54class ODeviceData {
55public: 55public:
56 bool m_qwsserver; 56 bool m_qwsserver : 1;
57 57
58 QString m_vendorstr; 58 QString m_vendorstr;
59 OVendor m_vendor; 59 OVendor m_vendor;
60 60
61 QString m_modelstr; 61 QString m_modelstr;
62 OModel m_model; 62 OModel m_model;
@@ -267,12 +267,15 @@ void ODevice::systemMessage ( const QCString &msg, const QByteArray & )
267} 267}
268 268
269void ODevice::init ( ) 269void ODevice::init ( )
270{ 270{
271} 271}
272 272
273/**
274 * This method initialises the button mapping
275 */
273void ODevice::initButtons ( ) 276void ODevice::initButtons ( )
274{ 277{
275 if ( d-> m_buttons ) 278 if ( d-> m_buttons )
276 return; 279 return;
277 280
278 // Simulation uses iPAQ 3660 device buttons 281 // Simulation uses iPAQ 3660 device buttons
@@ -310,13 +313,23 @@ bool ODevice::setSoftSuspend ( bool /*soft*/ )
310} 313}
311 314
312//#include <linux/apm_bios.h> 315//#include <linux/apm_bios.h>
313 316
314#define APM_IOC_SUSPEND OD_IO( 'A', 2 ) 317#define APM_IOC_SUSPEND OD_IO( 'A', 2 )
315 318
316 319/**
320 * This method will try to suspend the device
321 * It only works if the user is the QWS Server and the apm application
322 * is installed.
323 * It tries to suspend and then waits some time cause some distributions
324 * do have asynchronus apm implementations.
325 * This method will either fail and return false or it'll suspend the
326 * device and return once the device got woken up
327 *
328 * @return if the device got suspended
329 */
317bool ODevice::suspend ( ) 330bool ODevice::suspend ( )
318{ 331{
319 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend 332 if ( !d-> m_qwsserver ) // only qwsserver is allowed to suspend
320 return false; 333 return false;
321 334
322 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 335 if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
@@ -351,13 +364,15 @@ bool ODevice::suspend ( )
351/* VESA Blanking Levels */ 364/* VESA Blanking Levels */
352#define VESA_NO_BLANKING 0 365#define VESA_NO_BLANKING 0
353#define VESA_VSYNC_SUSPEND 1 366#define VESA_VSYNC_SUSPEND 1
354#define VESA_HSYNC_SUSPEND 2 367#define VESA_HSYNC_SUSPEND 2
355#define VESA_POWERDOWN 3 368#define VESA_POWERDOWN 3
356 369
357 370/**
371 * This sets the display on or off
372 */
358bool ODevice::setDisplayStatus ( bool on ) 373bool ODevice::setDisplayStatus ( bool on )
359{ 374{
360 if ( d-> m_model == Model_Unknown ) 375 if ( d-> m_model == Model_Unknown )
361 return false; 376 return false;
362 377
363 bool res = false; 378 bool res = false;
@@ -367,141 +382,222 @@ bool ODevice::setDisplayStatus ( bool on )
367 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); 382 res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 );
368 ::close ( fd ); 383 ::close ( fd );
369 } 384 }
370 return res; 385 return res;
371} 386}
372 387
373bool ODevice::setDisplayBrightness ( int ) 388/**
389 * This sets the display brightness
390 * @return success or failure
391 */
392bool ODevice::setDisplayBrightness ( int p)
374{ 393{
394 Q_UNUSED( p )
375 return false; 395 return false;
376} 396}
377 397
378int ODevice::displayBrightnessResolution ( ) const 398int ODevice::displayBrightnessResolution ( ) const
379{ 399{
380 return 16; 400 return 16;
381} 401}
382 402
403/**
404 * This returns the vendor as string
405 * @return Vendor as QString
406 */
383QString ODevice::vendorString ( ) const 407QString ODevice::vendorString ( ) const
384{ 408{
385 return d-> m_vendorstr; 409 return d-> m_vendorstr;
386} 410}
387 411
412/**
413 * This returns the vendor as one of the values of OVendor
414 * @return OVendor
415 */
388OVendor ODevice::vendor ( ) const 416OVendor ODevice::vendor ( ) const
389{ 417{
390 return d-> m_vendor; 418 return d-> m_vendor;
391} 419}
392 420
421/**
422 * This returns the model as a string
423 * @return A string representing the model
424 */
393QString ODevice::modelString ( ) const 425QString ODevice::modelString ( ) const
394{ 426{
395 return d-> m_modelstr; 427 return d-> m_modelstr;
396} 428}
397 429
430/**
431 * This does return the OModel used
432 */
398OModel ODevice::model ( ) const 433OModel ODevice::model ( ) const
399{ 434{
400 return d-> m_model; 435 return d-> m_model;
401} 436}
402 437
438/**
439 * This does return the systen name
440 */
403QString ODevice::systemString ( ) const 441QString ODevice::systemString ( ) const
404{ 442{
405 return d-> m_systemstr; 443 return d-> m_systemstr;
406} 444}
407 445
446/**
447 * Return System as OSystem value
448 */
408OSystem ODevice::system ( ) const 449OSystem ODevice::system ( ) const
409{ 450{
410 return d-> m_system; 451 return d-> m_system;
411} 452}
412 453
454/**
455 * @return the version string of the base system
456 */
413QString ODevice::systemVersionString ( ) const 457QString ODevice::systemVersionString ( ) const
414{ 458{
415 return d-> m_sysverstr; 459 return d-> m_sysverstr;
416} 460}
417 461
462/**
463 * @return the current Transformation
464 */
418Transformation ODevice::rotation ( ) const 465Transformation ODevice::rotation ( ) const
419{ 466{
420 return d-> m_rotation; 467 return d-> m_rotation;
421} 468}
422 469
470/**
471 * This plays an alarmSound
472 */
423void ODevice::alarmSound ( ) 473void ODevice::alarmSound ( )
424{ 474{
425#ifndef QT_NO_SOUND 475#ifndef QT_NO_SOUND
426 static Sound snd ( "alarm" ); 476 static Sound snd ( "alarm" );
427 477
428 if ( snd. isFinished ( )) 478 if ( snd. isFinished ( ))
429 snd. play ( ); 479 snd. play ( );
430#endif 480#endif
431} 481}
432 482
483/**
484 * This plays a key sound
485 */
433void ODevice::keySound ( ) 486void ODevice::keySound ( )
434{ 487{
435#ifndef QT_NO_SOUND 488#ifndef QT_NO_SOUND
436 static Sound snd ( "keysound" ); 489 static Sound snd ( "keysound" );
437 490
438 if ( snd. isFinished ( )) 491 if ( snd. isFinished ( ))
439 snd. play ( ); 492 snd. play ( );
440#endif 493#endif
441} 494}
442 495
496/**
497 * This plays a touch sound
498 */
443void ODevice::touchSound ( ) 499void ODevice::touchSound ( )
444{ 500{
445 501
446#ifndef QT_NO_SOUND 502#ifndef QT_NO_SOUND
447 static Sound snd ( "touchsound" ); 503 static Sound snd ( "touchsound" );
448 504
449 if ( snd. isFinished ( )) 505 if ( snd. isFinished ( ))
450 snd. play ( ); 506 snd. play ( );
451#endif 507#endif
452} 508}
453 509
454 510/**
511 * This method will return a list of leds
512 * available on this device
513 * @return a list of LEDs.
514 */
455QValueList <OLed> ODevice::ledList ( ) const 515QValueList <OLed> ODevice::ledList ( ) const
456{ 516{
457 return QValueList <OLed> ( ); 517 return QValueList <OLed> ( );
458} 518}
459 519
520/**
521 * This does return the state of the LEDs
522 */
460QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const 523QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const
461{ 524{
462 return QValueList <OLedState> ( ); 525 return QValueList <OLedState> ( );
463} 526}
464 527
528/**
529 * @return the state for a given OLed
530 */
465OLedState ODevice::ledState ( OLed /*which*/ ) const 531OLedState ODevice::ledState ( OLed /*which*/ ) const
466{ 532{
467 return Led_Off; 533 return Led_Off;
468} 534}
469 535
470bool ODevice::setLedState ( OLed /*which*/, OLedState /*st*/ ) 536/**
537 * Set the state for a LED
538 * @param which Which OLed to use
539 * @param st The state to set
540 * @return success or failure
541 */
542bool ODevice::setLedState ( OLed which, OLedState st )
471{ 543{
544 Q_UNUSED( which )
545 Q_UNUSED( st )
472 return false; 546 return false;
473} 547}
474 548
549/**
550 * @return if the device has a light sensor
551 */
475bool ODevice::hasLightSensor ( ) const 552bool ODevice::hasLightSensor ( ) const
476{ 553{
477 return false; 554 return false;
478} 555}
479 556
557/**
558 * @return a value from the light senso
559 */
480int ODevice::readLightSensor ( ) 560int ODevice::readLightSensor ( )
481{ 561{
482 return -1; 562 return -1;
483} 563}
484 564
565/**
566 * @return the light sensor resolution whatever that is ;)
567 */
485int ODevice::lightSensorResolution ( ) const 568int ODevice::lightSensorResolution ( ) const
486{ 569{
487 return 0; 570 return 0;
488} 571}
489 572
573/**
574 * @return a list of hardware buttons
575 */
490const QValueList <ODeviceButton> &ODevice::buttons ( ) 576const QValueList <ODeviceButton> &ODevice::buttons ( )
491{ 577{
492 initButtons ( ); 578 initButtons ( );
493 579
494 return *d-> m_buttons; 580 return *d-> m_buttons;
495} 581}
496 582
583/**
584 * @return The amount of time that would count as a hold
585 */
497uint ODevice::buttonHoldTime ( ) const 586uint ODevice::buttonHoldTime ( ) const
498{ 587{
499 return d-> m_holdtime; 588 return d-> m_holdtime;
500} 589}
501 590
591/**
592 * This method return a ODeviceButton for a key code
593 * or 0 if no special hardware button is available for the device
594 *
595 * @return The devicebutton or 0l
596 * @see ODeviceButton
597 */
502const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) 598const ODeviceButton *ODevice::buttonForKeycode ( ushort code )
503{ 599{
504 initButtons ( ); 600 initButtons ( );
505 601
506 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { 602 for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) {
507 if ( (*it). keycode ( ) == code ) 603 if ( (*it). keycode ( ) == code )