summaryrefslogtreecommitdiff
path: root/libopie2
authorzecke <zecke>2004-08-25 21:51:13 (UTC)
committer zecke <zecke>2004-08-25 21:51:13 (UTC)
commitdf3e4c8b13c16aeb96e70dbaa2d409f83eed988e (patch) (unidiff)
tree59b12028c6e8a53b99f1686278b6e9fdc57ab18e /libopie2
parente4811064703ad34f42f15c3044cd8f63c0e7583c (diff)
downloadopie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.zip
opie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.tar.gz
opie-df3e4c8b13c16aeb96e70dbaa2d409f83eed988e.tar.bz2
-Have a common implementation for reading the config value
and setting the Mixer. The mixer, sound and path is configurable -Restore the Opie HEADER (who is guilty? probably me) -Fix warnings -Port Zaurus,Simpad,Ipaq to configure the mixer
Diffstat (limited to 'libopie2') (more/less context) (ignore whitespace changes)
-rw-r--r--libopie2/opiecore/device/odevice.cpp57
-rw-r--r--libopie2/opiecore/device/odevice.h55
-rw-r--r--libopie2/opiecore/device/odevice_ipaq.cpp71
-rw-r--r--libopie2/opiecore/device/odevice_simpad.cpp47
-rw-r--r--libopie2/opiecore/device/odevice_simpad.h2
-rw-r--r--libopie2/opiecore/device/odevice_yopy.cpp2
-rw-r--r--libopie2/opiecore/device/odevice_zaurus.cpp99
7 files changed, 158 insertions, 175 deletions
diff --git a/libopie2/opiecore/device/odevice.cpp b/libopie2/opiecore/device/odevice.cpp
index b58f9eb..26c6dca 100644
--- a/libopie2/opiecore/device/odevice.cpp
+++ b/libopie2/opiecore/device/odevice.cpp
@@ -1,95 +1,96 @@
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 =. 4 =.
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_ipaq.h" 30#include "odevice_ipaq.h"
31#include "odevice_jornada.h" 31#include "odevice_jornada.h"
32#include "odevice_ramses.h" 32#include "odevice_ramses.h"
33#include "odevice_simpad.h" 33#include "odevice_simpad.h"
34#include "odevice_yopy.h" 34#include "odevice_yopy.h"
35#include "odevice_zaurus.h" 35#include "odevice_zaurus.h"
36 36
37/* QT */ 37/* QT */
38#include <qapplication.h> 38#include <qapplication.h>
39#include <qfile.h> 39#include <qfile.h>
40#include <qtextstream.h> 40#include <qtextstream.h>
41#include <qwindowsystem_qws.h> 41#include <qwindowsystem_qws.h>
42 42
43/* OPIE */ 43/* OPIE */
44#include <qpe/config.h> 44#include <qpe/config.h>
45#include <qpe/resource.h> 45#include <qpe/resource.h>
46#include <qpe/sound.h> 46#include <qpe/sound.h>
47#include <qpe/qcopenvelope_qws.h> 47#include <qpe/qcopenvelope_qws.h>
48#include <qpe/sound.h>
48#include <opie2/okeyfilter.h> 49#include <opie2/okeyfilter.h>
49 50
50/* STD */ 51/* STD */
51#include <fcntl.h> 52#include <fcntl.h>
52#include <math.h> 53#include <math.h>
53#include <stdlib.h> 54#include <stdlib.h>
54#include <signal.h> 55#include <signal.h>
55#include <sys/ioctl.h> 56#include <sys/ioctl.h>
56#include <sys/time.h> 57#include <sys/time.h>
57#include <unistd.h> 58#include <unistd.h>
58#ifndef QT_NO_SOUND 59#ifndef QT_NO_SOUND
59#include <linux/soundcard.h> 60#include <linux/soundcard.h>
60#endif 61#endif
61 62
62namespace Opie { 63namespace Opie {
63namespace Core { 64namespace Core {
64 65
65static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo"; 66static const char* PATH_PROC_CPUINFO = "/proc/cpuinfo";
66 67
67 68
68/* STATIC and common implementation */ 69/* STATIC and common implementation */
69/* EXPORT */ ODistribution distributions[] = { 70/* EXPORT */ ODistribution distributions[] = {
70 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" }, 71 { System_Familiar, "FamiliarLinux", "/etc/familiar-version" },
71 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" }, 72 { System_OpenZaurus, "OpenZaurus", "/etc/oz_version" },
72 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" }, 73 { System_OpenEmbedded, "OpenEmbedded", "/etc/oe-version" },
73 { System_Unknown, "Linux", "/etc/issue" }, 74 { System_Unknown, "Linux", "/etc/issue" },
74}; 75};
75 76
76 77
77/* EXPORT */ bool isQWS(){ 78/* EXPORT */ bool isQWS(){
78 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false; 79 return qApp ? ( qApp->type() == QApplication::GuiServer ) : false;
79} 80}
80 81
81/* EXPORT */ QCString makeChannel ( const char *str ){ 82/* EXPORT */ QCString makeChannel ( const char *str ){
82 if ( str && !::strchr ( str, '/' )) 83 if ( str && !::strchr ( str, '/' ))
83 return QCString ( "QPE/Application/" ) + str; 84 return QCString ( "QPE/Application/" ) + str;
84 else 85 else
85 return str; 86 return str;
86} 87}
87 88
88 89
89 90
90/* Now the default implementation of ODevice */ 91/* Now the default implementation of ODevice */
91 92
92struct default_button default_buttons [] = { 93struct default_button default_buttons [] = {
93 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"), 94 { Qt::Key_F9, QT_TRANSLATE_NOOP("Button", "Calendar Button"),
94 "devicebuttons/z_calendar", 95 "devicebuttons/z_calendar",
95 "datebook", "nextView()", 96 "datebook", "nextView()",
@@ -126,96 +127,100 @@ ODevice *ODevice::inst()
126 { 127 {
127 QTextStream s( &f ); 128 QTextStream s( &f );
128 while ( !s.atEnd() ) 129 while ( !s.atEnd() )
129 { 130 {
130 QString line; 131 QString line;
131 line = s.readLine(); 132 line = s.readLine();
132 if ( line.startsWith( "Hardware" ) ) 133 if ( line.startsWith( "Hardware" ) )
133 { 134 {
134 qDebug( "ODevice() - found '%s'", (const char*) line ); 135 qDebug( "ODevice() - found '%s'", (const char*) line );
135 cpu_info = line; 136 cpu_info = line;
136 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus(); 137 if ( line.contains( "sharp", false ) ) dev = new Internal::Zaurus();
137 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ(); 138 else if ( line.contains( "ipaq", false ) ) dev = new Internal::iPAQ();
138 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad(); 139 else if ( line.contains( "simpad", false ) ) dev = new Internal::SIMpad();
139 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada(); 140 else if ( line.contains( "jornada", false ) ) dev = new Internal::Jornada();
140 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses(); 141 else if ( line.contains( "ramses", false ) ) dev = new Internal::Ramses();
141 else qWarning( "ODevice() - unknown hardware - using default." ); 142 else qWarning( "ODevice() - unknown hardware - using default." );
142 break; 143 break;
143 } 144 }
144 } 145 }
145 } 146 }
146 else 147 else
147 { 148 {
148 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO ); 149 qWarning( "ODevice() - can't open '%s' - unknown hardware - using default.", PATH_PROC_CPUINFO );
149 } 150 }
150 if ( !dev ) dev = new ODevice(); 151 if ( !dev ) dev = new ODevice();
151 dev->init(cpu_info); 152 dev->init(cpu_info);
152 } 153 }
153 return dev; 154 return dev;
154} 155}
155 156
156ODevice::ODevice() 157ODevice::ODevice()
157{ 158{
158 d = new ODeviceData; 159 d = new ODeviceData;
159 160
160 d->m_modelstr = "Unknown"; 161 d->m_modelstr = "Unknown";
161 d->m_model = Model_Unknown; 162 d->m_model = Model_Unknown;
162 d->m_vendorstr = "Unknown"; 163 d->m_vendorstr = "Unknown";
163 d->m_vendor = Vendor_Unknown; 164 d->m_vendor = Vendor_Unknown;
164 d->m_systemstr = "Unknown"; 165 d->m_systemstr = "Unknown";
165 d->m_system = System_Unknown; 166 d->m_system = System_Unknown;
166 d->m_sysverstr = "0.0"; 167 d->m_sysverstr = "0.0";
167 d->m_rotation = Rot0; 168 d->m_rotation = Rot0;
168 d->m_direction = CW; 169 d->m_direction = CW;
169 170
170 d->m_holdtime = 1000; // 1000ms 171 d->m_holdtime = 1000; // 1000ms
171 d->m_buttons = 0; 172 d->m_buttons = 0;
172 d->m_cpu_frequencies = new QStrList; 173 d->m_cpu_frequencies = new QStrList;
173 174
175
176 /* mixer */
177 d->m_sound = d->m_vol = d->m_mixer = -1;
178
174 // New distribution detection code first checks for legacy distributions, 179 // New distribution detection code first checks for legacy distributions,
175 // identified by /etc/familiar-version or /etc/oz_version. 180 // identified by /etc/familiar-version or /etc/oz_version.
176 // Then check for OpenEmbedded and lastly, read /etc/issue 181 // Then check for OpenEmbedded and lastly, read /etc/issue
177 182
178 for ( unsigned int i = 0; i < sizeof distributions; ++i ) 183 for ( unsigned int i = 0; i < sizeof distributions; ++i )
179 { 184 {
180 if ( QFile::exists( distributions[i].sysvfile ) ) 185 if ( QFile::exists( distributions[i].sysvfile ) )
181 { 186 {
182 d->m_systemstr = distributions[i].sysstr; 187 d->m_systemstr = distributions[i].sysstr;
183 d->m_system = distributions[i].system; 188 d->m_system = distributions[i].system;
184 d->m_sysverstr = "<Unknown>"; 189 d->m_sysverstr = "<Unknown>";
185 QFile f( distributions[i].sysvfile ); 190 QFile f( distributions[i].sysvfile );
186 if ( f.open( IO_ReadOnly ) ) 191 if ( f.open( IO_ReadOnly ) )
187 { 192 {
188 QTextStream ts( &f ); 193 QTextStream ts( &f );
189 d->m_sysverstr = ts.readLine(); 194 d->m_sysverstr = ts.readLine();
190 } 195 }
191 break; 196 break;
192 } 197 }
193 } 198 }
194} 199}
195 200
196void ODevice::systemMessage( const QCString &msg, const QByteArray & ) 201void ODevice::systemMessage( const QCString &msg, const QByteArray & )
197{ 202{
198 if ( msg == "deviceButtonMappingChanged()" ) { 203 if ( msg == "deviceButtonMappingChanged()" ) {
199 reloadButtonMapping(); 204 reloadButtonMapping();
200 } 205 }
201} 206}
202 207
203void ODevice::init(const QString&) 208void ODevice::init(const QString&)
204{ 209{
205} 210}
206 211
207/** 212/**
208* This method initialises the button mapping 213* This method initialises the button mapping
209*/ 214*/
210void ODevice::initButtons() 215void ODevice::initButtons()
211{ 216{
212 if ( d->m_buttons ) 217 if ( d->m_buttons )
213 return; 218 return;
214 219
215 qDebug ( "init Buttons" ); 220 qDebug ( "init Buttons" );
216 d->m_buttons = new QValueList <ODeviceButton>; 221 d->m_buttons = new QValueList <ODeviceButton>;
217 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) { 222 for ( uint i = 0; i < ( sizeof( default_buttons ) / sizeof( default_button )); i++ ) {
218 default_button *db = default_buttons + i; 223 default_button *db = default_buttons + i;
219 ODeviceButton b; 224 ODeviceButton b;
220 b. setKeycode ( db->code ); 225 b. setKeycode ( db->code );
221 b. setUserText ( QObject::tr ( "Button", db->utext )); 226 b. setUserText ( QObject::tr ( "Button", db->utext ));
@@ -660,69 +665,121 @@ void ODevice::reloadButtonMapping()
660 665
661void ODevice::remapPressedAction ( int button, const OQCopMessage &action ) 666void ODevice::remapPressedAction ( int button, const OQCopMessage &action )
662{ 667{
663 initButtons(); 668 initButtons();
664 669
665 QString mb_chan; 670 QString mb_chan;
666 671
667 if ( button >= (int) d->m_buttons->count()) 672 if ( button >= (int) d->m_buttons->count())
668 return; 673 return;
669 674
670 ODeviceButton &b = ( *d->m_buttons ) [button]; 675 ODeviceButton &b = ( *d->m_buttons ) [button];
671 b. setPressedAction ( action ); 676 b. setPressedAction ( action );
672 677
673 mb_chan=b. pressedAction(). channel(); 678 mb_chan=b. pressedAction(). channel();
674 679
675 Config buttonFile ( "ButtonSettings" ); 680 Config buttonFile ( "ButtonSettings" );
676 buttonFile. setGroup ( "Button" + QString::number ( button )); 681 buttonFile. setGroup ( "Button" + QString::number ( button ));
677 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan); 682 buttonFile. writeEntry ( "PressedActionChannel", (const char*) mb_chan);
678 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message()); 683 buttonFile. writeEntry ( "PressedActionMessage", (const char*) b. pressedAction(). message());
679 684
680// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data())); 685// buttonFile. writeEntry ( "PressedActionArgs", encodeBase64 ( b. pressedAction(). data()));
681 686
682 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 687 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
683} 688}
684 689
685void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) 690void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
686{ 691{
687 initButtons(); 692 initButtons();
688 693
689 if ( button >= (int) d->m_buttons->count()) 694 if ( button >= (int) d->m_buttons->count())
690 return; 695 return;
691 696
692 ODeviceButton &b = ( *d->m_buttons ) [button]; 697 ODeviceButton &b = ( *d->m_buttons ) [button];
693 b. setHeldAction ( action ); 698 b. setHeldAction ( action );
694 699
695 Config buttonFile ( "ButtonSettings" ); 700 Config buttonFile ( "ButtonSettings" );
696 buttonFile. setGroup ( "Button" + QString::number ( button )); 701 buttonFile. setGroup ( "Button" + QString::number ( button ));
697 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); 702 buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel());
698 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); 703 buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message());
699 704
700// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); 705// buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data()));
701 706
702 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); 707 QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" );
703} 708}
704void ODevice::virtual_hook(int, void* ){ 709void ODevice::virtual_hook(int, void* ){
705 710
706} 711}
707 712
713/**
714 * Sends a QCOP message to channel QPE/System
715 * with the message "aboutToSuspend()" if this
716 * is the windowing server
717 */
708void ODevice::sendSuspendmsg() 718void ODevice::sendSuspendmsg()
709{ 719{
710 if ( isQWS() ) 720 if ( isQWS() )
711 return; 721 return;
712 722
713 QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); 723 QCopEnvelope ( "QPE/System", "aboutToSuspend()" );
714} 724}
715 725
726/**
727 * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters
728 *
729 * Prepend a QWSServer::KeyboardFilter to the List of Keyboard
730 * Filters. This function is the only way to prepend a KeyFilter.
731 *
732 * @param aFilter The KeyFilter to be prepended to the list of filters
733 *
734 * @see Opie::Core::OKeyFilter
735 * @see Opie::Core::OKeyFilter::inst()
736 */
716void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) 737void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter)
717{ 738{
718 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); 739 Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter);
719} 740}
720 741
742/**
743 * \brief Remove the QWSServer::KeyboardFilter in the param from the list
744 *
745 * Remove the QWSServer::KeyboardFilter \par aFilter from the List
746 * of Keyfilters. Call this when you delete the KeyFilter!
747 *
748 * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter
749 * @see Opie::Core::ODevice::addPreHandler
750 */
721void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) 751void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter)
722{ 752{
723 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); 753 Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter);
724} 754}
725 755
756void ODevice::playingStopped() {
757 const_cast<QObject*>(sender())->disconnect( this );
758 if ( d->m_sound >= 0 ) {
759 ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol );
760 ::close ( d->m_sound );
761 }
762}
763
764void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) {
765 if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) {
766 if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) {
767 Config cfg ( "qpe" );
768 cfg. setGroup ( "Volume" );
769
770 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
771 if ( volalarm < 0 )
772 volalarm = 0;
773 else if ( volalarm > 100 )
774 volalarm = 100;
775 volalarm |= ( volalarm << 8 );
776
777 if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 )
778 register_qpe_sound_finished(snd, this, SLOT(playingStopped()));
779 }
780 d->m_mixer = mixer;
781 }
782}
726 783
727} 784}
728} 785}
diff --git a/libopie2/opiecore/device/odevice.h b/libopie2/opiecore/device/odevice.h
index cb7a83f..f4b3e0e 100644
--- a/libopie2/opiecore/device/odevice.h
+++ b/libopie2/opiecore/device/odevice.h
@@ -1,95 +1,100 @@
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 =. 4 =.
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#ifndef ODEVICE_H_ 30#ifndef ODEVICE_H_
31#define ODEVICE_H_ 31#define ODEVICE_H_
32 32
33/* OPIE */ 33/* OPIE */
34#include <opie2/odevicebutton.h> 34#include <opie2/odevicebutton.h>
35#include <qpe/qpeapplication.h> /* for Transformation enum.. */ 35#include <qpe/qpeapplication.h> /* for Transformation enum.. */
36 36
37/* QT */ 37/* QT */
38#include <qnamespace.h> 38#include <qnamespace.h>
39#include <qobject.h> 39#include <qobject.h>
40#include <qstring.h> 40#include <qstring.h>
41
42
41#include <qstrlist.h> 43#include <qstrlist.h>
42#include <qwindowsystem_qws.h> 44#include <qwindowsystem_qws.h>
43 45
46
47class Sound;
48
44namespace Opie{ 49namespace Opie{
45namespace Core{ 50namespace Core{
46 51
47 class ODeviceData; 52class ODeviceData;
48/** 53/**
49 * The available devices 54 * The available devices
50 */ 55 */
51enum OModel { 56enum OModel {
52 Model_Unknown, // = 0 57 Model_Unknown, // = 0
53 58
54 Model_Series_Mask = 0xff000000, 59 Model_Series_Mask = 0xff000000,
55 60
56 Model_iPAQ = ( 1 << 24 ), 61 Model_iPAQ = ( 1 << 24 ),
57 62
58 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ), 63 Model_iPAQ_All = ( Model_iPAQ | 0xffffff ),
59 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ), 64 Model_iPAQ_H31xx = ( Model_iPAQ | 0x000001 ),
60 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ), 65 Model_iPAQ_H36xx = ( Model_iPAQ | 0x000002 ),
61 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ), 66 Model_iPAQ_H37xx = ( Model_iPAQ | 0x000004 ),
62 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ), 67 Model_iPAQ_H38xx = ( Model_iPAQ | 0x000008 ),
63 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ), 68 Model_iPAQ_H39xx = ( Model_iPAQ | 0x000010 ),
64 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ), 69 Model_iPAQ_H5xxx = ( Model_iPAQ | 0x000020 ),
65 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ), 70 Model_iPAQ_H22xx = ( Model_iPAQ | 0x000040 ),
66 71
67 Model_Jornada = ( 6 << 24 ), 72 Model_Jornada = ( 6 << 24 ),
68 Model_Jornada_56x = ( Model_Jornada | 0x000001 ), 73 Model_Jornada_56x = ( Model_Jornada | 0x000001 ),
69 74
70 Model_Zaurus = ( 2 << 24 ), 75 Model_Zaurus = ( 2 << 24 ),
71 76
72 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ), 77 Model_Zaurus_SL5000 = ( Model_Zaurus | 0x000001 ),
73 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ), 78 Model_Zaurus_SL5500 = ( Model_Zaurus | 0x000002 ),
74 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ), 79 Model_Zaurus_SLA300 = ( Model_Zaurus | 0x000003 ),
75 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ), 80 Model_Zaurus_SLB600 = ( Model_Zaurus | 0x000004 ),
76 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ), 81 Model_Zaurus_SLC7x0 = ( Model_Zaurus | 0x000005 ),
77 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ), 82 Model_Zaurus_SL6000 = ( Model_Zaurus | 0x000006 ),
78 83
79 Model_SIMpad = ( 3 << 24 ), 84 Model_SIMpad = ( 3 << 24 ),
80 85
81 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ), 86 Model_SIMpad_All = ( Model_SIMpad | 0xffffff ),
82 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ), 87 Model_SIMpad_CL4 = ( Model_SIMpad | 0x000001 ),
83 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ), 88 Model_SIMpad_SL4 = ( Model_SIMpad | 0x000002 ),
84 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ), 89 Model_SIMpad_SLC = ( Model_SIMpad | 0x000004 ),
85 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ), 90 Model_SIMpad_TSinus = ( Model_SIMpad | 0x000008 ),
86 91
87 Model_Ramses = ( 4 << 24 ), 92 Model_Ramses = ( 4 << 24 ),
88 93
89 Model_Ramses_All = ( Model_Ramses | 0xffffff ), 94 Model_Ramses_All = ( Model_Ramses | 0xffffff ),
90 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ), 95 Model_Ramses_MNCI = ( Model_Ramses | 0x000001 ),
91 96
92 Model_Yopy = ( 5 << 24 ), 97 Model_Yopy = ( 5 << 24 ),
93 98
94 Model_Yopy_All = ( Model_Yopy | 0xffffff ), 99 Model_Yopy_All = ( Model_Yopy | 0xffffff ),
95 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ), 100 Model_Yopy_3000 = ( Model_Yopy | 0x000001 ),
@@ -274,89 +279,95 @@ public:
274 virtual int readLightSensor(); 279 virtual int readLightSensor();
275 virtual int lightSensorResolution() const; 280 virtual int lightSensorResolution() const;
276 281
277 virtual bool hasHingeSensor() const; 282 virtual bool hasHingeSensor() const;
278 virtual OHingeStatus readHingeSensor(); 283 virtual OHingeStatus readHingeSensor();
279 284
280 const QStrList &allowedCpuFrequencies() const; 285 const QStrList &allowedCpuFrequencies() const;
281 bool setCurrentCpuFrequency(uint index); 286 bool setCurrentCpuFrequency(uint index);
282 287
283 /** 288 /**
284 * Returns the available buttons on this device. The number and location 289 * Returns the available buttons on this device. The number and location
285 * of buttons will vary depending on the device. Button numbers will be assigned 290 * of buttons will vary depending on the device. Button numbers will be assigned
286 * by the device manufacturer and will be from most preferred button to least preffered 291 * by the device manufacturer and will be from most preferred button to least preffered
287 * button. Note that this list only contains "user mappable" buttons. 292 * button. Note that this list only contains "user mappable" buttons.
288 * 293 *
289 * @todo Make method const and take care of calling initButtons or make that const too 294 * @todo Make method const and take care of calling initButtons or make that const too
290 * 295 *
291 */ 296 */
292 const QValueList<ODeviceButton> &buttons(); 297 const QValueList<ODeviceButton> &buttons();
293 298
294 /** 299 /**
295 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it 300 * Returns the DeviceButton for the \a keyCode. If \a keyCode is not found, it
296 * returns 0L 301 * returns 0L
297 */ 302 */
298 const ODeviceButton *buttonForKeycode ( ushort keyCode ); 303 const ODeviceButton *buttonForKeycode ( ushort keyCode );
299 304
300 /** 305 /**
301 * Reassigns the pressed action for \a button. To return to the factory 306 * Reassigns the pressed action for \a button. To return to the factory
302 * default pass an empty string as \a qcopMessage. 307 * default pass an empty string as \a qcopMessage.
303 */ 308 */
304 void remapPressedAction ( int button, const OQCopMessage &qcopMessage ); 309 void remapPressedAction ( int button, const OQCopMessage &qcopMessage );
305 310
306 /** 311 /**
307 * Reassigns the held action for \a button. To return to the factory 312 * Reassigns the held action for \a button. To return to the factory
308 * default pass an empty string as \a qcopMessage. 313 * default pass an empty string as \a qcopMessage.
309 */ 314 */
310 void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); 315 void remapHeldAction ( int button, const OQCopMessage &qcopMessage );
311 316
312 /** 317 /**
313 * How long (in ms) you have to press a button for a "hold" action 318 * How long (in ms) you have to press a button for a "hold" action
314 */ 319 */
315 uint buttonHoldTime() const; 320 uint buttonHoldTime() const;
316 321
317signals: 322signals:
318 void buttonMappingChanged(); 323 void buttonMappingChanged();
319 324
320private slots: 325private slots:
321 void systemMessage ( const QCString &, const QByteArray & ); 326 void systemMessage ( const QCString &, const QByteArray & );
327 void playingStopped();
322 328
323protected: 329protected:
324 void addPreHandler(QWSServer::KeyboardFilter*aFilter); 330 void addPreHandler(QWSServer::KeyboardFilter*aFilter);
325 void remPreHandler(QWSServer::KeyboardFilter*aFilter); 331 void remPreHandler(QWSServer::KeyboardFilter*aFilter);
326 void reloadButtonMapping(); 332 void reloadButtonMapping();
333 void changeMixerForAlarm( int mixer, const char* file, Sound *snd);
334
327 /* ugly virtual hook */ 335 /* ugly virtual hook */
328 virtual void virtual_hook( int id, void* data ); 336 virtual void virtual_hook( int id, void* data );
329}; 337};
330 338
331class ODeviceData { 339class ODeviceData {
332 340
333 public: 341 public:
334 QString m_vendorstr; 342 QString m_vendorstr;
335 OVendor m_vendor; 343 OVendor m_vendor;
336 344
337 QString m_modelstr; 345 QString m_modelstr;
338 OModel m_model; 346 OModel m_model;
339 347
340 QString m_systemstr; 348 QString m_systemstr;
341 OSystem m_system; 349 OSystem m_system;
342 350
343 QString m_sysverstr; 351 QString m_sysverstr;
344 352
345 Transformation m_rotation; 353 Transformation m_rotation;
346 ODirection m_direction; 354 ODirection m_direction;
347 355
348 QValueList <ODeviceButton> *m_buttons; 356 QValueList <ODeviceButton> *m_buttons;
349 uint m_holdtime; 357 uint m_holdtime;
350 QStrList *m_cpu_frequencies; 358 QStrList *m_cpu_frequencies;
359
360 /* values for changeMixerForAlarm */
361 int m_sound, m_vol, m_mixer;
351}; 362};
352 363
353extern bool isQWS(); 364extern bool isQWS();
354extern QCString makeChannel ( const char *str ); 365extern QCString makeChannel ( const char *str );
355} 366}
356} 367}
357 368
358 369
359 370
360 371
361#endif 372#endif
362 373
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp
index 21fed99..7f5aa7b 100644
--- a/libopie2/opiecore/device/odevice_ipaq.cpp
+++ b/libopie2/opiecore/device/odevice_ipaq.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) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
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_ipaq.h" 30#include "odevice_ipaq.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#include <opie2/okeyfilter.h> 43#include <opie2/okeyfilter.h>
44 44
45/* STD */ 45/* STD */
46#include <fcntl.h> 46#include <fcntl.h>
47#include <math.h> 47#include <math.h>
48#include <stdlib.h> 48#include <stdlib.h>
49#include <signal.h> 49#include <signal.h>
50#include <sys/ioctl.h> 50#include <sys/ioctl.h>
51#include <sys/time.h> 51#include <sys/time.h>
52#include <unistd.h> 52#include <unistd.h>
53#ifndef QT_NO_SOUND 53#ifndef QT_NO_SOUND
54#include <linux/soundcard.h> 54#include <linux/soundcard.h>
55#endif 55#endif
56 56
57 57
58using namespace Opie::Core; 58using namespace Opie::Core;
59using namespace Opie::Core::Internal; 59using namespace Opie::Core::Internal;
60 60
61/* KERNEL */ 61/* KERNEL */
62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 )) 62#define OD_IOC(dir,type,number,size) (( dir << 30 ) | ( type << 8 ) | ( number ) | ( size << 16 ))
63 63
64#define OD_IO(type,number) OD_IOC(0,type,number,0) 64#define OD_IO(type,number) OD_IOC(0,type,number,0)
65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size)) 65#define OD_IOW(type,number,size) OD_IOC(1,type,number,sizeof(size))
66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size)) 66#define OD_IOR(type,number,size) OD_IOC(2,type,number,sizeof(size))
67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size)) 67#define OD_IORW(type,number,size) OD_IOC(3,type,number,sizeof(size))
68 68
69typedef struct { 69typedef struct {
70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */ 70 unsigned char OffOnBlink; /* 0=off 1=on 2=Blink */
71 unsigned char TotalTime; /* Units of 5 seconds */ 71 unsigned char TotalTime; /* Units of 5 seconds */
72 unsigned char OnTime; /* units of 100m/s */ 72 unsigned char OnTime; /* units of 100m/s */
@@ -286,126 +286,99 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b
286 // keycode - Key_Left = position of the button starting from left clockwise 286 // keycode - Key_Left = position of the button starting from left clockwise
287 // add the rotation to it and modolo. No we've the original offset 287 // add the rotation to it and modolo. No we've the original offset
288 // add the offset to the Key_Left key 288 // add the offset to the Key_Left key
289 if ( d-> m_model == Model_iPAQ_H5xxx ) 289 if ( d-> m_model == Model_iPAQ_H5xxx )
290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; 290 newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4;
291 break; 291 break;
292 } 292 }
293 293
294 // map Power Button short/long press to F34/F35 294 // map Power Button short/long press to F34/F35
295 case Key_SysReq: { 295 case Key_SysReq: {
296 if ( isPress ) { 296 if ( isPress ) {
297 if ( m_power_timer ) 297 if ( m_power_timer )
298 killTimer ( m_power_timer ); 298 killTimer ( m_power_timer );
299 m_power_timer = startTimer ( 500 ); 299 m_power_timer = startTimer ( 500 );
300 } 300 }
301 else if ( m_power_timer ) { 301 else if ( m_power_timer ) {
302 killTimer ( m_power_timer ); 302 killTimer ( m_power_timer );
303 m_power_timer = 0; 303 m_power_timer = 0;
304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); 304 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false );
305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); 305 QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false );
306 } 306 }
307 newkeycode = Key_unknown; 307 newkeycode = Key_unknown;
308 break; 308 break;
309 } 309 }
310 } 310 }
311 311
312 if ( newkeycode != keycode ) { 312 if ( newkeycode != keycode ) {
313 if ( newkeycode != Key_unknown ) 313 if ( newkeycode != Key_unknown )
314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat ); 314 QWSServer::sendKeyEvent ( -1, newkeycode, modifiers, isPress, autoRepeat );
315 return true; 315 return true;
316 } 316 }
317 else 317 else
318 return false; 318 return false;
319} 319}
320 320
321void iPAQ::timerEvent ( QTimerEvent * ) 321void iPAQ::timerEvent ( QTimerEvent * )
322{ 322{
323 killTimer ( m_power_timer ); 323 killTimer ( m_power_timer );
324 m_power_timer = 0; 324 m_power_timer = 0;
325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 325 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 326 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
327} 327}
328 328
329 329
330void iPAQ::playAlarmSound() 330void iPAQ::playAlarmSound()
331{ 331{
332#ifndef QT_NO_SOUND 332#ifndef QT_NO_SOUND
333 static Sound snd ( "alarm" ); 333 static Sound snd ( "alarm" );
334 int fd;
335 int vol;
336 bool vol_reset = false;
337
338 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
339 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
340 Config cfg ( "qpe" );
341 cfg. setGroup ( "Volume" );
342
343 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
344 if ( volalarm < 0 )
345 volalarm = 0;
346 else if ( volalarm > 100 )
347 volalarm = 100;
348 volalarm |= ( volalarm << 8 );
349
350 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
351 vol_reset = true;
352 }
353 }
354 334
335 changeMixerForAlarm(0, "/dev/sound/mixer", &snd );
355 snd. play(); 336 snd. play();
356 while ( !snd. isFinished())
357 qApp->processEvents();
358
359 if ( fd >= 0 ) {
360 if ( vol_reset )
361 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
362 ::close ( fd );
363 }
364#endif 337#endif
365} 338}
366 339
367 340
368bool iPAQ::setSoftSuspend ( bool soft ) 341bool iPAQ::setSoftSuspend ( bool soft )
369{ 342{
370 bool res = false; 343 bool res = false;
371 int fd; 344 int fd;
372 345
373 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { 346 if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) {
374 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) 347 if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 )
375 res = true; 348 res = true;
376 else 349 else
377 ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); 350 ::perror ( "write to /proc/sys/ts/suspend_button_mode" );
378 351
379 ::close ( fd ); 352 ::close ( fd );
380 } 353 }
381 else 354 else
382 ::perror ( "/proc/sys/ts/suspend_button_mode" ); 355 ::perror ( "/proc/sys/ts/suspend_button_mode" );
383 356
384 return res; 357 return res;
385} 358}
386 359
387 360
388bool iPAQ::setDisplayBrightness ( int bright ) 361bool iPAQ::setDisplayBrightness ( int bright )
389{ 362{
390 bool res = false; 363 bool res = false;
391 int fd; 364 int fd;
392 365
393 if ( bright > 255 ) 366 if ( bright > 255 )
394 bright = 255; 367 bright = 255;
395 if ( bright < 0 ) 368 if ( bright < 0 )
396 bright = 0; 369 bright = 0;
397 370
398 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { 371 if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) {
399 FLITE_IN bl; 372 FLITE_IN bl;
400 bl. mode = 1; 373 bl. mode = 1;
401 bl. pwr = bright ? 1 : 0; 374 bl. pwr = bright ? 1 : 0;
402 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; 375 bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255;
403 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); 376 res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 );
404 ::close ( fd ); 377 ::close ( fd );
405 } 378 }
406 return res; 379 return res;
407} 380}
408 381
409int iPAQ::displayBrightnessResolution() const 382int iPAQ::displayBrightnessResolution() const
410{ 383{
411 switch ( model()) { 384 switch ( model()) {
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp
index c6de614..2d0160d 100644
--- a/libopie2/opiecore/device/odevice_simpad.cpp
+++ b/libopie2/opiecore/device/odevice_simpad.cpp
@@ -193,186 +193,157 @@ void SIMpad::initButtons()
193#define SIMPAD_RESET_SIMCARD 0x8000 193#define SIMPAD_RESET_SIMCARD 0x8000
194 194
195//SIMpad touchscreen backlight strength control 195//SIMpad touchscreen backlight strength control
196#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL" 196#define SIMPAD_BACKLIGHT_CONTROL "/proc/driver/mq200/registers/PWM_CONTROL"
197#define SIMPAD_BACKLIGHT_MASK 0x00a10044 197#define SIMPAD_BACKLIGHT_MASK 0x00a10044
198 198
199QValueList <OLed> SIMpad::ledList() const 199QValueList <OLed> SIMpad::ledList() const
200{ 200{
201 QValueList <OLed> vl; 201 QValueList <OLed> vl;
202 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? 202 vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one?
203 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway 203 //vl << Led_Mail; //TODO find out if LED1 is accessible anyway
204 return vl; 204 return vl;
205} 205}
206 206
207QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const 207QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const
208{ 208{
209 QValueList <OLedState> vl; 209 QValueList <OLedState> vl;
210 210
211 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? 211 if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one?
212 vl << Led_Off << Led_On; 212 vl << Led_Off << Led_On;
213 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway 213 //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway
214 //vl << Led_Off; 214 //vl << Led_Off;
215 return vl; 215 return vl;
216} 216}
217 217
218OLedState SIMpad::ledState ( OLed l ) const 218OLedState SIMpad::ledState ( OLed l ) const
219{ 219{
220 switch ( l ) { 220 switch ( l ) {
221 case Led_Power: 221 case Led_Power:
222 return m_leds [0]; 222 return m_leds [0];
223 //case Led_Mail: 223 //case Led_Mail:
224 // return m_leds [1]; 224 // return m_leds [1];
225 default: 225 default:
226 return Led_Off; 226 return Led_Off;
227 } 227 }
228} 228}
229 229
230bool SIMpad::setLedState ( OLed l, OLedState st ) 230bool SIMpad::setLedState ( OLed l, OLedState st )
231{ 231{
232#if 0 232#if 0
233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); 233 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK );
234 234
235 /*TODO Implement this like that: 235 /*TODO Implement this like that:
236 read from cs3 236 read from cs3
237 && with SIMPAD_LED2_ON 237 && with SIMPAD_LED2_ON
238 write to cs3 */ 238 write to cs3 */
239 m_leds [0] = st; 239 m_leds [0] = st;
240 return true; 240 return true;
241 } 241 // }
242 } 242// }
243 } 243#else
244 244 Q_UNUSED( l )
245 Q_UNUSED( st )
245#endif 246#endif
246 return false; 247 return false;
247} 248}
248 249
249 250
250bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) 251bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ )
251{ 252{
252 //TODO 253 //TODO
253 return false; 254 return false;
254} 255}
255 256
256void SIMpad::timerEvent ( QTimerEvent * ) 257void SIMpad::timerEvent ( QTimerEvent * )
257{ 258{
258 killTimer ( m_power_timer ); 259 killTimer ( m_power_timer );
259 m_power_timer = 0; 260 m_power_timer = 0;
260 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); 261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false );
261 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); 262 QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false );
262} 263}
263 264
264 265
265void SIMpad::playAlarmSound() 266void SIMpad::playAlarmSound()
266{ 267{
267#ifndef QT_NO_SOUND 268#ifndef QT_NO_SOUND
268 static Sound snd ( "alarm" ); 269 static Sound snd ( "alarm" );
269 int fd;
270 int vol;
271 bool vol_reset = false;
272
273 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
274 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
275 Config cfg ( "qpe" );
276 cfg. setGroup ( "Volume" );
277
278 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
279 if ( volalarm < 0 )
280 volalarm = 0;
281 else if ( volalarm > 100 )
282 volalarm = 100;
283 volalarm |= ( volalarm << 8 );
284
285 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
286 vol_reset = true;
287 }
288 }
289 270
271 /* save as the Sound is static! */
272 changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd);
290 snd. play(); 273 snd. play();
291 while ( !snd. isFinished())
292 qApp->processEvents();
293
294 if ( fd >= 0 ) {
295 if ( vol_reset )
296 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
297 ::close ( fd );
298 }
299#endif 274#endif
300} 275}
301 276
302 277
303bool SIMpad::suspend() // Must override because SIMpad does NOT have apm 278bool SIMpad::suspend() // Must override because SIMpad does NOT have apm
304{ 279{
305 qDebug( "ODevice for SIMpad: suspend()" ); 280 qDebug( "ODevice for SIMpad: suspend()" );
306 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 281 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
307 return false; 282 return false;
308 283
309 /* 284 /*
310 * we need to save the screen content 285 * we need to save the screen content
311 * then go to suspend using ODevice::suspend 286 * then go to suspend using ODevice::suspend
312 * and finally restore the screen content 287 * and finally restore the screen content
313 */ 288 */
314 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); 289 (void)::system( "cat /dev/fb/0 > /tmp/.buffer" );
315 bool res = ODevice::suspend(); 290 bool res = ODevice::suspend();
316 291
317 /* 292 /*
318 * restore 293 * restore
319 */ 294 */
320 if ( res ) 295 if ( res )
321 ::system( "cat /tmp/.buffer > /dev/fb/0" ); 296 ::system( "cat /tmp/.buffer > /dev/fb/0" );
322 297
323 return res; 298 return res;
324} 299}
325 300
326 301
327bool SIMpad::setSoftSuspend ( bool soft ) 302bool SIMpad::setSoftSuspend ( bool soft )
328{ 303{
329 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); 304 qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" );
330 return false; 305 return false;
331} 306}
332 307
333 308
334bool SIMpad::setDisplayStatus ( bool on ) 309bool SIMpad::setDisplayStatus ( bool on )
335{ 310{
336 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); 311 qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" );
337 312
338 bool res = false;
339 int fd;
340 313
341 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) 314 QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :)
342 315
343 res = ( ::system( (const char*) cmdline ) == 0 ); 316 return ( ::system( (const char*) cmdline ) == 0 );
344
345 return res;
346} 317}
347 318
348 319
349bool SIMpad::setDisplayBrightness ( int bright ) 320bool SIMpad::setDisplayBrightness ( int bright )
350{ 321{
351 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); 322 qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright );
352 bool res = false; 323 bool res = false;
353 int fd; 324 int fd;
354 325
355 if ( bright > 255 ) 326 if ( bright > 255 )
356 bright = 255; 327 bright = 255;
357 if ( bright < 1 ) 328 if ( bright < 1 )
358 bright = 0; 329 bright = 0;
359 330
360 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { 331 if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) {
361 int value = 255 - bright; 332 int value = 255 - bright;
362 const int mask = SIMPAD_BACKLIGHT_MASK; 333 const int mask = SIMPAD_BACKLIGHT_MASK;
363 value = value << 8; 334 value = value << 8;
364 value += mask; 335 value += mask;
365 char writeCommand[100]; 336 char writeCommand[100];
366 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); 337 const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value );
367 res = ( ::write ( fd, writeCommand, count ) != -1 ); 338 res = ( ::write ( fd, writeCommand, count ) != -1 );
368 ::close ( fd ); 339 ::close ( fd );
369 } 340 }
370 return res; 341 return res;
371} 342}
372 343
373 344
374int SIMpad::displayBrightnessResolution() const 345int SIMpad::displayBrightnessResolution() const
375{ 346{
376 return 255; // All SIMpad models share the same display 347 return 255; // All SIMpad models share the same display
377} 348}
378 349
diff --git a/libopie2/opiecore/device/odevice_simpad.h b/libopie2/opiecore/device/odevice_simpad.h
index d9ae5a5..6c42be7 100644
--- a/libopie2/opiecore/device/odevice_simpad.h
+++ b/libopie2/opiecore/device/odevice_simpad.h
@@ -1,51 +1,51 @@
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) 2003, 2004 The Opie Team <opie-devel@handhelds.org>
4 =. 4 =.
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#ifndef ODEVICE_SIMPAD 30#ifndef ODEVICE_SIMPAD
31#define ODEVICE_SIMPAD 31#define ODEVICE_SIMPAD
32 32
33#include <opie2/odevice.h> 33#include <opie2/odevice.h>
34 34
35/* QT */ 35/* QT */
36#include <qwindowsystem_qws.h> 36#include <qwindowsystem_qws.h>
37 37
38namespace Opie { 38namespace Opie {
39namespace Core { 39namespace Core {
40namespace Internal { 40namespace Internal {
41 41
42class SIMpad : public ODevice, public QWSServer::KeyboardFilter 42class SIMpad : public ODevice, public QWSServer::KeyboardFilter
43{ 43{
44 protected: 44 protected:
45 virtual void init(const QString&); 45 virtual void init(const QString&);
46 virtual void initButtons(); 46 virtual void initButtons();
47 47
48 public: 48 public:
49 virtual bool setSoftSuspend( bool soft ); 49 virtual bool setSoftSuspend( bool soft );
50 virtual bool suspend(); 50 virtual bool suspend();
51 51
diff --git a/libopie2/opiecore/device/odevice_yopy.cpp b/libopie2/opiecore/device/odevice_yopy.cpp
index 223aa76..a06d7ec 100644
--- a/libopie2/opiecore/device/odevice_yopy.cpp
+++ b/libopie2/opiecore/device/odevice_yopy.cpp
@@ -98,58 +98,60 @@ void Yopy::initButtons()
98 98
99 ODeviceButton b; 99 ODeviceButton b;
100 100
101 b. setKeycode ( ib->code ); 101 b. setKeycode ( ib->code );
102 b. setUserText ( QObject::tr ( "Button", ib->utext ) ); 102 b. setUserText ( QObject::tr ( "Button", ib->utext ) );
103 b. setPixmap ( Resource::loadPixmap ( ib->pix ) ); 103 b. setPixmap ( Resource::loadPixmap ( ib->pix ) );
104 b. setFactoryPresetPressedAction 104 b. setFactoryPresetPressedAction
105 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) ); 105 ( OQCopMessage( makeChannel( ib->fpressedservice ), ib->fpressedaction ) );
106 b. setFactoryPresetHeldAction 106 b. setFactoryPresetHeldAction
107 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) ); 107 ( OQCopMessage( makeChannel( ib->fheldservice ), ib->fheldaction ) );
108 108
109 d->m_buttons->append ( b ); 109 d->m_buttons->append ( b );
110 } 110 }
111 reloadButtonMapping(); 111 reloadButtonMapping();
112 112
113 QCopChannel *sysch = new QCopChannel( "QPE/System", this ); 113 QCopChannel *sysch = new QCopChannel( "QPE/System", this );
114 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ), 114 connect( sysch, SIGNAL( received(const QCString&,const QByteArray&) ),
115 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) ); 115 this, SLOT( systemMessage(const QCString&,const QByteArray&) ) );
116} 116}
117 117
118 118
119bool Yopy::suspend() 119bool Yopy::suspend()
120{ 120{
121 /* Opie for Yopy does not implement its own power management at the 121 /* Opie for Yopy does not implement its own power management at the
122 moment. The public version runs parallel to X, and relies on the 122 moment. The public version runs parallel to X, and relies on the
123 existing power management features. */ 123 existing power management features. */
124 return false; 124 return false;
125} 125}
126 126
127 127
128bool Yopy::setDisplayBrightness( int bright ) 128bool Yopy::setDisplayBrightness( int bright )
129{ 129{
130 /* The code here works, but is disabled as the current version runs 130 /* The code here works, but is disabled as the current version runs
131 parallel to X, and relies on the existing backlight demon. */ 131 parallel to X, and relies on the existing backlight demon. */
132#if 0 132#if 0
133 if ( QFile::exists( "/proc/sys/pm/light" ) ) 133 if ( QFile::exists( "/proc/sys/pm/light" ) )
134 { 134 {
135 int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); 135 int fd = ::open( "/proc/sys/pm/light", O_WRONLY );
136 if ( fd >= 0 ) 136 if ( fd >= 0 )
137 { 137 {
138 if ( bright ) 138 if ( bright )
139 ::write( fd, "1\n", 2 ); 139 ::write( fd, "1\n", 2 );
140 else 140 else
141 ::write( fd, "0\n", 2 ); 141 ::write( fd, "0\n", 2 );
142 ::close( fd ); 142 ::close( fd );
143 return true; 143 return true;
144 } 144 }
145 } 145 }
146#else
147 Q_UNUSED( bright )
146#endif 148#endif
147 return false; 149 return false;
148} 150}
149 151
150 152
151int Yopy::displayBrightnessResolution() const 153int Yopy::displayBrightnessResolution() const
152{ 154{
153 return 2; 155 return 2;
154} 156}
155 157
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp
index 47682bb..127fee9 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 =. 4 =.
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"),
@@ -138,98 +138,96 @@ void Zaurus::init(const QString& cpu_info)
138 FILE *uname = popen("uname -r", "r"); 138 FILE *uname = popen("uname -r", "r");
139 QFile f; 139 QFile f;
140 QString line; 140 QString line;
141 if ( f.open(IO_ReadOnly, uname) ) { 141 if ( f.open(IO_ReadOnly, uname) ) {
142 QTextStream ts ( &f ); 142 QTextStream ts ( &f );
143 line = ts. readLine(); 143 line = ts. readLine();
144 int loc = line. find ( "embedix" ); 144 int loc = line. find ( "embedix" );
145 if ( loc != -1 ) 145 if ( loc != -1 )
146 m_embedix = true; 146 m_embedix = true;
147 else 147 else
148 m_embedix = false; 148 m_embedix = false;
149 f.close(); 149 f.close();
150 } 150 }
151 pclose(uname); 151 pclose(uname);
152 } 152 }
153 153
154 // check the Zaurus model 154 // check the Zaurus model
155 QString model; 155 QString model;
156 int loc = cpu_info.find( ":" ); 156 int loc = cpu_info.find( ":" );
157 if ( loc != -1 ) 157 if ( loc != -1 )
158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace(); 158 model = cpu_info.mid( loc+2 ).simplifyWhiteSpace();
159 else 159 else
160 model = cpu_info; 160 model = cpu_info;
161 161
162 if ( model == "SHARP Corgi" ) { 162 if ( model == "SHARP Corgi" ) {
163 d->m_model = Model_Zaurus_SLC7x0; 163 d->m_model = Model_Zaurus_SLC7x0;
164 d->m_modelstr = "Zaurus SL-C700"; 164 d->m_modelstr = "Zaurus SL-C700";
165 } else if ( model == "SHARP Shepherd" ) { 165 } else if ( model == "SHARP Shepherd" ) {
166 d->m_model = Model_Zaurus_SLC7x0; 166 d->m_model = Model_Zaurus_SLC7x0;
167 d->m_modelstr = "Zaurus SL-C750"; 167 d->m_modelstr = "Zaurus SL-C750";
168 } else if ( model == "SHARP Husky" ) { 168 } else if ( model == "SHARP Husky" ) {
169 d->m_model = Model_Zaurus_SLC7x0; 169 d->m_model = Model_Zaurus_SLC7x0;
170 d->m_modelstr = "Zaurus SL-C760"; 170 d->m_modelstr = "Zaurus SL-C760";
171 } else if ( model == "SHARP Poodle" ) { 171 } else if ( model == "SHARP Poodle" ) {
172 d->m_model = Model_Zaurus_SLB600; 172 d->m_model = Model_Zaurus_SLB600;
173 d->m_modelstr = "Zaurus SL-B500 or SL-5600"; 173 d->m_modelstr = "Zaurus SL-B500 or SL-5600";
174 } else if ( model == "Sharp-Collie" || model == "Collie" ) { 174 } else if ( model == "Sharp-Collie" || model == "Collie" ) {
175 d->m_model = Model_Zaurus_SL5500; 175 d->m_model = Model_Zaurus_SL5500;
176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; 176 d->m_modelstr = "Zaurus SL-5500 or SL-5000d";
177 } else if ( model == "SHARP Tosa" ) { 177 } else if ( model == "SHARP Tosa" ) {
178 d->m_model = Model_Zaurus_SL6000; 178 d->m_model = Model_Zaurus_SL6000;
179 d->m_modelstr = "Zaurus SL-6000"; 179 d->m_modelstr = "Zaurus SL-6000";
180 } else { 180 } else {
181 d->m_model = Model_Zaurus_SL5500; 181 d->m_model = Model_Zaurus_SL5500;
182 d->m_modelstr = "Unkown Zaurus"; 182 d->m_modelstr = "Unkown Zaurus";
183 } 183 }
184 184
185 // set initial rotation 185 // set initial rotation
186
187 bool flipstate = false;
188 switch ( d->m_model ) { 186 switch ( d->m_model ) {
189 case Model_Zaurus_SL6000: 187 case Model_Zaurus_SL6000:
190 case Model_Zaurus_SLA300: 188 case Model_Zaurus_SLA300:
191 d->m_rotation = Rot0; 189 d->m_rotation = Rot0;
192 break; 190 break;
193 case Model_Zaurus_SLC7x0: 191 case Model_Zaurus_SLC7x0:
194 d->m_rotation = rotation(); 192 d->m_rotation = rotation();
195 d->m_direction = direction(); 193 d->m_direction = direction();
196 break; 194 break;
197 case Model_Zaurus_SLB600: 195 case Model_Zaurus_SLB600:
198 case Model_Zaurus_SL5500: 196 case Model_Zaurus_SL5500:
199 case Model_Zaurus_SL5000: 197 case Model_Zaurus_SL5000:
200 default: 198 default:
201 d->m_rotation = Rot270; 199 d->m_rotation = Rot270;
202 break; 200 break;
203 } 201 }
204 m_leds [0] = Led_Off; 202 m_leds [0] = Led_Off;
205} 203}
206 204
207void Zaurus::initButtons() 205void Zaurus::initButtons()
208{ 206{
209 if ( d->m_buttons ) 207 if ( d->m_buttons )
210 return; 208 return;
211 209
212 d->m_buttons = new QValueList <ODeviceButton>; 210 d->m_buttons = new QValueList <ODeviceButton>;
213 211
214 struct z_button * pz_buttons; 212 struct z_button * pz_buttons;
215 int buttoncount; 213 int buttoncount;
216 switch ( d->m_model ) { 214 switch ( d->m_model ) {
217 case Model_Zaurus_SLC7x0: 215 case Model_Zaurus_SLC7x0:
218 pz_buttons = z_buttons_c700; 216 pz_buttons = z_buttons_c700;
219 buttoncount = ARRAY_SIZE(z_buttons_c700); 217 buttoncount = ARRAY_SIZE(z_buttons_c700);
220 break; 218 break;
221 default: 219 default:
222 pz_buttons = z_buttons; 220 pz_buttons = z_buttons;
223 buttoncount = ARRAY_SIZE(z_buttons); 221 buttoncount = ARRAY_SIZE(z_buttons);
224 break; 222 break;
225 } 223 }
226 224
227 for ( int i = 0; i < buttoncount; i++ ) { 225 for ( int i = 0; i < buttoncount; i++ ) {
228 struct z_button *zb = pz_buttons + i; 226 struct z_button *zb = pz_buttons + i;
229 ODeviceButton b; 227 ODeviceButton b;
230 228
231 b. setKeycode ( zb->code ); 229 b. setKeycode ( zb->code );
232 b. setUserText ( QObject::tr ( "Button", zb->utext )); 230 b. setUserText ( QObject::tr ( "Button", zb->utext ));
233 b. setPixmap ( Resource::loadPixmap ( zb->pix )); 231 b. setPixmap ( Resource::loadPixmap ( zb->pix ));
234 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ), 232 b. setFactoryPresetPressedAction ( OQCopMessage ( makeChannel ( zb->fpressedservice ),
235 zb->fpressedaction )); 233 zb->fpressedaction ));
@@ -273,154 +271,125 @@ void Zaurus::initButtons()
273#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) 271#define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5)
274 272
275//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ 273//#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */
276//#define SHARP_BUZ_KEYSOUND 2 /* key sound */ 274//#define SHARP_BUZ_KEYSOUND 2 /* key sound */
277 275
278//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ 276//#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */
279//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ 277//#define SHARP_PDA_WARNSOUND 4 /* warning occurred */
280//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ 278//#define SHARP_PDA_ERRORSOUND 5 /* error occurred */
281//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ 279//#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */
282//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ 280//#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */
283//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ 281//#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */
284//#define SHARP_PDA_APPSTART 9 /* application start */ 282//#define SHARP_PDA_APPSTART 9 /* application start */
285//#define SHARP_PDA_APPQUIT 10 /* application ends */ 283//#define SHARP_PDA_APPQUIT 10 /* application ends */
286 284
287//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ 285//#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */
288//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ 286//#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */
289//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ 287//#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */
290//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ 288//#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */
291// 289//
292 290
293 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) 291 #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START)
294#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) 292#define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1)
295 293
296#define SHARP_IOCTL_GET_ROTATION 0x413c 294#define SHARP_IOCTL_GET_ROTATION 0x413c
297 295
298typedef struct sharp_led_status { 296typedef struct sharp_led_status {
299int which; /* select which LED status is wanted. */ 297int which; /* select which LED status is wanted. */
300int status; /* set new led status if you call SHARP_LED_SETSTATUS */ 298int status; /* set new led status if you call SHARP_LED_SETSTATUS */
301} sharp_led_status; 299} sharp_led_status;
302 300
303#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ 301#define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */
304 302
305#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ 303#define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */
306#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ 304#define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */
307#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ 305#define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */
308 306
309// #include <asm/sharp_apm.h> // including kernel headers is evil ... 307// #include <asm/sharp_apm.h> // including kernel headers is evil ...
310 308
311#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) 309#define APM_IOCGEVTSRC OD_IOR( 'A', 203, int )
312#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) 310#define APM_IOCSEVTSRC OD_IORW( 'A', 204, int )
313#define APM_EVT_POWER_BUTTON (1 << 0) 311#define APM_EVT_POWER_BUTTON (1 << 0)
314 312
315#define FL_IOCTL_STEP_CONTRAST 100 313#define FL_IOCTL_STEP_CONTRAST 100
316 314
317 315
318void Zaurus::buzzer ( int sound ) 316void Zaurus::buzzer ( int sound )
319{ 317{
320#ifndef QT_NO_SOUND 318#ifndef QT_NO_SOUND
321 QString soundname; 319 Sound *snd = 0;
322 320
323 // Not all devices have real sound 321 // Not all devices have real sound
324 if ( d->m_model == Model_Zaurus_SLC7x0 322 if ( d->m_model == Model_Zaurus_SLC7x0
325 || d->m_model == Model_Zaurus_SLB600 ){ 323 || d->m_model == Model_Zaurus_SLB600 ){
326 324
327 switch ( sound ){ 325 switch ( sound ){
328 case SHARP_BUZ_SCHEDULE_ALARM:
329 soundname = "alarm";
330 break;
331 case SHARP_BUZ_TOUCHSOUND: 326 case SHARP_BUZ_TOUCHSOUND:
332 soundname = "touchsound"; 327 static Sound touch_sound("touchsound");
328 snd = &touch_sound;
333 break; 329 break;
334 case SHARP_BUZ_KEYSOUND: 330 case SHARP_BUZ_KEYSOUND:
335 soundname = "keysound"; 331 static Sound key_sound( "keysound" );
332 snd = &key_sound;
336 break; 333 break;
334 case SHARP_BUZ_SCHEDULE_ALARM:
337 default: 335 default:
338 soundname = "alarm"; 336 static Sound alarm_sound("alarm");
339 337 snd = &alarm_sound;
338 break;
340 } 339 }
341 } 340 }
342 341
343 // If a soundname is defined, we expect that this device has 342 // If a soundname is defined, we expect that this device has
344 // sound capabilities.. Otherwise we expect to have the buzzer 343 // sound capabilities.. Otherwise we expect to have the buzzer
345 // device.. 344 // device..
346 if ( !soundname.isEmpty() ){ 345 if ( snd ){
347 int fd; 346 changeMixerForAlarm( 0, "/dev/sound/mixer", snd );
348 int vol; 347 snd-> play();
349 bool vol_reset = false;
350
351 Sound snd ( soundname );
352
353 if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) {
354 if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) {
355 Config cfg ( "qpe" );
356 cfg. setGroup ( "Volume" );
357
358 int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 );
359 if ( volalarm < 0 )
360 volalarm = 0;
361 else if ( volalarm > 100 )
362 volalarm = 100;
363 volalarm |= ( volalarm << 8 );
364
365 if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 )
366 vol_reset = true;
367 }
368 }
369
370 snd. play();
371 while ( !snd. isFinished())
372 qApp->processEvents();
373
374 if ( fd >= 0 ) {
375 if ( vol_reset )
376 ::ioctl ( fd, MIXER_WRITE( 0 ), &vol );
377 ::close ( fd );
378 }
379 } else { 348 } else {
380 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); 349 int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK );
381 350
382 if ( fd >= 0 ) { 351 if ( fd >= 0 ) {
383 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); 352 ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound );
384 ::close ( fd ); 353 ::close ( fd );
385 } 354 }
386 355
387 } 356 }
388#endif 357#endif
389} 358}
390 359
391 360
392void Zaurus::playAlarmSound() 361void Zaurus::playAlarmSound()
393{ 362{
394 buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); 363 buzzer ( SHARP_BUZ_SCHEDULE_ALARM );
395} 364}
396 365
397void Zaurus::playTouchSound() 366void Zaurus::playTouchSound()
398{ 367{
399 buzzer ( SHARP_BUZ_TOUCHSOUND ); 368 buzzer ( SHARP_BUZ_TOUCHSOUND );
400} 369}
401 370
402void Zaurus::playKeySound() 371void Zaurus::playKeySound()
403{ 372{
404 buzzer ( SHARP_BUZ_KEYSOUND ); 373 buzzer ( SHARP_BUZ_KEYSOUND );
405} 374}
406 375
407 376
408QValueList <OLed> Zaurus::ledList() const 377QValueList <OLed> Zaurus::ledList() const
409{ 378{
410 QValueList <OLed> vl; 379 QValueList <OLed> vl;
411 vl << Led_Mail; 380 vl << Led_Mail;
412 return vl; 381 return vl;
413} 382}
414 383
415QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const 384QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const
416{ 385{
417 QValueList <OLedState> vl; 386 QValueList <OLedState> vl;
418 387
419 if ( l == Led_Mail ) 388 if ( l == Led_Mail )
420 vl << Led_Off << Led_On << Led_BlinkSlow; 389 vl << Led_Off << Led_On << Led_BlinkSlow;
421 return vl; 390 return vl;
422} 391}
423 392
424OLedState Zaurus::ledState ( OLed which ) const 393OLedState Zaurus::ledState ( OLed which ) const
425{ 394{
426 if ( which == Led_Mail ) 395 if ( which == Led_Mail )
@@ -469,97 +438,97 @@ bool Zaurus::setSoftSuspend ( bool soft )
469 bool res = false; 438 bool res = false;
470 int fd; 439 int fd;
471 440
472 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || 441 if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) ||
473 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { 442 (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) {
474 443
475 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources 444 int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources
476 445
477 if ( sources >= 0 ) { 446 if ( sources >= 0 ) {
478 if ( soft ) 447 if ( soft )
479 sources &= ~APM_EVT_POWER_BUTTON; 448 sources &= ~APM_EVT_POWER_BUTTON;
480 else 449 else
481 sources |= APM_EVT_POWER_BUTTON; 450 sources |= APM_EVT_POWER_BUTTON;
482 451
483 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources 452 if ( ::ioctl ( fd, APM_IOCSEVTSRC, sources ) >= 0 ) // set new event sources
484 res = true; 453 res = true;
485 else 454 else
486 perror ( "APM_IOCGEVTSRC" ); 455 perror ( "APM_IOCGEVTSRC" );
487 } 456 }
488 else 457 else
489 perror ( "APM_IOCGEVTSRC" ); 458 perror ( "APM_IOCGEVTSRC" );
490 459
491 ::close ( fd ); 460 ::close ( fd );
492 } 461 }
493 else 462 else
494 perror ( "/dev/apm_bios or /dev/misc/apm_bios" ); 463 perror ( "/dev/apm_bios or /dev/misc/apm_bios" );
495 464
496 return res; 465 return res;
497} 466}
498 467
499 468
500bool Zaurus::setDisplayBrightness ( int bright ) 469bool Zaurus::setDisplayBrightness ( int bright )
501{ 470{
502 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright ); 471 //qDebug( "Zaurus::setDisplayBrightness( %d )", bright );
503 bool res = false; 472 bool res = false;
504 int fd; 473 int fd;
505 474
506 if ( bright > 255 ) bright = 255; 475 if ( bright > 255 ) bright = 255;
507 if ( bright < 0 ) bright = 0; 476 if ( bright < 0 ) bright = 0;
508 477
509 if ( m_embedix ) 478 if ( m_embedix )
510 { 479 {
511 if ( d->m_model == Model_Zaurus_SLC7x0 ) 480 if ( d->m_model == Model_Zaurus_SLC7x0 )
512 { 481 {
513 //qDebug( "using special treatment for devices with the corgi backlight interface" ); 482 //qDebug( "using special treatment for devices with the corgi backlight interface" );
514 // special treatment for devices with the corgi backlight interface 483 // special treatment for devices with the corgi backlight interface
515 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) 484 if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 )
516 { 485 {
517 int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); 486 int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) );
518 char writeCommand[100]; 487 char writeCommand[100];
519 const int count = sprintf( writeCommand, "0x%x\n", value ); 488 const int count = sprintf( writeCommand, "0x%x\n", value );
520 res = ( ::write ( fd, writeCommand, count ) != -1 ); 489 res = ( ::write ( fd, writeCommand, count ) != -1 );
521 ::close ( fd ); 490 ::close ( fd );
522 } 491 }
523 return res; 492 return res;
524 } 493 }
525 else 494 else
526 { 495 {
527 // standard treatment for devices with the dumb embedix frontlight interface 496 // standard treatment for devices with the dumb embedix frontlight interface
528 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { 497 if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) {
529 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus 498 int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus
530 if ( bright && !bl ) 499 if ( bright && !bl )
531 bl = 1; 500 bl = 1;
532 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 ); 501 res = ( ::ioctl ( fd, FL_IOCTL_STEP_CONTRAST, bl ) == 0 );
533 ::close ( fd ); 502 ::close ( fd );
534 } 503 }
535 } 504 }
536 } 505 }
537 else 506 else
538 { 507 {
539 // special treatment for the OpenZaurus unified interface 508 // special treatment for the OpenZaurus unified interface
540 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */ 509 #define FB_BACKLIGHT_SET_BRIGHTNESS _IOW('F', 1, u_int) /* set brightness */
541 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) { 510 if (( fd = ::open ( "/dev/fb0", O_WRONLY )) >= 0 ) {
542 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 ); 511 res = ( ::ioctl ( fd , FB_BACKLIGHT_SET_BRIGHTNESS, bright ) == 0 );
543 ::close ( fd ); 512 ::close ( fd );
544 } 513 }
545 } 514 }
546 return res; 515 return res;
547} 516}
548 517
549bool Zaurus::suspend() 518bool Zaurus::suspend()
550{ 519{
551 qDebug("ODevice::suspend"); 520 qDebug("ODevice::suspend");
552 if ( !isQWS( ) ) // only qwsserver is allowed to suspend 521 if ( !isQWS( ) ) // only qwsserver is allowed to suspend
553 return false; 522 return false;
554 523
555 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices 524 if ( d->m_model == Model_Unknown ) // better don't suspend in qvfb / on unkown devices
556 return false; 525 return false;
557 526
558 bool res = false; 527 bool res = false;
559 ODevice::sendSuspendmsg(); 528 ODevice::sendSuspendmsg();
560 529
561 struct timeval tvs, tvn; 530 struct timeval tvs, tvn;
562 ::gettimeofday ( &tvs, 0 ); 531 ::gettimeofday ( &tvs, 0 );
563 532
564 ::sync(); // flush fs caches 533 ::sync(); // flush fs caches
565 res = ( ::system ( "apm --suspend" ) == 0 ); 534 res = ( ::system ( "apm --suspend" ) == 0 );