-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 57 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 53 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 71 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 47 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.h | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_yopy.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 99 |
7 files changed, 157 insertions, 174 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 @@ -36,24 +36,25 @@ /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> /* OPIE */ #include <qpe/config.h> #include <qpe/resource.h> #include <qpe/sound.h> #include <qpe/qcopenvelope_qws.h> +#include <qpe/sound.h> #include <opie2/okeyfilter.h> /* STD */ #include <fcntl.h> #include <math.h> #include <stdlib.h> #include <signal.h> #include <sys/ioctl.h> #include <sys/time.h> #include <unistd.h> #ifndef QT_NO_SOUND #include <linux/soundcard.h> @@ -162,24 +163,28 @@ ODevice::ODevice() d->m_vendorstr = "Unknown"; d->m_vendor = Vendor_Unknown; d->m_systemstr = "Unknown"; d->m_system = System_Unknown; d->m_sysverstr = "0.0"; d->m_rotation = Rot0; d->m_direction = CW; d->m_holdtime = 1000; // 1000ms d->m_buttons = 0; d->m_cpu_frequencies = new QStrList; + + /* mixer */ + d->m_sound = d->m_vol = d->m_mixer = -1; + // New distribution detection code first checks for legacy distributions, // identified by /etc/familiar-version or /etc/oz_version. // Then check for OpenEmbedded and lastly, read /etc/issue for ( unsigned int i = 0; i < sizeof distributions; ++i ) { if ( QFile::exists( distributions[i].sysvfile ) ) { d->m_systemstr = distributions[i].sysstr; d->m_system = distributions[i].system; d->m_sysverstr = "<Unknown>"; QFile f( distributions[i].sysvfile ); @@ -696,33 +701,85 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) buttonFile. setGroup ( "Button" + QString::number ( button )); buttonFile. writeEntry ( "HeldActionChannel", (const char *) b. heldAction(). channel()); buttonFile. writeEntry ( "HeldActionMessage", (const char *) b. heldAction(). message()); // buttonFile. writeEntry ( "HeldActionArgs", decodeBase64 ( b. heldAction(). data())); QCopEnvelope ( "QPE/System", "deviceButtonMappingChanged()" ); } void ODevice::virtual_hook(int, void* ){ } +/** + * Sends a QCOP message to channel QPE/System + * with the message "aboutToSuspend()" if this + * is the windowing server + */ void ODevice::sendSuspendmsg() { if ( isQWS() ) return; QCopEnvelope ( "QPE/System", "aboutToSuspend()" ); } +/** + * \brief Prepend the QWSServer::KeyboardFilter to the list of installed KeyFilters + * + * Prepend a QWSServer::KeyboardFilter to the List of Keyboard + * Filters. This function is the only way to prepend a KeyFilter. + * + * @param aFilter The KeyFilter to be prepended to the list of filters + * + * @see Opie::Core::OKeyFilter + * @see Opie::Core::OKeyFilter::inst() + */ void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) { Opie::Core::OKeyFilter::inst()->addPreHandler(aFilter); } +/** + * \brief Remove the QWSServer::KeyboardFilter in the param from the list + * + * Remove the QWSServer::KeyboardFilter \par aFilter from the List + * of Keyfilters. Call this when you delete the KeyFilter! + * + * @param aFilter The filter to be removed from the Opie::Core::OKeyFilter + * @see Opie::Core::ODevice::addPreHandler + */ void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) { Opie::Core::OKeyFilter::inst()->remPreHandler(aFilter); } +void ODevice::playingStopped() { + const_cast<QObject*>(sender())->disconnect( this ); + if ( d->m_sound >= 0 ) { + ::ioctl ( d->m_sound, MIXER_WRITE( d->m_mixer ), &d->m_vol ); + ::close ( d->m_sound ); + } +} + +void ODevice::changeMixerForAlarm( int mixer, const char* file, Sound *snd ) { + if (( d->m_sound = ::open ( file, O_RDWR )) >= 0 ) { + if ( ::ioctl ( d->m_sound, MIXER_READ( mixer ), &d->m_vol ) >= 0 ) { + Config cfg ( "qpe" ); + cfg. setGroup ( "Volume" ); + + int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); + if ( volalarm < 0 ) + volalarm = 0; + else if ( volalarm > 100 ) + volalarm = 100; + volalarm |= ( volalarm << 8 ); + + if ( ::ioctl ( d->m_sound, MIXER_WRITE( mixer ), &volalarm ) >= 0 ) + register_qpe_sound_finished(snd, this, SLOT(playingStopped())); + } + d->m_mixer = mixer; + } +} } } 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,55 +1,60 @@ /* - This file is part of the Opie Project - Copyright (C) The Opie Team <opie-devel@handhelds.org> + This file is part of the Opie Project + Copyright (C) The Opie Team <opie-devel@handhelds.org> =. .=l. - .>+-= -_;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software -- . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. -: = ...= . :.=- --. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #ifndef ODEVICE_H_ #define ODEVICE_H_ /* OPIE */ #include <opie2/odevicebutton.h> #include <qpe/qpeapplication.h> /* for Transformation enum.. */ /* QT */ #include <qnamespace.h> #include <qobject.h> #include <qstring.h> + + #include <qstrlist.h> #include <qwindowsystem_qws.h> + +class Sound; + namespace Opie{ namespace Core{ class ODeviceData; /** * The available devices */ enum OModel { Model_Unknown, // = 0 Model_Series_Mask = 0xff000000, @@ -310,53 +315,59 @@ public: void remapHeldAction ( int button, const OQCopMessage &qcopMessage ); /** * How long (in ms) you have to press a button for a "hold" action */ uint buttonHoldTime() const; signals: void buttonMappingChanged(); private slots: void systemMessage ( const QCString &, const QByteArray & ); + void playingStopped(); protected: void addPreHandler(QWSServer::KeyboardFilter*aFilter); void remPreHandler(QWSServer::KeyboardFilter*aFilter); void reloadButtonMapping(); + void changeMixerForAlarm( int mixer, const char* file, Sound *snd); + /* ugly virtual hook */ virtual void virtual_hook( int id, void* data ); }; class ODeviceData { public: QString m_vendorstr; OVendor m_vendor; QString m_modelstr; OModel m_model; QString m_systemstr; OSystem m_system; QString m_sysverstr; Transformation m_rotation; ODirection m_direction; QValueList <ODeviceButton> *m_buttons; uint m_holdtime; QStrList *m_cpu_frequencies; + + /* values for changeMixerForAlarm */ + int m_sound, m_vol, m_mixer; }; extern bool isQWS(); extern QCString makeChannel ( const char *str ); } } #endif 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,36 +1,36 @@ /* - This file is part of the Opie Project - Copyright (C) The Opie Team <opie-devel@handhelds.org> + This file is part of the Opie Project + Copyright (C) 2002,2003,2004 The Opie Team <opie-devel@handhelds.org> =. .=l. - .>+-= -_;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software -- . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. -: = ...= . :.=- --. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "odevice_ipaq.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> @@ -322,54 +322,27 @@ void iPAQ::timerEvent ( QTimerEvent * ) { killTimer ( m_power_timer ); m_power_timer = 0; QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); } void iPAQ::playAlarmSound() { #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); - int fd; - int vol; - bool vol_reset = false; - - if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { - if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { - Config cfg ( "qpe" ); - cfg. setGroup ( "Volume" ); - - int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); - if ( volalarm < 0 ) - volalarm = 0; - else if ( volalarm > 100 ) - volalarm = 100; - volalarm |= ( volalarm << 8 ); - - if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) - vol_reset = true; - } - } + changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); snd. play(); - while ( !snd. isFinished()) - qApp->processEvents(); - - if ( fd >= 0 ) { - if ( vol_reset ) - ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); - ::close ( fd ); - } #endif } bool iPAQ::setSoftSuspend ( bool soft ) { bool res = false; int fd; if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) res = true; 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 @@ -229,82 +229,57 @@ OLedState SIMpad::ledState ( OLed l ) const bool SIMpad::setLedState ( OLed l, OLedState st ) { #if 0 static int fd = ::open ( SIMPAD_BOARDCONTROL, O_RDWR | O_NONBLOCK ); /*TODO Implement this like that: read from cs3 && with SIMPAD_LED2_ON write to cs3 */ m_leds [0] = st; return true; - } - } - } - + // } +// } +#else + Q_UNUSED( l ) + Q_UNUSED( st ) #endif return false; } -bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) +bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) { //TODO return false; } void SIMpad::timerEvent ( QTimerEvent * ) { killTimer ( m_power_timer ); m_power_timer = 0; QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); } void SIMpad::playAlarmSound() { #ifndef QT_NO_SOUND static Sound snd ( "alarm" ); - int fd; - int vol; - bool vol_reset = false; - - if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { - if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { - Config cfg ( "qpe" ); - cfg. setGroup ( "Volume" ); - - int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); - if ( volalarm < 0 ) - volalarm = 0; - else if ( volalarm > 100 ) - volalarm = 100; - volalarm |= ( volalarm << 8 ); - - if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) - vol_reset = true; - } - } + /* save as the Sound is static! */ + changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); snd. play(); - while ( !snd. isFinished()) - qApp->processEvents(); - - if ( fd >= 0 ) { - if ( vol_reset ) - ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); - ::close ( fd ); - } #endif } bool SIMpad::suspend() // Must override because SIMpad does NOT have apm { qDebug( "ODevice for SIMpad: suspend()" ); if ( !isQWS( ) ) // only qwsserver is allowed to suspend return false; /* * we need to save the screen content @@ -326,32 +301,28 @@ bool SIMpad::suspend() // Must override because SIMpad does NOT have apm bool SIMpad::setSoftSuspend ( bool soft ) { qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); return false; } bool SIMpad::setDisplayStatus ( bool on ) { qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); - bool res = false; - int fd; QString cmdline = QString().sprintf( "echo %s > /proc/cs3", on ? "0xd41a" : "0xd40a" ); //TODO make better :) - res = ( ::system( (const char*) cmdline ) == 0 ); - - return res; + return ( ::system( (const char*) cmdline ) == 0 ); } bool SIMpad::setDisplayBrightness ( int bright ) { qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); bool res = false; int fd; if ( bright > 255 ) bright = 255; if ( bright < 1 ) 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,15 +1,15 @@ /* This file is part of the Opie Project - Copyright (C) The Opie Team <opie-devel@handhelds.org> + Copyright (C) 2003, 2004 The Opie Team <opie-devel@handhelds.org> =. .=l. .>+-= _;:, .> :=|. This program is free software; you can .> <`_, > . <= redistribute it and/or modify it under :`=1 )Y*s>-.-- : the terms of the GNU Library General Public .="- .-=="i, .._ License as published by the Free Software - . .-<_> .<> Foundation; either version 2 of the License, ._= =} : or (at your option) any later version. .%`+i> _;_. .i_,=:_. -<s. This program is distributed in the hope that + . -:. = it will be useful, but WITHOUT ANY WARRANTY; 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 @@ -134,22 +134,24 @@ bool Yopy::setDisplayBrightness( int bright ) { int fd = ::open( "/proc/sys/pm/light", O_WRONLY ); if ( fd >= 0 ) { if ( bright ) ::write( fd, "1\n", 2 ); else ::write( fd, "0\n", 2 ); ::close( fd ); return true; } } +#else + Q_UNUSED( bright ) #endif return false; } int Yopy::displayBrightnessResolution() const { return 2; } 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,36 +1,36 @@ /* - This file is part of the Opie Project - Copyright (C) The Opie Team <opie-devel@handhelds.org> + This file is part of the Opie Project + Copyright (C) The Opie Team <opie-devel@handhelds.org> =. .=l. - .>+-= -_;:, .> :=|. This program is free software; you can -.> <`_, > . <= redistribute it and/or modify it under -:`=1 )Y*s>-.-- : the terms of the GNU Library General Public -.="- .-=="i, .._ License as published by the Free Software -- . .-<_> .<> Foundation; either version 2 of the License, - ._= =} : or (at your option) any later version. - .%`+i> _;_. - .i_,=:_. -<s. This program is distributed in the hope that - + . -:. = it will be useful, but WITHOUT ANY WARRANTY; - : .. .:, . . . without even the implied warranty of - =_ + =;=|` MERCHANTABILITY or FITNESS FOR A - _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU -..}^=.= = ; Library General Public License for more -++= -. .` .: details. -: = ...= . :.=- --. .:....=;==+<; You should have received a copy of the GNU - -_. . . )=. = Library General Public License along with - -- :-=` this library; see the file COPYING.LIB. + .>+-= + _;:, .> :=|. This program is free software; you can +.> <`_, > . <= redistribute it and/or modify it under +:`=1 )Y*s>-.-- : the terms of the GNU Library General Public +.="- .-=="i, .._ License as published by the Free Software + - . .-<_> .<> Foundation; either version 2 of the License, + ._= =} : or (at your option) any later version. + .%`+i> _;_. + .i_,=:_. -<s. This program is distributed in the hope that + + . -:. = it will be useful, but WITHOUT ANY WARRANTY; + : .. .:, . . . without even the implied warranty of + =_ + =;=|` MERCHANTABILITY or FITNESS FOR A + _.=:. : :=>`: PARTICULAR PURPOSE. See the GNU +..}^=.= = ; Library General Public License for more +++= -. .` .: details. + : = ...= . :.=- + -. .:....=;==+<; You should have received a copy of the GNU + -_. . . )=. = Library General Public License along with + -- :-=` this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "odevice_zaurus.h" /* QT */ #include <qapplication.h> #include <qfile.h> #include <qtextstream.h> #include <qwindowsystem_qws.h> @@ -174,26 +174,24 @@ void Zaurus::init(const QString& cpu_info) } else if ( model == "Sharp-Collie" || model == "Collie" ) { d->m_model = Model_Zaurus_SL5500; d->m_modelstr = "Zaurus SL-5500 or SL-5000d"; } else if ( model == "SHARP Tosa" ) { d->m_model = Model_Zaurus_SL6000; d->m_modelstr = "Zaurus SL-6000"; } else { d->m_model = Model_Zaurus_SL5500; d->m_modelstr = "Unkown Zaurus"; } // set initial rotation - - bool flipstate = false; switch ( d->m_model ) { case Model_Zaurus_SL6000: case Model_Zaurus_SLA300: d->m_rotation = Rot0; break; case Model_Zaurus_SLC7x0: d->m_rotation = rotation(); d->m_direction = direction(); break; case Model_Zaurus_SLB600: case Model_Zaurus_SL5500: case Model_Zaurus_SL5000: @@ -309,82 +307,53 @@ int status; /* set new led status if you call SHARP_LED_SETSTATUS */ // #include <asm/sharp_apm.h> // including kernel headers is evil ... #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) #define APM_EVT_POWER_BUTTON (1 << 0) #define FL_IOCTL_STEP_CONTRAST 100 void Zaurus::buzzer ( int sound ) { #ifndef QT_NO_SOUND - QString soundname; + Sound *snd = 0; // Not all devices have real sound if ( d->m_model == Model_Zaurus_SLC7x0 || d->m_model == Model_Zaurus_SLB600 ){ switch ( sound ){ - case SHARP_BUZ_SCHEDULE_ALARM: - soundname = "alarm"; - break; case SHARP_BUZ_TOUCHSOUND: - soundname = "touchsound"; + static Sound touch_sound("touchsound"); + snd = &touch_sound; break; case SHARP_BUZ_KEYSOUND: - soundname = "keysound"; + static Sound key_sound( "keysound" ); + snd = &key_sound; break; + case SHARP_BUZ_SCHEDULE_ALARM: default: - soundname = "alarm"; - + static Sound alarm_sound("alarm"); + snd = &alarm_sound; + break; } } // If a soundname is defined, we expect that this device has // sound capabilities.. Otherwise we expect to have the buzzer // device.. - if ( !soundname.isEmpty() ){ - int fd; - int vol; - bool vol_reset = false; - - Sound snd ( soundname ); - - if (( fd = ::open ( "/dev/sound/mixer", O_RDWR )) >= 0 ) { - if ( ::ioctl ( fd, MIXER_READ( 0 ), &vol ) >= 0 ) { - Config cfg ( "qpe" ); - cfg. setGroup ( "Volume" ); - - int volalarm = cfg. readNumEntry ( "AlarmPercent", 50 ); - if ( volalarm < 0 ) - volalarm = 0; - else if ( volalarm > 100 ) - volalarm = 100; - volalarm |= ( volalarm << 8 ); - - if ( ::ioctl ( fd, MIXER_WRITE( 0 ), &volalarm ) >= 0 ) - vol_reset = true; - } - } - - snd. play(); - while ( !snd. isFinished()) - qApp->processEvents(); - - if ( fd >= 0 ) { - if ( vol_reset ) - ::ioctl ( fd, MIXER_WRITE( 0 ), &vol ); - ::close ( fd ); - } + if ( snd ){ + changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); + snd-> play(); } else { int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); if ( fd >= 0 ) { ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); ::close ( fd ); } } #endif } @@ -505,25 +474,25 @@ bool Zaurus::setDisplayBrightness ( int bright ) if ( bright > 255 ) bright = 255; if ( bright < 0 ) bright = 0; if ( m_embedix ) { if ( d->m_model == Model_Zaurus_SLC7x0 ) { //qDebug( "using special treatment for devices with the corgi backlight interface" ); // special treatment for devices with the corgi backlight interface if (( fd = ::open ( "/proc/driver/fl/corgi-bl", O_WRONLY )) >= 0 ) { - int value = ( bright == 1 ) ? 1 : bright * ( 17.0 / 255.0 ); + int value = ( bright == 1 ) ? 1 : static_cast<int>( bright * ( 17.0 / 255.0 ) ); char writeCommand[100]; const int count = sprintf( writeCommand, "0x%x\n", value ); res = ( ::write ( fd, writeCommand, count ) != -1 ); ::close ( fd ); } return res; } else { // standard treatment for devices with the dumb embedix frontlight interface if (( fd = ::open ( "/dev/fl", O_WRONLY )) >= 0 ) { int bl = ( bright * 4 + 127 ) / 255; // only 4 steps on zaurus |