author | schurig <schurig> | 2004-09-10 11:59:05 (UTC) |
---|---|---|
committer | schurig <schurig> | 2004-09-10 11:59:05 (UTC) |
commit | ed70ec4945c7816ec6e899207ec8b99e20e10da5 (patch) (unidiff) | |
tree | 1b0a8adab9c7398a799f628297ed9d45a591008f | |
parent | 501c17ed2bb97f2062cb11daddeb698a6a9f2828 (diff) | |
download | opie-ed70ec4945c7816ec6e899207ec8b99e20e10da5.zip opie-ed70ec4945c7816ec6e899207ec8b99e20e10da5.tar.gz opie-ed70ec4945c7816ec6e899207ec8b99e20e10da5.tar.bz2 |
removed some warnings
-rw-r--r-- | libopie/odevice.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/libopie/odevice.cpp b/libopie/odevice.cpp index 013f804..21070bf 100644 --- a/libopie/odevice.cpp +++ b/libopie/odevice.cpp | |||
@@ -337,2488 +337,2487 @@ struct s_button { | |||
337 | 337 | ||
338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 338 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
339 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), | 339 | Qt::Key_F5, QT_TRANSLATE_NOOP("Button", "Upper+Up"), |
340 | "devicebuttons/simpad_upper_up", | 340 | "devicebuttons/simpad_upper_up", |
341 | "QPE/Launcher", "home()", | 341 | "QPE/Launcher", "home()", |
342 | "buttonsettings", "raise()" }, | 342 | "buttonsettings", "raise()" }, |
343 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 343 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), | 344 | Qt::Key_F6, QT_TRANSLATE_NOOP("Button", "Upper+Down"), |
345 | "devicebuttons/simpad_upper_down", | 345 | "devicebuttons/simpad_upper_down", |
346 | "addressbook", "raise()", | 346 | "addressbook", "raise()", |
347 | "addressbook", "beamBusinessCard()" }, | 347 | "addressbook", "beamBusinessCard()" }, |
348 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 348 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), | 349 | Qt::Key_F7, QT_TRANSLATE_NOOP("Button", "Upper+Right"), |
350 | "devicebuttons/simpad_upper_right", | 350 | "devicebuttons/simpad_upper_right", |
351 | "QPE/TaskBar", "toggleMenu()", | 351 | "QPE/TaskBar", "toggleMenu()", |
352 | "QPE/TaskBar", "toggleStartMenu()" }, | 352 | "QPE/TaskBar", "toggleStartMenu()" }, |
353 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 353 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), | 354 | Qt::Key_F13, QT_TRANSLATE_NOOP("Button", "Upper+Left"), |
355 | "devicebuttons/simpad_upper_left", | 355 | "devicebuttons/simpad_upper_left", |
356 | "QPE/Rotation", "flip()", | 356 | "QPE/Rotation", "flip()", |
357 | "QPE/Rotation", "flip()" }, | 357 | "QPE/Rotation", "flip()" }, |
358 | /* | 358 | /* |
359 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 359 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 360 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
361 | "devicebuttons/simpad_lower_upper", | 361 | "devicebuttons/simpad_lower_upper", |
362 | "QPE/Launcher", "home()", | 362 | "QPE/Launcher", "home()", |
363 | "buttonsettings", "raise()" }, | 363 | "buttonsettings", "raise()" }, |
364 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, | 364 | { Model_SIMpad_CL4 | Model_SIMpad_SL4 | Model_SIMpad_SLC | Model_SIMpad_TSinus, |
365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), | 365 | Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Lower+Upper"), |
366 | "devicebuttons/simpad_upper_lower", | 366 | "devicebuttons/simpad_upper_lower", |
367 | "QPE/Launcher", "home()", | 367 | "QPE/Launcher", "home()", |
368 | "buttonsettings", "raise()" }, | 368 | "buttonsettings", "raise()" }, |
369 | */ | 369 | */ |
370 | }; | 370 | }; |
371 | 371 | ||
372 | class Yopy : public ODevice { | 372 | class Yopy : public ODevice { |
373 | protected: | 373 | protected: |
374 | virtual void init ( ); | 374 | virtual void init ( ); |
375 | virtual void initButtons ( ); | 375 | virtual void initButtons ( ); |
376 | 376 | ||
377 | public: | 377 | public: |
378 | virtual bool suspend ( ); | 378 | virtual bool suspend ( ); |
379 | 379 | ||
380 | virtual bool setDisplayBrightness ( int b ); | 380 | virtual bool setDisplayBrightness ( int b ); |
381 | virtual int displayBrightnessResolution ( ) const; | 381 | virtual int displayBrightnessResolution ( ) const; |
382 | 382 | ||
383 | static bool isYopy ( ); | 383 | static bool isYopy ( ); |
384 | }; | 384 | }; |
385 | 385 | ||
386 | struct yopy_button { | 386 | struct yopy_button { |
387 | Qt::Key code; | 387 | Qt::Key code; |
388 | char *utext; | 388 | char *utext; |
389 | char *pix; | 389 | char *pix; |
390 | char *fpressedservice; | 390 | char *fpressedservice; |
391 | char *fpressedaction; | 391 | char *fpressedaction; |
392 | char *fheldservice; | 392 | char *fheldservice; |
393 | char *fheldaction; | 393 | char *fheldaction; |
394 | } yopy_buttons [] = { | 394 | } yopy_buttons [] = { |
395 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), | 395 | { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Action Button"), |
396 | "devicebuttons/yopy_action", | 396 | "devicebuttons/yopy_action", |
397 | "datebook", "nextView()", | 397 | "datebook", "nextView()", |
398 | "today", "raise()" }, | 398 | "today", "raise()" }, |
399 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), | 399 | { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "OK Button"), |
400 | "devicebuttons/yopy_ok", | 400 | "devicebuttons/yopy_ok", |
401 | "addressbook", "raise()", | 401 | "addressbook", "raise()", |
402 | "addressbook", "beamBusinessCard()" }, | 402 | "addressbook", "beamBusinessCard()" }, |
403 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), | 403 | { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "End Button"), |
404 | "devicebuttons/yopy_end", | 404 | "devicebuttons/yopy_end", |
405 | "QPE/Launcher", "home()", | 405 | "QPE/Launcher", "home()", |
406 | "buttonsettings", "raise()" }, | 406 | "buttonsettings", "raise()" }, |
407 | }; | 407 | }; |
408 | 408 | ||
409 | static QCString makeChannel ( const char *str ) | 409 | static QCString makeChannel ( const char *str ) |
410 | { | 410 | { |
411 | if ( str && !::strchr ( str, '/' )) | 411 | if ( str && !::strchr ( str, '/' )) |
412 | return QCString ( "QPE/Application/" ) + str; | 412 | return QCString ( "QPE/Application/" ) + str; |
413 | else | 413 | else |
414 | return str; | 414 | return str; |
415 | } | 415 | } |
416 | 416 | ||
417 | static inline bool isQWS() | 417 | static inline bool isQWS() |
418 | { | 418 | { |
419 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; | 419 | return qApp ? ( qApp-> type ( ) == QApplication::GuiServer ) : false; |
420 | } | 420 | } |
421 | 421 | ||
422 | ODevice *ODevice::inst ( ) | 422 | ODevice *ODevice::inst ( ) |
423 | { | 423 | { |
424 | static ODevice *dev = 0; | 424 | static ODevice *dev = 0; |
425 | 425 | ||
426 | if ( !dev ) { | 426 | if ( !dev ) { |
427 | if ( QFile::exists ( "/proc/hal/model" )) | 427 | if ( QFile::exists ( "/proc/hal/model" )) |
428 | dev = new iPAQ ( ); | 428 | dev = new iPAQ ( ); |
429 | else if ( Zaurus::isZaurus() ) | 429 | else if ( Zaurus::isZaurus() ) |
430 | dev = new Zaurus ( ); | 430 | dev = new Zaurus ( ); |
431 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) | 431 | else if ( QFile::exists ( "/proc/ucb1x00" ) && QFile::exists ( "/proc/cs3" )) |
432 | dev = new SIMpad ( ); | 432 | dev = new SIMpad ( ); |
433 | else if ( Yopy::isYopy() ) | 433 | else if ( Yopy::isYopy() ) |
434 | dev = new Yopy ( ); | 434 | dev = new Yopy ( ); |
435 | else if ( Jornada::isJornada() ) | 435 | else if ( Jornada::isJornada() ) |
436 | dev = new Jornada ( ); | 436 | dev = new Jornada ( ); |
437 | else if ( QFile::exists ( "/proc/sys/board/sys_name" )) | 437 | else if ( QFile::exists ( "/proc/sys/board/sys_name" )) |
438 | dev = new Ramses ( ); | 438 | dev = new Ramses ( ); |
439 | else | 439 | else |
440 | dev = new ODevice ( ); | 440 | dev = new ODevice ( ); |
441 | dev-> init ( ); | 441 | dev-> init ( ); |
442 | } | 442 | } |
443 | return dev; | 443 | return dev; |
444 | } | 444 | } |
445 | 445 | ||
446 | 446 | ||
447 | /************************************************** | 447 | /************************************************** |
448 | * | 448 | * |
449 | * common | 449 | * common |
450 | * | 450 | * |
451 | **************************************************/ | 451 | **************************************************/ |
452 | 452 | ||
453 | 453 | ||
454 | ODevice::ODevice ( ) | 454 | ODevice::ODevice ( ) |
455 | { | 455 | { |
456 | d = new ODeviceData; | 456 | d = new ODeviceData; |
457 | 457 | ||
458 | d-> m_modelstr = "Unknown"; | 458 | d-> m_modelstr = "Unknown"; |
459 | d-> m_model = Model_Unknown; | 459 | d-> m_model = Model_Unknown; |
460 | d-> m_vendorstr = "Unknown"; | 460 | d-> m_vendorstr = "Unknown"; |
461 | d-> m_vendor = Vendor_Unknown; | 461 | d-> m_vendor = Vendor_Unknown; |
462 | d-> m_systemstr = "Unknown"; | 462 | d-> m_systemstr = "Unknown"; |
463 | d-> m_system = System_Unknown; | 463 | d-> m_system = System_Unknown; |
464 | d-> m_sysverstr = "0.0"; | 464 | d-> m_sysverstr = "0.0"; |
465 | d-> m_rotation = Rot0; | 465 | d-> m_rotation = Rot0; |
466 | d-> m_direction = CW; | 466 | d-> m_direction = CW; |
467 | 467 | ||
468 | d-> m_holdtime = 1000; // 1000ms | 468 | d-> m_holdtime = 1000; // 1000ms |
469 | d-> m_buttons = 0; | 469 | d-> m_buttons = 0; |
470 | d-> m_cpu_frequencies = new QStrList; | 470 | d-> m_cpu_frequencies = new QStrList; |
471 | } | 471 | } |
472 | 472 | ||
473 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) | 473 | void ODevice::systemMessage ( const QCString &msg, const QByteArray & ) |
474 | { | 474 | { |
475 | if ( msg == "deviceButtonMappingChanged()" ) { | 475 | if ( msg == "deviceButtonMappingChanged()" ) { |
476 | reloadButtonMapping ( ); | 476 | reloadButtonMapping ( ); |
477 | } | 477 | } |
478 | } | 478 | } |
479 | 479 | ||
480 | void ODevice::init ( ) | 480 | void ODevice::init ( ) |
481 | { | 481 | { |
482 | } | 482 | } |
483 | 483 | ||
484 | /** | 484 | /** |
485 | * This method initialises the button mapping | 485 | * This method initialises the button mapping |
486 | */ | 486 | */ |
487 | void ODevice::initButtons ( ) | 487 | void ODevice::initButtons ( ) |
488 | { | 488 | { |
489 | if ( d-> m_buttons ) | 489 | if ( d-> m_buttons ) |
490 | return; | 490 | return; |
491 | 491 | ||
492 | // Simulation uses iPAQ 3660 device buttons | 492 | // Simulation uses iPAQ 3660 device buttons |
493 | 493 | ||
494 | qDebug ( "init Buttons" ); | 494 | qDebug ( "init Buttons" ); |
495 | d-> m_buttons = new QValueList <ODeviceButton>; | 495 | d-> m_buttons = new QValueList <ODeviceButton>; |
496 | 496 | ||
497 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 497 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
498 | i_button *ib = ipaq_buttons + i; | 498 | i_button *ib = ipaq_buttons + i; |
499 | ODeviceButton b; | 499 | ODeviceButton b; |
500 | 500 | ||
501 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 501 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
502 | b. setKeycode ( ib-> code ); | 502 | b. setKeycode ( ib-> code ); |
503 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 503 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
504 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 504 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
505 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 505 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
506 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 506 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
507 | d-> m_buttons-> append ( b ); | 507 | d-> m_buttons-> append ( b ); |
508 | } | 508 | } |
509 | } | 509 | } |
510 | reloadButtonMapping ( ); | 510 | reloadButtonMapping ( ); |
511 | 511 | ||
512 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 512 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
513 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 513 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
514 | } | 514 | } |
515 | 515 | ||
516 | ODevice::~ODevice ( ) | 516 | ODevice::~ODevice ( ) |
517 | { | 517 | { |
518 | // we leak m_devicebuttons and m_cpu_frequency | 518 | // we leak m_devicebuttons and m_cpu_frequency |
519 | // but it's a singleton and it is not so importantant | 519 | // but it's a singleton and it is not so importantant |
520 | // -zecke | 520 | // -zecke |
521 | delete d; | 521 | delete d; |
522 | } | 522 | } |
523 | 523 | ||
524 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) | 524 | bool ODevice::setSoftSuspend ( bool /*soft*/ ) |
525 | { | 525 | { |
526 | return false; | 526 | return false; |
527 | } | 527 | } |
528 | 528 | ||
529 | //#include <linux/apm_bios.h> | 529 | //#include <linux/apm_bios.h> |
530 | 530 | ||
531 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) | 531 | #define APM_IOC_SUSPEND OD_IO( 'A', 2 ) |
532 | 532 | ||
533 | /** | 533 | /** |
534 | * This method will try to suspend the device | 534 | * This method will try to suspend the device |
535 | * It only works if the user is the QWS Server and the apm application | 535 | * It only works if the user is the QWS Server and the apm application |
536 | * is installed. | 536 | * is installed. |
537 | * It tries to suspend and then waits some time cause some distributions | 537 | * It tries to suspend and then waits some time cause some distributions |
538 | * do have asynchronus apm implementations. | 538 | * do have asynchronus apm implementations. |
539 | * This method will either fail and return false or it'll suspend the | 539 | * This method will either fail and return false or it'll suspend the |
540 | * device and return once the device got woken up | 540 | * device and return once the device got woken up |
541 | * | 541 | * |
542 | * @return if the device got suspended | 542 | * @return if the device got suspended |
543 | */ | 543 | */ |
544 | bool ODevice::suspend ( ) | 544 | bool ODevice::suspend ( ) |
545 | { | 545 | { |
546 | qDebug("ODevice::suspend"); | 546 | qDebug("ODevice::suspend"); |
547 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 547 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
548 | return false; | 548 | return false; |
549 | 549 | ||
550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 550 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
551 | return false; | 551 | return false; |
552 | 552 | ||
553 | bool res = false; | 553 | bool res = false; |
554 | 554 | ||
555 | struct timeval tvs, tvn; | 555 | struct timeval tvs, tvn; |
556 | ::gettimeofday ( &tvs, 0 ); | 556 | ::gettimeofday ( &tvs, 0 ); |
557 | 557 | ||
558 | ::sync ( ); // flush fs caches | 558 | ::sync ( ); // flush fs caches |
559 | res = ( ::system ( "apm --suspend" ) == 0 ); | 559 | res = ( ::system ( "apm --suspend" ) == 0 ); |
560 | 560 | ||
561 | // This is needed because the iPAQ apm implementation is asynchronous and we | 561 | // This is needed because the iPAQ apm implementation is asynchronous and we |
562 | // can not be sure when exactly the device is really suspended | 562 | // can not be sure when exactly the device is really suspended |
563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 563 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
564 | 564 | ||
565 | if ( res ) { | 565 | if ( res ) { |
566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed | 566 | do { // wait at most 1.5 sec: either suspend didn't work or the device resumed |
567 | ::usleep ( 200 * 1000 ); | 567 | ::usleep ( 200 * 1000 ); |
568 | ::gettimeofday ( &tvn, 0 ); | 568 | ::gettimeofday ( &tvn, 0 ); |
569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); | 569 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 1500 ); |
570 | } | 570 | } |
571 | 571 | ||
572 | return res; | 572 | return res; |
573 | } | 573 | } |
574 | 574 | ||
575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... | 575 | //#include <linux/fb.h> better not rely on kernel headers in userspace ... |
576 | 576 | ||
577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 | 577 | #define FBIOBLANK OD_IO( 'F', 0x11 ) // 0x4611 |
578 | 578 | ||
579 | /* VESA Blanking Levels */ | 579 | /* VESA Blanking Levels */ |
580 | #define VESA_NO_BLANKING 0 | 580 | #define VESA_NO_BLANKING 0 |
581 | #define VESA_VSYNC_SUSPEND 1 | 581 | #define VESA_VSYNC_SUSPEND 1 |
582 | #define VESA_HSYNC_SUSPEND 2 | 582 | #define VESA_HSYNC_SUSPEND 2 |
583 | #define VESA_POWERDOWN 3 | 583 | #define VESA_POWERDOWN 3 |
584 | 584 | ||
585 | /** | 585 | /** |
586 | * This sets the display on or off | 586 | * This sets the display on or off |
587 | */ | 587 | */ |
588 | bool ODevice::setDisplayStatus ( bool on ) | 588 | bool ODevice::setDisplayStatus ( bool on ) |
589 | { | 589 | { |
590 | qDebug("ODevice::setDisplayStatus(%d)", on); | 590 | qDebug("ODevice::setDisplayStatus(%d)", on); |
591 | 591 | ||
592 | if ( d-> m_model == Model_Unknown ) | 592 | if ( d-> m_model == Model_Unknown ) |
593 | return false; | 593 | return false; |
594 | 594 | ||
595 | bool res = false; | 595 | bool res = false; |
596 | int fd; | 596 | int fd; |
597 | 597 | ||
598 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { | 598 | if (( fd = ::open ( "/dev/fb0", O_RDWR )) >= 0 ) { |
599 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); | 599 | res = ( ::ioctl ( fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN ) == 0 ); |
600 | ::close ( fd ); | 600 | ::close ( fd ); |
601 | } | 601 | } |
602 | return res; | 602 | return res; |
603 | } | 603 | } |
604 | 604 | ||
605 | /** | 605 | /** |
606 | * This sets the display brightness | 606 | * This sets the display brightness |
607 | * | 607 | * |
608 | * @param p The brightness to be set on a scale from 0 to 255 | 608 | * @param p The brightness to be set on a scale from 0 to 255 |
609 | * @return success or failure | 609 | * @return success or failure |
610 | */ | 610 | */ |
611 | bool ODevice::setDisplayBrightness ( int p) | 611 | bool ODevice::setDisplayBrightness ( int p) |
612 | { | 612 | { |
613 | Q_UNUSED( p ) | 613 | Q_UNUSED( p ) |
614 | return false; | 614 | return false; |
615 | } | 615 | } |
616 | 616 | ||
617 | /** | 617 | /** |
618 | * @return returns the number of steppings on the brightness slider | 618 | * @return returns the number of steppings on the brightness slider |
619 | * in the Light-'n-Power settings. | 619 | * in the Light-'n-Power settings. |
620 | */ | 620 | */ |
621 | int ODevice::displayBrightnessResolution ( ) const | 621 | int ODevice::displayBrightnessResolution ( ) const |
622 | { | 622 | { |
623 | return 16; | 623 | return 16; |
624 | } | 624 | } |
625 | 625 | ||
626 | /** | 626 | /** |
627 | * This sets the display contrast | 627 | * This sets the display contrast |
628 | * @param p The contrast to be set on a scale from 0 to 255 | 628 | * @param p The contrast to be set on a scale from 0 to 255 |
629 | * @return success or failure | 629 | * @return success or failure |
630 | */ | 630 | */ |
631 | bool ODevice::setDisplayContrast ( int p) | 631 | bool ODevice::setDisplayContrast ( int p) |
632 | { | 632 | { |
633 | Q_UNUSED( p ) | 633 | Q_UNUSED( p ) |
634 | return false; | 634 | return false; |
635 | } | 635 | } |
636 | 636 | ||
637 | /** | 637 | /** |
638 | * @return return the max value for the brightness settings slider | 638 | * @return return the max value for the brightness settings slider |
639 | * or 0 if the device doesn't support setting of a contrast | 639 | * or 0 if the device doesn't support setting of a contrast |
640 | */ | 640 | */ |
641 | int ODevice::displayContrastResolution ( ) const | 641 | int ODevice::displayContrastResolution ( ) const |
642 | { | 642 | { |
643 | return 0; | 643 | return 0; |
644 | } | 644 | } |
645 | 645 | ||
646 | /** | 646 | /** |
647 | * This returns the vendor as string | 647 | * This returns the vendor as string |
648 | * @return Vendor as QString | 648 | * @return Vendor as QString |
649 | */ | 649 | */ |
650 | QString ODevice::vendorString ( ) const | 650 | QString ODevice::vendorString ( ) const |
651 | { | 651 | { |
652 | return d-> m_vendorstr; | 652 | return d-> m_vendorstr; |
653 | } | 653 | } |
654 | 654 | ||
655 | /** | 655 | /** |
656 | * This returns the vendor as one of the values of OVendor | 656 | * This returns the vendor as one of the values of OVendor |
657 | * @return OVendor | 657 | * @return OVendor |
658 | */ | 658 | */ |
659 | OVendor ODevice::vendor ( ) const | 659 | OVendor ODevice::vendor ( ) const |
660 | { | 660 | { |
661 | return d-> m_vendor; | 661 | return d-> m_vendor; |
662 | } | 662 | } |
663 | 663 | ||
664 | /** | 664 | /** |
665 | * This returns the model as a string | 665 | * This returns the model as a string |
666 | * @return A string representing the model | 666 | * @return A string representing the model |
667 | */ | 667 | */ |
668 | QString ODevice::modelString ( ) const | 668 | QString ODevice::modelString ( ) const |
669 | { | 669 | { |
670 | return d-> m_modelstr; | 670 | return d-> m_modelstr; |
671 | } | 671 | } |
672 | 672 | ||
673 | /** | 673 | /** |
674 | * This does return the OModel used | 674 | * This does return the OModel used |
675 | */ | 675 | */ |
676 | OModel ODevice::model ( ) const | 676 | OModel ODevice::model ( ) const |
677 | { | 677 | { |
678 | return d-> m_model; | 678 | return d-> m_model; |
679 | } | 679 | } |
680 | 680 | ||
681 | /** | 681 | /** |
682 | * This does return the systen name | 682 | * This does return the systen name |
683 | */ | 683 | */ |
684 | QString ODevice::systemString ( ) const | 684 | QString ODevice::systemString ( ) const |
685 | { | 685 | { |
686 | return d-> m_systemstr; | 686 | return d-> m_systemstr; |
687 | } | 687 | } |
688 | 688 | ||
689 | /** | 689 | /** |
690 | * Return System as OSystem value | 690 | * Return System as OSystem value |
691 | */ | 691 | */ |
692 | OSystem ODevice::system ( ) const | 692 | OSystem ODevice::system ( ) const |
693 | { | 693 | { |
694 | return d-> m_system; | 694 | return d-> m_system; |
695 | } | 695 | } |
696 | 696 | ||
697 | /** | 697 | /** |
698 | * @return the version string of the base system | 698 | * @return the version string of the base system |
699 | */ | 699 | */ |
700 | QString ODevice::systemVersionString ( ) const | 700 | QString ODevice::systemVersionString ( ) const |
701 | { | 701 | { |
702 | return d-> m_sysverstr; | 702 | return d-> m_sysverstr; |
703 | } | 703 | } |
704 | 704 | ||
705 | /** | 705 | /** |
706 | * @return the current Transformation | 706 | * @return the current Transformation |
707 | */ | 707 | */ |
708 | Transformation ODevice::rotation ( ) const | 708 | Transformation ODevice::rotation ( ) const |
709 | { | 709 | { |
710 | VirtRotation rot; | 710 | VirtRotation rot; |
711 | ODevice* that =(ODevice* )this; | 711 | ODevice* that =(ODevice* )this; |
712 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); | 712 | that->virtual_hook( VIRTUAL_ROTATION, &rot ); |
713 | return rot.trans; | 713 | return rot.trans; |
714 | } | 714 | } |
715 | 715 | ||
716 | /** | 716 | /** |
717 | * @return the current rotation direction | 717 | * @return the current rotation direction |
718 | */ | 718 | */ |
719 | ODirection ODevice::direction ( ) const | 719 | ODirection ODevice::direction ( ) const |
720 | { | 720 | { |
721 | VirtDirection dir; | 721 | VirtDirection dir; |
722 | ODevice* that =(ODevice* )this; | 722 | ODevice* that =(ODevice* )this; |
723 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); | 723 | that->virtual_hook( VIRTUAL_DIRECTION, &dir ); |
724 | return dir.direct; | 724 | return dir.direct; |
725 | } | 725 | } |
726 | 726 | ||
727 | /** | 727 | /** |
728 | * This plays an alarmSound | 728 | * This plays an alarmSound |
729 | */ | 729 | */ |
730 | void ODevice::alarmSound ( ) | 730 | void ODevice::alarmSound ( ) |
731 | { | 731 | { |
732 | #ifndef QT_NO_SOUND | 732 | #ifndef QT_NO_SOUND |
733 | static Sound snd ( "alarm" ); | 733 | static Sound snd ( "alarm" ); |
734 | 734 | ||
735 | if ( snd. isFinished ( )) | 735 | if ( snd. isFinished ( )) |
736 | snd. play ( ); | 736 | snd. play ( ); |
737 | #endif | 737 | #endif |
738 | } | 738 | } |
739 | 739 | ||
740 | /** | 740 | /** |
741 | * This plays a key sound | 741 | * This plays a key sound |
742 | */ | 742 | */ |
743 | void ODevice::keySound ( ) | 743 | void ODevice::keySound ( ) |
744 | { | 744 | { |
745 | #ifndef QT_NO_SOUND | 745 | #ifndef QT_NO_SOUND |
746 | static Sound snd ( "keysound" ); | 746 | static Sound snd ( "keysound" ); |
747 | 747 | ||
748 | if ( snd. isFinished ( )) | 748 | if ( snd. isFinished ( )) |
749 | snd. play ( ); | 749 | snd. play ( ); |
750 | #endif | 750 | #endif |
751 | } | 751 | } |
752 | 752 | ||
753 | /** | 753 | /** |
754 | * This plays a touch sound | 754 | * This plays a touch sound |
755 | */ | 755 | */ |
756 | void ODevice::touchSound ( ) | 756 | void ODevice::touchSound ( ) |
757 | { | 757 | { |
758 | #ifndef QT_NO_SOUND | 758 | #ifndef QT_NO_SOUND |
759 | static Sound snd ( "touchsound" ); | 759 | static Sound snd ( "touchsound" ); |
760 | 760 | ||
761 | if ( snd. isFinished ( )) | 761 | if ( snd. isFinished ( )) |
762 | snd. play ( ); | 762 | snd. play ( ); |
763 | #endif | 763 | #endif |
764 | } | 764 | } |
765 | 765 | ||
766 | /** | 766 | /** |
767 | * This method will return a list of leds | 767 | * This method will return a list of leds |
768 | * available on this device | 768 | * available on this device |
769 | * @return a list of LEDs. | 769 | * @return a list of LEDs. |
770 | */ | 770 | */ |
771 | QValueList <OLed> ODevice::ledList ( ) const | 771 | QValueList <OLed> ODevice::ledList ( ) const |
772 | { | 772 | { |
773 | return QValueList <OLed> ( ); | 773 | return QValueList <OLed> ( ); |
774 | } | 774 | } |
775 | 775 | ||
776 | /** | 776 | /** |
777 | * This does return the state of the LEDs | 777 | * This does return the state of the LEDs |
778 | */ | 778 | */ |
779 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const | 779 | QValueList <OLedState> ODevice::ledStateList ( OLed /*which*/ ) const |
780 | { | 780 | { |
781 | return QValueList <OLedState> ( ); | 781 | return QValueList <OLedState> ( ); |
782 | } | 782 | } |
783 | 783 | ||
784 | /** | 784 | /** |
785 | * @return the state for a given OLed | 785 | * @return the state for a given OLed |
786 | */ | 786 | */ |
787 | OLedState ODevice::ledState ( OLed /*which*/ ) const | 787 | OLedState ODevice::ledState ( OLed /*which*/ ) const |
788 | { | 788 | { |
789 | return Led_Off; | 789 | return Led_Off; |
790 | } | 790 | } |
791 | 791 | ||
792 | /** | 792 | /** |
793 | * Set the state for a LED | 793 | * Set the state for a LED |
794 | * @param which Which OLed to use | 794 | * @param which Which OLed to use |
795 | * @param st The state to set | 795 | * @param st The state to set |
796 | * @return success or failure | 796 | * @return success or failure |
797 | */ | 797 | */ |
798 | bool ODevice::setLedState ( OLed which, OLedState st ) | 798 | bool ODevice::setLedState ( OLed which, OLedState st ) |
799 | { | 799 | { |
800 | Q_UNUSED( which ) | 800 | Q_UNUSED( which ) |
801 | Q_UNUSED( st ) | 801 | Q_UNUSED( st ) |
802 | return false; | 802 | return false; |
803 | } | 803 | } |
804 | 804 | ||
805 | /** | 805 | /** |
806 | * @return if the device has a light sensor | 806 | * @return if the device has a light sensor |
807 | */ | 807 | */ |
808 | bool ODevice::hasLightSensor ( ) const | 808 | bool ODevice::hasLightSensor ( ) const |
809 | { | 809 | { |
810 | return false; | 810 | return false; |
811 | } | 811 | } |
812 | 812 | ||
813 | /** | 813 | /** |
814 | * @return a value from the light sensor | 814 | * @return a value from the light sensor |
815 | */ | 815 | */ |
816 | int ODevice::readLightSensor ( ) | 816 | int ODevice::readLightSensor ( ) |
817 | { | 817 | { |
818 | return -1; | 818 | return -1; |
819 | } | 819 | } |
820 | 820 | ||
821 | /** | 821 | /** |
822 | * @return the light sensor resolution | 822 | * @return the light sensor resolution |
823 | */ | 823 | */ |
824 | int ODevice::lightSensorResolution ( ) const | 824 | int ODevice::lightSensorResolution ( ) const |
825 | { | 825 | { |
826 | return 0; | 826 | return 0; |
827 | } | 827 | } |
828 | 828 | ||
829 | /** | 829 | /** |
830 | * @return if the device has a hinge sensor | 830 | * @return if the device has a hinge sensor |
831 | */ | 831 | */ |
832 | bool ODevice::hasHingeSensor ( ) const | 832 | bool ODevice::hasHingeSensor ( ) const |
833 | { | 833 | { |
834 | VirtHasHinge hing; | 834 | VirtHasHinge hing; |
835 | ODevice* that =(ODevice* )this; | 835 | ODevice* that =(ODevice* )this; |
836 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); | 836 | that->virtual_hook( VIRTUAL_HAS_HINGE, &hing ); |
837 | return hing.hasHinge; | 837 | return hing.hasHinge; |
838 | } | 838 | } |
839 | 839 | ||
840 | /** | 840 | /** |
841 | * @return a value from the hinge sensor | 841 | * @return a value from the hinge sensor |
842 | */ | 842 | */ |
843 | OHingeStatus ODevice::readHingeSensor ( ) | 843 | OHingeStatus ODevice::readHingeSensor ( ) |
844 | { | 844 | { |
845 | VirtHingeStatus hing; | 845 | VirtHingeStatus hing; |
846 | virtual_hook( VIRTUAL_HINGE, &hing ); | 846 | virtual_hook( VIRTUAL_HINGE, &hing ); |
847 | return hing.hingeStat; | 847 | return hing.hingeStat; |
848 | } | 848 | } |
849 | 849 | ||
850 | /** | 850 | /** |
851 | * @return a list with CPU frequencies supported by the hardware | 851 | * @return a list with CPU frequencies supported by the hardware |
852 | */ | 852 | */ |
853 | const QStrList &ODevice::allowedCpuFrequencies ( ) const | 853 | const QStrList &ODevice::allowedCpuFrequencies ( ) const |
854 | { | 854 | { |
855 | return *d->m_cpu_frequencies; | 855 | return *d->m_cpu_frequencies; |
856 | } | 856 | } |
857 | 857 | ||
858 | 858 | ||
859 | /** | 859 | /** |
860 | * Set desired CPU frequency | 860 | * Set desired CPU frequency |
861 | * | 861 | * |
862 | * @param index index into d->m_cpu_frequencies of the frequency to be set | 862 | * @param index index into d->m_cpu_frequencies of the frequency to be set |
863 | */ | 863 | */ |
864 | bool ODevice::setCurrentCpuFrequency(uint index) | 864 | bool ODevice::setCurrentCpuFrequency(uint index) |
865 | { | 865 | { |
866 | if (index >= d->m_cpu_frequencies->count()) | 866 | if (index >= d->m_cpu_frequencies->count()) |
867 | return false; | 867 | return false; |
868 | 868 | ||
869 | char *freq = d->m_cpu_frequencies->at(index); | 869 | char *freq = d->m_cpu_frequencies->at(index); |
870 | qWarning("set freq to %s", freq); | 870 | qWarning("set freq to %s", freq); |
871 | 871 | ||
872 | int fd; | 872 | int fd; |
873 | 873 | ||
874 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { | 874 | if ((fd = ::open("/proc/sys/cpu/0/speed", O_WRONLY)) >= 0) { |
875 | char writeCommand[50]; | 875 | char writeCommand[50]; |
876 | const int count = sprintf(writeCommand, "%s\n", freq); | 876 | const int count = sprintf(writeCommand, "%s\n", freq); |
877 | int res = (::write(fd, writeCommand, count) != -1); | 877 | int res = (::write(fd, writeCommand, count) != -1); |
878 | ::close(fd); | 878 | ::close(fd); |
879 | return res; | 879 | return res; |
880 | } | 880 | } |
881 | 881 | ||
882 | return false; | 882 | return false; |
883 | } | 883 | } |
884 | 884 | ||
885 | 885 | ||
886 | /** | 886 | /** |
887 | * @return a list of hardware buttons | 887 | * @return a list of hardware buttons |
888 | */ | 888 | */ |
889 | const QValueList <ODeviceButton> &ODevice::buttons ( ) | 889 | const QValueList <ODeviceButton> &ODevice::buttons ( ) |
890 | { | 890 | { |
891 | initButtons ( ); | 891 | initButtons ( ); |
892 | 892 | ||
893 | return *d-> m_buttons; | 893 | return *d-> m_buttons; |
894 | } | 894 | } |
895 | 895 | ||
896 | /** | 896 | /** |
897 | * @return The amount of time that would count as a hold | 897 | * @return The amount of time that would count as a hold |
898 | */ | 898 | */ |
899 | uint ODevice::buttonHoldTime ( ) const | 899 | uint ODevice::buttonHoldTime ( ) const |
900 | { | 900 | { |
901 | return d-> m_holdtime; | 901 | return d-> m_holdtime; |
902 | } | 902 | } |
903 | 903 | ||
904 | /** | 904 | /** |
905 | * This method return a ODeviceButton for a key code | 905 | * This method return a ODeviceButton for a key code |
906 | * or 0 if no special hardware button is available for the device | 906 | * or 0 if no special hardware button is available for the device |
907 | * | 907 | * |
908 | * @return The devicebutton or 0l | 908 | * @return The devicebutton or 0l |
909 | * @see ODeviceButton | 909 | * @see ODeviceButton |
910 | */ | 910 | */ |
911 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) | 911 | const ODeviceButton *ODevice::buttonForKeycode ( ushort code ) |
912 | { | 912 | { |
913 | initButtons ( ); | 913 | initButtons ( ); |
914 | 914 | ||
915 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { | 915 | for ( QValueListConstIterator<ODeviceButton> it = d-> m_buttons-> begin ( ); it != d-> m_buttons-> end ( ); ++it ) { |
916 | if ( (*it). keycode ( ) == code ) | 916 | if ( (*it). keycode ( ) == code ) |
917 | return &(*it); | 917 | return &(*it); |
918 | } | 918 | } |
919 | return 0; | 919 | return 0; |
920 | } | 920 | } |
921 | 921 | ||
922 | void ODevice::reloadButtonMapping ( ) | 922 | void ODevice::reloadButtonMapping ( ) |
923 | { | 923 | { |
924 | initButtons ( ); | 924 | initButtons ( ); |
925 | 925 | ||
926 | Config cfg ( "ButtonSettings" ); | 926 | Config cfg ( "ButtonSettings" ); |
927 | 927 | ||
928 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { | 928 | for ( uint i = 0; i < d-> m_buttons-> count ( ); i++ ) { |
929 | ODeviceButton &b = ( *d-> m_buttons ) [i]; | 929 | ODeviceButton &b = ( *d-> m_buttons ) [i]; |
930 | QString group = "Button" + QString::number ( i ); | 930 | QString group = "Button" + QString::number ( i ); |
931 | 931 | ||
932 | QCString pch, hch; | 932 | QCString pch, hch; |
933 | QCString pm, hm; | 933 | QCString pm, hm; |
934 | QByteArray pdata, hdata; | 934 | QByteArray pdata, hdata; |
935 | 935 | ||
936 | if ( cfg. hasGroup ( group )) { | 936 | if ( cfg. hasGroup ( group )) { |
937 | cfg. setGroup ( group ); | 937 | cfg. setGroup ( group ); |
938 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); | 938 | pch = cfg. readEntry ( "PressedActionChannel" ). latin1 ( ); |
939 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); | 939 | pm = cfg. readEntry ( "PressedActionMessage" ). latin1 ( ); |
940 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); | 940 | // pdata = decodeBase64 ( buttonFile. readEntry ( "PressedActionArgs" )); |
941 | 941 | ||
942 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); | 942 | hch = cfg. readEntry ( "HeldActionChannel" ). latin1 ( ); |
943 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); | 943 | hm = cfg. readEntry ( "HeldActionMessage" ). latin1 ( ); |
944 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); | 944 | // hdata = decodeBase64 ( buttonFile. readEntry ( "HeldActionArgs" )); |
945 | } | 945 | } |
946 | 946 | ||
947 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); | 947 | b. setPressedAction ( OQCopMessage ( pch, pm, pdata )); |
948 | 948 | ||
949 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); | 949 | b. setHeldAction ( OQCopMessage ( hch, hm, hdata )); |
950 | } | 950 | } |
951 | } | 951 | } |
952 | 952 | ||
953 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) | 953 | void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) |
954 | { | 954 | { |
955 | initButtons ( ); | 955 | initButtons ( ); |
956 | 956 | ||
957 | QString mb_chan; | 957 | QString mb_chan; |
958 | 958 | ||
959 | if ( button >= (int) d-> m_buttons-> count ( )) | 959 | if ( button >= (int) d-> m_buttons-> count ( )) |
960 | return; | 960 | return; |
961 | 961 | ||
962 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 962 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
963 | b. setPressedAction ( action ); | 963 | b. setPressedAction ( action ); |
964 | 964 | ||
965 | mb_chan=b. pressedAction ( ). channel ( ); | 965 | mb_chan=b. pressedAction ( ). channel ( ); |
966 | 966 | ||
967 | Config buttonFile ( "ButtonSettings" ); | 967 | Config buttonFile ( "ButtonSettings" ); |
968 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 968 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
969 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); | 969 | buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); |
970 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); | 970 | buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction ( ). message ( )); |
971 | 971 | ||
972 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); | 972 | //buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction ( ). data ( ))); |
973 | 973 | ||
974 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 974 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
975 | } | 975 | } |
976 | 976 | ||
977 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | 977 | void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) |
978 | { | 978 | { |
979 | initButtons ( ); | 979 | initButtons ( ); |
980 | 980 | ||
981 | if ( button >= (int) d-> m_buttons-> count ( )) | 981 | if ( button >= (int) d-> m_buttons-> count ( )) |
982 | return; | 982 | return; |
983 | 983 | ||
984 | ODeviceButton &b = ( *d-> m_buttons ) [button]; | 984 | ODeviceButton &b = ( *d-> m_buttons ) [button]; |
985 | b. setHeldAction ( action ); | 985 | b. setHeldAction ( action ); |
986 | 986 | ||
987 | Config buttonFile ( "ButtonSettings" ); | 987 | Config buttonFile ( "ButtonSettings" ); |
988 | buttonFile. setGroup ( "Button" + QString::number ( button )); | 988 | buttonFile. setGroup ( "Button" + QString::number ( button )); |
989 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); | 989 | buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction ( ). channel ( )); |
990 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); | 990 | buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction ( ). message ( )); |
991 | 991 | ||
992 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); | 992 | //buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction ( ). data ( ))); |
993 | 993 | ||
994 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); | 994 | QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); |
995 | } | 995 | } |
996 | void ODevice::virtual_hook(int id, void* data){ | 996 | void ODevice::virtual_hook(int id, void* data){ |
997 | switch( id ) { | 997 | switch( id ) { |
998 | case VIRTUAL_ROTATION:{ | 998 | case VIRTUAL_ROTATION:{ |
999 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); | 999 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); |
1000 | rot->trans = d->m_rotation; | 1000 | rot->trans = d->m_rotation; |
1001 | break; | 1001 | break; |
1002 | } | 1002 | } |
1003 | case VIRTUAL_DIRECTION:{ | 1003 | case VIRTUAL_DIRECTION:{ |
1004 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); | 1004 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); |
1005 | dir->direct = d->m_direction; | 1005 | dir->direct = d->m_direction; |
1006 | break; | 1006 | break; |
1007 | } | 1007 | } |
1008 | case VIRTUAL_HAS_HINGE:{ | 1008 | case VIRTUAL_HAS_HINGE:{ |
1009 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); | 1009 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); |
1010 | hin->hasHinge = false; | 1010 | hin->hasHinge = false; |
1011 | break; | 1011 | break; |
1012 | } | 1012 | } |
1013 | case VIRTUAL_HINGE:{ | 1013 | case VIRTUAL_HINGE:{ |
1014 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); | 1014 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); |
1015 | hin->hingeStat = CASE_UNKNOWN; | 1015 | hin->hingeStat = CASE_UNKNOWN; |
1016 | break; | 1016 | break; |
1017 | } | 1017 | } |
1018 | } | 1018 | } |
1019 | } | 1019 | } |
1020 | 1020 | ||
1021 | /************************************************** | 1021 | /************************************************** |
1022 | * | 1022 | * |
1023 | * Yopy 3500/3700 | 1023 | * Yopy 3500/3700 |
1024 | * | 1024 | * |
1025 | **************************************************/ | 1025 | **************************************************/ |
1026 | 1026 | ||
1027 | bool Yopy::isYopy ( ) | 1027 | bool Yopy::isYopy ( ) |
1028 | { | 1028 | { |
1029 | QFile f( "/proc/cpuinfo" ); | 1029 | QFile f( "/proc/cpuinfo" ); |
1030 | if ( f. open ( IO_ReadOnly ) ) { | 1030 | if ( f. open ( IO_ReadOnly ) ) { |
1031 | QTextStream ts ( &f ); | 1031 | QTextStream ts ( &f ); |
1032 | QString line; | 1032 | QString line; |
1033 | while( line = ts. readLine ( ) ) { | 1033 | while( line = ts. readLine ( ) ) { |
1034 | if ( line. left ( 8 ) == "Hardware" ) { | 1034 | if ( line. left ( 8 ) == "Hardware" ) { |
1035 | int loc = line. find ( ":" ); | 1035 | int loc = line. find ( ":" ); |
1036 | if ( loc != -1 ) { | 1036 | if ( loc != -1 ) { |
1037 | QString model = | 1037 | QString model = |
1038 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1038 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1039 | return ( model == "Yopy" ); | 1039 | return ( model == "Yopy" ); |
1040 | } | 1040 | } |
1041 | } | 1041 | } |
1042 | } | 1042 | } |
1043 | } | 1043 | } |
1044 | return false; | 1044 | return false; |
1045 | } | 1045 | } |
1046 | 1046 | ||
1047 | void Yopy::init ( ) | 1047 | void Yopy::init ( ) |
1048 | { | 1048 | { |
1049 | d-> m_vendorstr = "G.Mate"; | 1049 | d-> m_vendorstr = "G.Mate"; |
1050 | d-> m_vendor = Vendor_GMate; | 1050 | d-> m_vendor = Vendor_GMate; |
1051 | d-> m_modelstr = "Yopy3700"; | 1051 | d-> m_modelstr = "Yopy3700"; |
1052 | d-> m_model = Model_Yopy_3700; | 1052 | d-> m_model = Model_Yopy_3700; |
1053 | d-> m_rotation = Rot0; | 1053 | d-> m_rotation = Rot0; |
1054 | 1054 | ||
1055 | d-> m_systemstr = "Linupy"; | 1055 | d-> m_systemstr = "Linupy"; |
1056 | d-> m_system = System_Linupy; | 1056 | d-> m_system = System_Linupy; |
1057 | 1057 | ||
1058 | QFile f ( "/etc/issue" ); | 1058 | QFile f ( "/etc/issue" ); |
1059 | if ( f. open ( IO_ReadOnly )) { | 1059 | if ( f. open ( IO_ReadOnly )) { |
1060 | QTextStream ts ( &f ); | 1060 | QTextStream ts ( &f ); |
1061 | ts.readLine(); | 1061 | ts.readLine(); |
1062 | d-> m_sysverstr = ts. readLine ( ); | 1062 | d-> m_sysverstr = ts. readLine ( ); |
1063 | f. close ( ); | 1063 | f. close ( ); |
1064 | } | 1064 | } |
1065 | } | 1065 | } |
1066 | 1066 | ||
1067 | void Yopy::initButtons ( ) | 1067 | void Yopy::initButtons ( ) |
1068 | { | 1068 | { |
1069 | if ( d-> m_buttons ) | 1069 | if ( d-> m_buttons ) |
1070 | return; | 1070 | return; |
1071 | 1071 | ||
1072 | d-> m_buttons = new QValueList <ODeviceButton>; | 1072 | d-> m_buttons = new QValueList <ODeviceButton>; |
1073 | 1073 | ||
1074 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { | 1074 | for (uint i = 0; i < ( sizeof( yopy_buttons ) / sizeof(yopy_button)); i++) { |
1075 | 1075 | ||
1076 | yopy_button *ib = yopy_buttons + i; | 1076 | yopy_button *ib = yopy_buttons + i; |
1077 | 1077 | ||
1078 | ODeviceButton b; | 1078 | ODeviceButton b; |
1079 | 1079 | ||
1080 | b. setKeycode ( ib-> code ); | 1080 | b. setKeycode ( ib-> code ); |
1081 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1081 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1082 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1082 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1083 | b. setFactoryPresetPressedAction | 1083 | b. setFactoryPresetPressedAction |
1084 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); | 1084 | (OQCopMessage(makeChannel(ib->fpressedservice), ib->fpressedaction)); |
1085 | b. setFactoryPresetHeldAction | 1085 | b. setFactoryPresetHeldAction |
1086 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); | 1086 | (OQCopMessage(makeChannel(ib->fheldservice), ib->fheldaction)); |
1087 | 1087 | ||
1088 | d-> m_buttons-> append ( b ); | 1088 | d-> m_buttons-> append ( b ); |
1089 | } | 1089 | } |
1090 | reloadButtonMapping ( ); | 1090 | reloadButtonMapping ( ); |
1091 | 1091 | ||
1092 | QCopChannel *sysch = new QCopChannel("QPE/System", this); | 1092 | QCopChannel *sysch = new QCopChannel("QPE/System", this); |
1093 | connect(sysch, SIGNAL(received(const QCString&,const QByteArray&)), | 1093 | connect(sysch, SIGNAL(received(const QCString&,const QByteArray&)), |
1094 | this, SLOT(systemMessage(const QCString&,const QByteArray&))); | 1094 | this, SLOT(systemMessage(const QCString&,const QByteArray&))); |
1095 | } | 1095 | } |
1096 | 1096 | ||
1097 | bool Yopy::suspend() | 1097 | bool Yopy::suspend() |
1098 | { | 1098 | { |
1099 | /* Opie for Yopy does not implement its own power management at the | 1099 | /* Opie for Yopy does not implement its own power management at the |
1100 | moment. The public version runs parallel to X, and relies on the | 1100 | moment. The public version runs parallel to X, and relies on the |
1101 | existing power management features. */ | 1101 | existing power management features. */ |
1102 | return false; | 1102 | return false; |
1103 | } | 1103 | } |
1104 | 1104 | ||
1105 | bool Yopy::setDisplayBrightness(int bright) | 1105 | bool Yopy::setDisplayBrightness(int /*bright*/) |
1106 | { | 1106 | { |
1107 | /* The code here works, but is disabled as the current version runs | 1107 | /* The code here works, but is disabled as the current version runs |
1108 | parallel to X, and relies on the existing backlight demon. */ | 1108 | parallel to X, and relies on the existing backlight demon. */ |
1109 | #if 0 | 1109 | #if 0 |
1110 | if ( QFile::exists("/proc/sys/pm/light") ) { | 1110 | if ( QFile::exists("/proc/sys/pm/light") ) { |
1111 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); | 1111 | int fd = ::open("/proc/sys/pm/light", O_WRONLY); |
1112 | if (fd >= 0 ) { | 1112 | if (fd >= 0 ) { |
1113 | if (bright) | 1113 | if (bright) |
1114 | ::write(fd, "1\n", 2); | 1114 | ::write(fd, "1\n", 2); |
1115 | else | 1115 | else |
1116 | ::write(fd, "0\n", 2); | 1116 | ::write(fd, "0\n", 2); |
1117 | ::close(fd); | 1117 | ::close(fd); |
1118 | return true; | 1118 | return true; |
1119 | } | 1119 | } |
1120 | } | 1120 | } |
1121 | #endif | 1121 | #endif |
1122 | return false; | 1122 | return false; |
1123 | } | 1123 | } |
1124 | 1124 | ||
1125 | int Yopy::displayBrightnessResolution() const | 1125 | int Yopy::displayBrightnessResolution() const |
1126 | { | 1126 | { |
1127 | return 2; | 1127 | return 2; |
1128 | } | 1128 | } |
1129 | 1129 | ||
1130 | /************************************************** | 1130 | /************************************************** |
1131 | * | 1131 | * |
1132 | * iPAQ | 1132 | * iPAQ |
1133 | * | 1133 | * |
1134 | **************************************************/ | 1134 | **************************************************/ |
1135 | 1135 | ||
1136 | void iPAQ::init ( ) | 1136 | void iPAQ::init ( ) |
1137 | { | 1137 | { |
1138 | d-> m_vendorstr = "HP"; | 1138 | d-> m_vendorstr = "HP"; |
1139 | d-> m_vendor = Vendor_HP; | 1139 | d-> m_vendor = Vendor_HP; |
1140 | 1140 | ||
1141 | QFile f ( "/proc/hal/model" ); | 1141 | QFile f ( "/proc/hal/model" ); |
1142 | 1142 | ||
1143 | if ( f. open ( IO_ReadOnly )) { | 1143 | if ( f. open ( IO_ReadOnly )) { |
1144 | QTextStream ts ( &f ); | 1144 | QTextStream ts ( &f ); |
1145 | 1145 | ||
1146 | d-> m_modelstr = "H" + ts. readLine ( ); | 1146 | d-> m_modelstr = "H" + ts. readLine ( ); |
1147 | 1147 | ||
1148 | if ( d-> m_modelstr == "H3100" ) | 1148 | if ( d-> m_modelstr == "H3100" ) |
1149 | d-> m_model = Model_iPAQ_H31xx; | 1149 | d-> m_model = Model_iPAQ_H31xx; |
1150 | else if ( d-> m_modelstr == "H3600" ) | 1150 | else if ( d-> m_modelstr == "H3600" ) |
1151 | d-> m_model = Model_iPAQ_H36xx; | 1151 | d-> m_model = Model_iPAQ_H36xx; |
1152 | else if ( d-> m_modelstr == "H3700" ) | 1152 | else if ( d-> m_modelstr == "H3700" ) |
1153 | d-> m_model = Model_iPAQ_H37xx; | 1153 | d-> m_model = Model_iPAQ_H37xx; |
1154 | else if ( d-> m_modelstr == "H3800" ) | 1154 | else if ( d-> m_modelstr == "H3800" ) |
1155 | d-> m_model = Model_iPAQ_H38xx; | 1155 | d-> m_model = Model_iPAQ_H38xx; |
1156 | else if ( d-> m_modelstr == "H3900" ) | 1156 | else if ( d-> m_modelstr == "H3900" ) |
1157 | d-> m_model = Model_iPAQ_H39xx; | 1157 | d-> m_model = Model_iPAQ_H39xx; |
1158 | else if ( d-> m_modelstr == "H5400" ) | 1158 | else if ( d-> m_modelstr == "H5400" ) |
1159 | d-> m_model = Model_iPAQ_H5xxx; | 1159 | d-> m_model = Model_iPAQ_H5xxx; |
1160 | else | 1160 | else |
1161 | d-> m_model = Model_Unknown; | 1161 | d-> m_model = Model_Unknown; |
1162 | 1162 | ||
1163 | f. close ( ); | 1163 | f. close ( ); |
1164 | } | 1164 | } |
1165 | 1165 | ||
1166 | switch ( d-> m_model ) { | 1166 | switch ( d-> m_model ) { |
1167 | case Model_iPAQ_H31xx: | 1167 | case Model_iPAQ_H31xx: |
1168 | case Model_iPAQ_H38xx: | 1168 | case Model_iPAQ_H38xx: |
1169 | d-> m_rotation = Rot90; | 1169 | d-> m_rotation = Rot90; |
1170 | break; | 1170 | break; |
1171 | case Model_iPAQ_H36xx: | 1171 | case Model_iPAQ_H36xx: |
1172 | case Model_iPAQ_H37xx: | 1172 | case Model_iPAQ_H37xx: |
1173 | case Model_iPAQ_H39xx: | 1173 | case Model_iPAQ_H39xx: |
1174 | 1174 | ||
1175 | default: | 1175 | default: |
1176 | d-> m_rotation = Rot270; | 1176 | d-> m_rotation = Rot270; |
1177 | break; | 1177 | break; |
1178 | case Model_iPAQ_H5xxx: | 1178 | case Model_iPAQ_H5xxx: |
1179 | d-> m_rotation = Rot0; | 1179 | d-> m_rotation = Rot0; |
1180 | } | 1180 | } |
1181 | 1181 | ||
1182 | f. setName ( "/etc/familiar-version" ); | 1182 | f. setName ( "/etc/familiar-version" ); |
1183 | if ( f. open ( IO_ReadOnly )) { | 1183 | if ( f. open ( IO_ReadOnly )) { |
1184 | d-> m_systemstr = "Familiar"; | 1184 | d-> m_systemstr = "Familiar"; |
1185 | d-> m_system = System_Familiar; | 1185 | d-> m_system = System_Familiar; |
1186 | 1186 | ||
1187 | QTextStream ts ( &f ); | 1187 | QTextStream ts ( &f ); |
1188 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 1188 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
1189 | 1189 | ||
1190 | f. close ( ); | 1190 | f. close ( ); |
1191 | } else { | 1191 | } else { |
1192 | f. setName ( "/etc/oz_version" ); | 1192 | f. setName ( "/etc/oz_version" ); |
1193 | 1193 | ||
1194 | if ( f. open ( IO_ReadOnly )) { | 1194 | if ( f. open ( IO_ReadOnly )) { |
1195 | d-> m_systemstr = "OpenEmbedded/iPaq"; | 1195 | d-> m_systemstr = "OpenEmbedded/iPaq"; |
1196 | d-> m_system = System_Familiar; | 1196 | d-> m_system = System_Familiar; |
1197 | 1197 | ||
1198 | QTextStream ts ( &f ); | 1198 | QTextStream ts ( &f ); |
1199 | ts.setDevice ( &f ); | 1199 | ts.setDevice ( &f ); |
1200 | d-> m_sysverstr = ts. readLine ( ); | 1200 | d-> m_sysverstr = ts. readLine ( ); |
1201 | f. close ( ); | 1201 | f. close ( ); |
1202 | } | 1202 | } |
1203 | } | 1203 | } |
1204 | 1204 | ||
1205 | 1205 | ||
1206 | 1206 | ||
1207 | 1207 | ||
1208 | 1208 | ||
1209 | m_leds [0] = m_leds [1] = Led_Off; | 1209 | m_leds [0] = m_leds [1] = Led_Off; |
1210 | 1210 | ||
1211 | m_power_timer = 0; | 1211 | m_power_timer = 0; |
1212 | 1212 | ||
1213 | } | 1213 | } |
1214 | 1214 | ||
1215 | void iPAQ::initButtons ( ) | 1215 | void iPAQ::initButtons ( ) |
1216 | { | 1216 | { |
1217 | if ( d-> m_buttons ) | 1217 | if ( d-> m_buttons ) |
1218 | return; | 1218 | return; |
1219 | 1219 | ||
1220 | if ( isQWS( ) ) | 1220 | if ( isQWS( ) ) |
1221 | QWSServer::setKeyboardFilter ( this ); | 1221 | QWSServer::setKeyboardFilter ( this ); |
1222 | 1222 | ||
1223 | d-> m_buttons = new QValueList <ODeviceButton>; | 1223 | d-> m_buttons = new QValueList <ODeviceButton>; |
1224 | 1224 | ||
1225 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 1225 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
1226 | i_button *ib = ipaq_buttons + i; | 1226 | i_button *ib = ipaq_buttons + i; |
1227 | ODeviceButton b; | 1227 | ODeviceButton b; |
1228 | 1228 | ||
1229 | if (( ib-> model & d-> m_model ) == d-> m_model ) { | 1229 | if (( ib-> model & d-> m_model ) == d-> m_model ) { |
1230 | b. setKeycode ( ib-> code ); | 1230 | b. setKeycode ( ib-> code ); |
1231 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 1231 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
1232 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 1232 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
1233 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 1233 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
1234 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 1234 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
1235 | 1235 | ||
1236 | d-> m_buttons-> append ( b ); | 1236 | d-> m_buttons-> append ( b ); |
1237 | } | 1237 | } |
1238 | } | 1238 | } |
1239 | reloadButtonMapping ( ); | 1239 | reloadButtonMapping ( ); |
1240 | 1240 | ||
1241 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1241 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1242 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 1242 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
1243 | } | 1243 | } |
1244 | 1244 | ||
1245 | 1245 | ||
1246 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... | 1246 | //#include <linux/h3600_ts.h> // including kernel headers is evil ... |
1247 | 1247 | ||
1248 | typedef struct { | 1248 | typedef struct { |
1249 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ | 1249 | unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ |
1250 | unsigned char TotalTime; /* Units of 5 seconds */ | 1250 | unsigned char TotalTime; /* Units of 5 seconds */ |
1251 | unsigned char OnTime; /* units of 100m/s */ | 1251 | unsigned char OnTime; /* units of 100m/s */ |
1252 | unsigned char OffTime; /* units of 100m/s */ | 1252 | unsigned char OffTime; /* units of 100m/s */ |
1253 | } LED_IN; | 1253 | } LED_IN; |
1254 | 1254 | ||
1255 | typedef struct { | 1255 | typedef struct { |
1256 | unsigned char mode; | 1256 | unsigned char mode; |
1257 | unsigned char pwr; | 1257 | unsigned char pwr; |
1258 | unsigned char brightness; | 1258 | unsigned char brightness; |
1259 | } FLITE_IN; | 1259 | } FLITE_IN; |
1260 | 1260 | ||
1261 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) | 1261 | #define LED_ON OD_IOW( 'f', 5, LED_IN ) |
1262 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) | 1262 | #define FLITE_ON OD_IOW( 'f', 7, FLITE_IN ) |
1263 | 1263 | ||
1264 | 1264 | ||
1265 | QValueList <OLed> iPAQ::ledList ( ) const | 1265 | QValueList <OLed> iPAQ::ledList ( ) const |
1266 | { | 1266 | { |
1267 | QValueList <OLed> vl; | 1267 | QValueList <OLed> vl; |
1268 | vl << Led_Power; | 1268 | vl << Led_Power; |
1269 | 1269 | ||
1270 | if ( d-> m_model == Model_iPAQ_H38xx ) | 1270 | if ( d-> m_model == Model_iPAQ_H38xx ) |
1271 | vl << Led_BlueTooth; | 1271 | vl << Led_BlueTooth; |
1272 | return vl; | 1272 | return vl; |
1273 | } | 1273 | } |
1274 | 1274 | ||
1275 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const | 1275 | QValueList <OLedState> iPAQ::ledStateList ( OLed l ) const |
1276 | { | 1276 | { |
1277 | QValueList <OLedState> vl; | 1277 | QValueList <OLedState> vl; |
1278 | 1278 | ||
1279 | if ( l == Led_Power ) | 1279 | if ( l == Led_Power ) |
1280 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; | 1280 | vl << Led_Off << Led_On << Led_BlinkSlow << Led_BlinkFast; |
1281 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) | 1281 | else if ( l == Led_BlueTooth && d-> m_model == Model_iPAQ_H38xx ) |
1282 | vl << Led_Off; // << Led_On << ??? | 1282 | vl << Led_Off; // << Led_On << ??? |
1283 | 1283 | ||
1284 | return vl; | 1284 | return vl; |
1285 | } | 1285 | } |
1286 | 1286 | ||
1287 | OLedState iPAQ::ledState ( OLed l ) const | 1287 | OLedState iPAQ::ledState ( OLed l ) const |
1288 | { | 1288 | { |
1289 | switch ( l ) { | 1289 | switch ( l ) { |
1290 | case Led_Power: | 1290 | case Led_Power: |
1291 | return m_leds [0]; | 1291 | return m_leds [0]; |
1292 | case Led_BlueTooth: | 1292 | case Led_BlueTooth: |
1293 | return m_leds [1]; | 1293 | return m_leds [1]; |
1294 | default: | 1294 | default: |
1295 | return Led_Off; | 1295 | return Led_Off; |
1296 | } | 1296 | } |
1297 | } | 1297 | } |
1298 | 1298 | ||
1299 | bool iPAQ::setLedState ( OLed l, OLedState st ) | 1299 | bool iPAQ::setLedState ( OLed l, OLedState st ) |
1300 | { | 1300 | { |
1301 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); | 1301 | static int fd = ::open ( "/dev/touchscreen/0", O_RDWR | O_NONBLOCK ); |
1302 | 1302 | ||
1303 | if ( l == Led_Power ) { | 1303 | if ( l == Led_Power ) { |
1304 | if ( fd >= 0 ) { | 1304 | if ( fd >= 0 ) { |
1305 | LED_IN leds; | 1305 | LED_IN leds; |
1306 | ::memset ( &leds, 0, sizeof( leds )); | 1306 | ::memset ( &leds, 0, sizeof( leds )); |
1307 | leds. TotalTime = 0; | 1307 | leds. TotalTime = 0; |
1308 | leds. OnTime = 0; | 1308 | leds. OnTime = 0; |
1309 | leds. OffTime = 1; | 1309 | leds. OffTime = 1; |
1310 | leds. OffOnBlink = 2; | 1310 | leds. OffOnBlink = 2; |
1311 | 1311 | ||
1312 | switch ( st ) { | 1312 | switch ( st ) { |
1313 | case Led_Off : leds. OffOnBlink = 0; break; | 1313 | case Led_Off : leds. OffOnBlink = 0; break; |
1314 | case Led_On : leds. OffOnBlink = 1; break; | 1314 | case Led_On : leds. OffOnBlink = 1; break; |
1315 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 1315 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
1316 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 1316 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
1317 | } | 1317 | } |
1318 | 1318 | ||
1319 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 1319 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
1320 | m_leds [0] = st; | 1320 | m_leds [0] = st; |
1321 | return true; | 1321 | return true; |
1322 | } | 1322 | } |
1323 | } | 1323 | } |
1324 | } | 1324 | } |
1325 | return false; | 1325 | return false; |
1326 | } | 1326 | } |
1327 | 1327 | ||
1328 | 1328 | ||
1329 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 1329 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
1330 | { | 1330 | { |
1331 | int newkeycode = keycode; | 1331 | int newkeycode = keycode; |
1332 | 1332 | ||
1333 | switch ( keycode ) { | 1333 | switch ( keycode ) { |
1334 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 1334 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
1335 | case HardKey_Menu: { | 1335 | case HardKey_Menu: { |
1336 | if (( d-> m_model == Model_iPAQ_H38xx ) || | 1336 | if (( d-> m_model == Model_iPAQ_H38xx ) || |
1337 | ( d-> m_model == Model_iPAQ_H39xx ) || | 1337 | ( d-> m_model == Model_iPAQ_H39xx ) || |
1338 | ( d-> m_model == Model_iPAQ_H5xxx)) { | 1338 | ( d-> m_model == Model_iPAQ_H5xxx)) { |
1339 | newkeycode = HardKey_Mail; | 1339 | newkeycode = HardKey_Mail; |
1340 | } | 1340 | } |
1341 | break; | 1341 | break; |
1342 | } | 1342 | } |
1343 | 1343 | ||
1344 | // Rotate cursor keys 180° or 270° | 1344 | // Rotate cursor keys 180° or 270° |
1345 | case Key_Left : | 1345 | case Key_Left : |
1346 | case Key_Right: | 1346 | case Key_Right: |
1347 | case Key_Up : | 1347 | case Key_Up : |
1348 | case Key_Down : { | 1348 | case Key_Down : { |
1349 | 1349 | ||
1350 | if (( d-> m_model == Model_iPAQ_H31xx ) || | 1350 | if (( d-> m_model == Model_iPAQ_H31xx ) || |
1351 | ( d-> m_model == Model_iPAQ_H38xx )) { | 1351 | ( d-> m_model == Model_iPAQ_H38xx )) { |
1352 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 1352 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
1353 | } | 1353 | } |
1354 | // Rotate the cursor keys by 270° | 1354 | // Rotate the cursor keys by 270° |
1355 | // keycode - Key_Left = position of the button starting from left clockwise | 1355 | // keycode - Key_Left = position of the button starting from left clockwise |
1356 | // add the rotation to it and modolo. No we've the original offset | 1356 | // add the rotation to it and modolo. No we've the original offset |
1357 | // add the offset to the Key_Left key | 1357 | // add the offset to the Key_Left key |
1358 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 1358 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
1359 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 1359 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
1360 | break; | 1360 | break; |
1361 | } | 1361 | } |
1362 | 1362 | ||
1363 | // map Power Button short/long press to F34/F35 | 1363 | // map Power Button short/long press to F34/F35 |
1364 | case Key_SysReq: { | 1364 | case Key_SysReq: { |
1365 | if ( isPress ) { | 1365 | if ( isPress ) { |
1366 | if ( m_power_timer ) | 1366 | if ( m_power_timer ) |
1367 | killTimer ( m_power_timer ); | 1367 | killTimer ( m_power_timer ); |
1368 | m_power_timer = startTimer ( 500 ); | 1368 | m_power_timer = startTimer ( 500 ); |
1369 | } | 1369 | } |
1370 | else if ( m_power_timer ) { | 1370 | else if ( m_power_timer ) { |
1371 | killTimer ( m_power_timer ); | 1371 | killTimer ( m_power_timer ); |
1372 | m_power_timer = 0; | 1372 | m_power_timer = 0; |
1373 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 1373 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
1374 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 1374 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
1375 | } | 1375 | } |
1376 | newkeycode = Key_unknown; | 1376 | newkeycode = Key_unknown; |
1377 | break; | 1377 | break; |
1378 | } | 1378 | } |
1379 | } | 1379 | } |
1380 | 1380 | ||
1381 | if ( newkeycode != keycode ) { | 1381 | if ( newkeycode != keycode ) { |
1382 | if ( newkeycode != Key_unknown ) | 1382 | if ( newkeycode != Key_unknown ) |
1383 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); | 1383 | QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); |
1384 | return true; | 1384 | return true; |
1385 | } | 1385 | } |
1386 | else | 1386 | else |
1387 | return false; | 1387 | return false; |
1388 | } | 1388 | } |
1389 | 1389 | ||
1390 | void iPAQ::timerEvent ( QTimerEvent * ) | 1390 | void iPAQ::timerEvent ( QTimerEvent * ) |
1391 | { | 1391 | { |
1392 | killTimer ( m_power_timer ); | 1392 | killTimer ( m_power_timer ); |
1393 | m_power_timer = 0; | 1393 | m_power_timer = 0; |
1394 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 1394 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
1395 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 1395 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
1396 | } | 1396 | } |
1397 | 1397 | ||
1398 | 1398 | ||
1399 | void iPAQ::alarmSound ( ) | 1399 | void iPAQ::alarmSound ( ) |
1400 | { | 1400 | { |
1401 | #ifndef QT_NO_SOUND | 1401 | #ifndef QT_NO_SOUND |
1402 | static Sound snd ( "alarm" ); | 1402 | static Sound snd ( "alarm" ); |
1403 | int fd; | 1403 | int fd; |
1404 | int vol; | 1404 | int vol; |
1405 | bool vol_reset = false; | 1405 | bool vol_reset = false; |
1406 | 1406 | ||
1407 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1407 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1408 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1408 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1409 | Config cfg ( "qpe" ); | 1409 | Config cfg ( "qpe" ); |
1410 | cfg. setGroup ( "Volume" ); | 1410 | cfg. setGroup ( "Volume" ); |
1411 | 1411 | ||
1412 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1412 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1413 | if ( volalarm < 0 ) | 1413 | if ( volalarm < 0 ) |
1414 | volalarm = 0; | 1414 | volalarm = 0; |
1415 | else if ( volalarm > 100 ) | 1415 | else if ( volalarm > 100 ) |
1416 | volalarm = 100; | 1416 | volalarm = 100; |
1417 | volalarm |= ( volalarm << 8 ); | 1417 | volalarm |= ( volalarm << 8 ); |
1418 | 1418 | ||
1419 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1419 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1420 | vol_reset = true; | 1420 | vol_reset = true; |
1421 | } | 1421 | } |
1422 | } | 1422 | } |
1423 | 1423 | ||
1424 | snd. play ( ); | 1424 | snd. play ( ); |
1425 | while ( !snd. isFinished ( )) | 1425 | while ( !snd. isFinished ( )) |
1426 | qApp-> processEvents ( ); | 1426 | qApp-> processEvents ( ); |
1427 | 1427 | ||
1428 | if ( fd >= 0 ) { | 1428 | if ( fd >= 0 ) { |
1429 | if ( vol_reset ) | 1429 | if ( vol_reset ) |
1430 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1430 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1431 | ::close ( fd ); | 1431 | ::close ( fd ); |
1432 | } | 1432 | } |
1433 | #endif | 1433 | #endif |
1434 | } | 1434 | } |
1435 | 1435 | ||
1436 | 1436 | ||
1437 | bool iPAQ::setSoftSuspend ( bool soft ) | 1437 | bool iPAQ::setSoftSuspend ( bool soft ) |
1438 | { | 1438 | { |
1439 | bool res = false; | 1439 | bool res = false; |
1440 | int fd; | 1440 | int fd; |
1441 | 1441 | ||
1442 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 1442 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
1443 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 1443 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
1444 | res = true; | 1444 | res = true; |
1445 | else | 1445 | else |
1446 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 1446 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
1447 | 1447 | ||
1448 | ::close ( fd ); | 1448 | ::close ( fd ); |
1449 | } | 1449 | } |
1450 | else | 1450 | else |
1451 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 1451 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
1452 | 1452 | ||
1453 | return res; | 1453 | return res; |
1454 | } | 1454 | } |
1455 | 1455 | ||
1456 | 1456 | ||
1457 | bool iPAQ::setDisplayBrightness ( int bright ) | 1457 | bool iPAQ::setDisplayBrightness ( int bright ) |
1458 | { | 1458 | { |
1459 | bool res = false; | 1459 | bool res = false; |
1460 | int fd; | 1460 | int fd; |
1461 | 1461 | ||
1462 | if ( bright > 255 ) | 1462 | if ( bright > 255 ) |
1463 | bright = 255; | 1463 | bright = 255; |
1464 | if ( bright < 0 ) | 1464 | if ( bright < 0 ) |
1465 | bright = 0; | 1465 | bright = 0; |
1466 | 1466 | ||
1467 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 1467 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
1468 | FLITE_IN bl; | 1468 | FLITE_IN bl; |
1469 | bl. mode = 1; | 1469 | bl. mode = 1; |
1470 | bl. pwr = bright ? 1 : 0; | 1470 | bl. pwr = bright ? 1 : 0; |
1471 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 1471 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
1472 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 1472 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
1473 | ::close ( fd ); | 1473 | ::close ( fd ); |
1474 | } | 1474 | } |
1475 | return res; | 1475 | return res; |
1476 | } | 1476 | } |
1477 | 1477 | ||
1478 | int iPAQ::displayBrightnessResolution ( ) const | 1478 | int iPAQ::displayBrightnessResolution ( ) const |
1479 | { | 1479 | { |
1480 | switch ( model ( )) { | 1480 | switch ( model ( )) { |
1481 | case Model_iPAQ_H31xx: | 1481 | case Model_iPAQ_H31xx: |
1482 | case Model_iPAQ_H36xx: | 1482 | case Model_iPAQ_H36xx: |
1483 | case Model_iPAQ_H37xx: | 1483 | case Model_iPAQ_H37xx: |
1484 | return 128; // really 256, but >128 could damage the LCD | 1484 | return 128; // really 256, but >128 could damage the LCD |
1485 | 1485 | ||
1486 | case Model_iPAQ_H38xx: | 1486 | case Model_iPAQ_H38xx: |
1487 | case Model_iPAQ_H39xx: | 1487 | case Model_iPAQ_H39xx: |
1488 | return 64; | 1488 | return 64; |
1489 | case Model_iPAQ_H5xxx: | 1489 | case Model_iPAQ_H5xxx: |
1490 | return 255; | 1490 | return 255; |
1491 | 1491 | ||
1492 | default: | 1492 | default: |
1493 | return 2; | 1493 | return 2; |
1494 | } | 1494 | } |
1495 | } | 1495 | } |
1496 | 1496 | ||
1497 | 1497 | ||
1498 | bool iPAQ::hasLightSensor ( ) const | 1498 | bool iPAQ::hasLightSensor ( ) const |
1499 | { | 1499 | { |
1500 | return true; | 1500 | return true; |
1501 | } | 1501 | } |
1502 | 1502 | ||
1503 | int iPAQ::readLightSensor ( ) | 1503 | int iPAQ::readLightSensor ( ) |
1504 | { | 1504 | { |
1505 | int fd; | 1505 | int fd; |
1506 | int val = -1; | 1506 | int val = -1; |
1507 | 1507 | ||
1508 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 1508 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
1509 | char buffer [8]; | 1509 | char buffer [8]; |
1510 | 1510 | ||
1511 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 1511 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
1512 | char *endptr; | 1512 | char *endptr; |
1513 | 1513 | ||
1514 | buffer [4] = 0; | 1514 | buffer [4] = 0; |
1515 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 1515 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
1516 | 1516 | ||
1517 | if ( *endptr != 0 ) | 1517 | if ( *endptr != 0 ) |
1518 | val = -1; | 1518 | val = -1; |
1519 | } | 1519 | } |
1520 | ::close ( fd ); | 1520 | ::close ( fd ); |
1521 | } | 1521 | } |
1522 | 1522 | ||
1523 | return val; | 1523 | return val; |
1524 | } | 1524 | } |
1525 | 1525 | ||
1526 | int iPAQ::lightSensorResolution ( ) const | 1526 | int iPAQ::lightSensorResolution ( ) const |
1527 | { | 1527 | { |
1528 | return 256; | 1528 | return 256; |
1529 | } | 1529 | } |
1530 | 1530 | ||
1531 | /************************************************** | 1531 | /************************************************** |
1532 | * | 1532 | * |
1533 | * Zaurus | 1533 | * Zaurus |
1534 | * | 1534 | * |
1535 | **************************************************/ | 1535 | **************************************************/ |
1536 | 1536 | ||
1537 | // Check whether this device is the sharp zaurus.. | 1537 | // Check whether this device is the sharp zaurus.. |
1538 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus | 1538 | // FIXME This gets unnecessary complicated. We should think about splitting the Zaurus |
1539 | // class up into individual classes. We need three classes | 1539 | // class up into individual classes. We need three classes |
1540 | // | 1540 | // |
1541 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) | 1541 | // Zaurus-Collie (SA-model w/ 320x240 lcd, for SL5500 and SL5000) |
1542 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) | 1542 | // Zaurus-Poodle (PXA-model w/ 320x240 lcd, for SL5600) |
1543 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) | 1543 | // Zaurus-Corgi (PXA-model w/ 640x480 lcd, for C700, C750, C760, and C860) |
1544 | // | 1544 | // |
1545 | // Only question right now is: Do we really need to do it? Because as soon | 1545 | // Only question right now is: Do we really need to do it? Because as soon |
1546 | // as the OpenZaurus kernel is ready, there will be a unified interface for all | 1546 | // as the OpenZaurus kernel is ready, there will be a unified interface for all |
1547 | // Zaurus models (concerning apm, backlight, buttons, etc.) | 1547 | // Zaurus models (concerning apm, backlight, buttons, etc.) |
1548 | // | 1548 | // |
1549 | // Comments? - mickeyl. | 1549 | // Comments? - mickeyl. |
1550 | 1550 | ||
1551 | bool Zaurus::isZaurus() | 1551 | bool Zaurus::isZaurus() |
1552 | { | 1552 | { |
1553 | 1553 | ||
1554 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! | 1554 | // If the special devices by embedix exist, it is quite simple: it is a Zaurus ! |
1555 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ | 1555 | if ( QFile::exists ( "/dev/sharp_buz" ) || QFile::exists ( "/dev/sharp_led" ) ){ |
1556 | return true; | 1556 | return true; |
1557 | } | 1557 | } |
1558 | 1558 | ||
1559 | // On non-embedix kernels, we have to look closer. | 1559 | // On non-embedix kernels, we have to look closer. |
1560 | bool is_zaurus = false; | 1560 | bool is_zaurus = false; |
1561 | QFile f ( "/proc/cpuinfo" ); | 1561 | QFile f ( "/proc/cpuinfo" ); |
1562 | if ( f. open ( IO_ReadOnly ) ) { | 1562 | if ( f. open ( IO_ReadOnly ) ) { |
1563 | QString model; | 1563 | QString model; |
1564 | QFile f ( "/proc/cpuinfo" ); | 1564 | QFile f ( "/proc/cpuinfo" ); |
1565 | 1565 | ||
1566 | QTextStream ts ( &f ); | 1566 | QTextStream ts ( &f ); |
1567 | QString line; | 1567 | QString line; |
1568 | while( line = ts. readLine ( ) ) { | 1568 | while( line = ts. readLine ( ) ) { |
1569 | if ( line. left ( 8 ) == "Hardware" ) | 1569 | if ( line. left ( 8 ) == "Hardware" ) |
1570 | break; | 1570 | break; |
1571 | } | 1571 | } |
1572 | int loc = line. find ( ":" ); | 1572 | int loc = line. find ( ":" ); |
1573 | if ( loc != -1 ) | 1573 | if ( loc != -1 ) |
1574 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1574 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1575 | 1575 | ||
1576 | if ( model == "Sharp-Collie" | 1576 | if ( model == "Sharp-Collie" |
1577 | || model == "Collie" | 1577 | || model == "Collie" |
1578 | || model == "SHARP Corgi" | 1578 | || model == "SHARP Corgi" |
1579 | || model == "SHARP Shepherd" | 1579 | || model == "SHARP Shepherd" |
1580 | || model == "SHARP Poodle" | 1580 | || model == "SHARP Poodle" |
1581 | || model == "SHARP Husky" | 1581 | || model == "SHARP Husky" |
1582 | ) | 1582 | ) |
1583 | is_zaurus = true; | 1583 | is_zaurus = true; |
1584 | 1584 | ||
1585 | } | 1585 | } |
1586 | return is_zaurus; | 1586 | return is_zaurus; |
1587 | } | 1587 | } |
1588 | 1588 | ||
1589 | 1589 | ||
1590 | void Zaurus::init ( ) | 1590 | void Zaurus::init ( ) |
1591 | { | 1591 | { |
1592 | d-> m_vendorstr = "Sharp"; | 1592 | d-> m_vendorstr = "Sharp"; |
1593 | d-> m_vendor = Vendor_Sharp; | 1593 | d-> m_vendor = Vendor_Sharp; |
1594 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! | 1594 | m_embedix = true; // Not openzaurus means: It has an embedix kernel ! |
1595 | 1595 | ||
1596 | // QFile f ( "/proc/filesystems" ); | 1596 | // QFile f ( "/proc/filesystems" ); |
1597 | QString model; | 1597 | QString model; |
1598 | 1598 | ||
1599 | // It isn't a good idea to check the system configuration to | 1599 | // It isn't a good idea to check the system configuration to |
1600 | // detect the distribution ! | 1600 | // detect the distribution ! |
1601 | // Otherwise it may happen that any other distribution is detected as openzaurus, just | 1601 | // Otherwise it may happen that any other distribution is detected as openzaurus, just |
1602 | // because it uses a jffs2 filesystem.. | 1602 | // because it uses a jffs2 filesystem.. |
1603 | // (eilers) | 1603 | // (eilers) |
1604 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { | 1604 | // if ( f. open ( IO_ReadOnly ) && ( QTextStream ( &f ). read ( ). find ( "\tjffs2\n" ) >= 0 )) { |
1605 | QFile f ("/etc/oz_version"); | 1605 | QFile f ("/etc/oz_version"); |
1606 | if ( f.exists() ){ | 1606 | if ( f.exists() ){ |
1607 | d-> m_vendorstr = "OpenZaurus Team"; | 1607 | d-> m_vendorstr = "OpenZaurus Team"; |
1608 | d-> m_systemstr = "OpenZaurus"; | 1608 | d-> m_systemstr = "OpenZaurus"; |
1609 | d-> m_system = System_OpenZaurus; | 1609 | d-> m_system = System_OpenZaurus; |
1610 | 1610 | ||
1611 | if ( f. open ( IO_ReadOnly )) { | 1611 | if ( f. open ( IO_ReadOnly )) { |
1612 | QTextStream ts ( &f ); | 1612 | QTextStream ts ( &f ); |
1613 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); | 1613 | d-> m_sysverstr = ts. readLine ( );//. mid ( 10 ); |
1614 | f. close ( ); | 1614 | f. close ( ); |
1615 | } | 1615 | } |
1616 | 1616 | ||
1617 | // Openzaurus sometimes uses the embedix kernel! | 1617 | // Openzaurus sometimes uses the embedix kernel! |
1618 | // => Check whether this is an embedix kernel | 1618 | // => Check whether this is an embedix kernel |
1619 | FILE *uname = popen("uname -r", "r"); | 1619 | FILE *uname = popen("uname -r", "r"); |
1620 | QString line; | 1620 | QString line; |
1621 | if ( f.open(IO_ReadOnly, uname) ) { | 1621 | if ( f.open(IO_ReadOnly, uname) ) { |
1622 | QTextStream ts ( &f ); | 1622 | QTextStream ts ( &f ); |
1623 | line = ts. readLine ( ); | 1623 | line = ts. readLine ( ); |
1624 | int loc = line. find ( "embedix" ); | 1624 | int loc = line. find ( "embedix" ); |
1625 | if ( loc != -1 ) | 1625 | if ( loc != -1 ) |
1626 | m_embedix = true; | 1626 | m_embedix = true; |
1627 | else | 1627 | else |
1628 | m_embedix = false; | 1628 | m_embedix = false; |
1629 | f. close ( ); | 1629 | f. close ( ); |
1630 | } | 1630 | } |
1631 | pclose(uname); | 1631 | pclose(uname); |
1632 | } | 1632 | } |
1633 | else { | 1633 | else { |
1634 | d-> m_systemstr = "Zaurus"; | 1634 | d-> m_systemstr = "Zaurus"; |
1635 | d-> m_system = System_Zaurus; | 1635 | d-> m_system = System_Zaurus; |
1636 | } | 1636 | } |
1637 | 1637 | ||
1638 | f. setName ( "/proc/cpuinfo" ); | 1638 | f. setName ( "/proc/cpuinfo" ); |
1639 | if ( f. open ( IO_ReadOnly ) ) { | 1639 | if ( f. open ( IO_ReadOnly ) ) { |
1640 | QTextStream ts ( &f ); | 1640 | QTextStream ts ( &f ); |
1641 | QString line; | 1641 | QString line; |
1642 | while( line = ts. readLine ( ) ) { | 1642 | while( line = ts. readLine ( ) ) { |
1643 | if ( line. left ( 8 ) == "Hardware" ) | 1643 | if ( line. left ( 8 ) == "Hardware" ) |
1644 | break; | 1644 | break; |
1645 | } | 1645 | } |
1646 | int loc = line. find ( ":" ); | 1646 | int loc = line. find ( ":" ); |
1647 | if ( loc != -1 ) | 1647 | if ( loc != -1 ) |
1648 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 1648 | model = line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
1649 | } | 1649 | } |
1650 | 1650 | ||
1651 | if ( model == "SHARP Corgi" ) { | 1651 | if ( model == "SHARP Corgi" ) { |
1652 | d-> m_model = Model_Zaurus_SLC7x0; | 1652 | d-> m_model = Model_Zaurus_SLC7x0; |
1653 | d-> m_modelstr = "Zaurus SL-C700"; | 1653 | d-> m_modelstr = "Zaurus SL-C700"; |
1654 | } else if ( model == "SHARP Shepherd" ) { | 1654 | } else if ( model == "SHARP Shepherd" ) { |
1655 | d-> m_model = Model_Zaurus_SLC7x0; | 1655 | d-> m_model = Model_Zaurus_SLC7x0; |
1656 | d-> m_modelstr = "Zaurus SL-C750"; | 1656 | d-> m_modelstr = "Zaurus SL-C750"; |
1657 | } else if ( model == "SHARP Husky" ) { | 1657 | } else if ( model == "SHARP Husky" ) { |
1658 | d-> m_model = Model_Zaurus_SLC7x0; | 1658 | d-> m_model = Model_Zaurus_SLC7x0; |
1659 | d-> m_modelstr = "Zaurus SL-C760"; | 1659 | d-> m_modelstr = "Zaurus SL-C760"; |
1660 | } else if ( model == "SHARP Poodle" ) { | 1660 | } else if ( model == "SHARP Poodle" ) { |
1661 | d-> m_model = Model_Zaurus_SLB600; | 1661 | d-> m_model = Model_Zaurus_SLB600; |
1662 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; | 1662 | d-> m_modelstr = "Zaurus SL-B500 or SL-5600"; |
1663 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { | 1663 | } else if ( model == "Sharp-Collie" || model == "Collie" ) { |
1664 | d-> m_model = Model_Zaurus_SL5500; | 1664 | d-> m_model = Model_Zaurus_SL5500; |
1665 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; | 1665 | d-> m_modelstr = "Zaurus SL-5500 or SL-5000d"; |
1666 | } else { | 1666 | } else { |
1667 | d-> m_model = Model_Zaurus_SL5500; | 1667 | d-> m_model = Model_Zaurus_SL5500; |
1668 | d-> m_modelstr = "Zaurus (Model unknown)"; | 1668 | d-> m_modelstr = "Zaurus (Model unknown)"; |
1669 | } | 1669 | } |
1670 | 1670 | ||
1671 | bool flipstate = false; | ||
1672 | switch ( d-> m_model ) { | 1671 | switch ( d-> m_model ) { |
1673 | case Model_Zaurus_SLA300: | 1672 | case Model_Zaurus_SLA300: |
1674 | d-> m_rotation = Rot0; | 1673 | d-> m_rotation = Rot0; |
1675 | break; | 1674 | break; |
1676 | case Model_Zaurus_SLC7x0: | 1675 | case Model_Zaurus_SLC7x0: |
1677 | d-> m_rotation = rotation(); | 1676 | d-> m_rotation = rotation(); |
1678 | d-> m_direction = direction(); | 1677 | d-> m_direction = direction(); |
1679 | break; | 1678 | break; |
1680 | case Model_Zaurus_SLB600: | 1679 | case Model_Zaurus_SLB600: |
1681 | case Model_Zaurus_SL5500: | 1680 | case Model_Zaurus_SL5500: |
1682 | case Model_Zaurus_SL5000: | 1681 | case Model_Zaurus_SL5000: |
1683 | default: | 1682 | default: |
1684 | d-> m_rotation = Rot270; | 1683 | d-> m_rotation = Rot270; |
1685 | break; | 1684 | break; |
1686 | } | 1685 | } |
1687 | m_leds [0] = Led_Off; | 1686 | m_leds [0] = Led_Off; |
1688 | } | 1687 | } |
1689 | 1688 | ||
1690 | void Zaurus::initButtons ( ) | 1689 | void Zaurus::initButtons ( ) |
1691 | { | 1690 | { |
1692 | if ( d-> m_buttons ) | 1691 | if ( d-> m_buttons ) |
1693 | return; | 1692 | return; |
1694 | 1693 | ||
1695 | d-> m_buttons = new QValueList <ODeviceButton>; | 1694 | d-> m_buttons = new QValueList <ODeviceButton>; |
1696 | 1695 | ||
1697 | struct z_button * pz_buttons; | 1696 | struct z_button * pz_buttons; |
1698 | int buttoncount; | 1697 | int buttoncount; |
1699 | switch ( d-> m_model ) { | 1698 | switch ( d-> m_model ) { |
1700 | case Model_Zaurus_SLC7x0: | 1699 | case Model_Zaurus_SLC7x0: |
1701 | pz_buttons = z_buttons_c700; | 1700 | pz_buttons = z_buttons_c700; |
1702 | buttoncount = ARRAY_SIZE(z_buttons_c700); | 1701 | buttoncount = ARRAY_SIZE(z_buttons_c700); |
1703 | break; | 1702 | break; |
1704 | default: | 1703 | default: |
1705 | pz_buttons = z_buttons; | 1704 | pz_buttons = z_buttons; |
1706 | buttoncount = ARRAY_SIZE(z_buttons); | 1705 | buttoncount = ARRAY_SIZE(z_buttons); |
1707 | break; | 1706 | break; |
1708 | } | 1707 | } |
1709 | 1708 | ||
1710 | for ( int i = 0; i < buttoncount; i++ ) { | 1709 | for ( int i = 0; i < buttoncount; i++ ) { |
1711 | struct z_button *zb = pz_buttons + i; | 1710 | struct z_button *zb = pz_buttons + i; |
1712 | ODeviceButton b; | 1711 | ODeviceButton b; |
1713 | 1712 | ||
1714 | b. setKeycode ( zb-> code ); | 1713 | b. setKeycode ( zb-> code ); |
1715 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); | 1714 | b. setUserText ( QObject::tr ( "Button", zb-> utext )); |
1716 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); | 1715 | b. setPixmap ( Resource::loadPixmap ( zb-> pix )); |
1717 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), | 1716 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb-> fpressedservice ), |
1718 | zb-> fpressedaction )); | 1717 | zb-> fpressedaction )); |
1719 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), | 1718 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( zb-> fheldservice ), |
1720 | zb-> fheldaction )); | 1719 | zb-> fheldaction )); |
1721 | 1720 | ||
1722 | d-> m_buttons-> append ( b ); | 1721 | d-> m_buttons-> append ( b ); |
1723 | } | 1722 | } |
1724 | 1723 | ||
1725 | reloadButtonMapping ( ); | 1724 | reloadButtonMapping ( ); |
1726 | 1725 | ||
1727 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 1726 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
1728 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), | 1727 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), |
1729 | this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 1728 | this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
1730 | } | 1729 | } |
1731 | 1730 | ||
1732 | #include <unistd.h> | 1731 | #include <unistd.h> |
1733 | #include <fcntl.h> | 1732 | #include <fcntl.h> |
1734 | #include <sys/ioctl.h> | 1733 | #include <sys/ioctl.h> |
1735 | 1734 | ||
1736 | //#include <asm/sharp_char.h> // including kernel headers is evil ... | 1735 | //#include <asm/sharp_char.h> // including kernel headers is evil ... |
1737 | 1736 | ||
1738 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 1737 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
1739 | 1738 | ||
1740 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1739 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1741 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1740 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1742 | 1741 | ||
1743 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1742 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1744 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1743 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1745 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1744 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1746 | 1745 | ||
1747 | /* --- for SHARP_BUZZER device --- */ | 1746 | /* --- for SHARP_BUZZER device --- */ |
1748 | 1747 | ||
1749 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1748 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1750 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 1749 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
1751 | 1750 | ||
1752 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 1751 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
1753 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 1752 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
1754 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 1753 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
1755 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 1754 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
1756 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 1755 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
1757 | 1756 | ||
1758 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 1757 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
1759 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 1758 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
1760 | 1759 | ||
1761 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 1760 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
1762 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 1761 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
1763 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 1762 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
1764 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 1763 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
1765 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 1764 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
1766 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 1765 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
1767 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 1766 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
1768 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 1767 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
1769 | 1768 | ||
1770 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 1769 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
1771 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 1770 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
1772 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 1771 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
1773 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 1772 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
1774 | // | 1773 | // |
1775 | 1774 | ||
1776 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 1775 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
1777 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 1776 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
1778 | 1777 | ||
1779 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 1778 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
1780 | 1779 | ||
1781 | typedef struct sharp_led_status { | 1780 | typedef struct sharp_led_status { |
1782 | int which; /* select which LED status is wanted. */ | 1781 | int which; /* select which LED status is wanted. */ |
1783 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 1782 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
1784 | } sharp_led_status; | 1783 | } sharp_led_status; |
1785 | 1784 | ||
1786 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 1785 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
1787 | 1786 | ||
1788 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 1787 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
1789 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 1788 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
1790 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 1789 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
1791 | 1790 | ||
1792 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 1791 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
1793 | 1792 | ||
1794 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 1793 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
1795 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 1794 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
1796 | #define APM_EVT_POWER_BUTTON (1 << 0) | 1795 | #define APM_EVT_POWER_BUTTON (1 << 0) |
1797 | 1796 | ||
1798 | #define FL_IOCTL_STEP_CONTRAST 100 | 1797 | #define FL_IOCTL_STEP_CONTRAST 100 |
1799 | 1798 | ||
1800 | 1799 | ||
1801 | void Zaurus::buzzer ( int sound ) | 1800 | void Zaurus::buzzer ( int sound ) |
1802 | { | 1801 | { |
1803 | #ifndef QT_NO_SOUND | 1802 | #ifndef QT_NO_SOUND |
1804 | QString soundname; | 1803 | QString soundname; |
1805 | 1804 | ||
1806 | // Not all devices have real sound | 1805 | // Not all devices have real sound |
1807 | if ( d->m_model == Model_Zaurus_SLC7x0 | 1806 | if ( d->m_model == Model_Zaurus_SLC7x0 |
1808 | || d->m_model == Model_Zaurus_SLB600 ){ | 1807 | || d->m_model == Model_Zaurus_SLB600 ){ |
1809 | 1808 | ||
1810 | switch ( sound ){ | 1809 | switch ( sound ){ |
1811 | case SHARP_BUZ_SCHEDULE_ALARM: | 1810 | case SHARP_BUZ_SCHEDULE_ALARM: |
1812 | soundname = "alarm"; | 1811 | soundname = "alarm"; |
1813 | break; | 1812 | break; |
1814 | case SHARP_BUZ_TOUCHSOUND: | 1813 | case SHARP_BUZ_TOUCHSOUND: |
1815 | soundname = "touchsound"; | 1814 | soundname = "touchsound"; |
1816 | break; | 1815 | break; |
1817 | case SHARP_BUZ_KEYSOUND: | 1816 | case SHARP_BUZ_KEYSOUND: |
1818 | soundname = "keysound"; | 1817 | soundname = "keysound"; |
1819 | break; | 1818 | break; |
1820 | default: | 1819 | default: |
1821 | soundname = "alarm"; | 1820 | soundname = "alarm"; |
1822 | 1821 | ||
1823 | } | 1822 | } |
1824 | } | 1823 | } |
1825 | 1824 | ||
1826 | // If a soundname is defined, we expect that this device has | 1825 | // If a soundname is defined, we expect that this device has |
1827 | // sound capabilities.. Otherwise we expect to have the buzzer | 1826 | // sound capabilities.. Otherwise we expect to have the buzzer |
1828 | // device.. | 1827 | // device.. |
1829 | if ( !soundname.isEmpty() ){ | 1828 | if ( !soundname.isEmpty() ){ |
1830 | int fd; | 1829 | int fd; |
1831 | int vol; | 1830 | int vol; |
1832 | bool vol_reset = false; | 1831 | bool vol_reset = false; |
1833 | 1832 | ||
1834 | Sound snd ( soundname ); | 1833 | Sound snd ( soundname ); |
1835 | 1834 | ||
1836 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 1835 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
1837 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 1836 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
1838 | Config cfg ( "qpe" ); | 1837 | Config cfg ( "qpe" ); |
1839 | cfg. setGroup ( "Volume" ); | 1838 | cfg. setGroup ( "Volume" ); |
1840 | 1839 | ||
1841 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 1840 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
1842 | if ( volalarm < 0 ) | 1841 | if ( volalarm < 0 ) |
1843 | volalarm = 0; | 1842 | volalarm = 0; |
1844 | else if ( volalarm > 100 ) | 1843 | else if ( volalarm > 100 ) |
1845 | volalarm = 100; | 1844 | volalarm = 100; |
1846 | volalarm |= ( volalarm << 8 ); | 1845 | volalarm |= ( volalarm << 8 ); |
1847 | 1846 | ||
1848 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 1847 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
1849 | vol_reset = true; | 1848 | vol_reset = true; |
1850 | } | 1849 | } |
1851 | } | 1850 | } |
1852 | 1851 | ||
1853 | snd. play ( ); | 1852 | snd. play ( ); |
1854 | while ( !snd. isFinished ( )) | 1853 | while ( !snd. isFinished ( )) |
1855 | qApp-> processEvents ( ); | 1854 | qApp-> processEvents ( ); |
1856 | 1855 | ||
1857 | if ( fd >= 0 ) { | 1856 | if ( fd >= 0 ) { |
1858 | if ( vol_reset ) | 1857 | if ( vol_reset ) |
1859 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 1858 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
1860 | ::close ( fd ); | 1859 | ::close ( fd ); |
1861 | } | 1860 | } |
1862 | } else { | 1861 | } else { |
1863 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 1862 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
1864 | 1863 | ||
1865 | if ( fd >= 0 ) { | 1864 | if ( fd >= 0 ) { |
1866 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 1865 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
1867 | ::close ( fd ); | 1866 | ::close ( fd ); |
1868 | } | 1867 | } |
1869 | 1868 | ||
1870 | } | 1869 | } |
1871 | #endif | 1870 | #endif |
1872 | } | 1871 | } |
1873 | 1872 | ||
1874 | 1873 | ||
1875 | void Zaurus::alarmSound ( ) | 1874 | void Zaurus::alarmSound ( ) |
1876 | { | 1875 | { |
1877 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 1876 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
1878 | } | 1877 | } |
1879 | 1878 | ||
1880 | void Zaurus::touchSound ( ) | 1879 | void Zaurus::touchSound ( ) |
1881 | { | 1880 | { |
1882 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 1881 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
1883 | } | 1882 | } |
1884 | 1883 | ||
1885 | void Zaurus::keySound ( ) | 1884 | void Zaurus::keySound ( ) |
1886 | { | 1885 | { |
1887 | buzzer ( SHARP_BUZ_KEYSOUND ); | 1886 | buzzer ( SHARP_BUZ_KEYSOUND ); |
1888 | } | 1887 | } |
1889 | 1888 | ||
1890 | 1889 | ||
1891 | QValueList <OLed> Zaurus::ledList ( ) const | 1890 | QValueList <OLed> Zaurus::ledList ( ) const |
1892 | { | 1891 | { |
1893 | QValueList <OLed> vl; | 1892 | QValueList <OLed> vl; |
1894 | vl << Led_Mail; | 1893 | vl << Led_Mail; |
1895 | return vl; | 1894 | return vl; |
1896 | } | 1895 | } |
1897 | 1896 | ||
1898 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 1897 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
1899 | { | 1898 | { |
1900 | QValueList <OLedState> vl; | 1899 | QValueList <OLedState> vl; |
1901 | 1900 | ||
1902 | if ( l == Led_Mail ) | 1901 | if ( l == Led_Mail ) |
1903 | vl << Led_Off << Led_On << Led_BlinkSlow; | 1902 | vl << Led_Off << Led_On << Led_BlinkSlow; |
1904 | return vl; | 1903 | return vl; |
1905 | } | 1904 | } |
1906 | 1905 | ||
1907 | OLedState Zaurus::ledState ( OLed which ) const | 1906 | OLedState Zaurus::ledState ( OLed which ) const |
1908 | { | 1907 | { |
1909 | if ( which == Led_Mail ) | 1908 | if ( which == Led_Mail ) |
1910 | return m_leds [0]; | 1909 | return m_leds [0]; |
1911 | else | 1910 | else |
1912 | return Led_Off; | 1911 | return Led_Off; |
1913 | } | 1912 | } |
1914 | 1913 | ||
1915 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 1914 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
1916 | { | 1915 | { |
1917 | if (!m_embedix) // Currently not supported on non_embedix kernels | 1916 | if (!m_embedix) // Currently not supported on non_embedix kernels |
1918 | return false; | 1917 | return false; |
1919 | 1918 | ||
1920 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 1919 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
1921 | 1920 | ||
1922 | if ( which == Led_Mail ) { | 1921 | if ( which == Led_Mail ) { |
1923 | if ( fd >= 0 ) { | 1922 | if ( fd >= 0 ) { |
1924 | struct sharp_led_status leds; | 1923 | struct sharp_led_status leds; |
1925 | ::memset ( &leds, 0, sizeof( leds )); | 1924 | ::memset ( &leds, 0, sizeof( leds )); |
1926 | leds. which = SHARP_LED_MAIL_EXISTS; | 1925 | leds. which = SHARP_LED_MAIL_EXISTS; |
1927 | bool ok = true; | 1926 | bool ok = true; |
1928 | 1927 | ||
1929 | switch ( st ) { | 1928 | switch ( st ) { |
1930 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 1929 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
1931 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 1930 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
1932 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 1931 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
1933 | default : ok = false; | 1932 | default : ok = false; |
1934 | } | 1933 | } |
1935 | 1934 | ||
1936 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 1935 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
1937 | m_leds [0] = st; | 1936 | m_leds [0] = st; |
1938 | return true; | 1937 | return true; |
1939 | } | 1938 | } |
1940 | } | 1939 | } |
1941 | } | 1940 | } |
1942 | return false; | 1941 | return false; |
1943 | } | 1942 | } |
1944 | 1943 | ||
1945 | bool Zaurus::setSoftSuspend ( bool soft ) | 1944 | bool Zaurus::setSoftSuspend ( bool soft ) |
1946 | { | 1945 | { |
1947 | if (!m_embedix) { | 1946 | if (!m_embedix) { |
1948 | /* non-Embedix kernels dont have kernel autosuspend */ | 1947 | /* non-Embedix kernels dont have kernel autosuspend */ |
1949 | return ODevice::setSoftSuspend( soft ); | 1948 | return ODevice::setSoftSuspend( soft ); |
1950 | } | 1949 | } |
1951 | 1950 | ||
1952 | bool res = false; | 1951 | bool res = false; |
1953 | int fd; | 1952 | int fd; |
1954 | 1953 | ||
1955 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 1954 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
1956 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 1955 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
1957 | 1956 | ||
1958 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 1957 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |
1959 | 1958 | ||
1960 | if ( sources >= 0 ) { | 1959 | if ( sources >= 0 ) { |
1961 | if ( soft ) | 1960 | if ( soft ) |
1962 | sources &= ~APM_EVT_POWER_BUTTON; | 1961 | sources &= ~APM_EVT_POWER_BUTTON; |
1963 | else | 1962 | else |
1964 | sources |= APM_EVT_POWER_BUTTON; | 1963 | sources |= APM_EVT_POWER_BUTTON; |
1965 | 1964 | ||
1966 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources | 1965 | if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources |
1967 | res = true; | 1966 | res = true; |
1968 | else | 1967 | else |
1969 | perror ( "APM_IOCGEVTSRC" ); | 1968 | perror ( "APM_IOCGEVTSRC" ); |
1970 | } | 1969 | } |
1971 | else | 1970 | else |
1972 | perror ( "APM_IOCGEVTSRC" ); | 1971 | perror ( "APM_IOCGEVTSRC" ); |
1973 | 1972 | ||
1974 | ::close ( fd ); | 1973 | ::close ( fd ); |
1975 | } | 1974 | } |
1976 | else | 1975 | else |
1977 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); | 1976 | perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); |
1978 | 1977 | ||
1979 | return res; | 1978 | return res; |
1980 | } | 1979 | } |
1981 | 1980 | ||
1982 | 1981 | ||
1983 | bool Zaurus::setDisplayBrightness ( int bright ) | 1982 | bool Zaurus::setDisplayBrightness ( int bright ) |
1984 | { | 1983 | { |
1985 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); | 1984 | //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); |
1986 | bool res = false; | 1985 | bool res = false; |
1987 | int fd; | 1986 | int fd; |
1988 | 1987 | ||
1989 | if ( bright > 255 ) bright = 255; | 1988 | if ( bright > 255 ) bright = 255; |
1990 | if ( bright < 0 ) bright = 0; | 1989 | if ( bright < 0 ) bright = 0; |
1991 | 1990 | ||
1992 | if ( m_embedix ) | 1991 | if ( m_embedix ) |
1993 | { | 1992 | { |
1994 | if ( d->m_model == Model_Zaurus_SLC7x0 ) | 1993 | if ( d->m_model == Model_Zaurus_SLC7x0 ) |
1995 | { | 1994 | { |
1996 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); | 1995 | //qDebug( "using special treatment for devices with the corgi backlight interface" ); |
1997 | // special treatment for devices with the corgi backlight interface | 1996 | // special treatment for devices with the corgi backlight interface |
1998 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) | 1997 | if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) |
1999 | { | 1998 | { |
2000 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); | 1999 | int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); |
2001 | char writeCommand[100]; | 2000 | char writeCommand[100]; |
2002 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 2001 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
2003 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 2002 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
2004 | ::close ( fd ); | 2003 | ::close ( fd ); |
2005 | } | 2004 | } |
2006 | return res; | 2005 | return res; |
2007 | } | 2006 | } |
2008 | else | 2007 | else |
2009 | { | 2008 | { |
2010 | // standard treatment for devices with the dumb embedix frontlight interface | 2009 | // standard treatment for devices with the dumb embedix frontlight interface |
2011 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { | 2010 | if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { |
2012 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus | 2011 | int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |
2013 | if ( bright && !bl ) | 2012 | if ( bright && !bl ) |
2014 | bl = 1; | 2013 | bl = 1; |
2015 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); | 2014 | res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); |
2016 | ::close ( fd ); | 2015 | ::close ( fd ); |
2017 | } | 2016 | } |
2018 | } | 2017 | } |
2019 | } | 2018 | } |
2020 | else | 2019 | else |
2021 | { | 2020 | { |
2022 | // special treatment for the OpenZaurus unified interface | 2021 | // special treatment for the OpenZaurus unified interface |
2023 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ | 2022 | #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ |
2024 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { | 2023 | if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { |
2025 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); | 2024 | res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); |
2026 | ::close ( fd ); | 2025 | ::close ( fd ); |
2027 | } | 2026 | } |
2028 | } | 2027 | } |
2029 | return res; | 2028 | return res; |
2030 | } | 2029 | } |
2031 | 2030 | ||
2032 | bool Zaurus::suspend ( ) | 2031 | bool Zaurus::suspend ( ) |
2033 | { | 2032 | { |
2034 | qDebug("ODevice::suspend"); | 2033 | qDebug("ODevice::suspend"); |
2035 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2034 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2036 | return false; | 2035 | return false; |
2037 | 2036 | ||
2038 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices | 2037 | if ( d-> m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices |
2039 | return false; | 2038 | return false; |
2040 | 2039 | ||
2041 | bool res = false; | 2040 | bool res = false; |
2042 | 2041 | ||
2043 | struct timeval tvs, tvn; | 2042 | struct timeval tvs, tvn; |
2044 | ::gettimeofday ( &tvs, 0 ); | 2043 | ::gettimeofday ( &tvs, 0 ); |
2045 | 2044 | ||
2046 | ::sync ( ); // flush fs caches | 2045 | ::sync ( ); // flush fs caches |
2047 | res = ( ::system ( "apm --suspend" ) == 0 ); | 2046 | res = ( ::system ( "apm --suspend" ) == 0 ); |
2048 | 2047 | ||
2049 | // This is needed because the iPAQ apm implementation is asynchronous and we | 2048 | // This is needed because the iPAQ apm implementation is asynchronous and we |
2050 | // can not be sure when exactly the device is really suspended | 2049 | // can not be sure when exactly the device is really suspended |
2051 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. | 2050 | // This can be deleted as soon as a stable familiar with a synchronous apm implementation exists. |
2052 | 2051 | ||
2053 | if ( res ) { | 2052 | if ( res ) { |
2054 | do { // Yes, wait 15 seconds. This APM bug sucks big time. | 2053 | do { // Yes, wait 15 seconds. This APM bug sucks big time. |
2055 | ::usleep ( 200 * 1000 ); | 2054 | ::usleep ( 200 * 1000 ); |
2056 | ::gettimeofday ( &tvn, 0 ); | 2055 | ::gettimeofday ( &tvn, 0 ); |
2057 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); | 2056 | } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); |
2058 | } | 2057 | } |
2059 | 2058 | ||
2060 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); | 2059 | QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); |
2061 | return res; | 2060 | return res; |
2062 | } | 2061 | } |
2063 | 2062 | ||
2064 | 2063 | ||
2065 | Transformation Zaurus::rotation ( ) const | 2064 | Transformation Zaurus::rotation ( ) const |
2066 | { | 2065 | { |
2067 | Transformation rot; | 2066 | Transformation rot; |
2068 | int handle = 0; | 2067 | int handle = 0; |
2069 | int retval = 0; | 2068 | int retval = 0; |
2070 | 2069 | ||
2071 | switch ( d-> m_model ) { | 2070 | switch ( d-> m_model ) { |
2072 | case Model_Zaurus_SLC7x0: | 2071 | case Model_Zaurus_SLC7x0: |
2073 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2072 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2074 | if (handle == -1) { | 2073 | if (handle == -1) { |
2075 | return Rot270; | 2074 | return Rot270; |
2076 | } else { | 2075 | } else { |
2077 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2076 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2078 | ::close (handle); | 2077 | ::close (handle); |
2079 | 2078 | ||
2080 | if (retval == 2 ) | 2079 | if (retval == 2 ) |
2081 | rot = Rot0; | 2080 | rot = Rot0; |
2082 | else | 2081 | else |
2083 | rot = Rot270; | 2082 | rot = Rot270; |
2084 | } | 2083 | } |
2085 | break; | 2084 | break; |
2086 | case Model_Zaurus_SLA300: | 2085 | case Model_Zaurus_SLA300: |
2087 | case Model_Zaurus_SLB600: | 2086 | case Model_Zaurus_SLB600: |
2088 | case Model_Zaurus_SL5500: | 2087 | case Model_Zaurus_SL5500: |
2089 | case Model_Zaurus_SL5000: | 2088 | case Model_Zaurus_SL5000: |
2090 | default: | 2089 | default: |
2091 | rot = d-> m_rotation; | 2090 | rot = d-> m_rotation; |
2092 | break; | 2091 | break; |
2093 | } | 2092 | } |
2094 | 2093 | ||
2095 | return rot; | 2094 | return rot; |
2096 | } | 2095 | } |
2097 | ODirection Zaurus::direction ( ) const | 2096 | ODirection Zaurus::direction ( ) const |
2098 | { | 2097 | { |
2099 | ODirection dir; | 2098 | ODirection dir; |
2100 | int handle = 0; | 2099 | int handle = 0; |
2101 | int retval = 0; | 2100 | int retval = 0; |
2102 | switch ( d-> m_model ) { | 2101 | switch ( d-> m_model ) { |
2103 | case Model_Zaurus_SLC7x0: | 2102 | case Model_Zaurus_SLC7x0: |
2104 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2103 | handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2105 | if (handle == -1) { | 2104 | if (handle == -1) { |
2106 | dir = CW; | 2105 | dir = CW; |
2107 | } else { | 2106 | } else { |
2108 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2107 | retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2109 | ::close (handle); | 2108 | ::close (handle); |
2110 | if (retval == 2 ) | 2109 | if (retval == 2 ) |
2111 | dir = CCW; | 2110 | dir = CCW; |
2112 | else | 2111 | else |
2113 | dir = CW; | 2112 | dir = CW; |
2114 | } | 2113 | } |
2115 | break; | 2114 | break; |
2116 | case Model_Zaurus_SLA300: | 2115 | case Model_Zaurus_SLA300: |
2117 | case Model_Zaurus_SLB600: | 2116 | case Model_Zaurus_SLB600: |
2118 | case Model_Zaurus_SL5500: | 2117 | case Model_Zaurus_SL5500: |
2119 | case Model_Zaurus_SL5000: | 2118 | case Model_Zaurus_SL5000: |
2120 | default: | 2119 | default: |
2121 | dir = d-> m_direction; | 2120 | dir = d-> m_direction; |
2122 | break; | 2121 | break; |
2123 | } | 2122 | } |
2124 | return dir; | 2123 | return dir; |
2125 | 2124 | ||
2126 | } | 2125 | } |
2127 | 2126 | ||
2128 | int Zaurus::displayBrightnessResolution ( ) const | 2127 | int Zaurus::displayBrightnessResolution ( ) const |
2129 | { | 2128 | { |
2130 | if (m_embedix) | 2129 | if (m_embedix) |
2131 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; | 2130 | return d->m_model == Model_Zaurus_SLC7x0 ? 18 : 5; |
2132 | else | 2131 | else |
2133 | return 256; | 2132 | return 256; |
2134 | } | 2133 | } |
2135 | 2134 | ||
2136 | bool Zaurus::hasHingeSensor() const | 2135 | bool Zaurus::hasHingeSensor() const |
2137 | { | 2136 | { |
2138 | return d->m_model == Model_Zaurus_SLC7x0; | 2137 | return d->m_model == Model_Zaurus_SLC7x0; |
2139 | } | 2138 | } |
2140 | 2139 | ||
2141 | OHingeStatus Zaurus::readHingeSensor() | 2140 | OHingeStatus Zaurus::readHingeSensor() |
2142 | { | 2141 | { |
2143 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); | 2142 | int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); |
2144 | if (handle == -1) | 2143 | if (handle == -1) |
2145 | { | 2144 | { |
2146 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror | 2145 | qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror |
2147 | return CASE_UNKNOWN; | 2146 | return CASE_UNKNOWN; |
2148 | } | 2147 | } |
2149 | else | 2148 | else |
2150 | { | 2149 | { |
2151 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); | 2150 | int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); |
2152 | ::close (handle); | 2151 | ::close (handle); |
2153 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) | 2152 | if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) |
2154 | { | 2153 | { |
2155 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); | 2154 | qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); |
2156 | return static_cast<OHingeStatus>( retval ); | 2155 | return static_cast<OHingeStatus>( retval ); |
2157 | } | 2156 | } |
2158 | else | 2157 | else |
2159 | { | 2158 | { |
2160 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); | 2159 | qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); |
2161 | return CASE_UNKNOWN; | 2160 | return CASE_UNKNOWN; |
2162 | } | 2161 | } |
2163 | } | 2162 | } |
2164 | } | 2163 | } |
2165 | 2164 | ||
2166 | 2165 | ||
2167 | void Zaurus::virtual_hook( int id, void *data ) { | 2166 | void Zaurus::virtual_hook( int id, void *data ) { |
2168 | switch( id ) { | 2167 | switch( id ) { |
2169 | case VIRTUAL_ROTATION:{ | 2168 | case VIRTUAL_ROTATION:{ |
2170 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); | 2169 | VirtRotation* rot = reinterpret_cast<VirtRotation*>( data ); |
2171 | rot->trans = rotation(); | 2170 | rot->trans = rotation(); |
2172 | break; | 2171 | break; |
2173 | } | 2172 | } |
2174 | case VIRTUAL_DIRECTION:{ | 2173 | case VIRTUAL_DIRECTION:{ |
2175 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); | 2174 | VirtDirection *dir = reinterpret_cast<VirtDirection*>( data ); |
2176 | dir->direct = direction(); | 2175 | dir->direct = direction(); |
2177 | break; | 2176 | break; |
2178 | } | 2177 | } |
2179 | case VIRTUAL_HAS_HINGE:{ | 2178 | case VIRTUAL_HAS_HINGE:{ |
2180 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); | 2179 | VirtHasHinge *hin = reinterpret_cast<VirtHasHinge*>( data ); |
2181 | hin->hasHinge = hasHingeSensor(); | 2180 | hin->hasHinge = hasHingeSensor(); |
2182 | break; | 2181 | break; |
2183 | } | 2182 | } |
2184 | case VIRTUAL_HINGE:{ | 2183 | case VIRTUAL_HINGE:{ |
2185 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); | 2184 | VirtHingeStatus *hin = reinterpret_cast<VirtHingeStatus*>( data ); |
2186 | hin->hingeStat = readHingeSensor(); | 2185 | hin->hingeStat = readHingeSensor(); |
2187 | break; | 2186 | break; |
2188 | } | 2187 | } |
2189 | default: | 2188 | default: |
2190 | ODevice::virtual_hook( id, data ); | 2189 | ODevice::virtual_hook( id, data ); |
2191 | break; | 2190 | break; |
2192 | } | 2191 | } |
2193 | } | 2192 | } |
2194 | 2193 | ||
2195 | /************************************************** | 2194 | /************************************************** |
2196 | * | 2195 | * |
2197 | * SIMpad | 2196 | * SIMpad |
2198 | * | 2197 | * |
2199 | **************************************************/ | 2198 | **************************************************/ |
2200 | 2199 | ||
2201 | void SIMpad::init ( ) | 2200 | void SIMpad::init ( ) |
2202 | { | 2201 | { |
2203 | d-> m_vendorstr = "SIEMENS"; | 2202 | d-> m_vendorstr = "SIEMENS"; |
2204 | d-> m_vendor = Vendor_SIEMENS; | 2203 | d-> m_vendor = Vendor_SIEMENS; |
2205 | 2204 | ||
2206 | QFile f ( "/proc/hal/model" ); | 2205 | QFile f ( "/proc/hal/model" ); |
2207 | 2206 | ||
2208 | //TODO Implement model checking | 2207 | //TODO Implement model checking |
2209 | //FIXME For now we assume an SL4 | 2208 | //FIXME For now we assume an SL4 |
2210 | 2209 | ||
2211 | d-> m_modelstr = "SL4"; | 2210 | d-> m_modelstr = "SL4"; |
2212 | d-> m_model = Model_SIMpad_SL4; | 2211 | d-> m_model = Model_SIMpad_SL4; |
2213 | 2212 | ||
2214 | switch ( d-> m_model ) { | 2213 | switch ( d-> m_model ) { |
2215 | default: | 2214 | default: |
2216 | d-> m_rotation = Rot0; | 2215 | d-> m_rotation = Rot0; |
2217 | d-> m_direction = CCW; | 2216 | d-> m_direction = CCW; |
2218 | d-> m_holdtime = 1000; // 1000ms | 2217 | d-> m_holdtime = 1000; // 1000ms |
2219 | 2218 | ||
2220 | break; | 2219 | break; |
2221 | } | 2220 | } |
2222 | 2221 | ||
2223 | f. setName ( "/etc/familiar-version" ); | 2222 | f. setName ( "/etc/familiar-version" ); |
2224 | if ( f. open ( IO_ReadOnly )) { | 2223 | if ( f. open ( IO_ReadOnly )) { |
2225 | d-> m_systemstr = "Familiar"; | 2224 | d-> m_systemstr = "Familiar"; |
2226 | d-> m_system = System_Familiar; | 2225 | d-> m_system = System_Familiar; |
2227 | 2226 | ||
2228 | QTextStream ts ( &f ); | 2227 | QTextStream ts ( &f ); |
2229 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2228 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2230 | 2229 | ||
2231 | f. close ( ); | 2230 | f. close ( ); |
2232 | } else { | 2231 | } else { |
2233 | f. setName ( "/etc/oz_version" ); | 2232 | f. setName ( "/etc/oz_version" ); |
2234 | 2233 | ||
2235 | if ( f. open ( IO_ReadOnly )) { | 2234 | if ( f. open ( IO_ReadOnly )) { |
2236 | d-> m_systemstr = "OpenEmbedded/SIMpad"; | 2235 | d-> m_systemstr = "OpenEmbedded/SIMpad"; |
2237 | d-> m_system = System_OpenZaurus; | 2236 | d-> m_system = System_OpenZaurus; |
2238 | 2237 | ||
2239 | QTextStream ts ( &f ); | 2238 | QTextStream ts ( &f ); |
2240 | ts.setDevice ( &f ); | 2239 | ts.setDevice ( &f ); |
2241 | d-> m_sysverstr = ts. readLine ( ); | 2240 | d-> m_sysverstr = ts. readLine ( ); |
2242 | f. close ( ); | 2241 | f. close ( ); |
2243 | } | 2242 | } |
2244 | } | 2243 | } |
2245 | 2244 | ||
2246 | m_leds [0] = m_leds [1] = Led_Off; | 2245 | m_leds [0] = m_leds [1] = Led_Off; |
2247 | 2246 | ||
2248 | m_power_timer = 0; | 2247 | m_power_timer = 0; |
2249 | 2248 | ||
2250 | } | 2249 | } |
2251 | 2250 | ||
2252 | void SIMpad::initButtons ( ) | 2251 | void SIMpad::initButtons ( ) |
2253 | { | 2252 | { |
2254 | if ( d-> m_buttons ) | 2253 | if ( d-> m_buttons ) |
2255 | return; | 2254 | return; |
2256 | 2255 | ||
2257 | if ( isQWS( ) ) | 2256 | if ( isQWS( ) ) |
2258 | QWSServer::setKeyboardFilter ( this ); | 2257 | QWSServer::setKeyboardFilter ( this ); |
2259 | 2258 | ||
2260 | d-> m_buttons = new QValueList <ODeviceButton>; | 2259 | d-> m_buttons = new QValueList <ODeviceButton>; |
2261 | 2260 | ||
2262 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { | 2261 | for ( uint i = 0; i < ( sizeof( simpad_buttons ) / sizeof( s_button )); i++ ) { |
2263 | s_button *sb = simpad_buttons + i; | 2262 | s_button *sb = simpad_buttons + i; |
2264 | ODeviceButton b; | 2263 | ODeviceButton b; |
2265 | 2264 | ||
2266 | if (( sb-> model & d-> m_model ) == d-> m_model ) { | 2265 | if (( sb-> model & d-> m_model ) == d-> m_model ) { |
2267 | b. setKeycode ( sb-> code ); | 2266 | b. setKeycode ( sb-> code ); |
2268 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); | 2267 | b. setUserText ( QObject::tr ( "Button", sb-> utext )); |
2269 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); | 2268 | b. setPixmap ( Resource::loadPixmap ( sb-> pix )); |
2270 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); | 2269 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( sb-> fpressedservice ), sb-> fpressedaction )); |
2271 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); | 2270 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( sb-> fheldservice ), sb-> fheldaction )); |
2272 | 2271 | ||
2273 | d-> m_buttons-> append ( b ); | 2272 | d-> m_buttons-> append ( b ); |
2274 | } | 2273 | } |
2275 | } | 2274 | } |
2276 | reloadButtonMapping ( ); | 2275 | reloadButtonMapping ( ); |
2277 | 2276 | ||
2278 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2277 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2279 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 2278 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
2280 | } | 2279 | } |
2281 | 2280 | ||
2282 | // SIMpad boardcontrol register CS3 | 2281 | // SIMpad boardcontrol register CS3 |
2283 | #define SIMPAD_BOARDCONTROL "/proc/cs3" | 2282 | #define SIMPAD_BOARDCONTROL "/proc/cs3" |
2284 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA | 2283 | #define SIMPAD_VCC_5V_EN 0x0001 // For 5V PCMCIA |
2285 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA | 2284 | #define SIMPAD_VCC_3V_EN 0x0002 // FOR 3.3V PCMCIA |
2286 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's | 2285 | #define SIMPAD_EN1 0x0004 // This is only for EPROM's |
2287 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V | 2286 | #define SIMPAD_EN0 0x0008 // Both should be enable for 3.3V or 5V |
2288 | #define SIMPAD_DISPLAY_ON 0x0010 | 2287 | #define SIMPAD_DISPLAY_ON 0x0010 |
2289 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 | 2288 | #define SIMPAD_PCMCIA_BUFF_DIS 0x0020 |
2290 | #define SIMPAD_MQ_RESET 0x0040 | 2289 | #define SIMPAD_MQ_RESET 0x0040 |
2291 | #define SIMPAD_PCMCIA_RESET 0x0080 | 2290 | #define SIMPAD_PCMCIA_RESET 0x0080 |
2292 | #define SIMPAD_DECT_POWER_ON 0x0100 | 2291 | #define SIMPAD_DECT_POWER_ON 0x0100 |
2293 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave | 2292 | #define SIMPAD_IRDA_SD 0x0200 // Shutdown for powersave |
2294 | #define SIMPAD_RS232_ON 0x0400 | 2293 | #define SIMPAD_RS232_ON 0x0400 |
2295 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave | 2294 | #define SIMPAD_SD_MEDIAQ 0x0800 // Shutdown for powersave |
2296 | #define SIMPAD_LED2_ON 0x1000 | 2295 | #define SIMPAD_LED2_ON 0x1000 |
2297 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode | 2296 | #define SIMPAD_IRDA_MODE 0x2000 // Fast/Slow IrDA mode |
2298 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit | 2297 | #define SIMPAD_ENABLE_5V 0x4000 // Enable 5V circuit |
2299 | #define SIMPAD_RESET_SIMCARD 0x8000 | 2298 | #define SIMPAD_RESET_SIMCARD 0x8000 |
2300 | 2299 | ||
2301 | //SIMpad touchscreen backlight strength control | 2300 | //SIMpad touchscreen backlight strength control |
2302 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" | 2301 | #define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" |
2303 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 | 2302 | #define SIMPAD_BACKLIGHT_MASK 0x00a10044 |
2304 | 2303 | ||
2305 | QValueList <OLed> SIMpad::ledList ( ) const | 2304 | QValueList <OLed> SIMpad::ledList ( ) const |
2306 | { | 2305 | { |
2307 | QValueList <OLed> vl; | 2306 | QValueList <OLed> vl; |
2308 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 2307 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
2309 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 2308 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
2310 | return vl; | 2309 | return vl; |
2311 | } | 2310 | } |
2312 | 2311 | ||
2313 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 2312 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
2314 | { | 2313 | { |
2315 | QValueList <OLedState> vl; | 2314 | QValueList <OLedState> vl; |
2316 | 2315 | ||
2317 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 2316 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
2318 | vl << Led_Off << Led_On; | 2317 | vl << Led_Off << Led_On; |
2319 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 2318 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
2320 | //vl << Led_Off; | 2319 | //vl << Led_Off; |
2321 | return vl; | 2320 | return vl; |
2322 | } | 2321 | } |
2323 | 2322 | ||
2324 | OLedState SIMpad::ledState ( OLed l ) const | 2323 | OLedState SIMpad::ledState ( OLed l ) const |
2325 | { | 2324 | { |
2326 | switch ( l ) { | 2325 | switch ( l ) { |
2327 | case Led_Power: | 2326 | case Led_Power: |
2328 | return m_leds [0]; | 2327 | return m_leds [0]; |
2329 | //case Led_Mail: | 2328 | //case Led_Mail: |
2330 | //return m_leds [1]; | 2329 | //return m_leds [1]; |
2331 | default: | 2330 | default: |
2332 | return Led_Off; | 2331 | return Led_Off; |
2333 | } | 2332 | } |
2334 | } | 2333 | } |
2335 | 2334 | ||
2336 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 2335 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
2337 | { | 2336 | { |
2338 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); | 2337 | static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); |
2339 | 2338 | ||
2340 | if ( l == Led_Power ) { | 2339 | if ( l == Led_Power ) { |
2341 | if ( fd >= 0 ) { | 2340 | if ( fd >= 0 ) { |
2342 | LED_IN leds; | 2341 | LED_IN leds; |
2343 | ::memset ( &leds, 0, sizeof( leds )); | 2342 | ::memset ( &leds, 0, sizeof( leds )); |
2344 | leds. TotalTime = 0; | 2343 | leds. TotalTime = 0; |
2345 | leds. OnTime = 0; | 2344 | leds. OnTime = 0; |
2346 | leds. OffTime = 1; | 2345 | leds. OffTime = 1; |
2347 | leds. OffOnBlink = 2; | 2346 | leds. OffOnBlink = 2; |
2348 | 2347 | ||
2349 | switch ( st ) { | 2348 | switch ( st ) { |
2350 | case Led_Off : leds. OffOnBlink = 0; break; | 2349 | case Led_Off : leds. OffOnBlink = 0; break; |
2351 | case Led_On : leds. OffOnBlink = 1; break; | 2350 | case Led_On : leds. OffOnBlink = 1; break; |
2352 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 2351 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
2353 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 2352 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
2354 | } | 2353 | } |
2355 | 2354 | ||
2356 | { | 2355 | { |
2357 | /*TODO Implement this like that: | 2356 | /*TODO Implement this like that: |
2358 | read from cs3 | 2357 | read from cs3 |
2359 | && with SIMPAD_LED2_ON | 2358 | && with SIMPAD_LED2_ON |
2360 | write to cs3 */ | 2359 | write to cs3 */ |
2361 | m_leds [0] = st; | 2360 | m_leds [0] = st; |
2362 | return true; | 2361 | return true; |
2363 | } | 2362 | } |
2364 | } | 2363 | } |
2365 | } | 2364 | } |
2366 | return false; | 2365 | return false; |
2367 | } | 2366 | } |
2368 | 2367 | ||
2369 | 2368 | ||
2370 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 2369 | bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) |
2371 | { | 2370 | { |
2372 | //TODO | 2371 | //TODO |
2373 | return false; | 2372 | return false; |
2374 | } | 2373 | } |
2375 | 2374 | ||
2376 | void SIMpad::timerEvent ( QTimerEvent * ) | 2375 | void SIMpad::timerEvent ( QTimerEvent * ) |
2377 | { | 2376 | { |
2378 | killTimer ( m_power_timer ); | 2377 | killTimer ( m_power_timer ); |
2379 | m_power_timer = 0; | 2378 | m_power_timer = 0; |
2380 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 2379 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
2381 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 2380 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
2382 | } | 2381 | } |
2383 | 2382 | ||
2384 | 2383 | ||
2385 | void SIMpad::alarmSound ( ) | 2384 | void SIMpad::alarmSound ( ) |
2386 | { | 2385 | { |
2387 | #ifndef QT_NO_SOUND | 2386 | #ifndef QT_NO_SOUND |
2388 | static Sound snd ( "alarm" ); | 2387 | static Sound snd ( "alarm" ); |
2389 | int fd; | 2388 | int fd; |
2390 | int vol; | 2389 | int vol; |
2391 | bool vol_reset = false; | 2390 | bool vol_reset = false; |
2392 | 2391 | ||
2393 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { | 2392 | if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { |
2394 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { | 2393 | if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { |
2395 | Config cfg ( "qpe" ); | 2394 | Config cfg ( "qpe" ); |
2396 | cfg. setGroup ( "Volume" ); | 2395 | cfg. setGroup ( "Volume" ); |
2397 | 2396 | ||
2398 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); | 2397 | int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); |
2399 | if ( volalarm < 0 ) | 2398 | if ( volalarm < 0 ) |
2400 | volalarm = 0; | 2399 | volalarm = 0; |
2401 | else if ( volalarm > 100 ) | 2400 | else if ( volalarm > 100 ) |
2402 | volalarm = 100; | 2401 | volalarm = 100; |
2403 | volalarm |= ( volalarm << 8 ); | 2402 | volalarm |= ( volalarm << 8 ); |
2404 | 2403 | ||
2405 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) | 2404 | if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) |
2406 | vol_reset = true; | 2405 | vol_reset = true; |
2407 | } | 2406 | } |
2408 | } | 2407 | } |
2409 | 2408 | ||
2410 | snd. play ( ); | 2409 | snd. play ( ); |
2411 | while ( !snd. isFinished ( )) | 2410 | while ( !snd. isFinished ( )) |
2412 | qApp-> processEvents ( ); | 2411 | qApp-> processEvents ( ); |
2413 | 2412 | ||
2414 | if ( fd >= 0 ) { | 2413 | if ( fd >= 0 ) { |
2415 | if ( vol_reset ) | 2414 | if ( vol_reset ) |
2416 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); | 2415 | ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); |
2417 | ::close ( fd ); | 2416 | ::close ( fd ); |
2418 | } | 2417 | } |
2419 | #endif | 2418 | #endif |
2420 | } | 2419 | } |
2421 | 2420 | ||
2422 | 2421 | ||
2423 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm | 2422 | bool SIMpad::suspend ( ) // Must override because SIMpad does NOT have apm |
2424 | { | 2423 | { |
2425 | qDebug( "ODevice for SIMpad: suspend()" ); | 2424 | qDebug( "ODevice for SIMpad: suspend()" ); |
2426 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 2425 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
2427 | return false; | 2426 | return false; |
2428 | 2427 | ||
2429 | bool res = false; | 2428 | bool res = false; |
2430 | 2429 | ||
2431 | struct timeval tvs, tvn; | 2430 | struct timeval tvs; |
2432 | ::gettimeofday ( &tvs, 0 ); | 2431 | ::gettimeofday ( &tvs, 0 ); |
2433 | 2432 | ||
2434 | ::sync ( ); // flush fs caches | 2433 | ::sync ( ); // flush fs caches |
2435 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) | 2434 | res = ( ::system ( "cat /dev/fb/0 >/tmp/.buffer; echo > /proc/sys/pm/suspend; cat /tmp/.buffer >/dev/fb/0" ) == 0 ); //TODO make better :) |
2436 | 2435 | ||
2437 | return res; | 2436 | return res; |
2438 | } | 2437 | } |
2439 | 2438 | ||
2440 | 2439 | ||
2441 | bool SIMpad::setSoftSuspend ( bool soft ) | 2440 | bool SIMpad::setSoftSuspend ( bool soft ) |
2442 | { | 2441 | { |
2443 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 2442 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
2444 | return false; | 2443 | return false; |
2445 | } | 2444 | } |
2446 | 2445 | ||
2447 | 2446 | ||
2448 | bool SIMpad::setDisplayStatus ( bool on ) | 2447 | bool SIMpad::setDisplayStatus ( bool on ) |
2449 | { | 2448 | { |
2450 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 2449 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
2451 | 2450 | ||
2452 | bool res = false; | 2451 | bool res = false; |
2453 | int fd; | ||
2454 | 2452 | ||
2455 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) | 2453 | QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) |
2456 | 2454 | ||
2457 | res = ( ::system( (const char*) cmdline ) == 0 ); | 2455 | res = ( ::system( (const char*) cmdline ) == 0 ); |
2458 | 2456 | ||
2459 | return res; | 2457 | return res; |
2460 | } | 2458 | } |
2461 | 2459 | ||
2462 | 2460 | ||
2463 | bool SIMpad::setDisplayBrightness ( int bright ) | 2461 | bool SIMpad::setDisplayBrightness ( int bright ) |
2464 | { | 2462 | { |
2465 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 2463 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
2466 | bool res = false; | 2464 | bool res = false; |
2467 | int fd; | 2465 | int fd; |
2468 | 2466 | ||
2469 | if ( bright > 255 ) | 2467 | if ( bright > 255 ) |
2470 | bright = 255; | 2468 | bright = 255; |
2471 | if ( bright < 1 ) | 2469 | if ( bright < 1 ) |
2472 | bright = 0; | 2470 | bright = 0; |
2473 | 2471 | ||
2474 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 2472 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
2475 | int value = 255 - bright; | 2473 | int value = 255 - bright; |
2476 | const int mask = SIMPAD_BACKLIGHT_MASK; | 2474 | const int mask = SIMPAD_BACKLIGHT_MASK; |
2477 | value = value << 8; | 2475 | value = value << 8; |
2478 | value += mask; | 2476 | value += mask; |
2479 | char writeCommand[100]; | 2477 | char writeCommand[100]; |
2480 | const int count = sprintf( writeCommand, "0x%x\n", value ); | 2478 | const int count = sprintf( writeCommand, "0x%x\n", value ); |
2481 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 2479 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
2482 | ::close ( fd ); | 2480 | ::close ( fd ); |
2483 | } | 2481 | } |
2484 | return res; | 2482 | return res; |
2485 | } | 2483 | } |
2486 | 2484 | ||
2487 | 2485 | ||
2488 | int SIMpad::displayBrightnessResolution ( ) const | 2486 | int SIMpad::displayBrightnessResolution ( ) const |
2489 | { | 2487 | { |
2490 | return 255; // All SIMpad models share the same display | 2488 | return 255; // All SIMpad models share the same display |
2491 | } | 2489 | } |
2492 | 2490 | ||
2493 | /************************************************** | 2491 | /************************************************** |
2494 | * | 2492 | * |
2495 | * Ramses | 2493 | * Ramses |
2496 | * | 2494 | * |
2497 | **************************************************/ | 2495 | **************************************************/ |
2498 | 2496 | ||
2499 | void Ramses::init() | 2497 | void Ramses::init() |
2500 | { | 2498 | { |
2501 | d->m_vendorstr = "M und N"; | 2499 | d->m_vendorstr = "M und N"; |
2502 | d->m_vendor = Vendor_MundN; | 2500 | d->m_vendor = Vendor_MundN; |
2503 | 2501 | ||
2504 | QFile f("/proc/sys/board/ramses"); | 2502 | QFile f("/proc/sys/board/ramses"); |
2505 | 2503 | ||
2506 | d->m_modelstr = "Ramses"; | 2504 | d->m_modelstr = "Ramses"; |
2507 | d->m_model = Model_Ramses_MNCI; | 2505 | d->m_model = Model_Ramses_MNCI; |
2508 | 2506 | ||
2509 | d->m_rotation = Rot90; | 2507 | d->m_rotation = Rot90; |
2510 | d->m_holdtime = 1000; | 2508 | d->m_holdtime = 1000; |
2511 | 2509 | ||
2512 | f.setName("/etc/oz_version"); | 2510 | f.setName("/etc/oz_version"); |
2513 | 2511 | ||
2514 | if (f.open(IO_ReadOnly)) { | 2512 | if (f.open(IO_ReadOnly)) { |
2515 | d->m_systemstr = "OpenEmbedded/Ramses"; | 2513 | d->m_systemstr = "OpenEmbedded/Ramses"; |
2516 | d->m_system = System_OpenZaurus; | 2514 | d->m_system = System_OpenZaurus; |
2517 | 2515 | ||
2518 | QTextStream ts(&f); | 2516 | QTextStream ts(&f); |
2519 | ts.setDevice(&f); | 2517 | ts.setDevice(&f); |
2520 | d->m_sysverstr = ts.readLine(); | 2518 | d->m_sysverstr = ts.readLine(); |
2521 | f.close(); | 2519 | f.close(); |
2522 | } | 2520 | } |
2523 | 2521 | ||
2524 | m_power_timer = 0; | 2522 | m_power_timer = 0; |
2525 | 2523 | ||
2526 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 2524 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
2527 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** | 2525 | #warning *** Overclocking enabled - this may fry your hardware - you have been warned *** |
2528 | #define OC(x...) x | 2526 | #define OC(x...) x |
2529 | #else | 2527 | #else |
2530 | #define OC(x...) | 2528 | #define OC(x...) |
2531 | #endif | 2529 | #endif |
2532 | 2530 | ||
2533 | 2531 | ||
2534 | // This table is true for a Intel XScale PXA 255 | 2532 | // This table is true for a Intel XScale PXA 255 |
2535 | 2533 | ||
2536 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 2534 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
2537 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 2535 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
2538 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 2536 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
2539 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 2537 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
2540 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 2538 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
2541 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 2539 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
2542 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 2540 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
2543 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 2541 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
2544 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 2542 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
2545 | 2543 | ||
2546 | } | 2544 | } |
2547 | 2545 | ||
2548 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) | 2546 | bool Ramses::filter(int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat) |
2549 | { | 2547 | { |
2550 | Q_UNUSED( keycode ); | 2548 | Q_UNUSED( keycode ); |
2551 | Q_UNUSED( modifiers ); | 2549 | Q_UNUSED( modifiers ); |
2552 | Q_UNUSED( isPress ); | 2550 | Q_UNUSED( isPress ); |
2553 | Q_UNUSED( autoRepeat ); | 2551 | Q_UNUSED( autoRepeat ); |
2554 | return false; | 2552 | return false; |
2555 | } | 2553 | } |
2556 | 2554 | ||
2557 | void Ramses::timerEvent(QTimerEvent *) | 2555 | void Ramses::timerEvent(QTimerEvent *) |
2558 | { | 2556 | { |
2559 | killTimer(m_power_timer); | 2557 | killTimer(m_power_timer); |
2560 | m_power_timer = 0; | 2558 | m_power_timer = 0; |
2561 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); | 2559 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, true, false); |
2562 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); | 2560 | QWSServer::sendKeyEvent(-1, HardKey_Backlight, 0, false, false); |
2563 | } | 2561 | } |
2564 | 2562 | ||
2565 | 2563 | ||
2566 | bool Ramses::setSoftSuspend(bool soft) | 2564 | bool Ramses::setSoftSuspend(bool soft) |
2567 | { | 2565 | { |
2568 | qDebug("Ramses::setSoftSuspend(%d)", soft); | 2566 | qDebug("Ramses::setSoftSuspend(%d)", soft); |
2569 | #if 0 | 2567 | #if 0 |
2570 | bool res = false; | 2568 | bool res = false; |
2571 | int fd; | 2569 | int fd; |
2572 | 2570 | ||
2573 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || | 2571 | if (((fd = ::open("/dev/apm_bios", O_RDWR)) >= 0) || |
2574 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { | 2572 | ((fd = ::open("/dev/misc/apm_bios",O_RDWR)) >= 0)) { |
2575 | 2573 | ||
2576 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources | 2574 | int sources = ::ioctl(fd, APM_IOCGEVTSRC, 0); // get current event sources |
2577 | 2575 | ||
2578 | if (sources >= 0) { | 2576 | if (sources >= 0) { |
2579 | if (soft) | 2577 | if (soft) |
2580 | sources &= ~APM_EVT_POWER_BUTTON; | 2578 | sources &= ~APM_EVT_POWER_BUTTON; |
2581 | else | 2579 | else |
2582 | sources |= APM_EVT_POWER_BUTTON; | 2580 | sources |= APM_EVT_POWER_BUTTON; |
2583 | 2581 | ||
2584 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources | 2582 | if (::ioctl(fd, APM_IOCSEVTSRC, sources) >= 0) // set new event sources |
2585 | res = true; | 2583 | res = true; |
2586 | else | 2584 | else |
2587 | perror("APM_IOCGEVTSRC"); | 2585 | perror("APM_IOCGEVTSRC"); |
2588 | } | 2586 | } |
2589 | else | 2587 | else |
2590 | perror("APM_IOCGEVTSRC"); | 2588 | perror("APM_IOCGEVTSRC"); |
2591 | 2589 | ||
2592 | ::close(fd); | 2590 | ::close(fd); |
2593 | } | 2591 | } |
2594 | else | 2592 | else |
2595 | perror("/dev/apm_bios or /dev/misc/apm_bios"); | 2593 | perror("/dev/apm_bios or /dev/misc/apm_bios"); |
2596 | 2594 | ||
2597 | return res; | 2595 | return res; |
2598 | #else | 2596 | #else |
2599 | return true; | 2597 | return true; |
2600 | #endif | 2598 | #endif |
2601 | } | 2599 | } |
2602 | 2600 | ||
2603 | bool Ramses::suspend ( ) | 2601 | bool Ramses::suspend ( ) |
2604 | { | 2602 | { |
2605 | qDebug("Ramses::suspend"); | 2603 | qDebug("Ramses::suspend"); |
2606 | return false; | 2604 | return false; |
2607 | } | 2605 | } |
2608 | 2606 | ||
2609 | /** | 2607 | /** |
2610 | * This sets the display on or off | 2608 | * This sets the display on or off |
2611 | */ | 2609 | */ |
2612 | bool Ramses::setDisplayStatus(bool on) | 2610 | bool Ramses::setDisplayStatus(bool on) |
2613 | { | 2611 | { |
2614 | qDebug("Ramses::setDisplayStatus(%d)", on); | 2612 | qDebug("Ramses::setDisplayStatus(%d)", on); |
2615 | #if 0 | 2613 | #if 0 |
2616 | bool res = false; | 2614 | bool res = false; |
2617 | int fd; | 2615 | int fd; |
2618 | 2616 | ||
2619 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { | 2617 | if ((fd = ::open ("/dev/fb/0", O_RDWR)) >= 0) { |
2620 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); | 2618 | res = (::ioctl(fd, FBIOBLANK, on ? VESA_NO_BLANKING : VESA_POWERDOWN) == 0); |
2621 | ::close(fd); | 2619 | ::close(fd); |
2622 | } | 2620 | } |
2623 | return res; | 2621 | return res; |
2624 | #else | 2622 | #else |
2625 | return true; | 2623 | return true; |
2626 | #endif | 2624 | #endif |
2627 | } | 2625 | } |
2628 | 2626 | ||
2629 | 2627 | ||
2630 | /* | 2628 | /* |
2631 | * We get something between 0..255 into us | 2629 | * We get something between 0..255 into us |
2632 | */ | 2630 | */ |
2633 | bool Ramses::setDisplayBrightness(int bright) | 2631 | bool Ramses::setDisplayBrightness(int bright) |
2634 | { | 2632 | { |
2635 | qDebug("Ramses::setDisplayBrightness(%d)", bright); | 2633 | qDebug("Ramses::setDisplayBrightness(%d)", bright); |
2636 | bool res = false; | 2634 | bool res = false; |
2637 | int fd; | 2635 | int fd; |
2638 | 2636 | ||
2639 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 2637 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
2640 | 2638 | ||
2641 | if (bright > 255 ) | 2639 | if (bright > 255 ) |
2642 | bright = 255; | 2640 | bright = 255; |
2643 | if (bright < 0) | 2641 | if (bright < 0) |
2644 | bright = 0; | 2642 | bright = 0; |
2645 | 2643 | ||
2646 | // Turn backlight completely off | 2644 | // Turn backlight completely off |
2647 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 2645 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
2648 | char writeCommand[10]; | 2646 | char writeCommand[10]; |
2649 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 2647 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
2650 | res = (::write(fd, writeCommand, count) != -1); | 2648 | res = (::write(fd, writeCommand, count) != -1); |
2651 | ::close(fd); | 2649 | ::close(fd); |
2652 | } | 2650 | } |
2653 | 2651 | ||
2654 | // scale backlight brightness to hardware | 2652 | // scale backlight brightness to hardware |
2655 | bright = 500-(bright * 500 / 255); | 2653 | bright = 500-(bright * 500 / 255); |
2656 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { | 2654 | if ((fd = ::open("/proc/sys/board/pwm1", O_WRONLY)) >= 0) { |
2657 | qDebug(" %d -> pwm1", bright); | 2655 | qDebug(" %d -> pwm1", bright); |
2658 | char writeCommand[100]; | 2656 | char writeCommand[100]; |
2659 | const int count = sprintf(writeCommand, "%d\n", bright); | 2657 | const int count = sprintf(writeCommand, "%d\n", bright); |
2660 | res = (::write(fd, writeCommand, count) != -1); | 2658 | res = (::write(fd, writeCommand, count) != -1); |
2661 | ::close(fd); | 2659 | ::close(fd); |
2662 | } | 2660 | } |
2663 | return res; | 2661 | return res; |
2664 | } | 2662 | } |
2665 | 2663 | ||
2666 | 2664 | ||
2667 | int Ramses::displayBrightnessResolution() const | 2665 | int Ramses::displayBrightnessResolution() const |
2668 | { | 2666 | { |
2669 | return 32; | 2667 | return 32; |
2670 | } | 2668 | } |
2671 | 2669 | ||
2672 | bool Ramses::setDisplayContrast(int contr) | 2670 | bool Ramses::setDisplayContrast(int contr) |
2673 | { | 2671 | { |
2674 | qDebug("Ramses::setDisplayContrast(%d)", contr); | 2672 | qDebug("Ramses::setDisplayContrast(%d)", contr); |
2675 | bool res = false; | 2673 | bool res = false; |
2676 | int fd; | 2674 | int fd; |
2677 | 2675 | ||
2678 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) | 2676 | // pwm0 contrast: 20 steps 79..90 (dunkel->hell) |
2679 | 2677 | ||
2680 | if (contr > 255 ) | 2678 | if (contr > 255 ) |
2681 | contr = 255; | 2679 | contr = 255; |
2682 | if (contr < 0) | 2680 | if (contr < 0) |
2683 | contr = 0; | 2681 | contr = 0; |
2684 | contr = 90 - (contr * 20 / 255); | 2682 | contr = 90 - (contr * 20 / 255); |
2685 | 2683 | ||
2686 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { | 2684 | if ((fd = ::open("/proc/sys/board/pwm0", O_WRONLY)) >= 0) { |
2687 | qDebug(" %d -> pwm0", contr); | 2685 | qDebug(" %d -> pwm0", contr); |
2688 | char writeCommand[100]; | 2686 | char writeCommand[100]; |
2689 | const int count = sprintf(writeCommand, "%d\n", contr); | 2687 | const int count = sprintf(writeCommand, "%d\n", contr); |
2690 | res = (::write(fd, writeCommand, count) != -1); | 2688 | res = (::write(fd, writeCommand, count) != -1); |
2691 | res = true; | 2689 | res = true; |
2692 | ::close(fd); | 2690 | ::close(fd); |
2693 | } | 2691 | } |
2694 | return res; | 2692 | return res; |
2695 | } | 2693 | } |
2696 | 2694 | ||
2697 | 2695 | ||
2698 | int Ramses::displayContrastResolution() const | 2696 | int Ramses::displayContrastResolution() const |
2699 | { | 2697 | { |
2700 | return 20; | 2698 | return 20; |
2701 | } | 2699 | } |
2702 | 2700 | ||
2703 | 2701 | ||
2704 | /************************************************** | 2702 | /************************************************** |
2705 | * * | 2703 | * * |
2706 | * Jornada * | 2704 | * Jornada * |
2707 | * * | 2705 | * * |
2708 | **************************************************/ | 2706 | **************************************************/ |
2709 | 2707 | ||
2710 | 2708 | ||
2711 | bool Jornada::isJornada ( ) | 2709 | bool Jornada::isJornada ( ) |
2712 | { | 2710 | { |
2713 | QFile f( "/proc/cpuinfo" ); | 2711 | QFile f( "/proc/cpuinfo" ); |
2714 | if ( f. open ( IO_ReadOnly ) ) { | 2712 | if ( f. open ( IO_ReadOnly ) ) { |
2715 | QTextStream ts ( &f ); | 2713 | QTextStream ts ( &f ); |
2716 | QString line; | 2714 | QString line; |
2717 | while( line = ts. readLine ( ) ) { | 2715 | while( line = ts. readLine ( ) ) { |
2718 | if ( line. left ( 8 ) == "Hardware" ) { | 2716 | if ( line. left ( 8 ) == "Hardware" ) { |
2719 | int loc = line. find ( ":" ); | 2717 | int loc = line. find ( ":" ); |
2720 | if ( loc != -1 ) { | 2718 | if ( loc != -1 ) { |
2721 | QString model = | 2719 | QString model = |
2722 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); | 2720 | line. mid ( loc + 2 ). simplifyWhiteSpace( ); |
2723 | return ( model == "HP Jornada 56x" ); | 2721 | return ( model == "HP Jornada 56x" ); |
2724 | } | 2722 | } |
2725 | } | 2723 | } |
2726 | } | 2724 | } |
2727 | } | 2725 | } |
2728 | return false; | 2726 | return false; |
2729 | } | 2727 | } |
2730 | 2728 | ||
2731 | void Jornada::init ( ) | 2729 | void Jornada::init ( ) |
2732 | { | 2730 | { |
2733 | d-> m_vendorstr = "HP"; | 2731 | d-> m_vendorstr = "HP"; |
2734 | d-> m_vendor = Vendor_HP; | 2732 | d-> m_vendor = Vendor_HP; |
2735 | d-> m_modelstr = "Jornada 56x"; | 2733 | d-> m_modelstr = "Jornada 56x"; |
2736 | d-> m_model = Model_Jornada_56x; | 2734 | d-> m_model = Model_Jornada_56x; |
2737 | d-> m_systemstr = "Familiar"; | 2735 | d-> m_systemstr = "Familiar"; |
2738 | d-> m_system = System_Familiar; | 2736 | d-> m_system = System_Familiar; |
2739 | d-> m_rotation = Rot0; | 2737 | d-> m_rotation = Rot0; |
2740 | 2738 | ||
2741 | QFile f ( "/etc/familiar-version" ); | 2739 | QFile f ( "/etc/familiar-version" ); |
2742 | f. setName ( "/etc/familiar-version" ); | 2740 | f. setName ( "/etc/familiar-version" ); |
2743 | if ( f. open ( IO_ReadOnly )) { | 2741 | if ( f. open ( IO_ReadOnly )) { |
2744 | 2742 | ||
2745 | QTextStream ts ( &f ); | 2743 | QTextStream ts ( &f ); |
2746 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); | 2744 | d-> m_sysverstr = ts. readLine ( ). mid ( 10 ); |
2747 | 2745 | ||
2748 | f. close ( ); | 2746 | f. close ( ); |
2749 | } | 2747 | } |
2750 | } | 2748 | } |
2751 | 2749 | ||
2752 | #if 0 | 2750 | #if 0 |
2753 | void Jornada::initButtons ( ) | 2751 | void Jornada::initButtons ( ) |
2754 | { | 2752 | { |
2755 | if ( d-> m_buttons ) | 2753 | if ( d-> m_buttons ) |
2756 | return; | 2754 | return; |
2757 | 2755 | ||
2758 | // Simulation uses iPAQ 3660 device buttons | 2756 | // Simulation uses iPAQ 3660 device buttons |
2759 | 2757 | ||
2760 | qDebug ( "init Buttons" ); | 2758 | qDebug ( "init Buttons" ); |
2761 | d-> m_buttons = new QValueList <ODeviceButton>; | 2759 | d-> m_buttons = new QValueList <ODeviceButton>; |
2762 | 2760 | ||
2763 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { | 2761 | for ( uint i = 0; i < ( sizeof( ipaq_buttons ) / sizeof( i_button )); i++ ) { |
2764 | i_button *ib = ipaq_buttons + i; | 2762 | i_button *ib = ipaq_buttons + i; |
2765 | ODeviceButton b; | 2763 | ODeviceButton b; |
2766 | 2764 | ||
2767 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { | 2765 | if (( ib-> model & Model_iPAQ_H36xx ) == Model_iPAQ_H36xx ) { |
2768 | b. setKeycode ( ib-> code ); | 2766 | b. setKeycode ( ib-> code ); |
2769 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); | 2767 | b. setUserText ( QObject::tr ( "Button", ib-> utext )); |
2770 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); | 2768 | b. setPixmap ( Resource::loadPixmap ( ib-> pix )); |
2771 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); | 2769 | b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( ib-> fpressedservice ), ib-> fpressedaction )); |
2772 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); | 2770 | b. setFactoryPresetHeldAction ( OQCopMessage ( makeChannel ( ib-> fheldservice ), ib-> fheldaction )); |
2773 | d-> m_buttons-> append ( b ); | 2771 | d-> m_buttons-> append ( b ); |
2774 | } | 2772 | } |
2775 | } | 2773 | } |
2776 | reloadButtonMapping ( ); | 2774 | reloadButtonMapping ( ); |
2777 | 2775 | ||
2778 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); | 2776 | QCopChannel *sysch = new QCopChannel ( "QPE/System", this ); |
2779 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); | 2777 | connect ( sysch, SIGNAL( received(const QCString&,const QByteArray&)), this, SLOT( systemMessage(const QCString&,const QByteArray&))); |
2780 | } | 2778 | } |
2781 | #endif | 2779 | #endif |
2782 | int Jornada::displayBrightnessResolution ( ) const | 2780 | int Jornada::displayBrightnessResolution ( ) const |
2783 | { | 2781 | { |
2782 | return 255; | ||
2784 | } | 2783 | } |
2785 | 2784 | ||
2786 | bool Jornada::setDisplayBrightness ( int bright ) | 2785 | bool Jornada::setDisplayBrightness ( int bright ) |
2787 | { | 2786 | { |
2788 | bool res = false; | 2787 | bool res = false; |
2789 | int fd; | 2788 | int fd; |
2790 | 2789 | ||
2791 | if ( bright > 255 ) | 2790 | if ( bright > 255 ) |
2792 | bright = 255; | 2791 | bright = 255; |
2793 | if ( bright < 0 ) | 2792 | if ( bright < 0 ) |
2794 | bright = 0; | 2793 | bright = 0; |
2795 | 2794 | ||
2796 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 2795 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
2797 | FLITE_IN bl; | 2796 | FLITE_IN bl; |
2798 | bl. mode = 1; | 2797 | bl. mode = 1; |
2799 | bl. pwr = bright ? 1 : 0; | 2798 | bl. pwr = bright ? 1 : 0; |
2800 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; | 2799 | bl. brightness = ( bright * ( displayBrightnessResolution ( ) - 1 ) + 127 ) / 255; |
2801 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 2800 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
2802 | ::close ( fd ); | 2801 | ::close ( fd ); |
2803 | } | 2802 | } |
2804 | return res; | 2803 | return res; |
2805 | } | 2804 | } |
2806 | 2805 | ||
2807 | bool Jornada::setSoftSuspend ( bool soft ) | 2806 | bool Jornada::setSoftSuspend ( bool soft ) |
2808 | { | 2807 | { |
2809 | bool res = false; | 2808 | bool res = false; |
2810 | int fd; | 2809 | int fd; |
2811 | 2810 | ||
2812 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 2811 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
2813 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 2812 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
2814 | res = true; | 2813 | res = true; |
2815 | else | 2814 | else |
2816 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 2815 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
2817 | 2816 | ||
2818 | ::close ( fd ); | 2817 | ::close ( fd ); |
2819 | } | 2818 | } |
2820 | else | 2819 | else |
2821 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 2820 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
2822 | 2821 | ||
2823 | return res; | 2822 | return res; |
2824 | } | 2823 | } |