-rw-r--r-- | libopie2/opiecore/device/odevice.cpp | 57 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice.h | 55 | ||||
-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, 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 | |||
@@ -44,8 +44,9 @@ | |||
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> |
@@ -170,8 +171,12 @@ ODevice::ODevice() | |||
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 | ||
@@ -704,25 +709,77 @@ void ODevice::remapHeldAction ( int button, const OQCopMessage &action ) | |||
704 | void ODevice::virtual_hook(int, void* ){ | 709 | void 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 | */ | ||
708 | void ODevice::sendSuspendmsg() | 718 | void 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 | */ | ||
716 | void ODevice::addPreHandler(QWSServer::KeyboardFilter*aFilter) | 737 | void 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 | */ | ||
721 | void ODevice::remPreHandler(QWSServer::KeyboardFilter*aFilter) | 751 | void 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 | ||
756 | void 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 | |||
764 | void 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,28 +1,28 @@ | |||
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 | */ |
@@ -37,15 +37,20 @@ _;:, .> :=|. This program is free software; you can | |||
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 | |||
47 | class Sound; | ||
48 | |||
44 | namespace Opie{ | 49 | namespace Opie{ |
45 | namespace Core{ | 50 | namespace Core{ |
46 | 51 | ||
47 | class ODeviceData; | 52 | class ODeviceData; |
48 | /** | 53 | /** |
49 | * The available devices | 54 | * The available devices |
50 | */ | 55 | */ |
51 | enum OModel { | 56 | enum OModel { |
@@ -318,13 +323,16 @@ signals: | |||
318 | void buttonMappingChanged(); | 323 | void buttonMappingChanged(); |
319 | 324 | ||
320 | private slots: | 325 | private slots: |
321 | void systemMessage ( const QCString &, const QByteArray & ); | 326 | void systemMessage ( const QCString &, const QByteArray & ); |
327 | void playingStopped(); | ||
322 | 328 | ||
323 | protected: | 329 | protected: |
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 | ||
@@ -347,8 +355,11 @@ class ODeviceData { | |||
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 | ||
353 | extern bool isQWS(); | 364 | extern bool isQWS(); |
354 | extern QCString makeChannel ( const char *str ); | 365 | extern QCString makeChannel ( const char *str ); |
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,28 +1,28 @@ | |||
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 | */ |
@@ -330,38 +330,11 @@ void iPAQ::timerEvent ( QTimerEvent * ) | |||
330 | void iPAQ::playAlarmSound() | 330 | void 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 | ||
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 | |||
@@ -237,18 +237,19 @@ bool SIMpad::setLedState ( OLed l, OLedState st ) | |||
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 | ||
250 | bool SIMpad::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 251 | bool 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 | } |
@@ -265,38 +266,12 @@ void SIMpad::timerEvent ( QTimerEvent * ) | |||
265 | void SIMpad::playAlarmSound() | 266 | void 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 | ||
@@ -334,16 +309,12 @@ bool SIMpad::setSoftSuspend ( bool soft ) | |||
334 | bool SIMpad::setDisplayStatus ( bool on ) | 309 | bool 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 | ||
349 | bool SIMpad::setDisplayBrightness ( int bright ) | 320 | bool SIMpad::setDisplayBrightness ( int 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,7 +1,7 @@ | |||
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 |
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 | |||
@@ -142,8 +142,10 @@ bool Yopy::setDisplayBrightness( int bright ) | |||
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 | ||
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,28 +1,28 @@ | |||
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 | */ |
@@ -182,10 +182,8 @@ void Zaurus::init(const QString& cpu_info) | |||
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; |
@@ -317,66 +315,37 @@ int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | |||
317 | 315 | ||
318 | void Zaurus::buzzer ( int sound ) | 316 | void 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 ) { |
@@ -513,9 +482,9 @@ bool Zaurus::setDisplayBrightness ( int bright ) | |||
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 ); |