-rw-r--r-- | libopie2/opiecore/device/odevice_ipaq.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_ramses.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_simpad.cpp | 2 | ||||
-rw-r--r-- | libopie2/opiecore/device/odevice_zaurus.cpp | 4 |
4 files changed, 8 insertions, 2 deletions
diff --git a/libopie2/opiecore/device/odevice_ipaq.cpp b/libopie2/opiecore/device/odevice_ipaq.cpp index 7f5aa7b..6193ddc 100644 --- a/libopie2/opiecore/device/odevice_ipaq.cpp +++ b/libopie2/opiecore/device/odevice_ipaq.cpp | |||
@@ -238,192 +238,194 @@ bool iPAQ::setLedState ( OLed l, OLedState st ) | |||
238 | ::memset ( &leds, 0, sizeof( leds )); | 238 | ::memset ( &leds, 0, sizeof( leds )); |
239 | leds. TotalTime = 0; | 239 | leds. TotalTime = 0; |
240 | leds. OnTime = 0; | 240 | leds. OnTime = 0; |
241 | leds. OffTime = 1; | 241 | leds. OffTime = 1; |
242 | leds. OffOnBlink = 2; | 242 | leds. OffOnBlink = 2; |
243 | 243 | ||
244 | switch ( st ) { | 244 | switch ( st ) { |
245 | case Led_Off : leds. OffOnBlink = 0; break; | 245 | case Led_Off : leds. OffOnBlink = 0; break; |
246 | case Led_On : leds. OffOnBlink = 1; break; | 246 | case Led_On : leds. OffOnBlink = 1; break; |
247 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; | 247 | case Led_BlinkSlow: leds. OnTime = 10; leds. OffTime = 10; break; |
248 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; | 248 | case Led_BlinkFast: leds. OnTime = 5; leds. OffTime = 5; break; |
249 | } | 249 | } |
250 | 250 | ||
251 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { | 251 | if ( ::ioctl ( fd, LED_ON, &leds ) >= 0 ) { |
252 | m_leds [0] = st; | 252 | m_leds [0] = st; |
253 | return true; | 253 | return true; |
254 | } | 254 | } |
255 | } | 255 | } |
256 | } | 256 | } |
257 | return false; | 257 | return false; |
258 | } | 258 | } |
259 | 259 | ||
260 | 260 | ||
261 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) | 261 | bool iPAQ::filter ( int /*unicode*/, int keycode, int modifiers, bool isPress, bool autoRepeat ) |
262 | { | 262 | { |
263 | int newkeycode = keycode; | 263 | int newkeycode = keycode; |
264 | 264 | ||
265 | switch ( keycode ) { | 265 | switch ( keycode ) { |
266 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key | 266 | // H38xx/H39xx have no "Q" key anymore - this is now the Mail key |
267 | case HardKey_Menu: { | 267 | case HardKey_Menu: { |
268 | if (( d->m_model == Model_iPAQ_H38xx ) || | 268 | if (( d->m_model == Model_iPAQ_H38xx ) || |
269 | ( d->m_model == Model_iPAQ_H39xx ) || | 269 | ( d->m_model == Model_iPAQ_H39xx ) || |
270 | ( d->m_model == Model_iPAQ_H5xxx)) { | 270 | ( d->m_model == Model_iPAQ_H5xxx)) { |
271 | newkeycode = HardKey_Mail; | 271 | newkeycode = HardKey_Mail; |
272 | } | 272 | } |
273 | break; | 273 | break; |
274 | } | 274 | } |
275 | 275 | ||
276 | // Rotate cursor keys 180 or 270 | 276 | // Rotate cursor keys 180 or 270 |
277 | case Key_Left : | 277 | case Key_Left : |
278 | case Key_Right: | 278 | case Key_Right: |
279 | case Key_Up : | 279 | case Key_Up : |
280 | case Key_Down : { | 280 | case Key_Down : { |
281 | if (( d->m_model == Model_iPAQ_H31xx ) || | 281 | if (( d->m_model == Model_iPAQ_H31xx ) || |
282 | ( d->m_model == Model_iPAQ_H38xx )) { | 282 | ( d->m_model == Model_iPAQ_H38xx )) { |
283 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; | 283 | newkeycode = Key_Left + ( keycode - Key_Left + 2 ) % 4; |
284 | } | 284 | } |
285 | // Rotate the cursor keys by 270 | 285 | // Rotate the cursor keys by 270 |
286 | // keycode - Key_Left = position of the button starting from left clockwise | 286 | // keycode - Key_Left = position of the button starting from left clockwise |
287 | // add the rotation to it and modolo. No we've the original offset | 287 | // add the rotation to it and modolo. No we've the original offset |
288 | // add the offset to the Key_Left key | 288 | // add the offset to the Key_Left key |
289 | if ( d-> m_model == Model_iPAQ_H5xxx ) | 289 | if ( d-> m_model == Model_iPAQ_H5xxx ) |
290 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; | 290 | newkeycode = Key_Left + ( keycode - Key_Left + 3 ) % 4; |
291 | break; | 291 | break; |
292 | } | 292 | } |
293 | 293 | ||
294 | // map Power Button short/long press to F34/F35 | 294 | // map Power Button short/long press to F34/F35 |
295 | case Key_SysReq: { | 295 | case Key_SysReq: { |
296 | if ( isPress ) { | 296 | if ( isPress ) { |
297 | if ( m_power_timer ) | 297 | if ( m_power_timer ) |
298 | killTimer ( m_power_timer ); | 298 | killTimer ( m_power_timer ); |
299 | m_power_timer = startTimer ( 500 ); | 299 | m_power_timer = startTimer ( 500 ); |
300 | } | 300 | } |
301 | else if ( m_power_timer ) { | 301 | else if ( m_power_timer ) { |
302 | killTimer ( m_power_timer ); | 302 | killTimer ( m_power_timer ); |
303 | m_power_timer = 0; | 303 | m_power_timer = 0; |
304 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); | 304 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, true, false ); |
305 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); | 305 | QWSServer::sendKeyEvent ( -1, HardKey_Suspend, 0, false, false ); |
306 | } | 306 | } |
307 | newkeycode = Key_unknown; | 307 | newkeycode = Key_unknown; |
308 | break; | 308 | break; |
309 | } | 309 | } |
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 | if(!snd.isFinished()) | ||
335 | return; | ||
334 | 336 | ||
335 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); | 337 | changeMixerForAlarm(0, "/dev/sound/mixer", &snd ); |
336 | snd. play(); | 338 | snd. play(); |
337 | #endif | 339 | #endif |
338 | } | 340 | } |
339 | 341 | ||
340 | 342 | ||
341 | bool iPAQ::setSoftSuspend ( bool soft ) | 343 | bool iPAQ::setSoftSuspend ( bool soft ) |
342 | { | 344 | { |
343 | bool res = false; | 345 | bool res = false; |
344 | int fd; | 346 | int fd; |
345 | 347 | ||
346 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { | 348 | if (( fd = ::open ( "/proc/sys/ts/suspend_button_mode", O_WRONLY )) >= 0 ) { |
347 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) | 349 | if ( ::write ( fd, soft ? "1" : "0", 1 ) == 1 ) |
348 | res = true; | 350 | res = true; |
349 | else | 351 | else |
350 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); | 352 | ::perror ( "write to /proc/sys/ts/suspend_button_mode" ); |
351 | 353 | ||
352 | ::close ( fd ); | 354 | ::close ( fd ); |
353 | } | 355 | } |
354 | else | 356 | else |
355 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); | 357 | ::perror ( "/proc/sys/ts/suspend_button_mode" ); |
356 | 358 | ||
357 | return res; | 359 | return res; |
358 | } | 360 | } |
359 | 361 | ||
360 | 362 | ||
361 | bool iPAQ::setDisplayBrightness ( int bright ) | 363 | bool iPAQ::setDisplayBrightness ( int bright ) |
362 | { | 364 | { |
363 | bool res = false; | 365 | bool res = false; |
364 | int fd; | 366 | int fd; |
365 | 367 | ||
366 | if ( bright > 255 ) | 368 | if ( bright > 255 ) |
367 | bright = 255; | 369 | bright = 255; |
368 | if ( bright < 0 ) | 370 | if ( bright < 0 ) |
369 | bright = 0; | 371 | bright = 0; |
370 | 372 | ||
371 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { | 373 | if (( fd = ::open ( "/dev/touchscreen/0", O_WRONLY )) >= 0 ) { |
372 | FLITE_IN bl; | 374 | FLITE_IN bl; |
373 | bl. mode = 1; | 375 | bl. mode = 1; |
374 | bl. pwr = bright ? 1 : 0; | 376 | bl. pwr = bright ? 1 : 0; |
375 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; | 377 | bl. brightness = ( bright * ( displayBrightnessResolution() - 1 ) + 127 ) / 255; |
376 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); | 378 | res = ( ::ioctl ( fd, FLITE_ON, &bl ) == 0 ); |
377 | ::close ( fd ); | 379 | ::close ( fd ); |
378 | } | 380 | } |
379 | return res; | 381 | return res; |
380 | } | 382 | } |
381 | 383 | ||
382 | int iPAQ::displayBrightnessResolution() const | 384 | int iPAQ::displayBrightnessResolution() const |
383 | { | 385 | { |
384 | switch ( model()) { | 386 | switch ( model()) { |
385 | case Model_iPAQ_H31xx: | 387 | case Model_iPAQ_H31xx: |
386 | case Model_iPAQ_H36xx: | 388 | case Model_iPAQ_H36xx: |
387 | case Model_iPAQ_H37xx: | 389 | case Model_iPAQ_H37xx: |
388 | return 128; // really 256, but >128 could damage the LCD | 390 | return 128; // really 256, but >128 could damage the LCD |
389 | 391 | ||
390 | case Model_iPAQ_H38xx: | 392 | case Model_iPAQ_H38xx: |
391 | case Model_iPAQ_H39xx: | 393 | case Model_iPAQ_H39xx: |
392 | return 64; | 394 | return 64; |
393 | case Model_iPAQ_H5xxx: | 395 | case Model_iPAQ_H5xxx: |
394 | return 255; | 396 | return 255; |
395 | 397 | ||
396 | default: | 398 | default: |
397 | return 2; | 399 | return 2; |
398 | } | 400 | } |
399 | } | 401 | } |
400 | 402 | ||
401 | 403 | ||
402 | bool iPAQ::hasLightSensor() const | 404 | bool iPAQ::hasLightSensor() const |
403 | { | 405 | { |
404 | return true; | 406 | return true; |
405 | } | 407 | } |
406 | 408 | ||
407 | int iPAQ::readLightSensor() | 409 | int iPAQ::readLightSensor() |
408 | { | 410 | { |
409 | int fd; | 411 | int fd; |
410 | int val = -1; | 412 | int val = -1; |
411 | 413 | ||
412 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { | 414 | if (( fd = ::open ( "/proc/hal/light_sensor", O_RDONLY )) >= 0 ) { |
413 | char buffer [8]; | 415 | char buffer [8]; |
414 | 416 | ||
415 | if ( ::read ( fd, buffer, 5 ) == 5 ) { | 417 | if ( ::read ( fd, buffer, 5 ) == 5 ) { |
416 | char *endptr; | 418 | char *endptr; |
417 | 419 | ||
418 | buffer [4] = 0; | 420 | buffer [4] = 0; |
419 | val = ::strtol ( buffer + 2, &endptr, 16 ); | 421 | val = ::strtol ( buffer + 2, &endptr, 16 ); |
420 | 422 | ||
421 | if ( *endptr != 0 ) | 423 | if ( *endptr != 0 ) |
422 | val = -1; | 424 | val = -1; |
423 | } | 425 | } |
424 | ::close ( fd ); | 426 | ::close ( fd ); |
425 | } | 427 | } |
426 | 428 | ||
427 | return val; | 429 | return val; |
428 | } | 430 | } |
429 | 431 | ||
diff --git a/libopie2/opiecore/device/odevice_ramses.cpp b/libopie2/opiecore/device/odevice_ramses.cpp index 0cddf85..c75ea3a 100644 --- a/libopie2/opiecore/device/odevice_ramses.cpp +++ b/libopie2/opiecore/device/odevice_ramses.cpp | |||
@@ -6,163 +6,165 @@ | |||
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_ramses.h" | 30 | #include "odevice_ramses.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 | 43 | ||
44 | /* STD */ | 44 | /* STD */ |
45 | #include <fcntl.h> | 45 | #include <fcntl.h> |
46 | #include <math.h> | 46 | #include <math.h> |
47 | #include <stdlib.h> | 47 | #include <stdlib.h> |
48 | #include <signal.h> | 48 | #include <signal.h> |
49 | #include <sys/ioctl.h> | 49 | #include <sys/ioctl.h> |
50 | #include <sys/time.h> | 50 | #include <sys/time.h> |
51 | #include <unistd.h> | 51 | #include <unistd.h> |
52 | #ifndef QT_NO_SOUND | 52 | #ifndef QT_NO_SOUND |
53 | #include <linux/soundcard.h> | 53 | #include <linux/soundcard.h> |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | using namespace Opie::Core; | 56 | using namespace Opie::Core; |
57 | using namespace Opie::Core::Internal; | 57 | using namespace Opie::Core::Internal; |
58 | 58 | ||
59 | 59 | ||
60 | void Ramses::init(const QString&) | 60 | void Ramses::init(const QString&) |
61 | { | 61 | { |
62 | d->m_vendorstr = "M und N"; | 62 | d->m_vendorstr = "M und N"; |
63 | d->m_vendor = Vendor_MundN; | 63 | d->m_vendor = Vendor_MundN; |
64 | 64 | ||
65 | // with old Prototype-LCD, /proc/sys/board/lcd_type = 1 | 65 | // with old Prototype-LCD, /proc/sys/board/lcd_type = 1 |
66 | //d->m_modelstr = "Ramses"; | 66 | //d->m_modelstr = "Ramses"; |
67 | //d->m_model = Model_Ramses_MNCI; | 67 | //d->m_model = Model_Ramses_MNCI; |
68 | //d->m_rotation = Rot0; | 68 | //d->m_rotation = Rot0; |
69 | 69 | ||
70 | // all current Hardware, with /proc/sys/board/lcd_type = 2 | 70 | // all current Hardware, with /proc/sys/board/lcd_type = 2 |
71 | d->m_modelstr = "MNCIRX"; | 71 | d->m_modelstr = "MNCIRX"; |
72 | d->m_model = Model_Ramses_MNCIRX; | 72 | d->m_model = Model_Ramses_MNCIRX; |
73 | d->m_rotation = Rot90; | 73 | d->m_rotation = Rot90; |
74 | 74 | ||
75 | d->m_holdtime = 500; | 75 | d->m_holdtime = 500; |
76 | 76 | ||
77 | 77 | ||
78 | // This table is true for a Intel XScale PXA 255 | 78 | // This table is true for a Intel XScale PXA 255 |
79 | 79 | ||
80 | #ifdef QT_QWS_ALLOW_OVERCLOCK | 80 | #ifdef QT_QWS_ALLOW_OVERCLOCK |
81 | #define OC(x...) x | 81 | #define OC(x...) x |
82 | #else | 82 | #else |
83 | #define OC(x...) | 83 | #define OC(x...) |
84 | #endif | 84 | #endif |
85 | 85 | ||
86 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 | 86 | d->m_cpu_frequencies->append("99000"); // mem= 99, run= 99, turbo= 99, PXbus= 50 |
87 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem | 87 | OC(d->m_cpu_frequencies->append("118000"); ) // mem=118, run=118, turbo=118, PXbus= 59 OC'd mem |
88 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 | 88 | d->m_cpu_frequencies->append("199100"); // mem= 99, run=199, turbo=199, PXbus= 99 |
89 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem | 89 | OC(d->m_cpu_frequencies->append("236000"); ) // mem=118, run=236, turbo=236, PXbus=118 OC'd mem |
90 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 | 90 | d->m_cpu_frequencies->append("298600"); // mem= 99, run=199, turbo=298, PXbus= 99 |
91 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem | 91 | OC(d->m_cpu_frequencies->append("354000"); ) // mem=118, run=236, turbo=354, PXbus=118 OC'd mem |
92 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 | 92 | d->m_cpu_frequencies->append("398099"); // mem= 99, run=199, turbo=398, PXbus= 99 |
93 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 | 93 | d->m_cpu_frequencies->append("398100"); // mem= 99, run=398, turbo=398, PXbus=196 |
94 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus | 94 | OC(d->m_cpu_frequencies->append("471000"); ) // mem=118, run=471, turbo=471, PXbus=236 OC'd mem/core/bus |
95 | } | 95 | } |
96 | 96 | ||
97 | 97 | ||
98 | void Ramses::playAlarmSound() | 98 | void Ramses::playAlarmSound() |
99 | { | 99 | { |
100 | #ifndef QT_NO_SOUND | 100 | #ifndef QT_NO_SOUND |
101 | static Sound snd ( "alarm" ); | 101 | static Sound snd ( "alarm" ); |
102 | if(!snd.isFinished()) | ||
103 | return; | ||
102 | 104 | ||
103 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 105 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
104 | snd.play(); | 106 | snd.play(); |
105 | #else | 107 | #else |
106 | #error QT_NO_SOUND defined | 108 | #error QT_NO_SOUND defined |
107 | #endif | 109 | #endif |
108 | } | 110 | } |
109 | 111 | ||
110 | 112 | ||
111 | bool Ramses::suspend() | 113 | bool Ramses::suspend() |
112 | { | 114 | { |
113 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 115 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
114 | return false; | 116 | return false; |
115 | 117 | ||
116 | sendSuspendmsg(); | 118 | sendSuspendmsg(); |
117 | ::sync(); | 119 | ::sync(); |
118 | 120 | ||
119 | int fd; | 121 | int fd; |
120 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { | 122 | if ((fd = ::open("/proc/sys/pm/suspend", O_WRONLY)) >= 0) { |
121 | char writeCommand[] = "1\n"; | 123 | char writeCommand[] = "1\n"; |
122 | ::write(fd, writeCommand, sizeof(writeCommand) ); | 124 | ::write(fd, writeCommand, sizeof(writeCommand) ); |
123 | ::close(fd); | 125 | ::close(fd); |
124 | } | 126 | } |
125 | 127 | ||
126 | ::usleep ( 200 * 1000 ); | 128 | ::usleep ( 200 * 1000 ); |
127 | return true; | 129 | return true; |
128 | } | 130 | } |
129 | 131 | ||
130 | 132 | ||
131 | bool Ramses::setDisplayBrightness(int bright) | 133 | bool Ramses::setDisplayBrightness(int bright) |
132 | { | 134 | { |
133 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); | 135 | //qDebug("Ramses::setDisplayBrightness(%d)", bright); |
134 | bool res = false; | 136 | bool res = false; |
135 | int fd; | 137 | int fd; |
136 | 138 | ||
137 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) | 139 | // pwm1 brighness: 20 steps 500..0 (dunkel->hell) |
138 | 140 | ||
139 | if (bright > 255 ) | 141 | if (bright > 255 ) |
140 | bright = 255; | 142 | bright = 255; |
141 | if (bright < 0) | 143 | if (bright < 0) |
142 | bright = 0; | 144 | bright = 0; |
143 | 145 | ||
144 | // Turn backlight completely off if brightness=0 | 146 | // Turn backlight completely off if brightness=0 |
145 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { | 147 | if ((fd = ::open("/proc/sys/board/lcd_backlight", O_WRONLY)) >= 0) { |
146 | char writeCommand[10]; | 148 | char writeCommand[10]; |
147 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); | 149 | const int count = sprintf(writeCommand, "%d\n", bright ? 1 : 0); |
148 | res = (::write(fd, writeCommand, count) != -1); | 150 | res = (::write(fd, writeCommand, count) != -1); |
149 | ::close(fd); | 151 | ::close(fd); |
150 | } | 152 | } |
151 | 153 | ||
152 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { | 154 | if ((fd = ::open("/proc/sys/board/lcd_brightness", O_WRONLY)) >= 0) { |
153 | char writeCommand[10]; | 155 | char writeCommand[10]; |
154 | const int count = sprintf(writeCommand, "%d\n", bright); | 156 | const int count = sprintf(writeCommand, "%d\n", bright); |
155 | res = (::write(fd, writeCommand, count) != -1); | 157 | res = (::write(fd, writeCommand, count) != -1); |
156 | ::close(fd); | 158 | ::close(fd); |
157 | } | 159 | } |
158 | return res; | 160 | return res; |
159 | } | 161 | } |
160 | 162 | ||
161 | 163 | ||
162 | int Ramses::displayBrightnessResolution() const | 164 | int Ramses::displayBrightnessResolution() const |
163 | { | 165 | { |
164 | return 32; | 166 | return 32; |
165 | } | 167 | } |
166 | 168 | ||
167 | 169 | ||
168 | // TODO: add displayContrast for old MNCI | 170 | // TODO: add displayContrast for old MNCI |
diff --git a/libopie2/opiecore/device/odevice_simpad.cpp b/libopie2/opiecore/device/odevice_simpad.cpp index fd46b95..34876da 100644 --- a/libopie2/opiecore/device/odevice_simpad.cpp +++ b/libopie2/opiecore/device/odevice_simpad.cpp | |||
@@ -226,173 +226,175 @@ static bool setCS3Bit( bool bitset, int bit ) { | |||
226 | line[31] = '\0'; | 226 | line[31] = '\0'; |
227 | if (::sscanf(line, "Chipselect3 : %x", &val )) | 227 | if (::sscanf(line, "Chipselect3 : %x", &val )) |
228 | ok = true; | 228 | ok = true; |
229 | } | 229 | } |
230 | 230 | ||
231 | ::close(cs3_fd); | 231 | ::close(cs3_fd); |
232 | 232 | ||
233 | /* | 233 | /* |
234 | * we were not able to find the current value | 234 | * we were not able to find the current value |
235 | * and as a result we won't set it | 235 | * and as a result we won't set it |
236 | */ | 236 | */ |
237 | if ( !ok ) | 237 | if ( !ok ) |
238 | return false; | 238 | return false; |
239 | 239 | ||
240 | /* | 240 | /* |
241 | * change the value | 241 | * change the value |
242 | */ | 242 | */ |
243 | val = bitset ? (val | bit) : (val & ~bit); | 243 | val = bitset ? (val | bit) : (val & ~bit); |
244 | 244 | ||
245 | /* | 245 | /* |
246 | * write it back | 246 | * write it back |
247 | */ | 247 | */ |
248 | cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); | 248 | cs3_fd = ::open( SIMPAD_BOARDCONTROL, O_WRONLY ); |
249 | if ( cs3_fd < 0 ) | 249 | if ( cs3_fd < 0 ) |
250 | return false; | 250 | return false; |
251 | 251 | ||
252 | ::snprintf(line, sizeof(line), "0x%04x\n", val); | 252 | ::snprintf(line, sizeof(line), "0x%04x\n", val); |
253 | ::write(cs3_fd, line, strlen(line)); | 253 | ::write(cs3_fd, line, strlen(line)); |
254 | ::close(cs3_fd); | 254 | ::close(cs3_fd); |
255 | 255 | ||
256 | return true; | 256 | return true; |
257 | } | 257 | } |
258 | 258 | ||
259 | 259 | ||
260 | QValueList <OLed> SIMpad::ledList() const | 260 | QValueList <OLed> SIMpad::ledList() const |
261 | { | 261 | { |
262 | QValueList <OLed> vl; | 262 | QValueList <OLed> vl; |
263 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? | 263 | vl << Led_Power; //FIXME which LED is LED2 ? The green one or the amber one? |
264 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway | 264 | //vl << Led_Mail; //TODO find out if LED1 is accessible anyway |
265 | return vl; | 265 | return vl; |
266 | } | 266 | } |
267 | 267 | ||
268 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const | 268 | QValueList <OLedState> SIMpad::ledStateList ( OLed l ) const |
269 | { | 269 | { |
270 | QValueList <OLedState> vl; | 270 | QValueList <OLedState> vl; |
271 | 271 | ||
272 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? | 272 | if ( l == Led_Power ) //FIXME which LED is LED2 ? The green one or the amber one? |
273 | vl << Led_Off << Led_On; | 273 | vl << Led_Off << Led_On; |
274 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway | 274 | //else if ( l == Led_Mail ) //TODO find out if LED1 is accessible anyway |
275 | //vl << Led_Off; | 275 | //vl << Led_Off; |
276 | return vl; | 276 | return vl; |
277 | } | 277 | } |
278 | 278 | ||
279 | OLedState SIMpad::ledState ( OLed l ) const | 279 | OLedState SIMpad::ledState ( OLed l ) const |
280 | { | 280 | { |
281 | switch ( l ) { | 281 | switch ( l ) { |
282 | case Led_Power: | 282 | case Led_Power: |
283 | return m_leds [0]; | 283 | return m_leds [0]; |
284 | //case Led_Mail: | 284 | //case Led_Mail: |
285 | // return m_leds [1]; | 285 | // return m_leds [1]; |
286 | default: | 286 | default: |
287 | return Led_Off; | 287 | return Led_Off; |
288 | } | 288 | } |
289 | } | 289 | } |
290 | 290 | ||
291 | bool SIMpad::setLedState ( OLed l, OLedState st ) | 291 | bool SIMpad::setLedState ( OLed l, OLedState st ) |
292 | { | 292 | { |
293 | if ( l == Led_Power ) { | 293 | if ( l == Led_Power ) { |
294 | m_leds [0] = st; | 294 | m_leds [0] = st; |
295 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); | 295 | setCS3Bit(st == Led_On, SIMPAD_LED2_ON); |
296 | return true; | 296 | return true; |
297 | } | 297 | } |
298 | 298 | ||
299 | return false; | 299 | return false; |
300 | } | 300 | } |
301 | 301 | ||
302 | 302 | ||
303 | bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) | 303 | bool SIMpad::filter ( int /*unicode*/, int /*keycode*/, int /*modifiers*/, bool /*isPress*/, bool /*autoRepeat*/ ) |
304 | { | 304 | { |
305 | //TODO | 305 | //TODO |
306 | return false; | 306 | return false; |
307 | } | 307 | } |
308 | 308 | ||
309 | void SIMpad::timerEvent ( QTimerEvent * ) | 309 | void SIMpad::timerEvent ( QTimerEvent * ) |
310 | { | 310 | { |
311 | killTimer ( m_power_timer ); | 311 | killTimer ( m_power_timer ); |
312 | m_power_timer = 0; | 312 | m_power_timer = 0; |
313 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); | 313 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, true, false ); |
314 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); | 314 | QWSServer::sendKeyEvent ( -1, HardKey_Backlight, 0, false, false ); |
315 | } | 315 | } |
316 | 316 | ||
317 | 317 | ||
318 | void SIMpad::playAlarmSound() | 318 | void SIMpad::playAlarmSound() |
319 | { | 319 | { |
320 | #ifndef QT_NO_SOUND | 320 | #ifndef QT_NO_SOUND |
321 | static Sound snd ( "alarm" ); | 321 | static Sound snd ( "alarm" ); |
322 | if(!snd.isFinished()) | ||
323 | return; | ||
322 | 324 | ||
323 | /* save as the Sound is static! */ | 325 | /* save as the Sound is static! */ |
324 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); | 326 | changeMixerForAlarm( 0, "/dev/sound/mixer" , &snd); |
325 | snd. play(); | 327 | snd. play(); |
326 | #endif | 328 | #endif |
327 | } | 329 | } |
328 | 330 | ||
329 | 331 | ||
330 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm | 332 | bool SIMpad::suspend() // Must override because SIMpad does NOT have apm |
331 | { | 333 | { |
332 | qDebug( "ODevice for SIMpad: suspend()" ); | 334 | qDebug( "ODevice for SIMpad: suspend()" ); |
333 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend | 335 | if ( !isQWS( ) ) // only qwsserver is allowed to suspend |
334 | return false; | 336 | return false; |
335 | 337 | ||
336 | /* | 338 | /* |
337 | * we need to save the screen content | 339 | * we need to save the screen content |
338 | * then go to suspend using ODevice::suspend | 340 | * then go to suspend using ODevice::suspend |
339 | * and finally restore the screen content | 341 | * and finally restore the screen content |
340 | */ | 342 | */ |
341 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); | 343 | (void)::system( "cat /dev/fb/0 > /tmp/.buffer" ); |
342 | bool res = ODevice::suspend(); | 344 | bool res = ODevice::suspend(); |
343 | 345 | ||
344 | /* | 346 | /* |
345 | * restore | 347 | * restore |
346 | */ | 348 | */ |
347 | if ( res ) | 349 | if ( res ) |
348 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); | 350 | ::system( "cat /tmp/.buffer > /dev/fb/0" ); |
349 | 351 | ||
350 | return res; | 352 | return res; |
351 | } | 353 | } |
352 | 354 | ||
353 | 355 | ||
354 | bool SIMpad::setSoftSuspend ( bool soft ) | 356 | bool SIMpad::setSoftSuspend ( bool soft ) |
355 | { | 357 | { |
356 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); | 358 | qDebug( "ODevice for SIMpad: UNHANDLED setSoftSuspend(%s)", soft? "on" : "off" ); |
357 | return false; | 359 | return false; |
358 | } | 360 | } |
359 | 361 | ||
360 | 362 | ||
361 | bool SIMpad::setDisplayStatus ( bool on ) | 363 | bool SIMpad::setDisplayStatus ( bool on ) |
362 | { | 364 | { |
363 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); | 365 | qDebug( "ODevice for SIMpad: setDisplayStatus(%s)", on? "on" : "off" ); |
364 | 366 | ||
365 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); | 367 | return setCS3Bit(on, SIMPAD_DISPLAY_ON); |
366 | } | 368 | } |
367 | 369 | ||
368 | 370 | ||
369 | bool SIMpad::setDisplayBrightness ( int bright ) | 371 | bool SIMpad::setDisplayBrightness ( int bright ) |
370 | { | 372 | { |
371 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); | 373 | qDebug( "ODevice for SIMpad: setDisplayBrightness( %d )", bright ); |
372 | bool res = false; | 374 | bool res = false; |
373 | int fd; | 375 | int fd; |
374 | 376 | ||
375 | if ( bright > 255 ) | 377 | if ( bright > 255 ) |
376 | bright = 255; | 378 | bright = 255; |
377 | if ( bright < 1 ) | 379 | if ( bright < 1 ) |
378 | bright = 0; | 380 | bright = 0; |
379 | 381 | ||
380 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { | 382 | if (( fd = ::open ( SIMPAD_BACKLIGHT_CONTROL, O_WRONLY )) >= 0 ) { |
381 | int value = 255 - bright; | 383 | int value = 255 - bright; |
382 | const int mask = SIMPAD_BACKLIGHT_MASK; | 384 | const int mask = SIMPAD_BACKLIGHT_MASK; |
383 | value = value << 8; | 385 | value = value << 8; |
384 | value += mask; | 386 | value += mask; |
385 | char writeCommand[100]; | 387 | char writeCommand[100]; |
386 | const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); | 388 | const int count = snprintf( writeCommand, sizeof(writeCommand), "0x%x\n", value ); |
387 | res = ( ::write ( fd, writeCommand, count ) != -1 ); | 389 | res = ( ::write ( fd, writeCommand, count ) != -1 ); |
388 | ::close ( fd ); | 390 | ::close ( fd ); |
389 | } | 391 | } |
390 | return res; | 392 | return res; |
391 | } | 393 | } |
392 | 394 | ||
393 | 395 | ||
394 | int SIMpad::displayBrightnessResolution() const | 396 | int SIMpad::displayBrightnessResolution() const |
395 | { | 397 | { |
396 | return 255; // All SIMpad models share the same display | 398 | return 255; // All SIMpad models share the same display |
397 | } | 399 | } |
398 | 400 | ||
diff --git a/libopie2/opiecore/device/odevice_zaurus.cpp b/libopie2/opiecore/device/odevice_zaurus.cpp index 64fa199..733479e 100644 --- a/libopie2/opiecore/device/odevice_zaurus.cpp +++ b/libopie2/opiecore/device/odevice_zaurus.cpp | |||
@@ -252,196 +252,196 @@ void Zaurus::initButtons() | |||
252 | 252 | ||
253 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 | 253 | #define SHARP_DEV_IOCTL_COMMAND_START 0x5680 |
254 | 254 | ||
255 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 255 | #defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
256 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 256 | #define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
257 | 257 | ||
258 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 258 | #define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
259 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 259 | #define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
260 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 260 | #define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
261 | 261 | ||
262 | /* --- for SHARP_BUZZER device --- */ | 262 | /* --- for SHARP_BUZZER device --- */ |
263 | 263 | ||
264 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 264 | //#defineSHARP_BUZZER_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
265 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) | 265 | //#define SHARP_BUZZER_MAKESOUND (SHARP_BUZZER_IOCTL_START) |
266 | 266 | ||
267 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) | 267 | #define SHARP_BUZZER_SETVOLUME (SHARP_BUZZER_IOCTL_START+1) |
268 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) | 268 | #define SHARP_BUZZER_GETVOLUME (SHARP_BUZZER_IOCTL_START+2) |
269 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) | 269 | #define SHARP_BUZZER_ISSUPPORTED (SHARP_BUZZER_IOCTL_START+3) |
270 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) | 270 | #define SHARP_BUZZER_SETMUTE (SHARP_BUZZER_IOCTL_START+4) |
271 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) | 271 | #define SHARP_BUZZER_STOPSOUND (SHARP_BUZZER_IOCTL_START+5) |
272 | 272 | ||
273 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ | 273 | //#define SHARP_BUZ_TOUCHSOUND 1 /* touch panel sound */ |
274 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ | 274 | //#define SHARP_BUZ_KEYSOUND 2 /* key sound */ |
275 | 275 | ||
276 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ | 276 | //#define SHARP_PDA_ILLCLICKSOUND 3 /* illegal click */ |
277 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ | 277 | //#define SHARP_PDA_WARNSOUND 4 /* warning occurred */ |
278 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ | 278 | //#define SHARP_PDA_ERRORSOUND 5 /* error occurred */ |
279 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ | 279 | //#define SHARP_PDA_CRITICALSOUND 6 /* critical error occurred */ |
280 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ | 280 | //#define SHARP_PDA_SYSSTARTSOUND 7 /* system start */ |
281 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ | 281 | //#define SHARP_PDA_SYSTEMENDSOUND 8 /* system shutdown */ |
282 | //#define SHARP_PDA_APPSTART 9 /* application start */ | 282 | //#define SHARP_PDA_APPSTART 9 /* application start */ |
283 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ | 283 | //#define SHARP_PDA_APPQUIT 10 /* application ends */ |
284 | 284 | ||
285 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ | 285 | //#define SHARP_BUZ_SCHEDULE_ALARM 11 /* schedule alarm */ |
286 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ | 286 | //#define SHARP_BUZ_DAILY_ALARM 12 /* daily alarm */ |
287 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ | 287 | //#define SHARP_BUZ_GOT_PHONE_CALL 13 /* phone call sound */ |
288 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ | 288 | //#define SHARP_BUZ_GOT_MAIL 14 /* mail sound */ |
289 | // | 289 | // |
290 | 290 | ||
291 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) | 291 | #defineSHARP_LED_IOCTL_START (SHARP_DEV_IOCTL_COMMAND_START) |
292 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) | 292 | #define SHARP_LED_SETSTATUS (SHARP_LED_IOCTL_START+1) |
293 | 293 | ||
294 | #define SHARP_IOCTL_GET_ROTATION 0x413c | 294 | #define SHARP_IOCTL_GET_ROTATION 0x413c |
295 | 295 | ||
296 | typedef struct sharp_led_status { | 296 | typedef struct sharp_led_status { |
297 | int which; /* select which LED status is wanted. */ | 297 | int which; /* select which LED status is wanted. */ |
298 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ | 298 | int status; /* set new led status if you call SHARP_LED_SETSTATUS */ |
299 | } sharp_led_status; | 299 | } sharp_led_status; |
300 | 300 | ||
301 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ | 301 | #define SHARP_LED_MAIL_EXISTS 9 /* mail status (exists or not) */ |
302 | 302 | ||
303 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ | 303 | #define LED_MAIL_NO_UNREAD_MAIL 0 /* for SHARP_LED_MAIL_EXISTS */ |
304 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ | 304 | #define LED_MAIL_NEWMAIL_EXISTS 1 /* for SHARP_LED_MAIL_EXISTS */ |
305 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ | 305 | #define LED_MAIL_UNREAD_MAIL_EX 2 /* for SHARP_LED_MAIL_EXISTS */ |
306 | 306 | ||
307 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... | 307 | // #include <asm/sharp_apm.h> // including kernel headers is evil ... |
308 | 308 | ||
309 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) | 309 | #define APM_IOCGEVTSRC OD_IOR( 'A', 203, int ) |
310 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) | 310 | #define APM_IOCSEVTSRC OD_IORW( 'A', 204, int ) |
311 | #define APM_EVT_POWER_BUTTON (1 << 0) | 311 | #define APM_EVT_POWER_BUTTON (1 << 0) |
312 | 312 | ||
313 | #define FL_IOCTL_STEP_CONTRAST 100 | 313 | #define FL_IOCTL_STEP_CONTRAST 100 |
314 | 314 | ||
315 | 315 | ||
316 | void Zaurus::buzzer ( int sound ) | 316 | void Zaurus::buzzer ( int sound ) |
317 | { | 317 | { |
318 | #ifndef QT_NO_SOUND | 318 | #ifndef QT_NO_SOUND |
319 | Sound *snd = 0; | 319 | Sound *snd = 0; |
320 | 320 | ||
321 | // Not all devices have real sound | 321 | // Not all devices have real sound |
322 | if ( d->m_model == Model_Zaurus_SLC7x0 | 322 | if ( d->m_model == Model_Zaurus_SLC7x0 |
323 | || d->m_model == Model_Zaurus_SLB600 ){ | 323 | || d->m_model == Model_Zaurus_SLB600 ){ |
324 | 324 | ||
325 | switch ( sound ){ | 325 | switch ( sound ){ |
326 | case SHARP_BUZ_TOUCHSOUND: { | 326 | case SHARP_BUZ_TOUCHSOUND: { |
327 | static Sound touch_sound("touchsound"); | 327 | static Sound touch_sound("touchsound"); |
328 | snd = &touch_sound; | 328 | snd = &touch_sound; |
329 | } | 329 | } |
330 | break; | 330 | break; |
331 | case SHARP_BUZ_KEYSOUND: { | 331 | case SHARP_BUZ_KEYSOUND: { |
332 | static Sound key_sound( "keysound" ); | 332 | static Sound key_sound( "keysound" ); |
333 | snd = &key_sound; | 333 | snd = &key_sound; |
334 | } | 334 | } |
335 | break; | 335 | break; |
336 | case SHARP_BUZ_SCHEDULE_ALARM: | 336 | case SHARP_BUZ_SCHEDULE_ALARM: |
337 | default: { | 337 | default: { |
338 | static Sound alarm_sound("alarm"); | 338 | static Sound alarm_sound("alarm"); |
339 | snd = &alarm_sound; | 339 | snd = &alarm_sound; |
340 | } | 340 | } |
341 | break; | 341 | break; |
342 | } | 342 | } |
343 | } | 343 | } |
344 | 344 | ||
345 | // If a soundname is defined, we expect that this device has | 345 | // If a soundname is defined, we expect that this device has |
346 | // sound capabilities.. Otherwise we expect to have the buzzer | 346 | // sound capabilities.. Otherwise we expect to have the buzzer |
347 | // device.. | 347 | // device.. |
348 | if ( snd ){ | 348 | if ( snd && snd->isFinished() ){ |
349 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); | 349 | changeMixerForAlarm( 0, "/dev/sound/mixer", snd ); |
350 | snd-> play(); | 350 | snd-> play(); |
351 | } else { | 351 | } else if( !snd ) { |
352 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); | 352 | int fd = ::open ( "/dev/sharp_buz", O_WRONLY|O_NONBLOCK ); |
353 | 353 | ||
354 | if ( fd >= 0 ) { | 354 | if ( fd >= 0 ) { |
355 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); | 355 | ::ioctl ( fd, SHARP_BUZZER_MAKESOUND, sound ); |
356 | ::close ( fd ); | 356 | ::close ( fd ); |
357 | } | 357 | } |
358 | 358 | ||
359 | } | 359 | } |
360 | #endif | 360 | #endif |
361 | } | 361 | } |
362 | 362 | ||
363 | 363 | ||
364 | void Zaurus::playAlarmSound() | 364 | void Zaurus::playAlarmSound() |
365 | { | 365 | { |
366 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); | 366 | buzzer ( SHARP_BUZ_SCHEDULE_ALARM ); |
367 | } | 367 | } |
368 | 368 | ||
369 | void Zaurus::playTouchSound() | 369 | void Zaurus::playTouchSound() |
370 | { | 370 | { |
371 | buzzer ( SHARP_BUZ_TOUCHSOUND ); | 371 | buzzer ( SHARP_BUZ_TOUCHSOUND ); |
372 | } | 372 | } |
373 | 373 | ||
374 | void Zaurus::playKeySound() | 374 | void Zaurus::playKeySound() |
375 | { | 375 | { |
376 | buzzer ( SHARP_BUZ_KEYSOUND ); | 376 | buzzer ( SHARP_BUZ_KEYSOUND ); |
377 | } | 377 | } |
378 | 378 | ||
379 | 379 | ||
380 | QValueList <OLed> Zaurus::ledList() const | 380 | QValueList <OLed> Zaurus::ledList() const |
381 | { | 381 | { |
382 | QValueList <OLed> vl; | 382 | QValueList <OLed> vl; |
383 | vl << Led_Mail; | 383 | vl << Led_Mail; |
384 | return vl; | 384 | return vl; |
385 | } | 385 | } |
386 | 386 | ||
387 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const | 387 | QValueList <OLedState> Zaurus::ledStateList ( OLed l ) const |
388 | { | 388 | { |
389 | QValueList <OLedState> vl; | 389 | QValueList <OLedState> vl; |
390 | 390 | ||
391 | if ( l == Led_Mail ) | 391 | if ( l == Led_Mail ) |
392 | vl << Led_Off << Led_On << Led_BlinkSlow; | 392 | vl << Led_Off << Led_On << Led_BlinkSlow; |
393 | return vl; | 393 | return vl; |
394 | } | 394 | } |
395 | 395 | ||
396 | OLedState Zaurus::ledState ( OLed which ) const | 396 | OLedState Zaurus::ledState ( OLed which ) const |
397 | { | 397 | { |
398 | if ( which == Led_Mail ) | 398 | if ( which == Led_Mail ) |
399 | return m_leds [0]; | 399 | return m_leds [0]; |
400 | else | 400 | else |
401 | return Led_Off; | 401 | return Led_Off; |
402 | } | 402 | } |
403 | 403 | ||
404 | bool Zaurus::setLedState ( OLed which, OLedState st ) | 404 | bool Zaurus::setLedState ( OLed which, OLedState st ) |
405 | { | 405 | { |
406 | if (!m_embedix) // Currently not supported on non_embedix kernels | 406 | if (!m_embedix) // Currently not supported on non_embedix kernels |
407 | return false; | 407 | return false; |
408 | 408 | ||
409 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); | 409 | static int fd = ::open ( "/dev/sharp_led", O_RDWR|O_NONBLOCK ); |
410 | 410 | ||
411 | if ( which == Led_Mail ) { | 411 | if ( which == Led_Mail ) { |
412 | if ( fd >= 0 ) { | 412 | if ( fd >= 0 ) { |
413 | struct sharp_led_status leds; | 413 | struct sharp_led_status leds; |
414 | ::memset ( &leds, 0, sizeof( leds )); | 414 | ::memset ( &leds, 0, sizeof( leds )); |
415 | leds. which = SHARP_LED_MAIL_EXISTS; | 415 | leds. which = SHARP_LED_MAIL_EXISTS; |
416 | bool ok = true; | 416 | bool ok = true; |
417 | 417 | ||
418 | switch ( st ) { | 418 | switch ( st ) { |
419 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; | 419 | case Led_Off : leds. status = LED_MAIL_NO_UNREAD_MAIL; break; |
420 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; | 420 | case Led_On : leds. status = LED_MAIL_NEWMAIL_EXISTS; break; |
421 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; | 421 | case Led_BlinkSlow: leds. status = LED_MAIL_UNREAD_MAIL_EX; break; |
422 | default : ok = false; | 422 | default : ok = false; |
423 | } | 423 | } |
424 | 424 | ||
425 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { | 425 | if ( ok && ( ::ioctl ( fd, SHARP_LED_SETSTATUS, &leds ) >= 0 )) { |
426 | m_leds [0] = st; | 426 | m_leds [0] = st; |
427 | return true; | 427 | return true; |
428 | } | 428 | } |
429 | } | 429 | } |
430 | } | 430 | } |
431 | return false; | 431 | return false; |
432 | } | 432 | } |
433 | 433 | ||
434 | bool Zaurus::setSoftSuspend ( bool soft ) | 434 | bool Zaurus::setSoftSuspend ( bool soft ) |
435 | { | 435 | { |
436 | if (!m_embedix) { | 436 | if (!m_embedix) { |
437 | /* non-Embedix kernels dont have kernel autosuspend */ | 437 | /* non-Embedix kernels dont have kernel autosuspend */ |
438 | return ODevice::setSoftSuspend( soft ); | 438 | return ODevice::setSoftSuspend( soft ); |
439 | } | 439 | } |
440 | 440 | ||
441 | bool res = false; | 441 | bool res = false; |
442 | int fd; | 442 | int fd; |
443 | 443 | ||
444 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || | 444 | if ((( fd = ::open ( "/dev/apm_bios", O_RDWR )) >= 0 ) || |
445 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { | 445 | (( fd = ::open ( "/dev/misc/apm_bios",O_RDWR )) >= 0 )) { |
446 | 446 | ||
447 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources | 447 | int sources = ::ioctl ( fd, APM_IOCGEVTSRC, 0 ); // get current event sources |