summaryrefslogtreecommitdiff
path: root/libopie2/opiecore
Unidiff
Diffstat (limited to 'libopie2/opiecore') (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
@@ -42,12 +42,13 @@
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>
@@ -168,12 +169,16 @@ ODevice::ODevice()
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 {
@@ -702,27 +707,79 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action )
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,30 +1,30 @@
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_
@@ -35,19 +35,24 @@ _;:, .> :=|. This program is free software; you can
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
@@ -316,17 +321,20 @@ public:
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
@@ -345,12 +353,15 @@ class ODeviceData {
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}
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,30 +1,30 @@
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"
@@ -328,42 +328,15 @@ void iPAQ::timerEvent ( QTimerEvent * )
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{
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
@@ -235,22 +235,23 @@ bool SIMpad::setLedState ( OLed l, OLedState st )
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 * )
@@ -263,42 +264,16 @@ void SIMpad::timerEvent ( QTimerEvent * )
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{
@@ -332,20 +307,16 @@ bool SIMpad::setSoftSuspend ( bool soft )
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 );
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,9 +1,9 @@
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
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
@@ -140,12 +140,14 @@ bool Yopy::setDisplayBrightness( int bright )
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
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,30 +1,30 @@
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"
@@ -180,14 +180,12 @@ void Zaurus::init(const QString& cpu_info)
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:
@@ -315,70 +313,41 @@ int status; /* set new led status if you call SHARP_LED_SETSTATUS */
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 );
@@ -511,13 +480,13 @@ bool Zaurus::setDisplayBrightness ( int bright )
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;