Diffstat (limited to 'libopie2/opiecore/device/odevice_zaurus.cpp') (more/less context) (ignore whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 99 |
1 files changed, 34 insertions, 65 deletions
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 ); |