Diffstat (limited to 'libopie2/opiecore/device/odevice_ipaq.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 71 |
1 files changed, 22 insertions, 49 deletions
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,48 +1,48 @@ | |||
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> |
@@ -310,78 +310,51 @@ bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, b | |||
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 | ||
321 | void iPAQ::timerEvent ( QTimerEvent * ) | 321 | void 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 | ||
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 | ||
368 | bool iPAQ::setSoftSuspend ( bool soft ) | 341 | bool 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 | ||