summaryrefslogtreecommitdiff
path: root/libopie2/opiecore/device
authordrw <drw>2005-01-24 22:31:49 (UTC)
committer drw <drw>2005-01-24 22:31:49 (UTC)
commit3d4c2eb3932f024bd046e8c4ac747d147a823d63 (patch) (unidiff)
treeab7bee60b86709ac0adb40aaebfefd12a60bf944 /libopie2/opiecore/device
parentfa3041f9acfd171b62c0ab73cde8b9d0f0772a9c (diff)
downloadopie-3d4c2eb3932f024bd046e8c4ac747d147a823d63.zip
opie-3d4c2eb3932f024bd046e8c4ac747d147a823d63.tar.gz
opie-3d4c2eb3932f024bd046e8c4ac747d147a823d63.tar.bz2
Fix compile of odevice_zaurus.cpp
Diffstat (limited to 'libopie2/opiecore/device') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp64
1 files changed, 33 insertions, 31 deletions
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index cbc7a24..2128d46 100644
--- a/libopie2/opiecore/device/odevice_zaurus.cpp
+++ b/libopie2/opiecore/device/odevice_zaurus.cpp
@@ -1,72 +1,72 @@
1/* 1/*
2                 This file is part of the Opie Project 2 This file is part of the Opie Project
3              Copyright (C) The Opie Team <opie-devel@handhelds.org> 3 Copyright (C) The Opie Team <opie-devel@handhelds.org>
4 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de> 4 =. Copyright (C) 2003-2005 Michael 'Mickey' Lauer <mickey@Vanille.de>
5 .=l. 5 .=l.
6           .>+-= 6 .>+-=
7 _;:,     .>    :=|. This program is free software; you can 7_;:, .> :=|. This program is free software; you can
8.> <`_,   >  .   <= redistribute it and/or modify it under 8.> <`_, > . <= redistribute it and/or modify it under
9:`=1 )Y*s>-.--   : the terms of the GNU Library General Public 9:`=1 )Y*s>-.-- : the terms of the GNU Library General Public
10.="- .-=="i,     .._ License as published by the Free Software 10.="- .-=="i, .._ License as published by the Free Software
11 - .   .-<_>     .<> Foundation; either version 2 of the License, 11- . .-<_> .<> Foundation; either version 2 of the License,
12     ._= =}       : or (at your option) any later version. 12 ._= =} : or (at your option) any later version.
13    .%`+i>       _;_. 13 .%`+i> _;_.
14    .i_,=:_.      -<s. This program is distributed in the hope that 14 .i_,=:_. -<s. This program is distributed in the hope that
15     +  .  -:.       = it will be useful, but WITHOUT ANY WARRANTY; 15 + . -:. = it will be useful, but WITHOUT ANY WARRANTY;
16    : ..    .:,     . . . without even the implied warranty of 16 : .. .:, . . . without even the implied warranty of
17    =_        +     =;=|` MERCHANTABILITY or FITNESS FOR A 17 =_ + =;=|` MERCHANTABILITY or FITNESS FOR A
18  _.=:.       :    :=>`: PARTICULAR PURPOSE. See the GNU 18 _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU
19..}^=.=       =       ; Library General Public License for more 19..}^=.= = ; Library General Public License for more
20++=   -.     .`     .: details. 20++= -. .` .: details.
21 :     =  ...= . :.=- 21: = ...= . :.=-
22 -.   .:....=;==+<; You should have received a copy of the GNU 22-. .:....=;==+<; You should have received a copy of the GNU
23  -_. . .   )=.  = Library General Public License along with 23 -_. . . )=. = Library General Public License along with
24    --        :-=` this library; see the file COPYING.LIB. 24 -- :-=` this library; see the file COPYING.LIB.
25 If not, write to the Free Software Foundation, 25 If not, write to the Free Software Foundation,
26 Inc., 59 Temple Place - Suite 330, 26 Inc., 59 Temple Place - Suite 330,
27 Boston, MA 02111-1307, USA. 27 Boston, MA 02111-1307, USA.
28*/ 28*/
29 29
30#include "odevice_zaurus.h" 30#include "odevice_zaurus.h"
31 31
32/* QT */ 32/* QT */
33#include <qapplication.h> 33#include <qapplication.h>
34#include <qfile.h> 34#include <qfile.h>
35#include <qtextstream.h> 35#include <qtextstream.h>
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38/* OPIE */ 38/* OPIE */
39#include <qpe/config.h> 39#include <qpe/config.h>
40#include <qpe/resource.h> 40#include <qpe/resource.h>
41#include <qpe/sound.h> 41#include <qpe/sound.h>
42#include <qpe/qcopenvelope_qws.h> 42#include <qpe/qcopenvelope_qws.h>
43 43
44/* STD */ 44/* STD */
45#include <fcntl.h> 45#include <fcntl.h>
46#include <math.h> 46#include <math.h>
47#include <stdlib.h> 47#include <stdlib.h>
48#include <signal.h> 48#include <signal.h>
49#include <sys/ioctl.h> 49#include <sys/ioctl.h>
50#include <sys/time.h> 50#include <sys/time.h>
51#include <unistd.h> 51#include <unistd.h>
52#ifndef QT_NO_SOUND 52#ifndef QT_NO_SOUND
53#include <linux/soundcard.h> 53#include <linux/soundcard.h>
54#endif 54#endif
55 55
56using namespace Opie::Core; 56using namespace Opie::Core;
57using namespace Opie::Core::Internal; 57using namespace Opie::Core::Internal;
58 58
59struct z_button z_buttons [] = { 59struct z_button z_buttons [] = {
60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 60 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
61 "devicebuttons/z_calendar", 61 "devicebuttons/z_calendar",
62 "datebook", "nextView()", 62 "datebook", "nextView()",
63 "today", "raise()" }, 63 "today", "raise()" },
64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"), 64 { Qt::Key_F10, QT_TRANSLATE_NOOP("Button", "Contacts Button"),
65 "devicebuttons/z_contact", 65 "devicebuttons/z_contact",
66 "addressbook", "raise()", 66 "addressbook", "raise()",
67 "addressbook", "beamBusinessCard()" }, 67 "addressbook", "beamBusinessCard()" },
68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"), 68 { Qt::Key_F12, QT_TRANSLATE_NOOP("Button", "Home Button"),
69 "devicebuttons/z_home", 69 "devicebuttons/z_home",
70 "QPE/Launcher", "home()", 70 "QPE/Launcher", "home()",
71 "buttonsettings", "raise()" }, 71 "buttonsettings", "raise()" },
72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"), 72 { Qt::Key_F11, QT_TRANSLATE_NOOP("Button", "Menu Button"),
@@ -461,125 +461,127 @@ bool Zaurus::setDisplayStatus( bool on )
461 char buf[10]; 461 char buf[10];
462 buf[0] = on ? '1' : '0'; 462 buf[0] = on ? '1' : '0';
463 buf[1] = '\0'; 463 buf[1] = '\0';
464 res = ( ::write( fd, &buf[0], 2 ) == 0 ); 464 res = ( ::write( fd, &buf[0], 2 ) == 0 );
465 ::close( fd ); 465 ::close( fd );
466 } 466 }
467 } 467 }
468 return res; 468 return res;
469} 469}
470 470
471bool Zaurus::suspend() 471bool Zaurus::suspend()
472{ 472{
473 qDebug("ODevice::suspend"); 473 qDebug("ODevice::suspend");
474 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 474 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
475 return false; 475 return false;
476 476
477 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 477 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
478 return false; 478 return false;
479 479
480 bool res = false; 480 bool res = false;
481 ODevice::sendSuspendmsg(); 481 ODevice::sendSuspendmsg();
482 482
483 struct timeval tvs, tvn; 483 struct timeval tvs, tvn;
484 ::gettimeofday ( &tvs, 0 ); 484 ::gettimeofday ( &tvs, 0 );
485 485
486 ::sync(); // flush fs caches 486 ::sync(); // flush fs caches
487 res = ( ::system ( "apm --suspend" ) == 0 ); 487 res = ( ::system ( "apm --suspend" ) == 0 );
488 488
489 // This is needed because the apm implementation is asynchronous and we 489 // This is needed because the apm implementation is asynchronous and we
490 // can not be sure when exactly the device is really suspended 490 // can not be sure when exactly the device is really suspended
491 if ( res ) { 491 if ( res ) {
492 do { // Yes, wait 15 seconds. This APM sucks big time. 492 do { // Yes, wait 15 seconds. This APM sucks big time.
493 ::usleep ( 200 * 1000 ); 493 ::usleep ( 200 * 1000 );
494 ::gettimeofday ( &tvn, 0 ); 494 ::gettimeofday ( &tvn, 0 );
495 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 ); 495 } while ((( tvn. tv_sec - tvs. tv_sec ) * 1000 + ( tvn. tv_usec - tvs. tv_usec ) / 1000 ) < 15000 );
496 } 496 }
497 497
498 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" ); 498 QCopEnvelope ( "QPE/Rotation", "rotateDefault()" );
499 return res; 499 return res;
500} 500}
501 501
502 502
503Transformation Zaurus::rotation() const 503Transformation Zaurus::rotation() const
504{ 504{
505 Transformation rot; 505 Transformation rot;
506 506
507 switch ( d->m_model ) { 507 switch ( d->m_model ) {
508 case Model_Zaurus_SLC3000: // fallthrough 508 case Model_Zaurus_SLC3000: // fallthrough
509 case Model_Zaurus_SLC7x0: 509 case Model_Zaurus_SLC7x0: {
510 OHingeStatus hs = readHingeSensor(); 510 OHingeStatus hs = readHingeSensor();
511 if ( hs == CASE_PORTRAIT ) rot = Rot0; 511 if ( hs == CASE_PORTRAIT ) rot = Rot0;
512 else if ( hs == CASE_UNKNOWN ) rot = Rot0; 512 else if ( hs == CASE_UNKNOWN ) rot = Rot0;
513 else rot = Rot270; 513 else rot = Rot270;
514 }
514 break; 515 break;
515 case Model_Zaurus_SL6000: 516 case Model_Zaurus_SL6000:
516 case Model_Zaurus_SLB600: 517 case Model_Zaurus_SLB600:
517 case Model_Zaurus_SLA300: 518 case Model_Zaurus_SLA300:
518 case Model_Zaurus_SL5500: 519 case Model_Zaurus_SL5500:
519 case Model_Zaurus_SL5000: 520 case Model_Zaurus_SL5000:
520 default: 521 default:
521 rot = d->m_rotation; 522 rot = d->m_rotation;
522 break; 523 break;
523 } 524 }
524 525
525 return rot; 526 return rot;
526} 527}
527ODirection Zaurus::direction() const 528ODirection Zaurus::direction() const
528{ 529{
529 ODirection dir; 530 ODirection dir;
530 531
531 switch ( d->m_model ) { 532 switch ( d->m_model ) {
532 case Model_Zaurus_SLC3000: // fallthrough 533 case Model_Zaurus_SLC3000: // fallthrough
533 case Model_Zaurus_SLC7x0: 534 case Model_Zaurus_SLC7x0: {
534 OHingeStatus hs = readHingeSensor(); 535 OHingeStatus hs = readHingeSensor();
535 if ( hs == CASE_PORTRAIT ) dir = CCW; 536 if ( hs == CASE_PORTRAIT ) dir = CCW;
536 else if ( hs == CASE_UNKNOWN ) dir = CCW; 537 else if ( hs == CASE_UNKNOWN ) dir = CCW;
537 else dir = CW; 538 else dir = CW;
539 }
538 break; 540 break;
539 case Model_Zaurus_SL6000: 541 case Model_Zaurus_SL6000:
540 case Model_Zaurus_SLA300: 542 case Model_Zaurus_SLA300:
541 case Model_Zaurus_SLB600: 543 case Model_Zaurus_SLB600:
542 case Model_Zaurus_SL5500: 544 case Model_Zaurus_SL5500:
543 case Model_Zaurus_SL5000: 545 case Model_Zaurus_SL5000:
544 default: dir = d->m_direction; 546 default: dir = d->m_direction;
545 break; 547 break;
546 } 548 }
547 return dir; 549 return dir;
548 550
549} 551}
550 552
551bool Zaurus::hasHingeSensor() const 553bool Zaurus::hasHingeSensor() const
552{ 554{
553 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000; 555 return d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLC3000;
554} 556}
555 557
556OHingeStatus Zaurus::readHingeSensor() const 558OHingeStatus Zaurus::readHingeSensor() const
557{ 559{
558 if (m_embedix) 560 if (m_embedix)
559 { 561 {
560 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK); 562 int handle = ::open("/dev/apm_bios", O_RDWR|O_NONBLOCK);
561 if (handle == -1) 563 if (handle == -1)
562 { 564 {
563 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror 565 qWarning("Zaurus::readHingeSensor() - failed (%s)", "unknown reason" ); //FIXME: use strerror
564 return CASE_UNKNOWN; 566 return CASE_UNKNOWN;
565 } 567 }
566 else 568 else
567 { 569 {
568 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION); 570 int retval = ::ioctl(handle, SHARP_IOCTL_GET_ROTATION);
569 ::close (handle); 571 ::close (handle);
570 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE ) 572 if ( retval == CASE_CLOSED || retval == CASE_PORTRAIT || retval == CASE_LANDSCAPE )
571 { 573 {
572 qDebug( "Zaurus::readHingeSensor() - result = %d", retval ); 574 qDebug( "Zaurus::readHingeSensor() - result = %d", retval );
573 return static_cast<OHingeStatus>( retval ); 575 return static_cast<OHingeStatus>( retval );
574 } 576 }
575 else 577 else
576 { 578 {
577 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" ); 579 qWarning("Zaurus::readHingeSensor() - couldn't compute hinge status!" );
578 return CASE_UNKNOWN; 580 return CASE_UNKNOWN;
579 } 581 }
580 } 582 }
581 } 583 }
582 else 584 else
583 { 585 {
584 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" ); 586 qDebug( "Zaurus::readHingeSensor: ODevice handling for non-embedix kernels not yet implemented" );
585 return CASE_UNKNOWN; 587 return CASE_UNKNOWN;